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

archived_projects_service.js « service « groups « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b9d48cc660e02db1f3b89afe6b9b9d05f978e301 (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
47
48
49
50
51
52
53
54
55
56
57
import Api from '~/api';

export default class ArchivedProjectsService {
  constructor(groupId, initialSort) {
    this.groupId = groupId;
    this.initialSort = initialSort;
  }

  async getGroups(parentId, page, query, sortParam) {
    const supportedOrderBy = {
      name: 'name',
      created: 'created_at',
      latest_activity: 'last_activity_at',
    };

    const [, orderBy, sort] = (sortParam || this.initialSort)?.match(/(\w+)_(asc|desc)/) || [];

    const { data: projects, headers } = await Api.groupProjects(this.groupId, query, {
      archived: true,
      include_subgroups: true,
      page,
      order_by: supportedOrderBy[orderBy],
      sort,
    });

    return {
      data: projects.map((project) => {
        return {
          id: project.id,
          name: project.name,
          full_name: project.name_with_namespace,
          markdown_description: project.description_html,
          visibility: project.visibility,
          avatar_url: project.avatar_url,
          relative_path: `/${project.path_with_namespace}`,
          edit_path: null,
          leave_path: null,
          can_edit: false,
          can_leave: false,
          can_remove: false,
          type: 'project',
          permission: null,
          children: [],
          parent_id: project.namespace.id,
          project_count: 0,
          subgroup_count: 0,
          number_users_with_delimiter: 0,
          star_count: project.star_count,
          updated_at: project.updated_at,
          marked_for_deletion: Boolean(project.marked_for_deletion_at),
          last_activity_at: project.last_activity_at,
        };
      }),
      headers,
    };
  }
}