From 89d3f9b871c5a97c51175dd12289eb2473922ac4 Mon Sep 17 00:00:00 2001 From: Sam Word Date: Thu, 7 Aug 2025 19:26:10 -0400 Subject: [PATCH 1/2] Updated frontend warning when importing to personal namespace --- .../components/provider_repo_table_row.vue | 26 ++++++++----- app/controllers/import/base_controller.rb | 5 +++ locale/gitlab.pot | 3 ++ .../provider_repo_table_row_spec.js | 39 ++++++++++++++++++- 4 files changed, 61 insertions(+), 12 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 ab166b8fba197d..3e6c88b2eb25ad 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 @@ -12,6 +12,7 @@ import { // eslint-disable-next-line no-restricted-imports import { mapState, mapGetters, mapActions } from 'vuex'; import { __, s__ } from '~/locale'; +import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import HelpPageLink from '~/vue_shared/components/help_page_link/help_page_link.vue'; import HelpPopover from '~/vue_shared/components/help_popover.vue'; import ImportTargetDropdown from '../../components/import_target_dropdown.vue'; @@ -35,6 +36,7 @@ export default { GlSprintf, GlModal, }, + mixins: [glFeatureFlagMixin()], inject: { userNamespace: { default: null, @@ -128,6 +130,18 @@ export default { this.updateImportTarget({ newName: value }); }, }, + + personalNamespaceWarning() { + if (this.glFeatures.userMappingToPersonalNamespaceOwner) { + return s__( + 'ImportProjects|Importing a project into a personal namespace results in all contributions being mapped to the personal namespace owner and they cannot be reassigned. To map contributions to real users, import projects into a group instead.', + ); + } + + return s__( + 'ImportProjects|Importing a project into a personal namespace results in all contributions being mapped to the same bot user and they cannot be reassigned. To map contributions to actual users, import the project to a group instead.', + ); + }, }, methods: { @@ -272,11 +286,7 @@ export default { @primary="handleImportRepo" >

- {{ - s__( - 'ImportProjects|Importing a project into a personal namespace results in all contributions being mapped to the same bot user and they cannot be reassigned. To map contributions to actual users, import the project to a group instead.', - ) - }} + {{ personalNamespaceWarning }} - {{ - s__( - 'ImportProjects|Importing a project into a personal namespace results in all contributions being mapped to the same bot user and they cannot be reassigned. To map contributions to actual users, import the project to a group instead.', - ) - }} + {{ personalNamespaceWarning }} { return buttons.length ? buttons.at(0) : buttons; }; - function mountComponent(props, { storeOptions = {} } = {}) { + function mountComponent( + props, + { storeOptions = {}, userMappingToPersonalNamespaceOwner = true } = {}, + ) { Vue.use(Vuex); const store = initStore(storeOptions); @@ -65,6 +68,9 @@ describe('ProviderRepoTableRow', () => { propsData: { optionalStages: {}, ...props }, provide: { userNamespace, + glFeatures: { + userMappingToPersonalNamespaceOwner, + }, }, }); } @@ -118,7 +124,7 @@ describe('ProviderRepoTableRow', () => { 'Are you sure you want to import the project to a personal namespace?', ); expect(modal.text()).toContain( - 'Importing a project into a personal namespace results in all contributions being mapped to the same bot user and they cannot be reassigned. To map contributions to actual users, import the project to a group instead.', + 'Importing a project into a personal namespace results in all contributions being mapped to the personal namespace owner and they cannot be reassigned. To map contributions to real users, import projects into a group instead.', ); }); @@ -133,6 +139,35 @@ describe('ProviderRepoTableRow', () => { optionalStages: {}, }); }); + + describe('when user_mapping_to_personal_namespace_owner feature flag is disabled', () => { + beforeEach(() => { + mountComponent( + { repo }, + { + storeOptions: { importTarget: { targetNamespace: userNamespace } }, + userMappingToPersonalNamespaceOwner: false, + }, + ); + }); + + it('shows message warning user about mapping to import user', async () => { + findImportButton().vm.$emit('click'); + await nextTick(); + + const modal = findGlModal(); + expect(modal.text()).toContain( + 'Importing a project into a personal namespace results in all contributions being mapped to the same bot user and they cannot be reassigned. To map contributions to actual users, import the project to a group instead.', + ); + }); + + it('shows original warning message in memberships warning', () => { + const membershipsWarning = findMembershipsWarning(); + expect(membershipsWarning.text()).toContain( + 'Importing a project into a personal namespace results in all contributions being mapped to the same bot user and they cannot be reassigned. To map contributions to actual users, import the project to a group instead.', + ); + }); + }); }); describe('when group namespace is selected as import target', () => { -- GitLab From 76a42b91759bde2ca70102e46f6ed9e4884478d5 Mon Sep 17 00:00:00 2001 From: Sam Word Date: Thu, 14 Aug 2025 13:56:17 -0400 Subject: [PATCH 2/2] Updated text, removed redundant FE test --- .../components/provider_repo_table_row.vue | 4 ++-- locale/gitlab.pot | 12 ++++++------ .../components/provider_repo_table_row_spec.js | 11 ++--------- 3 files changed, 10 insertions(+), 17 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 3e6c88b2eb25ad..22fd5ca01433e0 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 @@ -134,12 +134,12 @@ export default { personalNamespaceWarning() { if (this.glFeatures.userMappingToPersonalNamespaceOwner) { return s__( - 'ImportProjects|Importing a project into a personal namespace results in all contributions being mapped to the personal namespace owner and they cannot be reassigned. To map contributions to real users, import projects into a group instead.', + 'ImportProjects|When you import to a personal namespace, all contributions are assigned to the personal namespace owner and they cannot be reassigned. To map contributions to real users, import to a group instead.', ); } return s__( - 'ImportProjects|Importing a project into a personal namespace results in all contributions being mapped to the same bot user and they cannot be reassigned. To map contributions to actual users, import the project to a group instead.', + 'ImportProjects|When you import to a personal namespace, all contributions are assigned to a single non-functional user and they cannot be reassigned. To map contributions to real users, import to a group instead.', ); }, }, diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 67716dcb5674f8..9b71a304cdb0cc 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -33169,12 +33169,6 @@ msgstr "" msgid "ImportProjects|Imported files will be kept. You can import this repository again later." msgstr "" -msgid "ImportProjects|Importing a project into a personal namespace results in all contributions being mapped to the personal namespace owner and they cannot be reassigned. To map contributions to real users, import projects into a group instead." -msgstr "" - -msgid "ImportProjects|Importing a project into a personal namespace results in all contributions being mapped to the same bot user and they cannot be reassigned. To map contributions to actual users, import the project to a group instead." -msgstr "" - msgid "ImportProjects|Importing the project failed" msgstr "" @@ -33220,6 +33214,12 @@ msgstr "" msgid "ImportProjects|Update of imported projects with realtime changes failed" msgstr "" +msgid "ImportProjects|When you import to a personal namespace, all contributions are assigned to a single non-functional user and they cannot be reassigned. To map contributions to real users, import to a group instead." +msgstr "" + +msgid "ImportProjects|When you import to a personal namespace, all contributions are assigned to the personal namespace owner and they cannot be reassigned. To map contributions to real users, import to a group instead." +msgstr "" + msgid "Imported" msgstr "" 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 edb7d8f47ef7fd..42900c234ff99a 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 @@ -124,7 +124,7 @@ describe('ProviderRepoTableRow', () => { 'Are you sure you want to import the project to a personal namespace?', ); expect(modal.text()).toContain( - 'Importing a project into a personal namespace results in all contributions being mapped to the personal namespace owner and they cannot be reassigned. To map contributions to real users, import projects into a group instead.', + 'When you import to a personal namespace, all contributions are assigned to the personal namespace owner and they cannot be reassigned. To map contributions to real users, import to a group instead.', ); }); @@ -157,14 +157,7 @@ describe('ProviderRepoTableRow', () => { const modal = findGlModal(); expect(modal.text()).toContain( - 'Importing a project into a personal namespace results in all contributions being mapped to the same bot user and they cannot be reassigned. To map contributions to actual users, import the project to a group instead.', - ); - }); - - it('shows original warning message in memberships warning', () => { - const membershipsWarning = findMembershipsWarning(); - expect(membershipsWarning.text()).toContain( - 'Importing a project into a personal namespace results in all contributions being mapped to the same bot user and they cannot be reassigned. To map contributions to actual users, import the project to a group instead.', + 'When you import to a personal namespace, all contributions are assigned to a single non-functional user and they cannot be reassigned. To map contributions to real users, import to a group instead.', ); }); }); -- GitLab