Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions crates/ui/src/admin/alerts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ fn author(update: &AlertUpdate) -> String {
/// The current alerts, `cards`, newest first, each with posting an update on
/// it, and a link to the alerts that cleared, at `previous`.
#[component]
pub async fn alert_list<'a>(cards: &'a [AlertCard<'a>], previous: &'a str) -> Result<impl View> {
pub async fn alert_list<'a>(
/// The alerts, newest first.
cards: &'a [AlertCard<'a>],
/// Where the cleared alerts are listed.
previous: &'a str,
) -> Result<impl View> {
Ok(view! {
page_head(
title: "Alerts",
Expand All @@ -76,8 +81,11 @@ pub async fn alert_list<'a>(cards: &'a [AlertCard<'a>], previous: &'a str) -> Re
/// `limit`, and a link back to the current ones, at `current`.
#[component]
pub async fn previous_alerts<'a>(
/// The cleared alerts, most recently cleared first.
cards: &'a [AlertCard<'a>],
/// Where the current alerts are listed.
current: &'a str,
/// The most alerts shown.
limit: u32,
) -> Result<impl View> {
let full = u32::try_from(cards.len()).is_ok_and(|shown| shown >= limit);
Expand All @@ -102,7 +110,10 @@ pub async fn previous_alerts<'a>(
/// One alert: what it says, when it was raised, last seen and cleared, the
/// updates posted on it, newest first, and posting one while it is current.
#[component]
async fn alert_card<'a>(card: &'a AlertCard<'a>) -> Result<impl View> {
async fn alert_card<'a>(
/// The alert shown.
card: &'a AlertCard<'a>,
) -> Result<impl View> {
let detail = card.detail;
let alert = &detail.alert;
let subject = alert.alert.as_ref().map_or(Alert::UNKNOWN, Alert::subject);
Expand Down Expand Up @@ -157,8 +168,11 @@ async fn alert_card<'a>(card: &'a AlertCard<'a>) -> Result<impl View> {
pub async fn alert_update_fields<'a>(
#[into]
#[default]
/// The status the form holds, if a refused update set one.
status: Option<AlertStatus>,
#[default] note: &'a str,
/// The note the form holds.
#[default]
note: &'a str,
) -> Result<impl View> {
Ok(view! {
<label>
Expand Down
13 changes: 13 additions & 0 deletions crates/ui/src/admin/announcements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ fn audience(announcement: &Announcement) -> String {
/// `create`.
#[component]
pub async fn announcement_list<'a>(
/// The announcements, newest first.
rows: &'a [AdminAnnouncementRow<'a>],
/// Where an announcement is drafted.
create: &'a str,
) -> Result<impl View> {
Ok(view! {
Expand Down Expand Up @@ -99,11 +101,15 @@ pub async fn announcement_list<'a>(
/// its emails fared and how many recipients read it.
#[component]
pub async fn announcement_page<'a>(
/// The announcement.
detail: &'a AnnouncementDetail,
/// The accounts chosen to receive it, each with its page.
accounts: &'a [(&'a User, String)],
/// The email as it will be sent.
preview: &'a Mail,
#[into]
#[default]
/// The draft-only actions, if it is still a draft.
drafts: Option<DraftActions<'a>>,
) -> Result<impl View> {
let announcement = &detail.announcement;
Expand Down Expand Up @@ -225,12 +231,17 @@ pub struct FoundAccount<'a> {
/// as saved, after the dashboard's passkey confirmation; "Save draft" needs none.
#[component]
pub async fn announcement_form<'a>(
/// The change the form makes.
change: Change,
/// Where the form goes back to.
back: &'a str,
/// The values the form holds.
form: &'a DraftAnnouncement,
/// The accounts the search found.
found: &'a [FoundAccount<'a>],
#[into]
#[default]
/// Why the last attempt was refused, if it was.
refusal: Option<&'a str>,
) -> Result<impl View> {
let chosen = form.audience == AnnouncementAudience::Accounts;
Expand Down Expand Up @@ -288,7 +299,9 @@ pub async fn announcement_form<'a>(
/// chooses everyone.
#[component]
async fn chosen_accounts<'a>(
/// The announcement being drafted.
form: &'a DraftAnnouncement,
/// The accounts the search found.
found: &'a [FoundAccount<'a>],
) -> Result<impl View> {
let find = form.find.trim();
Expand Down
11 changes: 10 additions & 1 deletion crates/ui/src/admin/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ use topcoat::{
/// verification from here checks against.
#[component]
pub async fn audit_page<'a>(
/// The checkpoints shown.
page: &'a AuditPage,
/// The keys the chain is verified with.
keys: VerificationKeys,
#[into]
#[default]
/// Why the last attempt to verify was refused, if it was.
refusal: Option<&'a str>,
#[into]
#[default]
/// Where the next page of checkpoints is, if there is one.
later: Option<String>,
) -> Result<impl View> {
// Without a committed key, the CLI checks against the one the notice saves.
Expand Down Expand Up @@ -82,7 +86,12 @@ pub async fn audit_page<'a>(
/// with the form that verifies it again, warning of keys a compromised server
/// could hold if they are `uncommitted`.
#[component]
async fn chain_card<'a>(page: &'a AuditPage, uncommitted: bool) -> Result<impl View> {
async fn chain_card<'a>(
/// The checkpoints the card summarizes.
page: &'a AuditPage,
/// Whether events are recorded that no checkpoint covers yet.
uncommitted: bool,
) -> Result<impl View> {
let chain = &page.chain;
let point = |point: &Option<ChainPoint>| {
point
Expand Down
44 changes: 39 additions & 5 deletions crates/ui/src/admin/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,15 @@ impl Registration<'_> {
/// the last attempt was refused.
#[component]
pub async fn client_registration<'a>(
/// The client being registered or changed.
registration: Registration<'a>,
/// The settings the form holds.
settings: &'a OperatorDraft,
/// Where the form posts.
action: &'a str,
#[into]
#[default]
/// Why the last attempt was refused, if it was.
refusal: Option<&'a str>,
) -> Result<impl View> {
let (title, lead, label) = registration.words();
Expand Down Expand Up @@ -269,7 +273,12 @@ pub struct ClientPage<'a> {
/// The OIDC clients, each linking its page, with the page registering a client
/// at `new`.
#[component]
pub async fn client_list<'a>(rows: &'a [AdminClientRow<'a>], new: &'a str) -> Result<impl View> {
pub async fn client_list<'a>(
/// The clients.
rows: &'a [AdminClientRow<'a>],
/// Where a client is registered.
new: &'a str,
) -> Result<impl View> {
Ok(view! {
page_head(
title: "Clients",
Expand Down Expand Up @@ -306,7 +315,10 @@ pub async fn client_list<'a>(rows: &'a [AdminClientRow<'a>], new: &'a str) -> Re

/// A listed client's status, as a badge.
#[component]
async fn listed_status<'a>(client: &'a Client) -> Result<impl View> {
async fn listed_status<'a>(
/// The client.
client: &'a Client,
) -> Result<impl View> {
let shown = match client.status() {
"enabled" => Badge::new("ok", "Enabled"),
"suspended" => Badge::new("danger", "Suspended"),
Expand All @@ -320,7 +332,12 @@ async fn listed_status<'a>(client: &'a Client) -> Result<impl View> {
/// if it does not, its changes, a confidential client's secrets, and the
/// origins its pages sign users in on.
#[component]
pub async fn client_page<'a>(page: &'a ClientPage<'a>, now: DateTime<Utc>) -> Result<impl View> {
pub async fn client_page<'a>(
/// The client.
page: &'a ClientPage<'a>,
/// The time the page is as of.
now: DateTime<Utc>,
) -> Result<impl View> {
let client = page.client;
let title = if client.name.is_empty() {
client.id.as_str()
Expand Down Expand Up @@ -404,14 +421,21 @@ pub async fn client_page<'a>(page: &'a ClientPage<'a>, now: DateTime<Utc>) -> Re
/// the `reason` typed. `refusal` says why the last rotation was refused.
#[component]
pub async fn client_secrets<'a>(
/// The page the secrets belong on.
page: &'a str,
/// The client's name.
name: &'a str,
/// The client's secrets.
secrets: &'a [SecretRow],
/// The time lifetimes are counted from.
now: DateTime<Utc>,
/// The secret a rotation just made, if any.
state: &'a SecretsState,
/// What the reason field holds.
reason: &'a str,
#[into]
#[default]
/// Why the last attempt was refused, if it was.
refusal: Option<&'a str>,
) -> Result<impl View> {
Ok(view! {
Expand All @@ -423,7 +447,12 @@ pub async fn client_secrets<'a>(

/// A client just registered: its first `secret`, shown once, then its `page`.
#[component]
pub async fn client_created<'a>(secret: &'a Revealed, page: &'a str) -> Result<impl View> {
pub async fn client_created<'a>(
/// The first secret.
secret: &'a Revealed,
/// The client's page.
page: &'a str,
) -> Result<impl View> {
Ok(view! {
secret_panel(secret: secret, page: page, next: page)
})
Expand All @@ -432,7 +461,10 @@ pub async fn client_created<'a>(secret: &'a Revealed, page: &'a str) -> Result<i
/// What `page`'s client is: how it signs users in, who manages it, its settings
/// and when it was registered, changed and last used.
#[component]
async fn client_facts<'a>(page: &'a ClientPage<'a>) -> Result<impl View> {
async fn client_facts<'a>(
/// The client.
page: &'a ClientPage<'a>,
) -> Result<impl View> {
let client = page.client;
let yes_no = |yes: bool, said: &'static str| if yes { said } else { "No" };
Ok(view! {
Expand Down Expand Up @@ -491,7 +523,9 @@ async fn client_facts<'a>(page: &'a ClientPage<'a>) -> Result<impl View> {
/// or enabling it, suspending it or lifting its suspension, and deleting it.
#[component]
async fn client_actions<'a>(
/// The client.
client: ClientRow<'a>,
/// The changes the dashboard makes to it.
changes: &'a ClientChanges,
) -> Result<impl View> {
Ok(view! {
Expand Down
5 changes: 5 additions & 0 deletions crates/ui/src/admin/deliveries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,19 @@ const fn status_badge(status: DeliveryStatus) -> Badge {
/// `action` by `GET`.
#[component]
pub async fn delivery_list<'a>(
/// Where the filter form posts.
action: &'a str,
#[into]
#[default]
/// The status chosen, if any.
status: Option<DeliveryStatus>,
#[into]
#[default]
/// The channel chosen, if any.
channel: Option<&'a str>,
/// The deliveries, newest first.
rows: &'a [DeliveryRow<'a>],
/// The most deliveries shown.
limit: u32,
) -> Result<impl View> {
let full = u32::try_from(rows.len()).is_ok_and(|shown| shown >= limit);
Expand Down
15 changes: 13 additions & 2 deletions crates/ui/src/admin/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,16 +556,24 @@ const UUID_PATTERN: &str =
/// by itself), the events, and the `pages` through them.
#[component]
pub async fn event_list<'a>(
/// Where the filter form posts.
action: &'a str,
#[into]
#[default]
/// The account filtered on, if any.
user: Option<String>,
#[into]
#[default]
/// The event kind filtered on, if any.
kind: Option<&'a str>,
#[default] views: bool,
/// Whether administrators' views of accounts are shown.
#[default]
views: bool,
/// Where showing or hiding those views goes.
toggle_views: &'a str,
/// The events, newest first.
rows: &'a [EventRow<'a>],
/// The pages through the events.
pages: &'a Pager,
) -> Result<impl View> {
Ok(view! {
Expand Down Expand Up @@ -620,7 +628,10 @@ pub async fn event_list<'a>(
/// A feed of events, each in words, linking the account it concerns and the one
/// that caused it, with its stored JSON behind a disclosure.
#[component]
pub async fn event_rows<'a>(rows: &'a [EventRow<'a>]) -> Result<impl View> {
pub async fn event_rows<'a>(
/// The events.
rows: &'a [EventRow<'a>],
) -> Result<impl View> {
Ok(view! {
if rows.is_empty() {
<p class="empty">"No event."</p>
Expand Down
10 changes: 8 additions & 2 deletions crates/ui/src/admin/handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ pub struct HandlesPage<'a> {
/// The handles page: the reserved list, with the built-in names, the accounts
/// holding a reserved handle, and the released handles, each with its change.
#[component]
pub async fn handle_list<'a>(page: HandlesPage<'a>) -> Result<impl View> {
pub async fn handle_list<'a>(
/// The handles shown.
page: HandlesPage<'a>,
) -> Result<impl View> {
Ok(view! {
page_head(
title: "Handles",
Expand Down Expand Up @@ -153,7 +156,10 @@ pub async fn handle_list<'a>(page: HandlesPage<'a>) -> Result<impl View> {

/// The choice letting a rename take a reserved handle, `checked` or not.
#[component]
pub async fn reserved_handle_choice(checked: bool) -> Result<impl View> {
pub async fn reserved_handle_choice(
/// Whether the choice is ticked.
checked: bool,
) -> Result<impl View> {
Ok(view! {
choice(
name: "allow_reserved",
Expand Down
13 changes: 12 additions & 1 deletion crates/ui/src/admin/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ const fn state_badge(state: SigningKeyState) -> Badge {
/// `rotate` and rewrapping them at `rewrap`.
#[component]
pub async fn signing_key_list<'a>(
/// The signing keys, oldest first.
rows: &'a [SigningKeyRow<'a>],
/// Where the signing key is rotated.
rotate: &'a str,
/// Where the keys are rewrapped.
rewrap: &'a str,
) -> Result<impl View> {
Ok(view! {
Expand Down Expand Up @@ -71,7 +74,11 @@ pub async fn signing_key_list<'a>(

/// A moment, or a dash before it happens.
#[component]
async fn when(#[into] at: Option<DateTime<Utc>>) -> Result<impl View> {
async fn when(
/// The moment, if it has happened.
#[into]
at: Option<DateTime<Utc>>,
) -> Result<impl View> {
Ok(view! {
match at {
Some(at) => moment(at: at),
Expand All @@ -85,13 +92,17 @@ async fn when(#[into] at: Option<DateTime<Utc>>) -> Result<impl View> {
/// to `back`.
#[component]
pub async fn signing_key_rotation<'a>(
/// Where the page goes back to.
back: &'a str,
#[into]
#[default]
/// Why the last attempt was refused, if it was.
refused: Option<&'a str>,
/// Whether the form asks for the new key to sign at once.
now: bool,
#[into]
#[default]
/// What the reason field holds.
reason: Option<&'a str>,
) -> Result<impl View> {
Ok(view! {
Expand Down
Loading