Welcome to mirror list, hosted at ThFree Co, Russian Federation.

groups_store.js « stores « groups « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2602ad0ad2bb9198c639190f0949ff939c6242f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
export default class GroupsStore {
  constructor() {
    this.state = {};
    this.state.groups = [];

    return this;
  }

  setGroups(rawGroups, parent = null) {
    const parentGroup = parent;

    if (parentGroup) {
      parentGroup.subGroups = this.decorateGroups(rawGroups);
    } else {
      this.state.groups = this.decorateGroups(rawGroups);
    }

    return rawGroups;
  }

  decorateGroups(rawGroups) {
    this.groups = rawGroups.map(GroupsStore.decorateGroup);
    return this.groups;
  }

  static decorateGroup(rawGroup) {
    return {
      id: rawGroup.id,
      fullName: rawGroup.full_name,
      description: rawGroup.description,
      webUrl: rawGroup.web_url,
      parentId: rawGroup.parent_id,
      visibility: rawGroup.visibility,
      isOpen: false,
      numberProjects: 10,
      numberMembers: 10,
      subGroups: [],
    };
  }

  static toggleSubGroups(toggleGroup) {
    const group = toggleGroup;
    group.isOpen = !group.isOpen;
    return group;
  }
}