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.
3.1 KiB
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 |
|
/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.rs— create the new page componentsrc/bin/ui/pages/mod.rs— addpub mod admin;src/bin/ui/main.rs— add the/adminroute 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 inreset_resultand clearsreset_error. OnApiError::Forbidden, setsreset_error = "Wrong auth code.". On other errors, sets a generic message. - Lock button (shown when
submissions_locked == Some(false)): callsapi::admin_lock(&admin_code). On success, setssubmissions_locked = Some(true). OnApiError::Forbidden, setslock_error. - Unlock button (shown when
submissions_locked == Some(true)): callsapi::admin_unlock(&admin_code). On success, setssubmissions_locked = Some(false). OnApiError::Forbidden, setslock_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