feat: pre-fill the admin config form on Edit, separate from "Create" #54

Merged
rcsheets merged 1 commit from feat/admin-config-edit-prefill into main 2026-05-01 11:43:13 +00:00
Owner

Previously the only way to "update" a config was to type its slug into
the bottom form again with all the values you wanted, since there was
no edit affordance — the form was always blank, and any field you
forgot to re-enter got silently wiped on save.

Each config card now has an Edit button that links to
/admin/configs?edit=#config-form. The handler reads that query
parameter, finds the matching row, and threads it into the template
as EditTarget. The form switches its heading to "Editing ",
pre-fills every field with the current value, marks the slug as
read-only (it's the natural key for upsert; renaming it makes things
weird), and offers a Cancel link back to the unfiltered list.

When EditTarget is nil (the default), the form keeps its old "Create
a new configuration" framing with a blank slug and the
"Enable immediately" checkbox pre-checked.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

Previously the only way to "update" a config was to type its slug into the bottom form again with all the values you wanted, since there was no edit affordance — the form was always blank, and any field you forgot to re-enter got silently wiped on save. Each config card now has an Edit button that links to /admin/configs?edit=<slug>#config-form. The handler reads that query parameter, finds the matching row, and threads it into the template as EditTarget. The form switches its heading to "Editing <slug>", pre-fills every field with the current value, marks the slug as read-only (it's the natural key for upsert; renaming it makes things weird), and offers a Cancel link back to the unfiltered list. When EditTarget is nil (the default), the form keeps its old "Create a new configuration" framing with a blank slug and the "Enable immediately" checkbox pre-checked. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
feat: pre-fill the admin config form on Edit, separate from "Create"
All checks were successful
ci / check (pull_request) Successful in 44s
3a69ff91af
Previously the only way to "update" a config was to type its slug into
the bottom form again with all the values you wanted, since there was
no edit affordance — the form was always blank, and any field you
forgot to re-enter got silently wiped on save.

Each config card now has an Edit button that links to
/admin/configs?edit=<slug>#config-form. The handler reads that query
parameter, finds the matching row, and threads it into the template
as EditTarget. The form switches its heading to "Editing <slug>",
pre-fills every field with the current value, marks the slug as
read-only (it's the natural key for upsert; renaming it makes things
weird), and offers a Cancel link back to the unfiltered list.

When EditTarget is nil (the default), the form keeps its old "Create
a new configuration" framing with a blank slug and the
"Enable immediately" checkbox pre-checked.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator

Automated review by pr-reviewer v0.22.0 | Safety Check | Claude Sonnet 4 | tracking id r-f4915a-ef784a
This is an AI-generated review and may contain mistakes.

Status: Completed


Verdict: LGTM — The changes implement a straightforward edit form pre-population feature with proper query parameter handling and no obvious security or logic issues.
Complexity: moderate

Safety Check Review

Overview

This PR adds edit functionality to admin config forms by pre-filling form fields when an ?edit=<slug> query parameter is present.

Key Changes Reviewed

  • Backend: Added query parameter parsing to find and pass the target config to the template
  • Frontend: Conditionally renders either an edit form (pre-filled) or create form (blank) based on EditTarget

Safety Assessment

  • Query parameter handling is safe - uses strings.TrimSpace() and simple string comparison
  • No SQL injection risk - slug lookup uses slice iteration, not database query
  • Unknown slugs fail gracefully (editTarget remains nil, shows create form)
  • Form structure is preserved with appropriate readonly constraint on slug field
  • No credentials or sensitive data exposed

Minor Notes

  • Template logic properly handles conditional rendering with {{with .EditTarget}}
  • Edit form maintains same validation and security as create form
  • Cancel functionality correctly returns to unfiltered list

No alarming issues found.

*Automated review by [pr-reviewer](https://git.brooktrails.org/brooktrails/pr-reviewer) v0.22.0 | Safety Check | Claude Sonnet 4 | tracking id `r-f4915a-ef784a`* *This is an AI-generated review and may contain mistakes.* **Status:** ✅ Completed --- **✅ Verdict: LGTM** — The changes implement a straightforward edit form pre-population feature with proper query parameter handling and no obvious security or logic issues. **Complexity:** moderate # Safety Check Review ## Overview This PR adds edit functionality to admin config forms by pre-filling form fields when an `?edit=<slug>` query parameter is present. ## Key Changes Reviewed - **Backend**: Added query parameter parsing to find and pass the target config to the template - **Frontend**: Conditionally renders either an edit form (pre-filled) or create form (blank) based on `EditTarget` ## Safety Assessment - ✅ Query parameter handling is safe - uses `strings.TrimSpace()` and simple string comparison - ✅ No SQL injection risk - slug lookup uses slice iteration, not database query - ✅ Unknown slugs fail gracefully (editTarget remains nil, shows create form) - ✅ Form structure is preserved with appropriate readonly constraint on slug field - ✅ No credentials or sensitive data exposed ## Minor Notes - Template logic properly handles conditional rendering with `{{with .EditTarget}}` - Edit form maintains same validation and security as create form - Cancel functionality correctly returns to unfiltered list No alarming issues found.
rcsheets deleted branch feat/admin-config-edit-prefill 2026-05-01 11:43:13 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
brooktrails/pr-reviewer!54
No description provided.