Draft: Drive the Policy Store editor from the URL

What does this MR do and why?

Gives the Policy Store editor URL-addressable state, so a refresh or a shared link restores the exact editor view instead of falling back to the list.

  • no params — the policy list
  • ?editor=new&step=build|scope|review — creating a policy
  • ?editor=edit&policy=<id-or-name>&step=… — editing a policy, addressed by id when it has one, by name otherwise

Guard rails: an unknown step normalizes to build; an unknown editor value reads as the list; an edit link to a policy the list does not know returns to the list.

Implementation — plain frontend routing, no Vue Router and no backend changes (query params survive a refresh on the existing index route):

  • editor_url.js owns the URL shape over ~/lib/utils/url_utility (queryToObject, setUrlParams, removeParams).
  • App holds the state parsed from the URL, navigates with updateHistory, and follows popstate, so browser Back/Forward walk the wizard.
  • StepWizard takes the step as a prop and emits change-step; Next/Back/Edit all round-trip through the URL.

Stacked on !248607 (merged) (targets 607341-policy-store-editor-design); merge that first.

References

Screenshots or screen recordings

No visual changes — the list and editor render exactly as before; only the URL bar changes while navigating.

Before After
/-/security/policy_store for every editor state /-/security/policy_store?editor=new&step=build, …?editor=edit&policy=1&step=review, …

How to set up and validate locally

  1. Enable the experiment for a top-level group:

    # rails console
    Feature.enable(:security_policies_v2)
    ApplicationSetting.current.update!(policy_store_experiment_enabled: true)
    Group.find_by_full_path('flightjs').namespace_settings.update!(policy_store_experiment_enabled: true)
  2. Visit http://gdk.test:3000/groups/flightjs/-/security/policy_store.

  3. Click Create new policy — the URL gains ?editor=new&step=build; Next/Back move it through scope and review, and browser Back/Forward walk the steps.

  4. Refresh on any step — the editor reopens on that step.

  5. Edit a policy from the list — the URL gains ?editor=edit&policy=1&step=build; refresh restores it. Replace 1 with the policy name (URL-encoded) — the same editor opens.

  6. Try a bogus step (…&step=nonsense) or an unknown policy (…&policy=999) — you land on build / the list respectively.

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.

Edited by Artur Fedorov

Merge request reports

Loading
Loading