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 ab166b8fba197d5b303e050ad427563d4116c088..22fd5ca01433e0d2687b54254dd755d902af77ce 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|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|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.', + ); + }, }, 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.', + '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.', ); }); @@ -133,6 +139,28 @@ 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( + '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.', + ); + }); + }); }); describe('when group namespace is selected as import target', () => {