Skip to content

Admin utilities to display form versions#1376

Merged
alexluckett merged 38 commits intomainfrom
feature/admin-utilities-forms-versions
Apr 13, 2026
Merged

Admin utilities to display form versions#1376
alexluckett merged 38 commits intomainfrom
feature/admin-utilities-forms-versions

Conversation

@alexluckett
Copy link
Copy Markdown
Contributor

@alexluckett alexluckett commented Apr 10, 2026

Adds a new Form Inspect developer tool to the admin area, gated behind a new FormsInspect scope (superadmin only). The tool lets administrators look up any form by ID or slug and inspect its state across several tabs.

What's included

  • Superadmin utility to view metadata, draft def, live def, versions and compare version history
  • Added Scopes.FormsInspect = 'forms-inspect' to the model and routes
  • Added jsondiffpatch as a dependency for structured JSON delta computation and server-side HTML rendering.

Form Inspect routes (/admin/form-inspect)

Route	Description
GET /admin/form-inspect	Lookup form — radio + text input for ID or slug
GET /admin/form-inspect/{id}/metadata	View form metadata as formatted JSON
GET /admin/form-inspect/{id}/definition/live	View live form definition JSON
GET /admin/form-inspect/{id}/definition/draft	View draft form definition JSON
GET /admin/form-inspect/{id}/versions/{versionId}	View a specific version's definition JSON
GET /admin/form-inspect/{id}/versions/{from}..{to}	Render visual JSON diff between two versions
Version diffing with jsondiffpatch

Adds formInspect to session names, creates an empty route file, wires it
into the admin index routes/supports/scope, and adds a conditional link
in the admin index view gated on the FormsInspect scope.
- Add braces to braceless if statements in objectHash
- Extract duplicated string literals to module-level constants
- Rename shadowed joiError variable in slug-not-found catch block
- Use replaceAll over replace for XSS-strip regex
- Darken deleted-text colour in diff view to meet AA contrast (3.67 → 5.28:1)
- Add tests for error rethrow paths and objectHash branch coverage
@alexluckett alexluckett force-pushed the feature/admin-utilities-forms-versions branch from 56eea8d to 845071d Compare April 10, 2026 22:15
@alexluckett alexluckett reopened this Apr 10, 2026
</div>
{% endmacro %}

{% macro appJsonDisplay(data) %}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that this is now a macro. Is the DLQ stuff now using this macro or is that another PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I forgot to refactor that. I'll do that as a follow-up.

Copy link
Copy Markdown
Contributor

@jbarnsley10 jbarnsley10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work. A couple of minor comments (and probs the 404 try/catches I now realise are because your page might display things like 'No draft versions for this form' etc), so probs ok.
Obvs forms-entitlement-api will need a model bump once this PR is mergd to pick up the new extra scope on superadmin.

@sonarqubecloud
Copy link
Copy Markdown

@alexluckett alexluckett merged commit 15920ec into main Apr 13, 2026
10 checks passed
@alexluckett alexluckett deleted the feature/admin-utilities-forms-versions branch April 13, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants