feat(web): admin UI to edit and create application distribution config #64

Merged
nrupard merged 2 commits from feat/bunyip-51-app-distribution-admin-ui into main 2026-06-04 16:01:09 +02:00
Owner

What

Add a web admin UI to edit and create an application's Forgejo binary and OCI container distribution config. The bunyip-api backend already accepted these fields (validated by DistributionConfig::validate on both create and update); the gap was entirely in bunyip-web, which only exposed is_active/maintenance_mode toggles, dropped the distribution fields from its AdminApplication DTO, and had no create-application form.

Changes

  • New per-application "Edit" action: GET /admin/applications/{id}/edit renders a distribution form prefilled from the current row; POST /admin/applications/{id}/distribution persists via the existing PUT /admin/applications/{id}.
  • New "New application" action: GET /admin/applications/new plus POST /admin/applications, capturing the required identity fields (name, slug, display_name, container_name) plus distribution config, via a new admin_api::create_application client.
  • artifact_source renders as a select (release | generic_package). Empty inputs are omitted so existing column values are kept, EXCEPT forgejo_package, which is always sent so an empty value clears it to NULL via the backend's documented sentinel.
  • Backend validation failures (partial OCI/release triples, forgejo_package on a release source, empty/whitespace values) are surfaced as an inline error banner with the submitted values preserved, instead of being silently swallowed.
  • Extend the web AdminApplication DTO with the eight distribution fields for prefill.
  • Unit tests on the request-body builders cover the omit-empty rule and the forgejo_package clear-to-NULL sentinel.

Verification

just check-container green: fmt, clippy -D warnings, and tests. bunyip-web is a binary crate, so its unit tests run under cargo test -p bunyip-web --bins (3 new tests pass alongside the existing 7).

Issue

BUNYIP-51

## What Add a web admin UI to edit and create an application's Forgejo binary and OCI container distribution config. The bunyip-api backend already accepted these fields (validated by `DistributionConfig::validate` on both create and update); the gap was entirely in bunyip-web, which only exposed `is_active`/`maintenance_mode` toggles, dropped the distribution fields from its `AdminApplication` DTO, and had no create-application form. ## Changes - New per-application "Edit" action: `GET /admin/applications/{id}/edit` renders a distribution form prefilled from the current row; `POST /admin/applications/{id}/distribution` persists via the existing `PUT /admin/applications/{id}`. - New "New application" action: `GET /admin/applications/new` plus `POST /admin/applications`, capturing the required identity fields (name, slug, display_name, container_name) plus distribution config, via a new `admin_api::create_application` client. - `artifact_source` renders as a select (`release` | `generic_package`). Empty inputs are omitted so existing column values are kept, EXCEPT `forgejo_package`, which is always sent so an empty value clears it to NULL via the backend's documented sentinel. - Backend validation failures (partial OCI/release triples, `forgejo_package` on a `release` source, empty/whitespace values) are surfaced as an inline error banner with the submitted values preserved, instead of being silently swallowed. - Extend the web `AdminApplication` DTO with the eight distribution fields for prefill. - Unit tests on the request-body builders cover the omit-empty rule and the `forgejo_package` clear-to-NULL sentinel. ## Verification `just check-container` green: fmt, clippy `-D warnings`, and tests. bunyip-web is a binary crate, so its unit tests run under `cargo test -p bunyip-web --bins` (3 new tests pass alongside the existing 7). ## Issue BUNYIP-51
feat(web): admin UI to edit and create application distribution config
All checks were successful
Check / fmt / clippy / build / test (pull_request) Successful in 1m33s
d52cff9270
The bunyip-api backend already accepts the full per-application distribution config (Forgejo binary coordinates artifact_source/forgejo_owner/forgejo_repo/forgejo_package/pinned_release_tag and OCI container coordinates oci_image_owner/oci_image_name/pinned_image_tag, validated by DistributionConfig::validate on both create and update), but the bunyip-web admin UI exposed none of it: the applications page had only is_active/maintenance_mode toggles, the AdminApplication DTO dropped the distribution fields, and there was no create-application form at all.

Add an edit form (per-application Edit action, GET /admin/applications/{id}/edit, POST .../distribution) and a create form (New application action, GET /admin/applications/new, POST /admin/applications), both reusing the existing PUT/POST endpoints. The edit form scopes to distribution fields; the create form adds the required identity fields (name, slug, display_name, container_name). artifact_source renders as a select, the form prefills from the current row, and empty inputs are omitted so existing values are kept, EXCEPT forgejo_package which is always sent so an empty value clears it to NULL via the backend sentinel. Backend validation failures (partial OCI/release triples, forgejo_package on a release source, empty values) are now surfaced as an inline error banner with the submitted values preserved, instead of being silently swallowed.

Extend the web AdminApplication DTO to deserialize the eight distribution fields for prefill, add an admin_api::create_application client, and unit-test the request-body builders for the omit-empty and forgejo_package clear-to-NULL semantics.

#BUNYIP-51

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix(web): address review of application distribution admin UI
All checks were successful
Create release / Create release from merged PR (pull_request) Has been skipped
Check / fmt / clippy / build / test (pull_request) Successful in 1m31s
bd5a1bbce7
Apply code-review findings on the application distribution edit/create UI:

Expose is_hosted in the form. The create form previously never sent is_hosted, so every application created through the UI inherited the DB column default (TRUE) and became a hub launch tile, with no way to create a catalog-only distribution product (downloads / OCI pulls only) and no edit control to fix it. Add a "Hosted app" checkbox to both the create and edit forms. The checkbox value is always sent (false when unchecked) so the flag can be toggled in either direction; the backend UPDATE already COALESCEs is_hosted. Add the field to the AdminApplication DTO (defaulting to true) so the edit form prefills it.

Stop re-sending a stale forgejo_package when the source is not generic_package. On edit, forgejo_package was always re-sent with its prefilled value, so flipping the Artifact source select from generic_package to release while leaving the package field populated produced a body that failed backend validation (forgejo_package is invalid on a release source). distribution_update_body now forces forgejo_package empty (the clear-to-NULL sentinel) on any non-generic source, and create_app_body only sends it for a generic_package source.

Surface a failed application-list fetch distinctly from a missing application. application_edit used unwrap_or_default() on the list call, so a network / auth / 5xx failure rendered the misleading "Application not found" for an application that exists. It now renders the API error in an error box and only reports "not found" when the list genuinely lacks the id.

Reuse the shared error_box() UI helper instead of a bespoke error_banner div, so the admin forms match every other error-surfacing site in bunyip-web.

Extend the unit tests to cover the is_hosted checkbox semantics and the release-source package clearing.

#BUNYIP-51

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
nrupard deleted branch feat/bunyip-51-app-distribution-admin-ui 2026-06-04 16:01:09 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
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
psa-systems/bunyip!64
No description provided.