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:
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 **Edit policy**.
......
<script>
import { __ } from '~/locale';
import { s__ } from '~/locale';
export default {
props: {
......@@ -10,8 +10,10 @@ export default {
},
},
computed: {
enforcementStatusLabel() {
return this.policy?.enabled ? __('Enabled') : __('Disabled');
statusLabel() {
return this.policy?.enabled
? s__('SecurityOrchestration|Enabled')
: s__('SecurityOrchestration|Disabled');
},
},
};
......@@ -23,6 +25,6 @@ export default {
<p data-testid="policy-type">
<slot name="type"></slot>
</p>
<slot v-bind="{ enforcementStatusLabel }"></slot>
<slot v-bind="{ statusLabel }"></slot>
</div>
</template>
<script>
import { GlIntersperse } from '@gitlab/ui';
import { n__, s__ } from '~/locale';
import { removeUnnecessaryDashes } from '../../utils';
import { fromYaml, humanizeNetworkPolicy } from '../policy_editor/network_policy/lib';
import PolicyPreview from '../policy_editor/policy_preview.vue';
......@@ -7,6 +8,11 @@ import BasePolicy from './base_policy.vue';
import PolicyInfoRow from './policy_info_row.vue';
export default {
i18n: {
description: s__('SecurityOrchestration|Description'),
network: s__('NetworkPolicies|Network'),
status: s__('SecurityOrchestration|Status'),
},
components: {
GlIntersperse,
BasePolicy,
......@@ -40,36 +46,38 @@ export default {
environments() {
return this.policy.environments?.nodes ?? [];
},
environmentLabel() {
return n__('Environment', 'Environments', this.environments.length);
},
},
};
</script>
<template>
<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">
<policy-info-row
v-if="parsedYaml.description"
data-testid="description"
:label="__('Description')"
>{{ parsedYaml.description }}</policy-info-row
:label="$options.i18n.description"
>
{{ parsedYaml.description }}
</policy-info-row>
<policy-info-row :label="s__('NetworkPolicies|Enforcement status')">{{
enforcementStatusLabel
}}</policy-info-row>
<policy-info-row :label="$options.i18n.status">{{ statusLabel }}</policy-info-row>
<policy-info-row
v-if="environments.length"
data-testid="environments"
:label="s__('SecurityPolicies|Environment(s)')"
:label="environmentLabel"
>
<gl-intersperse>
<span v-for="environment in environments" :key="environment.name">{{
environment.name
}}</span>
<span v-for="environment in environments" :key="environment.name">
{{ environment.name }}
</span>
</gl-intersperse>
</policy-info-row>
</div>
......
<script>
import { GlLink } from '@gitlab/ui';
import { s__ } from '~/locale';
import {
fromYaml,
humanizeActions,
......@@ -9,6 +10,15 @@ import BasePolicy from './base_policy.vue';
import PolicyInfoRow from './policy_info_row.vue';
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: {
GlLink,
BasePolicy,
......@@ -40,38 +50,38 @@ export default {
<template>
<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">
<policy-info-row
v-if="parsedYaml.description"
data-testid="policy-description"
:label="s__('SecurityOrchestration|Description')"
:label="$options.i18n.description"
>
{{ parsedYaml.description }}
</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>
</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>
</policy-info-row>
<policy-info-row :label="s__('SecurityOrchestration|Enforcement Status')">
{{ enforcementStatusLabel }}
<policy-info-row :label="$options.i18n.status">
{{ statusLabel }}
</policy-info-row>
<policy-info-row
v-if="policy.latestScan"
data-testid="policy-latest-scan"
:label="s__('SecurityOrchestration|Latest scan')"
:label="$options.i18n.latestScan"
>
{{ policy.latestScan.date }}
<gl-link :href="policy.latestScan.pipelineUrl">
{{ s__('SecurityOrchestration|view results') }}
{{ $options.i18n.viewResults }}
</gl-link></policy-info-row
>
</div>
......
......@@ -19,11 +19,13 @@ exports[`CiliumNetworkPolicy component supported YAML renders policy preview tab
data-testid="description"
label="Description"
>
test description
test description
</policy-info-row-stub>
<policy-info-row-stub
label="Enforcement status"
label="Status"
>
Disabled
</policy-info-row-stub>
......
......@@ -5,7 +5,7 @@ describe('BasePolicy component', () => {
let wrapper;
const findPolicyType = () => wrapper.findByTestId('policy-type');
const findEnforcementStatusLabel = () => wrapper.findByTestId('enforcement-status-label');
const findStatusLabel = () => wrapper.findByTestId('status-label');
const factory = (propsData = {}) => {
wrapper = shallowMountExtended(BasePolicy, {
......@@ -14,8 +14,7 @@ describe('BasePolicy component', () => {
type: 'Policy type',
},
scopedSlots: {
default:
'<span data-testid="enforcement-status-label">{{ props.enforcementStatusLabel }}</span>',
default: '<span data-testid="status-label">{{ props.statusLabel }}</span>',
},
});
};
......@@ -34,16 +33,13 @@ describe('BasePolicy component', () => {
description | enabled | expectedLabel
${'enabled'} | ${true} | ${'Enabled'}
${'disabled'} | ${false} | ${'Disabled'}
`(
'renders the enforcement status label when policy is $description',
({ enabled, expectedLabel }) => {
factory({
policy: {
enabled,
},
});
expect(findEnforcementStatusLabel().text()).toBe(expectedLabel);
},
);
`('renders the status label when policy is $description', ({ enabled, expectedLabel }) => {
factory({
policy: {
enabled,
},
});
expect(findStatusLabel().text()).toBe(expectedLabel);
});
});
......@@ -95,7 +95,8 @@ describe('CiliumNetworkPolicy component', () => {
},
});
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", () => {
......
......@@ -12890,7 +12890,9 @@ msgid "Enterprise"
msgstr ""
msgid "Environment"
msgstr ""
msgid_plural "Environments"
msgstr[0] ""
msgstr[1] ""
msgid "Environment does not have deployments"
msgstr ""
......@@ -22591,9 +22593,6 @@ msgstr ""
msgid "NetworkPolicies|Edit policy"
msgstr ""
msgid "NetworkPolicies|Enforcement status"
msgstr ""
msgid "NetworkPolicies|Environment does not have deployment platform"
msgstr ""
......@@ -30242,16 +30241,19 @@ msgstr ""
msgid "SecurityOrchestration|Description"
msgstr ""
msgid "SecurityOrchestration|Disabled"
msgstr ""
msgid "SecurityOrchestration|Edit policy"
msgstr ""
msgid "SecurityOrchestration|Edit policy project"
msgstr ""
msgid "SecurityOrchestration|Enforce security for this project. %{linkStart}More information.%{linkEnd}"
msgid "SecurityOrchestration|Enabled"
msgstr ""
msgid "SecurityOrchestration|Enforcement Status"
msgid "SecurityOrchestration|Enforce security for this project. %{linkStart}More information.%{linkEnd}"
msgstr ""
msgid "SecurityOrchestration|Executes a %{scanType} scan"
......@@ -30320,6 +30322,9 @@ msgstr ""
msgid "SecurityOrchestration|Sorry, your filter produced no results."
msgstr ""
msgid "SecurityOrchestration|Status"
msgstr ""
msgid "SecurityOrchestration|There was a problem creating the new security policy"
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