From d06170ef46f82145c24fa4221e805e396d716058 Mon Sep 17 00:00:00 2001 From: Alexander Turinske <aturinske@gitlab.com> Date: Fri, 12 Apr 2024 13:27:58 +0000 Subject: [PATCH] Add pipeline execution conditions section - update text - update tests --- .../pipeline_execution/constants.js | 2 -- .../pipeline_execution/editor_component.vue | 17 ++++---------- .../pipeline_execution/rule/rule_section.vue | 23 ++++++++++++++++--- .../editor_component_spec.js | 6 ++++- .../rule/rule_section_spec.js | 22 ++++++++++++++++-- locale/gitlab.pot | 3 +++ 6 files changed, 52 insertions(+), 21 deletions(-) diff --git a/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/constants.js b/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/constants.js index 73f8b2199f478..3f6dd443220a2 100644 --- a/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/constants.js +++ b/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/constants.js @@ -4,8 +4,6 @@ export const DEFAULT_PIPELINE_EXECUTION_POLICY = `type: pipeline_execution_polic name: '' description: '' enabled: true -rules: - - foo: bar actions: - foo: bar `; diff --git a/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/editor_component.vue b/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/editor_component.vue index 9e481b7bcb61b..a7e3081f04139 100644 --- a/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/editor_component.vue +++ b/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/editor_component.vue @@ -8,24 +8,22 @@ import { PARSING_ERROR_MESSAGE, SECURITY_POLICY_ACTIONS, ACTIONS_LABEL, - RULES_LABEL, } from '../constants'; import EditorLayout from '../editor_layout.vue'; import DimDisableContainer from '../dim_disable_container.vue'; import RuleSection from './rule/rule_section.vue'; import ActionSection from './action/action_section.vue'; import { createPolicyObject, policyToYaml } from './utils'; -import { DEFAULT_PIPELINE_EXECUTION_POLICY } from './constants'; +import { CONDITIONS_LABEL, DEFAULT_PIPELINE_EXECUTION_POLICY } from './constants'; export default { ACTION: 'actions', - RULE: 'rules', EDITOR_MODE_RULE, EDITOR_MODE_YAML, SECURITY_POLICY_ACTIONS, i18n: { ACTIONS_LABEL, - RULES_LABEL, + CONDITIONS_LABEL, PARSING_ERROR_MESSAGE, notOwnerButtonText: __('Learn more'), }, @@ -107,21 +105,14 @@ export default { <template #rules> <dim-disable-container :disabled="hasParsingError"> <template #title> - <h4>{{ $options.i18n.RULES_LABEL }}</h4> + <h4>{{ $options.i18n.CONDITIONS_LABEL }}</h4> </template> <template #disabled> <div class="gl-bg-gray-10 gl-rounded-base gl-p-6"></div> </template> - <rule-section - v-for="(rule, index) in policy.rules" - :key="rule.id" - :data-testid="`rule-${index}`" - class="gl-mb-4" - :init-rule="rule" - :rule-index="index" - /> + <rule-section class="gl-mb-4" /> </dim-disable-container> </template> diff --git a/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/rule/rule_section.vue b/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/rule/rule_section.vue index 6f366fb3878c0..a215258d224a4 100644 --- a/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/rule/rule_section.vue +++ b/ee/app/assets/javascripts/security_orchestration/components/policy_editor/pipeline_execution/rule/rule_section.vue @@ -1,13 +1,30 @@ <script> -import { RULES_LABEL } from '../../constants'; +import { GlLink, GlSprintf } from '@gitlab/ui'; +import { s__ } from '~/locale'; +import { helpPagePath } from '~/helpers/help_page_helper'; export default { i18n: { - RULES_LABEL, + conditionText: s__( + 'SecurityOrchestration|Configure your conditions in the pipeline execution file. %{linkStart}What can pipeline execution do?%{linkEnd}', + ), + helpPageLink: helpPagePath('user/application_security/policies/pipeline-execution-policies'), + }, + components: { + GlLink, + GlSprintf, }, }; </script> <template> - <div>{{ $options.i18n.RULES_LABEL }}</div> + <div + class="gl-display-flex gl-flex-direction-column gl-lg-flex-direction-row gl-gap-3 security-policies-bg-gray-10 gl-rounded-base gl-p-5" + > + <gl-sprintf :message="$options.i18n.conditionText"> + <template #link="{ content }"> + <gl-link :href="$options.i18n.helpPageLink" target="_blank">{{ content }}</gl-link> + </template> + </gl-sprintf> + </div> </template> diff --git a/ee/spec/frontend/security_orchestration/components/policy_editor/pipeline_execution/editor_component_spec.js b/ee/spec/frontend/security_orchestration/components/policy_editor/pipeline_execution/editor_component_spec.js index a70ce696cb0ea..339d200824570 100644 --- a/ee/spec/frontend/security_orchestration/components/policy_editor/pipeline_execution/editor_component_spec.js +++ b/ee/spec/frontend/security_orchestration/components/policy_editor/pipeline_execution/editor_component_spec.js @@ -35,10 +35,14 @@ describe('RuleSection', () => { factory(); expect(findPolicyEditorLayout().exists()).toBe(true); expect(findActionSection().exists()).toBe(true); - expect(findRuleSection().exists()).toBe(true); expect(findEmptyState().exists()).toBe(false); }); + it('renders the rule section', () => { + factory(); + expect(findRuleSection().exists()).toBe(true); + }); + it('renders the empty page', () => { factory({ provide: { disableScanPolicyUpdate: true } }); expect(findPolicyEditorLayout().exists()).toBe(false); diff --git a/ee/spec/frontend/security_orchestration/components/policy_editor/pipeline_execution/rule/rule_section_spec.js b/ee/spec/frontend/security_orchestration/components/policy_editor/pipeline_execution/rule/rule_section_spec.js index ce4514eeb53a6..3902de760d142 100644 --- a/ee/spec/frontend/security_orchestration/components/policy_editor/pipeline_execution/rule/rule_section_spec.js +++ b/ee/spec/frontend/security_orchestration/components/policy_editor/pipeline_execution/rule/rule_section_spec.js @@ -1,3 +1,4 @@ +import { GlSprintf, GlLink } from '@gitlab/ui'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import RuleSection from 'ee/security_orchestration/components/policy_editor/pipeline_execution/rule/rule_section.vue'; @@ -12,11 +13,28 @@ describe('RuleSection', () => { provide: { ...provide, }, + stubs: { + GlSprintf, + }, }); }; - it('renders', () => { + const findGlSprintf = () => wrapper.findComponent(GlSprintf); + const findGlLink = () => wrapper.findComponent(GlLink); + + it('renders text', () => { + factory(); + expect(findGlSprintf().text()).toBe( + 'Configure your conditions in the pipeline execution file.', + ); + }); + + it('renders link', () => { factory(); - expect(wrapper.find('div').exists()).toBe(true); + expect(findGlLink().exists()).toBe(true); + expect(findGlLink().text()).toBe('What can pipeline execution do?'); + expect(findGlLink().attributes('href')).toBe( + '/help/user/application_security/policies/pipeline-execution-policies', + ); }); }); diff --git a/locale/gitlab.pot b/locale/gitlab.pot index f20d7363e4aa4..ca425e521b9ad 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -45949,6 +45949,9 @@ msgstr "" msgid "SecurityOrchestration|Compliance framework has no projects" msgstr "" +msgid "SecurityOrchestration|Configure your conditions in the pipeline execution file. %{linkStart}What can pipeline execution do?%{linkEnd}" +msgstr "" + msgid "SecurityOrchestration|Create more robust vulnerability rules and apply them to all your projects." msgstr "" -- GitLab