[frontend] Enforce max policy limit

Why are we doing this work

There is a limit set of maximum 5 active vulnerability management policies in the backend, but we're not enforcing this in the frontend. This is similar to the scan execution and merge request approval policies.

Non-functional requirements

  • Documentation:
  • Feature flag: vulnerability_management_policy_type
  • Performance:
  • Testing: unit tests

Implementation plan

  1. Pass through maxActiveVulnerabilityManagementPoliciesReached and maxVulnerabilityManagementPoliciesAllowed in /security_orchestration/policy_editor.js
  2. Update policyLimitReached(), policyLimit(), and type() and inject maxActiveVulnerabilityManagementPoliciesReached and maxVulnerabilityManagementPoliciesAllowed in security_orchestration/components/policy_editor/editor_layout.vue
  3. Set hasMax and maxPoliciesAllowed and inject maxActiveVulnerabilityManagementPoliciesReached and maxVulnerabilityManagementPoliciesAllowed for vulnerability management policy in /security_orchestration/components/policy_editor/policy_type_selector.vue
  4. Update specs

Verification steps

  1. Go to https://staging.gitlab.com/govern-team-test/verify-vulnerability-management-policy/verify-465728/-/security/policies
  2. Click "New policy"
  3. Verify you can see message " You already have the maximum 5 vulnerability management policies." and you can't create a new vulnerability management policy
  4. Go back to the policies list
  5. Click on the disabled policy "Vulnerability management policy 1" and click "Edit policy"
  6. Verify that the Policy status radio button cannot be set to enabled in the rule mode (because we already have 5 enabled vuln management policies)
  7. Verify that hovering the radio buttons shows a tooltip
Edited by Lorenz van Herwaarden