diff --git a/ee/app/assets/javascripts/security_orchestration/components/policies/no_policies_empty_state.vue b/ee/app/assets/javascripts/security_orchestration/components/policies/no_policies_empty_state.vue index ad1add78c7593e2b2396cf6de25ea63e018b5d50..6b41295e13aa6d7f200525d4e82d21e095cc4fab 100644 --- a/ee/app/assets/javascripts/security_orchestration/components/policies/no_policies_empty_state.vue +++ b/ee/app/assets/javascripts/security_orchestration/components/policies/no_policies_empty_state.vue @@ -1,6 +1,6 @@ <script> import { GlEmptyState } from '@gitlab/ui'; -import { s__ } from '~/locale'; +import { sprintf, s__ } from '~/locale'; import { NEW_POLICY_BUTTON_TEXT } from '../constants'; export default { @@ -13,11 +13,11 @@ export default { 'SecurityOrchestration|To widen your search, change filters above or select a different security policy project.', ), emptyStateDescription: s__( - 'SecurityOrchestration|This project does not contain any security policies.', + 'SecurityOrchestration|This %{namespaceType} does not contain any security policies.', ), newPolicyButtonText: NEW_POLICY_BUTTON_TEXT, }, - inject: ['emptyFilterSvgPath', 'emptyListSvgPath', 'newPolicyPath'], + inject: ['emptyFilterSvgPath', 'emptyListSvgPath', 'namespaceType', 'newPolicyPath'], props: { hasExistingPolicies: { type: Boolean, @@ -25,6 +25,13 @@ export default { default: false, }, }, + computed: { + description() { + return sprintf(this.$options.i18n.emptyStateDescription, { + namespaceType: this.namespaceType, + }); + }, + }, }; </script> <template> @@ -47,7 +54,7 @@ export default { > <template #description> <p class="gl-font-weight-bold"> - {{ $options.i18n.emptyStateDescription }} + {{ description }} </p> </template> </gl-empty-state> diff --git a/ee/spec/frontend/security_orchestration/components/policies/no_policies_empty_state_spec.js b/ee/spec/frontend/security_orchestration/components/policies/no_policies_empty_state_spec.js index 0ed70424b7d9aea489f3d4a8d2f8a24266c22976..96158a003c512cf7f3f5d24d3537af6fdf15de00 100644 --- a/ee/spec/frontend/security_orchestration/components/policies/no_policies_empty_state_spec.js +++ b/ee/spec/frontend/security_orchestration/components/policies/no_policies_empty_state_spec.js @@ -5,10 +5,13 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; describe('NoPoliciesEmptyState component', () => { let wrapper; + const projectNamespace = 'project'; + const groupNamespace = 'group'; + const findEmptyFilterState = () => wrapper.findByTestId('empty-filter-state'); const findEmptyListState = () => wrapper.findByTestId('empty-list-state'); - const factory = (hasExistingPolicies = false) => { + const factory = ({ hasExistingPolicies = false, namespaceType = projectNamespace } = {}) => { wrapper = shallowMountExtended(NoPoliciesEmptyState, { propsData: { hasExistingPolicies, @@ -16,6 +19,7 @@ describe('NoPoliciesEmptyState component', () => { provide: { emptyFilterSvgPath: 'path/to/filter/svg', emptyListSvgPath: 'path/to/list/svg', + namespaceType, newPolicyPath: 'path/to/new/policy', }, }); @@ -29,11 +33,21 @@ describe('NoPoliciesEmptyState component', () => { title | findComponent | state | factoryFn ${'does display the empty filter state'} | ${findEmptyFilterState} | ${false} | ${factory} ${'does not display the empty list state'} | ${findEmptyListState} | ${true} | ${factory} - ${'does not display the empty filter state'} | ${findEmptyFilterState} | ${true} | ${() => factory(true)} - ${'does display the empty list state'} | ${findEmptyListState} | ${false} | ${() => factory(true)} + ${'does not display the empty filter state'} | ${findEmptyFilterState} | ${true} | ${() => factory({ hasExistingPolicies: true })} + ${'does display the empty list state'} | ${findEmptyListState} | ${false} | ${() => factory({ hasExistingPolicies: true })} `('$title', async ({ factoryFn, findComponent, state }) => { factoryFn(); await nextTick(); expect(findComponent().exists()).toBe(state); }); + + it.each` + title | namespaceType + ${'does display the correct description for a project'} | ${projectNamespace} + ${'does display the correct description for a group'} | ${groupNamespace} + `('$title', async ({ namespaceType }) => { + factory({ namespaceType }); + await nextTick(); + expect(findEmptyListState().text()).toContain(namespaceType); + }); }); diff --git a/locale/gitlab.pot b/locale/gitlab.pot index a7e9a6a6c75c38d6da6b5efeab8df5ed3d8f3ea0..269362f872acae7d6d7b9cae5498cb68c295fa96 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -34686,6 +34686,9 @@ msgstr "" msgid "SecurityOrchestration|There was a problem creating the new security policy" msgstr "" +msgid "SecurityOrchestration|This %{namespaceType} does not contain any security policies." +msgstr "" + msgid "SecurityOrchestration|This group" msgstr "" @@ -34704,9 +34707,6 @@ msgstr "" msgid "SecurityOrchestration|This project" msgstr "" -msgid "SecurityOrchestration|This project does not contain any security policies." -msgstr "" - msgid "SecurityOrchestration|This view only shows scan results for the agent %{agent}. You can view scan results for all agents in the %{linkStart}Operational Vulnerabilities tab of the vulnerability report%{linkEnd}." msgstr ""