Skip to content

Fix action/rule deletion bug

What does this MR do and why?

Fix action/rule deletion bug

  • the bug is that the v-for items are using the index for the :key, so the UI is not updating properly
  • create a unique id for each action/rule in the policy object, use the key id, and use it for the :key in the v-for
    • add unique id to default actions/rules
    • add unique id to actions/rules if they exist when creating the policy object in the fromYaml methods
    • remove unique id from the actions/rules if they exist when created the policy yaml in the toYaml methods
      • only have the unique id appear in the policy object, which is used in rule mode, which is where the bug is
      • the unique id should never appear in the policy yaml because the policy yaml is what is saved
  • update all the tests
  • mock uniqueId in tests

Changelog: fixed

EE: true

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Scenario Before After
Scan Result Policy srp_-_b srp_-_a
Scan Execution Policy sep_-_b sep_-_a

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Scan Result Policy

  1. Upload a GitLab Ultimate license
  2. Navigate to a project/group => Secure => Policies => New policy => Scan Result Policy
  3. Create multiple rules of the same type and change various other parameters to distinguish between them
  4. Remove the first rule
  5. Verify the correct rule was removed from the UI and the yaml preview

Scan Execution Policy

  1. Upload a GitLab Ultimate license
  2. Navigate to a project/group => Secure => Policies => New policy => Scan Execution Policy
  3. Create multiple rules of the same type and change various other parameters to distinguish between them
  4. Remove the first rule
  5. Verify the correct rule was removed from the UI and the yaml preview
  6. Create multiple actions of the same type and change various other parameters to distinguish between them
  7. Remove the first action
  8. Verify the correct action was removed from the UI and the yaml preview

Related to #433293 (closed)

Edited by Alexander Turinske

Merge request reports