Add Policy Store Build policy step
What does this MR do and why?
Summary
This merge request introduces a new "Build Policy" step to the policy editor wizard, allowing users to visually assemble a policy by selecting triggers, rules, and actions from a categorized catalog — rather than writing configuration manually.
Key changes include:
- New UI components: A
BuilderSectiondisplays the user's current selections (with expand/collapse and remove buttons), and aCatalogGroupshows available options in a searchable, grouped list with selection indicators. - New serializer: Translates between the editor's internal form state and the format the Policy Store API expects, handling both saving and loading of existing policies.
- Wizard integration: The new Build step is inserted into the existing step-by-step wizard flow, and the overall policy summary (used in the review step) now includes the trigger, rules, and actions chosen in this step.
- Code cleanup: Some verbose comments in the category constants file were shortened, and a few minor refactors were made to the wizard's step label logic.
In plain terms: users can now pick the building blocks of their policy (when it runs, what it checks, and what it does) through a point-and-click interface, instead of editing raw configuration.
A3's own changes
Screenshots or screen recordings
| Description | UI |
|---|---|
| Policy builder |
References
- Plan: https://gitlab.com/gitlab-org/gitlab/-/issues/607341
- Depends on: !247890 (merged) (A2, included in this branch)
- Builds on: !247679 (merged) (A1, merged)
- Ported shell: !246660 (closed)
How to set up and validate locally
The Policy Store is behind a flag and a two-level experiment opt-in:
-
Enable the feature flag:
Feature.enable(:security_policies_v2) -
Enable the instance setting:
ApplicationSetting.current.update!(policy_store_experiment_enabled: true) -
Enable it for a top-level group with an Ultimate licence:
Group.find_by_full_path('your-group').namespace_settings.update!(policy_store_experiment_enabled: true) -
Go to Group → Secure → Policy Store, then New policy.
-
On Build policy: pick the Deployment trigger, then a rule or two, then an action. Check that
- selecting a second trigger replaces the first
- each selected entry expands into its own config form
- the Rego rule is pre-filled with the deployment gate template and Browse templates works
- values survive clicking Next to Scope and Back again
yarn jest ee/spec/frontend/policy_store126 tests across 12 suites. The serializer's round-trip spec (state → payload → state) is the one to look at first — it is the contract C2 depends on.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.