diff options
Diffstat (limited to 'app/assets/javascripts/import_entities/import_groups')
5 files changed, 24 insertions, 39 deletions
diff --git a/app/assets/javascripts/import_entities/import_groups/components/import_table.vue b/app/assets/javascripts/import_entities/import_groups/components/import_table.vue index 66dff77eef8..6412f26fde7 100644 --- a/app/assets/javascripts/import_entities/import_groups/components/import_table.vue +++ b/app/assets/javascripts/import_entities/import_groups/components/import_table.vue @@ -21,12 +21,13 @@ import { getGroupPathAvailability } from '~/rest_api'; import axios from '~/lib/utils/axios_utils'; import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import { helpPagePath } from '~/helpers/help_page_helper'; +import searchNamespacesWhereUserCanCreateProjectsQuery from '~/projects/new/queries/search_namespaces_where_user_can_create_projects.query.graphql'; +import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { STATUSES } from '../../constants'; import ImportStatusCell from '../../components/import_status.vue'; import importGroupsMutation from '../graphql/mutations/import_groups.mutation.graphql'; import updateImportStatusMutation from '../graphql/mutations/update_import_status.mutation.graphql'; -import availableNamespacesQuery from '../graphql/queries/available_namespaces.query.graphql'; import bulkImportSourceGroupsQuery from '../graphql/queries/bulk_import_source_groups.query.graphql'; import { NEW_NAME_FIELD, ROOT_NAMESPACE, i18n } from '../constants'; import { StatusPoller } from '../services/status_poller'; @@ -107,7 +108,12 @@ export default { return { page: this.page, filter: this.filter, perPage: this.perPage }; }, }, - availableNamespaces: availableNamespacesQuery, + availableNamespaces: { + query: searchNamespacesWhereUserCanCreateProjectsQuery, + update(data) { + return data.currentUser.groups.nodes; + }, + }, }, fields: [ @@ -158,7 +164,7 @@ export default { } return this.groups.map((group) => { - const importTarget = this.getImportTarget(group); + const importTarget = this.importTargets[group.id]; const status = this.getStatus(group); const flags = { @@ -250,10 +256,14 @@ export default { this.page = 1; }, - groupsTableData() { + groups() { const table = this.getTableRef(); const matches = new Set(); - this.groupsTableData.forEach((g, idx) => { + this.groups.forEach((g, idx) => { + if (!this.importGroups[g.id]) { + this.setDefaultImportTarget(g); + } + if (this.selectedGroupsIds.includes(g.id)) { matches.add(g.id); this.$nextTick(() => { @@ -421,7 +431,7 @@ export default { data: { exists }, } = await getGroupPathAvailability( importTarget.newName, - importTarget.targetNamespace.id, + getIdFromGraphQLId(importTarget.targetNamespace.id), { cancelToken: importTarget.cancellationToken?.token, }, @@ -444,11 +454,7 @@ export default { importTarget.validationErrors = newValidationErrors; }, VALIDATION_DEBOUNCE_TIME), - getImportTarget(group) { - if (this.importTargets[group.id]) { - return this.importTargets[group.id]; - } - + setDefaultImportTarget(group) { // If we've reached this Vue application we have at least one potential import destination const defaultTargetNamespace = // first option: namespace id was explicitly provided @@ -482,9 +488,13 @@ export default { validationErrors: [], }); - getGroupPathAvailability(importTarget.newName, importTarget.targetNamespace.id, { - cancelToken: cancellationToken.token, - }) + getGroupPathAvailability( + importTarget.newName, + getIdFromGraphQLId(importTarget.targetNamespace.id), + { + cancelToken: cancellationToken.token, + }, + ) .then(({ data: { exists, suggests: suggestions } }) => { if (!exists) return; @@ -505,7 +515,6 @@ export default { .catch(() => { // empty catch intended }); - return this.importTargets[group.id]; }, }, @@ -692,7 +701,6 @@ export default { <template #cell(importTarget)="{ item: group }"> <import-target-cell :group="group" - :available-namespaces="availableNamespaces" :group-path-regex="groupPathRegex" @update-target-namespace="updateImportTarget(group, { targetNamespace: $event })" @update-new-name="updateImportTarget(group, { newName: $event })" diff --git a/app/assets/javascripts/import_entities/import_groups/components/import_target_cell.vue b/app/assets/javascripts/import_entities/import_groups/components/import_target_cell.vue index 4fbbd5b239c..04a90d9c20c 100644 --- a/app/assets/javascripts/import_entities/import_groups/components/import_target_cell.vue +++ b/app/assets/javascripts/import_entities/import_groups/components/import_target_cell.vue @@ -22,10 +22,6 @@ export default { type: Object, required: true, }, - availableNamespaces: { - type: Array, - required: true, - }, }, computed: { @@ -53,7 +49,6 @@ export default { #default="{ namespaces }" :text="fullPath" :disabled="!group.flags.isAvailableForImport" - :namespaces="availableNamespaces" toggle-class="gl-rounded-top-right-none! gl-rounded-bottom-right-none!" class="gl-h-7 gl-flex-grow-1" data-qa-selector="target_namespace_selector_dropdown" diff --git a/app/assets/javascripts/import_entities/import_groups/graphql/client_factory.js b/app/assets/javascripts/import_entities/import_groups/graphql/client_factory.js index 36da996ea17..913a5a659b3 100644 --- a/app/assets/javascripts/import_entities/import_groups/graphql/client_factory.js +++ b/app/assets/javascripts/import_entities/import_groups/graphql/client_factory.js @@ -10,7 +10,6 @@ import typeDefs from './typedefs.graphql'; export const clientTypenames = { BulkImportSourceGroupConnection: 'ClientBulkImportSourceGroupConnection', BulkImportSourceGroup: 'ClientBulkImportSourceGroup', - AvailableNamespace: 'ClientAvailableNamespace', BulkImportPageInfo: 'ClientBulkImportPageInfo', BulkImportTarget: 'ClientBulkImportTarget', BulkImportProgress: 'ClientBulkImportProgress', @@ -110,15 +109,6 @@ export function createResolvers({ endpoints }) { }; return response; }, - - availableNamespaces: () => - axios.get(endpoints.availableNamespaces).then(({ data }) => - data.map((namespace) => ({ - __typename: clientTypenames.AvailableNamespace, - id: namespace.id, - fullPath: namespace.full_path, - })), - ), }, Mutation: { async updateImportStatus(_, { id, status: newStatus }, { client, getCacheKey }) { diff --git a/app/assets/javascripts/import_entities/import_groups/graphql/queries/available_namespaces.query.graphql b/app/assets/javascripts/import_entities/import_groups/graphql/queries/available_namespaces.query.graphql deleted file mode 100644 index b0741dfbe5c..00000000000 --- a/app/assets/javascripts/import_entities/import_groups/graphql/queries/available_namespaces.query.graphql +++ /dev/null @@ -1,6 +0,0 @@ -query availableNamespaces { - availableNamespaces @client { - id - fullPath - } -} diff --git a/app/assets/javascripts/import_entities/import_groups/index.js b/app/assets/javascripts/import_entities/import_groups/index.js index 5d7e7911f5a..494a845b1f9 100644 --- a/app/assets/javascripts/import_entities/import_groups/index.js +++ b/app/assets/javascripts/import_entities/import_groups/index.js @@ -12,7 +12,6 @@ export function mountImportGroupsApp(mountElement) { const { statusPath, - availableNamespacesPath, createBulkImportPath, jobsPath, historyPath, @@ -25,7 +24,6 @@ export function mountImportGroupsApp(mountElement) { sourceUrl, endpoints: { status: statusPath, - availableNamespaces: availableNamespacesPath, createBulkImport: createBulkImportPath, }, }), |