From cbf0ef336dcdd7ca3cca886b251ebb3be93ef481 Mon Sep 17 00:00:00 2001 From: Oiza Baiye Date: Tue, 27 May 2025 16:43:52 -0400 Subject: [PATCH] Revert "Merge branch..." This reverts merge request !190598 --- .../components/provider_repo_table_row.vue | 37 +----- .../import_projects/store/getters.js | 2 +- app/views/import/_githubish_status.html.haml | 2 +- locale/gitlab.pot | 6 - spec/features/import/manifest_import_spec.rb | 1 + .../provider_repo_table_row_spec.js | 116 +++++------------- .../import_projects/store/actions_spec.js | 2 +- .../import_projects/store/getters_spec.js | 2 +- 8 files changed, 41 insertions(+), 127 deletions(-) diff --git a/app/assets/javascripts/import_entities/import_projects/components/provider_repo_table_row.vue b/app/assets/javascripts/import_entities/import_projects/components/provider_repo_table_row.vue index 447bed7f9d0300..ab166b8fba197d 100644 --- a/app/assets/javascripts/import_entities/import_projects/components/provider_repo_table_row.vue +++ b/app/assets/javascripts/import_entities/import_projects/components/provider_repo_table_row.vue @@ -60,8 +60,6 @@ export default { return { isSelectedForReimport: false, showMembershipsModal: false, - userHasSelectedNamespace: false, - showNamespaceRequiredError: false, }; }, @@ -74,13 +72,8 @@ export default { }, showMembershipsWarning() { - const usersNamespaceIsSelected = this.importTarget.targetNamespace === this.userNamespace; - - return this.isNotImporting && usersNamespaceIsSelected; - }, - - isNotImporting() { - return this.isImportNotStarted || this.isSelectedForReimport; + const userNamespaceSelected = this.importTarget.targetNamespace === this.userNamespace; + return (this.isImportNotStarted || this.isSelectedForReimport) && userNamespaceSelected; }, isFinished() { @@ -135,15 +128,6 @@ export default { this.updateImportTarget({ newName: value }); }, }, - shouldBlockImportForNamespace() { - if (this.importTarget.targetNamespace) { - return false; - } - - return ( - !this.repo.importSource.target && this.isNotImporting && !this.userHasSelectedNamespace - ); - }, }, methods: { @@ -172,9 +156,7 @@ export default { }, onImportClick() { - if (this.shouldBlockImportForNamespace) { - this.showNamespaceRequiredError = true; - } else if (this.showMembershipsWarning) { + if (this.showMembershipsWarning) { this.showMembershipsModal = true; } else { this.handleImportRepo(); @@ -182,8 +164,6 @@ export default { }, onSelect(value) { - this.userHasSelectedNamespace = true; - this.showNamespaceRequiredError = false; this.updateImportTarget({ targetNamespace: value }); }, }, @@ -229,7 +209,6 @@ export default {
@@ -245,14 +224,6 @@ export default { data-testid="project-path-field" />
- @@ -293,11 +264,9 @@ export default { (repoId) => { return { newName: repo.importSource.sanitizedName, - targetNamespace: null, + targetNamespace: state.defaultTargetNamespace, }; }; diff --git a/app/views/import/_githubish_status.html.haml b/app/views/import/_githubish_status.html.haml index b6d4dc6b9c915b..ad68a0587f2fb2 100644 --- a/app/views/import/_githubish_status.html.haml +++ b/app/views/import/_githubish_status.html.haml @@ -3,7 +3,7 @@ - extra_data = local_assigns.fetch(:extra_data, {}) - filterable = local_assigns.fetch(:filterable, true) - paginatable = local_assigns.fetch(:paginatable, false) -- default_namespace_path = local_assigns[:default_namespace]&.full_path +- default_namespace_path = (local_assigns[:default_namespace] || current_user.namespace).full_path - cancel_path = local_assigns.fetch(:cancel_path, nil) - details_path = local_assigns.fetch(:details_path, nil) - provider_title = Gitlab::ImportSources.title(local_assigns.fetch(:provider)) diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 2507979b4811a3..c9b1def4d0540a 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -32029,12 +32029,6 @@ msgstr "" msgid "ImportProjects|Requesting your %{provider} repositories failed" msgstr "" -msgid "ImportProjects|Select a destination namespace." -msgstr "" - -msgid "ImportProjects|Select namespace" -msgstr "" - msgid "ImportProjects|Select the repositories you want to import" msgstr "" diff --git a/spec/features/import/manifest_import_spec.rb b/spec/features/import/manifest_import_spec.rb index 35c25966e878b3..175ae2fee8c00b 100644 --- a/spec/features/import/manifest_import_spec.rb +++ b/spec/features/import/manifest_import_spec.rb @@ -34,6 +34,7 @@ page.within(second_row) do click_on 'Import' end + click_on 'Continue import' wait_for_requests diff --git a/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js b/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js index ffe3953a405226..a135570656693c 100644 --- a/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js +++ b/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js @@ -1,4 +1,4 @@ -import { GlBadge, GlButton } from '@gitlab/ui'; +import { GlBadge, GlButton, GlModal } from '@gitlab/ui'; import Vue, { nextTick } from 'vue'; // eslint-disable-next-line no-restricted-imports import Vuex from 'vuex'; @@ -15,7 +15,7 @@ describe('ProviderRepoTableRow', () => { const cancelImport = jest.fn(); const setImportTarget = jest.fn(); const groupImportTarget = { - targetNamespace: null, + targetNamespace: 'target', newName: 'newName', }; @@ -45,8 +45,7 @@ describe('ProviderRepoTableRow', () => { const findImportStatus = () => wrapper.findComponent(ImportStatus); const findProviderLink = () => wrapper.findByTestId('provider-link'); const findMembershipsWarning = () => wrapper.findByTestId('memberships-warning'); - const findMembershipsWarningModal = () => wrapper.findByTestId('memberships-warning-modal'); - const findNamespaceRequiredWarning = () => wrapper.findByTestId('namespace-required-warning'); + const findGlModal = () => wrapper.findComponent(GlModal); const findCancelButton = () => { const buttons = wrapper @@ -98,37 +97,12 @@ describe('ProviderRepoTableRow', () => { expect(findImportTargetDropdown().exists()).toBe(true); }); - it('renders the dropdown without a default selected', () => { - expect(findImportTargetDropdown().props('selected')).toBe(null); - expect(findImportTargetDropdown().props().toggleText).toBe('Select namespace'); - }); - - describe('when no namespace is selected', () => { - it('shows namespace required warning when import button is clicked', async () => { - findImportButton().vm.$emit('click'); - await nextTick(); - - expect(findNamespaceRequiredWarning().text()).toBe('Select a destination namespace.'); - }); - - it('does not trigger import when clicking import button', async () => { - findImportButton().vm.$emit('click'); - await nextTick(); - - expect(fetchImport).not.toHaveBeenCalled(); - }); - }); - describe('when user namespace is selected as import target', () => { - beforeEach(async () => { + beforeEach(() => { mountComponent( { repo }, { storeOptions: { importTarget: { targetNamespace: userNamespace } } }, ); - - const dropdown = findImportTargetDropdown(); - dropdown.vm.$emit('select', userNamespace); - await nextTick(); }); it('shows memberships warning', () => { @@ -139,7 +113,7 @@ describe('ProviderRepoTableRow', () => { findImportButton().vm.$emit('click'); await nextTick(); - const modal = findMembershipsWarningModal(); + const modal = findGlModal(); expect(modal.props('title')).toBe( 'Are you sure you want to import the project to a personal namespace?', ); @@ -148,15 +122,11 @@ describe('ProviderRepoTableRow', () => { ); }); - it('does not show `missing namespace` warning', () => { - expect(findNamespaceRequiredWarning().exists()).toBe(false); - }); - it('triggers import when clicking modal primary button', async () => { findImportButton().vm.$emit('click'); await nextTick(); - findMembershipsWarningModal().vm.$emit('primary'); + findGlModal().vm.$emit('primary'); expect(fetchImport).toHaveBeenCalledWith(expect.anything(), { repoId: repo.importSource.id, @@ -166,68 +136,53 @@ describe('ProviderRepoTableRow', () => { }); describe('when group namespace is selected as import target', () => { - beforeEach(async () => { - const dropdown = findImportTargetDropdown(); - dropdown.vm.$emit('select', 'target'); - await nextTick(); - }); - it('does not show memberships warning', () => { expect(findMembershipsWarning().isVisible()).toBe(false); }); - it('does not show memberships modal when import button is clicked', async () => { + it('does not show modal when import button is clicked', async () => { findImportButton().vm.$emit('click'); await nextTick(); - expect(findMembershipsWarningModal().exists()).toBe(false); - }); - - it('does not show `missing namespace` warning when import button is clicked', async () => { - findImportButton().vm.$emit('click'); - await nextTick(); - expect(findNamespaceRequiredWarning().exists()).toBe(false); + expect(findGlModal().exists()).toBe(false); }); + }); - it('renders import button', () => { - expect(findImportButton().exists()).toBe(true); - }); + it('renders import button', () => { + expect(findImportButton().exists()).toBe(true); + }); - it('imports repo when clicking import button', async () => { - findImportButton().vm.$emit('click'); + it('imports repo when clicking import button', async () => { + findImportButton().vm.$emit('click'); - await nextTick(); + await nextTick(); - expect(fetchImport).toHaveBeenCalledWith(expect.anything(), { - repoId: repo.importSource.id, - optionalStages: {}, - }); + expect(fetchImport).toHaveBeenCalledWith(expect.anything(), { + repoId: repo.importSource.id, + optionalStages: {}, }); + }); - it('includes optionalStages to import', async () => { - const OPTIONAL_STAGES = { stage1: true, stage2: false }; + it('includes optionalStages to import', async () => { + const OPTIONAL_STAGES = { stage1: true, stage2: false }; - mountComponent({ - repo, - optionalStages: OPTIONAL_STAGES, - }); + mountComponent({ + repo, + optionalStages: OPTIONAL_STAGES, + }); - const dropdown = findImportTargetDropdown(); - dropdown.vm.$emit('select', 'target'); - await nextTick(); + findImportButton().vm.$emit('click'); - findImportButton().vm.$emit('click'); - await nextTick(); + await nextTick(); - expect(fetchImport).toHaveBeenCalledWith(expect.anything(), { - repoId: repo.importSource.id, - optionalStages: OPTIONAL_STAGES, - }); + expect(fetchImport).toHaveBeenCalledWith(expect.anything(), { + repoId: repo.importSource.id, + optionalStages: OPTIONAL_STAGES, }); + }); - it('does not render re-import button', () => { - expect(findReimportButton().exists()).toBe(false); - }); + it('does not render re-import button', () => { + expect(findReimportButton().exists()).toBe(false); }); }); @@ -335,12 +290,7 @@ describe('ProviderRepoTableRow', () => { await nextTick(); - findImportTargetDropdown().vm.$emit('select', 'some-namespace'); - await nextTick(); - findReimportButton().vm.$emit('click'); - await nextTick(); - expect(findNamespaceRequiredWarning().exists()).toBe(false); expect(fetchImport).toHaveBeenCalledWith(expect.anything(), { repoId: repo.importSource.id, diff --git a/spec/frontend/import_entities/import_projects/store/actions_spec.js b/spec/frontend/import_entities/import_projects/store/actions_spec.js index aa57ae9f041371..918821dfa59816 100644 --- a/spec/frontend/import_entities/import_projects/store/actions_spec.js +++ b/spec/frontend/import_entities/import_projects/store/actions_spec.js @@ -55,7 +55,7 @@ describe('import_projects store actions', () => { let localState; const importRepoId = 1; const otherImportRepoId = 2; - const defaultTargetNamespace = null; + const defaultTargetNamespace = 'default'; const sanitizedName = 'sanitizedName'; const defaultImportTarget = { newName: sanitizedName, targetNamespace: defaultTargetNamespace }; diff --git a/spec/frontend/import_entities/import_projects/store/getters_spec.js b/spec/frontend/import_entities/import_projects/store/getters_spec.js index e25a6e099287de..fced5670f25b3e 100644 --- a/spec/frontend/import_entities/import_projects/store/getters_spec.js +++ b/spec/frontend/import_entities/import_projects/store/getters_spec.js @@ -99,7 +99,7 @@ describe('import_projects store getters', () => { expect(getImportTarget(localState)(IMPORTABLE_REPO.importSource.id)).toStrictEqual({ newName: IMPORTABLE_REPO.importSource.sanitizedName, - targetNamespace: null, + targetNamespace: localState.defaultTargetNamespace, }); }); -- GitLab