Commit c41ba9bd authored by Alexander Turinske's avatar Alexander Turinske

Fix policy preview for non-parseable policies

- pass in yaml
- update initial tab to yaml preview
- update tests

Changelog: changed
EE: true
parent 4024dda1
......@@ -48,7 +48,6 @@ export default {
noEnvironmentButton: __('Learn more'),
policyPreview: s__('SecurityOrchestration|Policy preview'),
rules: s__('SecurityOrchestration|Rules'),
unparseable: s__('SecurityOrchestration|Unable to parse policy'),
},
components: {
GlEmptyState,
......@@ -102,6 +101,9 @@ export default {
humanizedPolicy() {
return this.policy.error ? null : humanizeNetworkPolicy(this.policy);
},
initialTab() {
return this.hasParsingError ? 1 : 0;
},
policyAlert() {
return Boolean(this.policy.annotations);
},
......@@ -282,7 +284,7 @@ export default {
</template>
<template #disabled>
<policy-preview :policy-yaml="$options.i18n.unparsable" />
<policy-preview :initial-tab="initialTab" :policy-yaml="yamlEditorValue" />
</template>
<policy-preview :policy-yaml="policyYaml" :policy-description="humanizedPolicy" />
......
import { GlEmptyState, GlLoadingIcon, GlToggle } from '@gitlab/ui';
import { EDITOR_MODE_YAML } from 'ee/threat_monitoring/components/policy_editor/constants';
import DimDisableContainer from 'ee/threat_monitoring/components/policy_editor/dim_disable_container.vue';
import {
RuleDirectionInbound,
PortMatchModeAny,
......@@ -56,7 +57,7 @@ describe('NetworkPolicyEditor component', () => {
...provide,
},
store,
stubs: { PolicyYamlEditor: true },
stubs: { DimDisableContainer, PolicyYamlEditor: true },
});
};
......@@ -212,8 +213,12 @@ describe('NetworkPolicyEditor component', () => {
expect(wrapper.findByTestId('policy-action-container').props().disabled).toBe(true);
});
it('disables policy preview', () => {
it('disables policy preview and sets initial tab to yaml', () => {
expect(wrapper.findByTestId('policy-preview-container').props().disabled).toBe(true);
expect(findPreview().props()).toMatchObject({
initialTab: 1,
policyYaml: mockExistingL7Policy.manifest,
});
});
it('does not update yaml editor value on switch to yaml editor', async () => {
......
......@@ -29914,9 +29914,6 @@ msgstr ""
msgid "SecurityOrchestration|To widen your search, change filters above or select a different security policy project."
msgstr ""
msgid "SecurityOrchestration|Unable to parse policy"
msgstr ""
msgid "SecurityOrchestration|Update scan execution policies"
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