Skip to content

Add policy rule multi select for when the number of items is constant

Zamir Martins requested to merge add_simple_multi_select into master

What does this MR do and why?

Add policy rule multi select for when the number of items is constant and items have only a key and value being the identifier and the text respectively.

I suspect that this is going to be a common pattern for the features CI or YAML based like policy orchestration.

Related work to #351166 (closed)

Example of usage:

data(){
  return {
    severityLevelsToAdd: this.rule.severity_levels,
  };
},
//...
watch:{
  severityLevelsToAdd(values){
    this.rule.severity_levels = values;
  },
},
//...
 <policy-rule-multi-select
  class="gl-mr-3 gl-ml-3"
  :item-type-name="$options.APPROVAL_DIALOG_I18N.form.severityLevels"
  :items="$options.SEVERITY_LEVELS"
  v-model="severityLevelsToAdd"
/>

Screenshots or screen recordings

Live behavior:

simple_multi_select_640

How to set up and validate locally

  1. This example can be used:
import PolicyRuleMultiSelect from 'ee/threat_monitoring/components/policy_rule_multi_select.vue';

// Include PolicyRuleMultiSelect as part of the components list if rendering from another vue class

data(){
  return {
    selected: ['first_value'],
  };
},
//...
watch:{
  selected(values){
    this.demoValues = values;
  },
},
//...
<policy-rule-multi-select
 class="gl-mr-3 gl-ml-3"
 item-type-name="demo values"
 :items="{first_value: 'First Value!', second_value: 'Second Value!!', third_value: 'Third Value!!!'}"
 v-model="selected"
/>
  1. The output should be similar to the following:

Screen_Shot_2022-01-31_at_6.12.42_PM

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Zamir Martins

Merge request reports