You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vibed/quotesdb/.beans/quotesdb-250z--quotesdbui-a...

3.1 KiB

title status type priority created_at updated_at blocked_by
quotesdb/ui: /admin page component completed feature normal 2026-03-10T23:32:10Z 2026-03-10T23:32:18Z
quotesdb-d09v

/admin page component (UI)

Create the /admin route and page component. The page provides a persistent admin auth code input, an auth code reset section, and a submissions lock/unlock section.

Depends on ticket 161f32 (admin API client functions). Complete that ticket first.


Files to create / modify

  • src/bin/ui/pages/admin.rscreate the new page component
  • src/bin/ui/pages/mod.rs — add pub mod admin;
  • src/bin/ui/main.rs — add the /admin route to the Yew Router switch and add an "Admin" link to the top nav (or wherever the nav links are defined)

Component: AdminPage

The component holds the following local state:

State field Type Purpose
admin_code String The persistent admin auth code input
new_passphrase String Optional input for reset section
reset_result Option<String> Newly returned auth code after reset
reset_error Option<String> Error message for the reset section
submissions_locked Option<bool> Current lock state, fetched on mount
lock_error Option<String> Error message for lock/unlock section
loading bool Disables buttons during in-flight requests

On mount

Call api::get_status() and set submissions_locked from the response.

Layout

[ Admin ]                              (page heading)

Admin auth code: [__________________]  (persistent text input)

--- Reset auth code ---
New passphrase (optional): [__________]
[ Reset ]
> (success) New code: ocean-table-purple-storm
> (error)   Wrong auth code.

--- Submissions ---
Status: Open | Closed
[ Lock submissions ] / [ Unlock submissions ]
> (error) Wrong auth code.

Behaviour

  • Reset button: calls api::admin_reset_auth_code(&admin_code, new_passphrase_opt, &admin_code). On success, shows the new code in reset_result and clears reset_error. On ApiError::Forbidden, sets reset_error = "Wrong auth code.". On other errors, sets a generic message.
  • Lock button (shown when submissions_locked == Some(false)): calls api::admin_lock(&admin_code). On success, sets submissions_locked = Some(true). On ApiError::Forbidden, sets lock_error.
  • Unlock button (shown when submissions_locked == Some(true)): calls api::admin_unlock(&admin_code). On success, sets submissions_locked = Some(false). On ApiError::Forbidden, sets lock_error.
  • While loading = true, disable all buttons.

Route registration (src/bin/ui/main.rs)

Add to the router switch:

Route { path: "/admin".to_string(), render: ... }
// or whichever router pattern is already in use

Tests

No runtime unit tests (wasm-only). Verify the build:

cargo check --target wasm32-unknown-unknown --bin ui

Validation

cargo fmt && cargo check --target wasm32-unknown-unknown --bin ui

Commit

feat(quotesdb): /admin page component