Commit e7db9b39 authored by Alexander Turinske's avatar Alexander Turinske Committed by Simon Knox

Update policy drawer status section

- add icon for enabled and css styling
- update wording when not enabled
- update tests

Changelog: other

EE: true
parent 64985d9a
<script> <script>
import { s__ } from '~/locale'; import { ENABLED_LABEL, NOT_ENABLED_LABEL } from './constants';
export default { export default {
props: { props: {
...@@ -11,9 +11,7 @@ export default { ...@@ -11,9 +11,7 @@ export default {
}, },
computed: { computed: {
statusLabel() { statusLabel() {
return this.policy?.enabled return this.policy?.enabled ? ENABLED_LABEL : NOT_ENABLED_LABEL;
? s__('SecurityOrchestration|Enabled')
: s__('SecurityOrchestration|Disabled');
}, },
}, },
}; };
......
import { s__ } from '~/locale';
export const ENABLED_LABEL = s__('SecurityOrchestration|Enabled');
export const NOT_ENABLED_LABEL = s__('SecurityOrchestration|Not enabled');
<script> <script>
import { GlLink } from '@gitlab/ui'; import { GlIcon, GlLink } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { import {
fromYaml, fromYaml,
...@@ -20,6 +20,7 @@ export default { ...@@ -20,6 +20,7 @@ export default {
viewResults: s__('SecurityOrchestration|view results'), viewResults: s__('SecurityOrchestration|view results'),
}, },
components: { components: {
GlIcon,
GlLink, GlLink,
BasePolicy, BasePolicy,
PolicyInfoRow, PolicyInfoRow,
...@@ -71,7 +72,12 @@ export default { ...@@ -71,7 +72,12 @@ export default {
</policy-info-row> </policy-info-row>
<policy-info-row :label="$options.i18n.status"> <policy-info-row :label="$options.i18n.status">
<div v-if="policy.enabled" class="gl-text-green-500" data-testid="enabled-status-text">
<gl-icon name="check-circle-filled" class="gl-mr-3" />{{ statusLabel }}
</div>
<div v-else class="gl-text-gray-500" data-testid="not-enabled-status-text">
{{ statusLabel }} {{ statusLabel }}
</div>
</policy-info-row> </policy-info-row>
<policy-info-row <policy-info-row
......
...@@ -35,7 +35,7 @@ exports[`CiliumNetworkPolicy component supported YAML renders policy preview 1`] ...@@ -35,7 +35,7 @@ exports[`CiliumNetworkPolicy component supported YAML renders policy preview 1`]
<policy-info-row-stub <policy-info-row-stub
label="Status" label="Status"
> >
Disabled Not enabled
</policy-info-row-stub> </policy-info-row-stub>
<!----> <!---->
......
import BasePolicy from 'ee/threat_monitoring/components/policy_drawer/base_policy.vue'; import BasePolicy from 'ee/threat_monitoring/components/policy_drawer/base_policy.vue';
import {
ENABLED_LABEL,
NOT_ENABLED_LABEL,
} from 'ee/threat_monitoring/components/policy_drawer/constants';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
describe('BasePolicy component', () => { describe('BasePolicy component', () => {
...@@ -31,8 +35,8 @@ describe('BasePolicy component', () => { ...@@ -31,8 +35,8 @@ describe('BasePolicy component', () => {
it.each` it.each`
description | enabled | expectedLabel description | enabled | expectedLabel
${'enabled'} | ${true} | ${'Enabled'} ${ENABLED_LABEL} | ${true} | ${ENABLED_LABEL}
${'disabled'} | ${false} | ${'Disabled'} ${NOT_ENABLED_LABEL} | ${false} | ${NOT_ENABLED_LABEL}
`('renders the status label when policy is $description', ({ enabled, expectedLabel }) => { `('renders the status label when policy is $description', ({ enabled, expectedLabel }) => {
factory({ factory({
policy: { policy: {
......
...@@ -13,6 +13,8 @@ describe('ScanExecutionPolicy component', () => { ...@@ -13,6 +13,8 @@ describe('ScanExecutionPolicy component', () => {
const findDescription = () => wrapper.findByTestId('policy-description'); const findDescription = () => wrapper.findByTestId('policy-description');
const findLatestScan = () => wrapper.findByTestId('policy-latest-scan'); const findLatestScan = () => wrapper.findByTestId('policy-latest-scan');
const findRules = () => wrapper.findByTestId('policy-rules'); const findRules = () => wrapper.findByTestId('policy-rules');
const findEnabledText = () => wrapper.findByTestId('enabled-status-text');
const findNotEnabledText = () => wrapper.findByTestId('not-enabled-status-text');
const factory = ({ propsData } = {}) => { const factory = ({ propsData } = {}) => {
wrapper = shallowMountExtended(ScanExecutionPolicy, { wrapper = shallowMountExtended(ScanExecutionPolicy, {
...@@ -38,6 +40,7 @@ describe('ScanExecutionPolicy component', () => { ...@@ -38,6 +40,7 @@ describe('ScanExecutionPolicy component', () => {
${'rules'} | ${findRules} | ${''} ${'rules'} | ${findRules} | ${''}
${'description'} | ${findDescription} | ${'This policy enforces pipeline configuration to have a job with DAST scan'} ${'description'} | ${findDescription} | ${'This policy enforces pipeline configuration to have a job with DAST scan'}
${'latest scan'} | ${findLatestScan} | ${''} ${'latest scan'} | ${findLatestScan} | ${''}
${'enabled text'} | ${findEnabledText} | ${''}
`('does render the policy $component', ({ finder, text }) => { `('does render the policy $component', ({ finder, text }) => {
const component = finder(); const component = finder();
expect(component.exists()).toBe(true); expect(component.exists()).toBe(true);
...@@ -47,6 +50,16 @@ describe('ScanExecutionPolicy component', () => { ...@@ -47,6 +50,16 @@ describe('ScanExecutionPolicy component', () => {
}); });
}); });
describe('not enabled policy', () => {
beforeEach(() => {
factory({ propsData: { policy: { ...mockScanExecutionPolicy, enabled: false } } });
});
it('does render the policy not enabled text', () => {
expect(findNotEnabledText().exists()).toBe(true);
});
});
describe('empty policy', () => { describe('empty policy', () => {
beforeEach(() => { beforeEach(() => {
factory({ factory({
......
...@@ -31974,9 +31974,6 @@ msgstr "" ...@@ -31974,9 +31974,6 @@ msgstr ""
msgid "SecurityOrchestration|Description" msgid "SecurityOrchestration|Description"
msgstr "" msgstr ""
msgid "SecurityOrchestration|Disabled"
msgstr ""
msgid "SecurityOrchestration|Edit policy" msgid "SecurityOrchestration|Edit policy"
msgstr "" msgstr ""
...@@ -32010,6 +32007,9 @@ msgstr "" ...@@ -32010,6 +32007,9 @@ msgstr ""
msgid "SecurityOrchestration|No rules defined - policy will not run." msgid "SecurityOrchestration|No rules defined - policy will not run."
msgstr "" msgstr ""
msgid "SecurityOrchestration|Not enabled"
msgstr ""
msgid "SecurityOrchestration|Only owners can update Security Policy Project" msgid "SecurityOrchestration|Only owners can update Security Policy Project"
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