Profile link to im in the user menu, settings leaves the nav
Browse files at this commit71c4130d42ca9963a864c8685aa628a41939ac42Parent: 99c2821- feat
- profile link to im in the user menu, settings leaves the nav
2 changed files +28 -8
crates/in-web/src/layout.rsmodified+6 -8
| @@ -21,7 +21,7 @@ use topcoat::{ | |||
| 21 | use in_core::store::User; | 21 | use in_core::store::User; |
| 22 | 22 | ||
| 23 | use crate::i18n::{Key, Lang, t}; | 23 | use crate::i18n::{Key, Lang, t}; |
| 24 | -use crate::server::current_user; | 24 | +use crate::server::{app, current_user}; |
| 25 | 25 | ||
| 26 | /// The In monogram again, as the tab icon: the same drawing as `mark`, | 26 | /// The In monogram again, as the tab icon: the same drawing as `mark`, |
| 27 | /// inlined because it must carry its own colours — a data URI has no page to | 27 | /// inlined because it must carry its own colours — a data URI has no page to |
| @@ -124,6 +124,7 @@ pub async fn user_menu(cx: &Cx, user: &User, lang: Lang) -> Result { | |||
| 124 | if user.admin { | 124 | if user.admin { |
| 125 | <div class="user-menu-role">(t(lang, Key::AdminBadge))</div> | 125 | <div class="user-menu-role">(t(lang, Key::AdminBadge))</div> |
| 126 | } | 126 | } |
| 127 | + <a class="user-menu-item" href=(format!("{}/", app(cx).config.oidc.issuer)) data-hard="">(t(lang, Key::Profile))</a> | ||
| 127 | <a class="user-menu-item" href="/settings">(t(lang, Key::NavSettings))</a> | 128 | <a class="user-menu-item" href="/settings">(t(lang, Key::NavSettings))</a> |
| 128 | <a class="user-menu-item" href="/auth/logout" data-hard="">(t(lang, Key::SignOut))</a> | 129 | <a class="user-menu-item" href="/auth/logout" data-hard="">(t(lang, Key::SignOut))</a> |
| 129 | </div> | 130 | </div> |
| @@ -142,13 +143,10 @@ pub enum NavPage { | |||
| 142 | } | 143 | } |
| 143 | 144 | ||
| 144 | impl NavPage { | 145 | impl NavPage { |
| 145 | - const ALL: [Self; 5] = [ | 146 | + /// Settings is deliberately absent: it lives in the user menu, not the |
| 146 | - Self::Drive, | 147 | + /// page nav — the variant stays so the settings page can still name |
| 147 | - Self::Shared, | 148 | + /// itself active without a link to mark. |
| 148 | - Self::Trash, | 149 | + const ALL: [Self; 4] = [Self::Drive, Self::Shared, Self::Trash, Self::Search]; |
| 149 | - Self::Search, | ||
| 150 | - Self::Settings, | ||
| 151 | - ]; | ||
| 152 | 150 | ||
| 153 | fn href(self) -> &'static str { | 151 | fn href(self) -> &'static str { |
| 154 | match self { | 152 | match self { |
crates/in-web/tests/http.rsmodified+22 -0
| @@ -2266,3 +2266,25 @@ async fn settings_quota_button_wears_the_quiet_class() { | |||
| 2266 | let form_end = body[quota_at..].find("</form>").expect("quota form never closes"); | 2266 | let form_end = body[quota_at..].find("</form>").expect("quota form never closes"); |
| 2267 | assert!(button_at < form_end, "quiet button escapes the quota form: {body}"); | 2267 | assert!(button_at < form_end, "quiet button escapes the quota form: {body}"); |
| 2268 | } | 2268 | } |
| 2269 | + | ||
| 2270 | +#[tokio::test] | ||
| 2271 | +async fn settings_lives_in_the_user_menu_not_the_topbar() { | ||
| 2272 | + let app = TestApp::build().await; | ||
| 2273 | + let cookie = app.sign_in("sub-menu", "menu@in.test", "Menu").await; | ||
| 2274 | + let page = app.get("/drive", Some(&cookie)).await; | ||
| 2275 | + assert_eq!(page.status, StatusCode::OK, "{}", page.text()); | ||
| 2276 | + let body = page.text(); | ||
| 2277 | + | ||
| 2278 | + // The page nav carries no settings link… | ||
| 2279 | + let nav_start = body.find("topbar-nav-links").expect("no nav"); | ||
| 2280 | + let nav_end = body[nav_start..].find("</nav>").expect("nav never closes"); | ||
| 2281 | + let nav = &body[nav_start..nav_start + nav_end]; | ||
| 2282 | + assert!(!nav.contains("/settings"), "settings leaked into the nav: {nav}"); | ||
| 2283 | + | ||
| 2284 | + // …the user menu carries it, plus the profile link out to im. | ||
| 2285 | + let menu_start = body.find("user-menu-panel").expect("no user menu"); | ||
| 2286 | + let menu = &body[menu_start..]; | ||
| 2287 | + assert!(menu.contains("href=\"/settings\""), "{menu}"); | ||
| 2288 | + let issuer = format!("href=\"{}/\"", app.config.oidc.issuer); | ||
| 2289 | + assert!(menu.contains(&issuer), "no profile link to the issuer: {menu}"); | ||
| 2290 | +} | ||