Commit 438c3b27 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '339509-update-to-status' into 'master'

Change enforcement label to status

See merge request gitlab-org/gitlab!72394
parents cca64f4d 60b82d46
...@@ -118,9 +118,9 @@ examining the Cilium logs: ...@@ -118,9 +118,9 @@ examining the Cilium logs:
kubectl -n gitlab-managed-apps logs -l k8s-app=cilium -c cilium-monitor kubectl -n gitlab-managed-apps logs -l k8s-app=cilium -c cilium-monitor
``` ```
### Change the enforcement status ### Change the status
To change a network policy's enforcement status: To change a network policy's status:
- Select the network policy you want to update. - Select the network policy you want to update.
- Select **Edit policy**. - Select **Edit policy**.
......
<script> <script>
import { __ } from '~/locale'; import { s__ } from '~/locale';
export default { export default {
props: { props: {
...@@ -10,8 +10,10 @@ export default { ...@@ -10,8 +10,10 @@ export default {
}, },
}, },
computed: { computed: {
enforcementStatusLabel() { statusLabel() {
return this.policy?.enabled ? __('Enabled') : __('Disabled'); return this.policy?.enabled
? s__('SecurityOrchestration|Enabled')
: s__('SecurityOrchestration|Disabled');
}, },
}, },
}; };
...@@ -23,6 +25,6 @@ export default { ...@@ -23,6 +25,6 @@ export default {
<p data-testid="policy-type"> <p data-testid="policy-type">
<slot name="type"></slot> <slot name="type"></slot>
</p> </p>
<slot v-bind="{ enforcementStatusLabel }"></slot> <slot v-bind="{ statusLabel }"></slot>
</div> </div>
</template> </template>
<script> <script>
import { GlIntersperse } from '@gitlab/ui'; import { GlIntersperse } from '@gitlab/ui';
import { n__, s__ } from '~/locale';
import { removeUnnecessaryDashes } from '../../utils'; import { removeUnnecessaryDashes } from '../../utils';
import { fromYaml, humanizeNetworkPolicy } from '../policy_editor/network_policy/lib'; import { fromYaml, humanizeNetworkPolicy } from '../policy_editor/network_policy/lib';
import PolicyPreview from '../policy_editor/policy_preview.vue'; import PolicyPreview from '../policy_editor/policy_preview.vue';
...@@ -7,6 +8,11 @@ import BasePolicy from './base_policy.vue'; ...@@ -7,6 +8,11 @@ import BasePolicy from './base_policy.vue';
import PolicyInfoRow from './policy_info_row.vue'; import PolicyInfoRow from './policy_info_row.vue';
export default { export default {
i18n: {
description: s__('SecurityOrchestration|Description'),
network: s__('NetworkPolicies|Network'),
status: s__('SecurityOrchestration|Status'),
},
components: { components: {
GlIntersperse, GlIntersperse,
BasePolicy, BasePolicy,
...@@ -40,36 +46,38 @@ export default { ...@@ -40,36 +46,38 @@ export default {
environments() { environments() {
return this.policy.environments?.nodes ?? []; return this.policy.environments?.nodes ?? [];
}, },
environmentLabel() {
return n__('Environment', 'Environments', this.environments.length);
},
}, },
}; };
</script> </script>
<template> <template>
<base-policy :policy="policy"> <base-policy :policy="policy">
<template #type>{{ s__('NetworkPolicies|Network') }}</template> <template #type>{{ $options.i18n.network }}</template>
<template #default="{ enforcementStatusLabel }"> <template #default="{ statusLabel }">
<div v-if="parsedYaml"> <div v-if="parsedYaml">
<policy-info-row <policy-info-row
v-if="parsedYaml.description" v-if="parsedYaml.description"
data-testid="description" data-testid="description"
:label="__('Description')" :label="$options.i18n.description"
>{{ parsedYaml.description }}</policy-info-row
> >
{{ parsedYaml.description }}
</policy-info-row>
<policy-info-row :label="s__('NetworkPolicies|Enforcement status')">{{ <policy-info-row :label="$options.i18n.status">{{ statusLabel }}</policy-info-row>
enforcementStatusLabel
}}</policy-info-row>
<policy-info-row <policy-info-row
v-if="environments.length" v-if="environments.length"
data-testid="environments" data-testid="environments"
:label="s__('SecurityPolicies|Environment(s)')" :label="environmentLabel"
> >
<gl-intersperse> <gl-intersperse>
<span v-for="environment in environments" :key="environment.name">{{ <span v-for="environment in environments" :key="environment.name">
environment.name {{ environment.name }}
}}</span> </span>
</gl-intersperse> </gl-intersperse>
</policy-info-row> </policy-info-row>
</div> </div>
......
<script> <script>
import { GlLink } from '@gitlab/ui'; import { GlLink } from '@gitlab/ui';
import { s__ } from '~/locale';
import { import {
fromYaml, fromYaml,
humanizeActions, humanizeActions,
...@@ -9,6 +10,15 @@ import BasePolicy from './base_policy.vue'; ...@@ -9,6 +10,15 @@ import BasePolicy from './base_policy.vue';
import PolicyInfoRow from './policy_info_row.vue'; import PolicyInfoRow from './policy_info_row.vue';
export default { export default {
i18n: {
action: s__('SecurityOrchestration|Action'),
description: s__('SecurityOrchestration|Description'),
latestScan: s__('SecurityOrchestration|Latest scan'),
rule: s__('SecurityOrchestration|Rule'),
scanExecution: s__('SecurityOrchestration|Scan execution'),
status: s__('SecurityOrchestration|Status'),
viewResults: s__('SecurityOrchestration|view results'),
},
components: { components: {
GlLink, GlLink,
BasePolicy, BasePolicy,
...@@ -40,38 +50,38 @@ export default { ...@@ -40,38 +50,38 @@ export default {
<template> <template>
<base-policy :policy="policy"> <base-policy :policy="policy">
<template #type>{{ s__('SecurityOrchestration|Scan execution') }}</template> <template #type>{{ $options.i18n.scanExecution }}</template>
<template #default="{ enforcementStatusLabel }"> <template #default="{ statusLabel }">
<div v-if="parsedYaml"> <div v-if="parsedYaml">
<policy-info-row <policy-info-row
v-if="parsedYaml.description" v-if="parsedYaml.description"
data-testid="policy-description" data-testid="policy-description"
:label="s__('SecurityOrchestration|Description')" :label="$options.i18n.description"
> >
{{ parsedYaml.description }} {{ parsedYaml.description }}
</policy-info-row> </policy-info-row>
<policy-info-row data-testid="policy-rules" :label="s__('SecurityOrchestration|Rule')"> <policy-info-row data-testid="policy-rules" :label="$options.i18n.rule">
<p v-for="rule in humanizedRules" :key="rule">{{ rule }}</p> <p v-for="rule in humanizedRules" :key="rule">{{ rule }}</p>
</policy-info-row> </policy-info-row>
<policy-info-row data-testid="policy-actions" :label="s__('SecurityOrchestration|Action')"> <policy-info-row data-testid="policy-actions" :label="$options.i18n.action">
<p v-for="action in humanizedActions" :key="action">{{ action }}</p> <p v-for="action in humanizedActions" :key="action">{{ action }}</p>
</policy-info-row> </policy-info-row>
<policy-info-row :label="s__('SecurityOrchestration|Enforcement Status')"> <policy-info-row :label="$options.i18n.status">
{{ enforcementStatusLabel }} {{ statusLabel }}
</policy-info-row> </policy-info-row>
<policy-info-row <policy-info-row
v-if="policy.latestScan" v-if="policy.latestScan"
data-testid="policy-latest-scan" data-testid="policy-latest-scan"
:label="s__('SecurityOrchestration|Latest scan')" :label="$options.i18n.latestScan"
> >
{{ policy.latestScan.date }} {{ policy.latestScan.date }}
<gl-link :href="policy.latestScan.pipelineUrl"> <gl-link :href="policy.latestScan.pipelineUrl">
{{ s__('SecurityOrchestration|view results') }} {{ $options.i18n.viewResults }}
</gl-link></policy-info-row </gl-link></policy-info-row
> >
</div> </div>
......
...@@ -19,11 +19,13 @@ exports[`CiliumNetworkPolicy component supported YAML renders policy preview tab ...@@ -19,11 +19,13 @@ exports[`CiliumNetworkPolicy component supported YAML renders policy preview tab
data-testid="description" data-testid="description"
label="Description" label="Description"
> >
test description
test description
</policy-info-row-stub> </policy-info-row-stub>
<policy-info-row-stub <policy-info-row-stub
label="Enforcement status" label="Status"
> >
Disabled Disabled
</policy-info-row-stub> </policy-info-row-stub>
......
...@@ -5,7 +5,7 @@ describe('BasePolicy component', () => { ...@@ -5,7 +5,7 @@ describe('BasePolicy component', () => {
let wrapper; let wrapper;
const findPolicyType = () => wrapper.findByTestId('policy-type'); const findPolicyType = () => wrapper.findByTestId('policy-type');
const findEnforcementStatusLabel = () => wrapper.findByTestId('enforcement-status-label'); const findStatusLabel = () => wrapper.findByTestId('status-label');
const factory = (propsData = {}) => { const factory = (propsData = {}) => {
wrapper = shallowMountExtended(BasePolicy, { wrapper = shallowMountExtended(BasePolicy, {
...@@ -14,8 +14,7 @@ describe('BasePolicy component', () => { ...@@ -14,8 +14,7 @@ describe('BasePolicy component', () => {
type: 'Policy type', type: 'Policy type',
}, },
scopedSlots: { scopedSlots: {
default: default: '<span data-testid="status-label">{{ props.statusLabel }}</span>',
'<span data-testid="enforcement-status-label">{{ props.enforcementStatusLabel }}</span>',
}, },
}); });
}; };
...@@ -34,16 +33,13 @@ describe('BasePolicy component', () => { ...@@ -34,16 +33,13 @@ describe('BasePolicy component', () => {
description | enabled | expectedLabel description | enabled | expectedLabel
${'enabled'} | ${true} | ${'Enabled'} ${'enabled'} | ${true} | ${'Enabled'}
${'disabled'} | ${false} | ${'Disabled'} ${'disabled'} | ${false} | ${'Disabled'}
`( `('renders the status label when policy is $description', ({ enabled, expectedLabel }) => {
'renders the enforcement status label when policy is $description', factory({
({ enabled, expectedLabel }) => { policy: {
factory({ enabled,
policy: { },
enabled, });
},
}); expect(findStatusLabel().text()).toBe(expectedLabel);
});
expect(findEnforcementStatusLabel().text()).toBe(expectedLabel);
},
);
}); });
...@@ -95,7 +95,8 @@ describe('CiliumNetworkPolicy component', () => { ...@@ -95,7 +95,8 @@ describe('CiliumNetworkPolicy component', () => {
}, },
}); });
expect(findEnvironments().exists()).toBe(true); expect(findEnvironments().exists()).toBe(true);
expect(findEnvironments().text()).toBe('production, local'); expect(findEnvironments().text()).toContain('production');
expect(findEnvironments().text()).toContain('local');
}); });
it("does not render environments row if there aren't any", () => { it("does not render environments row if there aren't any", () => {
......
...@@ -12890,7 +12890,9 @@ msgid "Enterprise" ...@@ -12890,7 +12890,9 @@ msgid "Enterprise"
msgstr "" msgstr ""
msgid "Environment" msgid "Environment"
msgstr "" msgid_plural "Environments"
msgstr[0] ""
msgstr[1] ""
msgid "Environment does not have deployments" msgid "Environment does not have deployments"
msgstr "" msgstr ""
...@@ -22591,9 +22593,6 @@ msgstr "" ...@@ -22591,9 +22593,6 @@ msgstr ""
msgid "NetworkPolicies|Edit policy" msgid "NetworkPolicies|Edit policy"
msgstr "" msgstr ""
msgid "NetworkPolicies|Enforcement status"
msgstr ""
msgid "NetworkPolicies|Environment does not have deployment platform" msgid "NetworkPolicies|Environment does not have deployment platform"
msgstr "" msgstr ""
...@@ -30242,16 +30241,19 @@ msgstr "" ...@@ -30242,16 +30241,19 @@ msgstr ""
msgid "SecurityOrchestration|Description" msgid "SecurityOrchestration|Description"
msgstr "" msgstr ""
msgid "SecurityOrchestration|Disabled"
msgstr ""
msgid "SecurityOrchestration|Edit policy" msgid "SecurityOrchestration|Edit policy"
msgstr "" msgstr ""
msgid "SecurityOrchestration|Edit policy project" msgid "SecurityOrchestration|Edit policy project"
msgstr "" msgstr ""
msgid "SecurityOrchestration|Enforce security for this project. %{linkStart}More information.%{linkEnd}" msgid "SecurityOrchestration|Enabled"
msgstr "" msgstr ""
msgid "SecurityOrchestration|Enforcement Status" msgid "SecurityOrchestration|Enforce security for this project. %{linkStart}More information.%{linkEnd}"
msgstr "" msgstr ""
msgid "SecurityOrchestration|Executes a %{scanType} scan" msgid "SecurityOrchestration|Executes a %{scanType} scan"
...@@ -30320,6 +30322,9 @@ msgstr "" ...@@ -30320,6 +30322,9 @@ msgstr ""
msgid "SecurityOrchestration|Sorry, your filter produced no results." msgid "SecurityOrchestration|Sorry, your filter produced no results."
msgstr "" msgstr ""
msgid "SecurityOrchestration|Status"
msgstr ""
msgid "SecurityOrchestration|There was a problem creating the new security policy" msgid "SecurityOrchestration|There was a problem creating the new security policy"
msgstr "" msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment