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

import_table.vue « components « import_groups « import_entities « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 80e2e73f4206e6bffc4bcb1827daa2f6ce07676d (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<script>
import { GlLoadingIcon } from '@gitlab/ui';
import bulkImportSourceGroupsQuery from '../graphql/queries/bulk_import_source_groups.query.graphql';
import availableNamespacesQuery from '../graphql/queries/available_namespaces.query.graphql';
import setTargetNamespaceMutation from '../graphql/mutations/set_target_namespace.mutation.graphql';
import setNewNameMutation from '../graphql/mutations/set_new_name.mutation.graphql';
import importGroupMutation from '../graphql/mutations/import_group.mutation.graphql';
import ImportTableRow from './import_table_row.vue';

const mapApolloMutations = (mutations) =>
  Object.fromEntries(
    Object.entries(mutations).map(([key, mutation]) => [
      key,
      function mutate(config) {
        return this.$apollo.mutate({
          mutation,
          ...config,
        });
      },
    ]),
  );

export default {
  components: {
    GlLoadingIcon,
    ImportTableRow,
  },

  apollo: {
    bulkImportSourceGroups: bulkImportSourceGroupsQuery,
    availableNamespaces: availableNamespacesQuery,
  },

  methods: {
    ...mapApolloMutations({
      setTargetNamespace: setTargetNamespaceMutation,
      setNewName: setNewNameMutation,
      importGroup: importGroupMutation,
    }),
  },
};
</script>

<template>
  <div>
    <gl-loading-icon v-if="$apollo.loading" size="md" class="gl-mt-5" />
    <div v-else-if="bulkImportSourceGroups.length">
      <table class="gl-w-full">
        <thead class="gl-border-solid gl-border-gray-200 gl-border-0 gl-border-b-1">
          <th class="gl-py-4 import-jobs-from-col">{{ s__('BulkImport|From source group') }}</th>
          <th class="gl-py-4 import-jobs-to-col">{{ s__('BulkImport|To new group') }}</th>
          <th class="gl-py-4 import-jobs-status-col">{{ __('Status') }}</th>
          <th class="gl-py-4 import-jobs-cta-col"></th>
        </thead>
        <tbody>
          <template v-for="group in bulkImportSourceGroups">
            <import-table-row
              :key="group.id"
              :group="group"
              :available-namespaces="availableNamespaces"
              @update-target-namespace="
                setTargetNamespace({
                  variables: { sourceGroupId: group.id, targetNamespace: $event },
                })
              "
              @update-new-name="
                setNewName({
                  variables: { sourceGroupId: group.id, newName: $event },
                })
              "
              @import-group="importGroup({ variables: { sourceGroupId: group.id } })"
            />
          </template>
        </tbody>
      </table>
    </div>
  </div>
</template>