Skip to content

Commit 958aefd

Browse files
PiquelChipsclaude
andcommitted
fix(admin): the crumb leads through the tab, so an account reads admin / users / handle
Pages inside a tab, such as one account under Users or one client under Clients, showed only "admin / <page>" in the top bar. The dashboard frame now puts the current tab between the area and the page, linking the tab's list, and the tab's own page still names it once. The client page's "← Clients" link goes, since the crumb leads there. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 5380816 commit 958aefd

6 files changed

Lines changed: 41 additions & 11 deletions

File tree

‎apps/auth-service/src/web/admin/clients.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ pub(super) async fn detail(cx: &Cx) -> Result<Response> {
145145
approve,
146146
changes,
147147
};
148-
let (shown, back) = (&shown, &href!(list).resolve(cx));
148+
let shown = &shown;
149149
let page = view! { cx =>
150-
piquel_ui::client_page(page: shown, back: back.as_str(), now: Utc::now())
150+
piquel_ui::client_page(page: shown, now: Utc::now())
151151
};
152152
// A large page: its future is boxed, off the handler's stack.
153153
Box::pin(App::render(cx, StatusCode::OK, App::title(stored), page)).await

‎apps/auth-service/src/web/admin/tests.rs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,24 @@ async fn an_accounts_page_names_no_passkey() {
547547
assert!(!page.contains(&passkey.friendly_name), "{page}");
548548
}
549549

550+
/// A page inside a tab has the tab in its crumb, linking its page: an account's
551+
/// reads "admin / users / handle". The tab's own page names it once.
552+
#[tokio::test]
553+
#[ignore = "requires TEST_DATABASE_URL"]
554+
async fn the_crumb_leads_through_the_tab() {
555+
let harness = Harness::new().await;
556+
let admin = harness.admin().await;
557+
let owner = Browser::new_account(&harness.database).await;
558+
let account = format!("/users/{}", owner.user_id);
559+
let dashboard = harness.sign_in(&admin, &account).await;
560+
let page = html(harness.visit(&dashboard, &account).await).await;
561+
let users = r#"<a href="/users">users</a>"#;
562+
assert!(page.contains(users), "{page}");
563+
let page = html(harness.visit(&dashboard, "/users").await).await;
564+
assert!(!page.contains(users), "{page}");
565+
assert!(page.contains("<b>Users</b>"), "{page}");
566+
}
567+
550568
/// The audit page shows the chain as `audit verify` reports it, and says that
551569
/// pruning is the database owner's, from the command line.
552570
#[tokio::test]

‎crates/ui/src/admin/clients.rs‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,23 +301,18 @@ async fn listed_status<'a>(client: &'a Client) -> Result<impl View> {
301301
})
302302
}
303303

304-
/// One client's page, linking back to the clients at `back`, as of `now`: what
305-
/// it is, why it does not sign users in, if it does not, its changes, a
306-
/// confidential client's secrets, and the origins its pages sign users in on.
304+
/// One client's page as of `now`: what it is, why it does not sign users in,
305+
/// if it does not, its changes, a confidential client's secrets, and the
306+
/// origins its pages sign users in on.
307307
#[component]
308-
pub async fn client_page<'a>(
309-
page: &'a ClientPage<'a>,
310-
back: &'a str,
311-
now: DateTime<Utc>,
312-
) -> Result<impl View> {
308+
pub async fn client_page<'a>(page: &'a ClientPage<'a>, now: DateTime<Utc>) -> Result<impl View> {
313309
let client = page.client;
314310
let title = if client.name.is_empty() {
315311
client.id.as_str()
316312
} else {
317313
client.name
318314
};
319315
Ok(view! {
320-
<p><a href=(back)>"← Clients"</a></p>
321316
page_head(
322317
title: title,
323318
lead: client.id.to_string(),

‎crates/ui/src/admin/mod.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ pub async fn dashboard_frame<'a>(
219219
warning: warning && *tab == Tab::Overview,
220220
})
221221
.collect();
222+
// A page inside a tab, such as one account under Users, has the tab in its
223+
// crumb; the tab's own page, at its path, is named once.
224+
let path = dashboard.here.split('?').next().unwrap_or_default();
225+
let tab = dashboard
226+
.current
227+
.and_then(|current| dashboard.tabs.iter().find(|(tab, _)| *tab == current))
228+
.filter(|(_, href)| *href != path)
229+
.map(|(tab, href)| (tab.label(), *href));
222230
Ok(view! {
223231
let groups = [NavGroup {
224232
label: Some("dashboard"),
@@ -231,6 +239,7 @@ pub async fn dashboard_frame<'a>(
231239
groups: &groups,
232240
who: dashboard.administrator,
233241
me: dashboard.administrator.map(|_| dashboard.me),
242+
tab,
234243
page: dashboard.title,
235244
search: dashboard.administrator.map(|_| dashboard.search),
236245
preferences: dashboard.preferences,

‎crates/ui/src/layout/sections.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ pub async fn account<'a>(
148148
groups: &groups,
149149
who: Some(who),
150150
me: Some(home),
151+
tab: None,
151152
page: title,
152153
search: None,
153154
preferences,

‎crates/ui/src/layout/signed_in.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ pub struct Shell<'a> {
100100
pub who: Option<Who<'a>>,
101101
/// Their own page, which the top bar's avatar links.
102102
pub me: Option<&'a str>,
103+
/// The tab the page belongs to, between the area and the page in the
104+
/// crumb, when the page is not the tab's own: its name and its page.
105+
pub tab: Option<(&'a str, &'a str)>,
103106
/// The page's name in the crumb, after the area's link.
104107
pub page: &'a str,
105108
/// A search form in the top bar, if the area has one.
@@ -235,6 +238,10 @@ async fn topbar<'a>(frame: &'a Shell<'a>) -> Result<impl View> {
235238
<div class="crumb">
236239
<a href=(frame.area_home)>(frame.area.to_lowercase())</a>
237240
<span aria-hidden="true">"/"</span>
241+
if let Some((label, href)) = frame.tab {
242+
<a href=(href)>(label.to_lowercase())</a>
243+
<span aria-hidden="true">"/"</span>
244+
}
238245
<b>(frame.page)</b>
239246
</div>
240247
<div class="right">

0 commit comments

Comments
 (0)