diff --git a/crates/izlek-web/src/i18n.rs b/crates/izlek-web/src/i18n.rs index 39aaaf7..21028fe 100644 --- a/crates/izlek-web/src/i18n.rs +++ b/crates/izlek-web/src/i18n.rs @@ -166,6 +166,8 @@ pub enum Key { SigningInAsLabel, NewPasswordLabel, SetPasswordAndSignIn, + CurrentPasswordLabel, + ChangePassword, // rules.rs MailRules, @@ -562,6 +564,10 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (NewPasswordLabel, Tr) => "YENİ PAROLA", (SetPasswordAndSignIn, En) => "Set password and sign in", (SetPasswordAndSignIn, Tr) => "Parolayı ayarla ve giriş yap", + (CurrentPasswordLabel, En) => "CURRENT PASSWORD", + (CurrentPasswordLabel, Tr) => "MEVCUT PAROLA", + (ChangePassword, En) => "Change password", + (ChangePassword, Tr) => "Parolayı değiştir", (AdminMadeYouAnAccount, En) => "An admin made you an account.", (AdminMadeYouAnAccount, Tr) => "Bir yönetici sana hesap oluşturdu.", diff --git a/crates/izlek-web/src/logs.rs b/crates/izlek-web/src/logs.rs index c21ad77..145867f 100644 --- a/crates/izlek-web/src/logs.rs +++ b/crates/izlek-web/src/logs.rs @@ -422,7 +422,7 @@ async fn logs_screen(cx: &Cx, snapshot: LogsSnapshot) -> Result {

(t(lang, Key::MailQueue))

-
+
for line in queue { let is_failed_or_held = line.state_kind == "failed" || line.state_kind == "held"; let state_note = if is_failed_or_held { @@ -454,7 +454,7 @@ async fn logs_screen(cx: &Cx, snapshot: LogsSnapshot) -> Result {

(t(lang, Key::MailDecisions))

-
+
for group in decisions { let header = match group.happened { Some(happened) => format!("{} · {}", group.task, happened), @@ -489,7 +489,7 @@ async fn logs_screen(cx: &Cx, snapshot: LogsSnapshot) -> Result {

(t(lang, Key::Activity))

-
+
for line in activity {
diff --git a/crates/izlek-web/src/settings.rs b/crates/izlek-web/src/settings.rs index df9fd63..84d22a1 100644 --- a/crates/izlek-web/src/settings.rs +++ b/crates/izlek-web/src/settings.rs @@ -182,23 +182,39 @@ fn redirect_to(query: &str) -> (StatusCode, HeaderMap, Vec) { (StatusCode::SEE_OTHER, headers, Vec::new()) } +/// Which rail section a call's redirect lands back on, so the reload shows +/// the panel the form it answers actually lives in. +fn section_of_call(call: &str) -> &'static str { + match call { + "save_sender" | "send_test_mail" => "outgoing", + "save_limits" => "limits", + "invite_member" | "set_role" | "resend_link" => "members", + _ => "profile", + } +} + /// Where a save lands: back on Settings, with the refusal (if any) on the /// query the same way `files.rs`'s upload carries one, or `saved=` -/// when there was nothing to refuse. +/// when there was nothing to refuse — either way, on the rail section that +/// call belongs to. pub(crate) fn saved_or_refused( call: &str, refusal: Option, ) -> (StatusCode, HeaderMap, Vec) { + let section = section_of_call(call); match refusal { // `BadSender`'s code collapses six different complaints into one // generic "bad-sender"; the sentence save time actually wrote rides // along as `why` so the redirect does not have to guess it back. Some(Refusal::BadSender(problem)) => redirect_to(&format!( - "refusal=bad-sender&on={call}&why={}", + "refusal=bad-sender&on={call}&why={}§ion={section}", qsencode(&problem) )), - Some(refusal) => redirect_to(&format!("refusal={}&on={call}", refusal.code())), - None => redirect_to(&format!("saved={call}")), + Some(refusal) => redirect_to(&format!( + "refusal={}&on={call}§ion={section}", + refusal.code() + )), + None => redirect_to(&format!("saved={call}§ion={section}")), } } @@ -803,6 +819,27 @@ fn query_value<'q>(query: &'q str, key: &str) -> Option<&'q str> { }) } +/// Which rail section the page renders. Only one is drawn at a time; an +/// admin-only value asked for by anyone else falls back to `Profile`, same as +/// a section name it does not recognize at all. +#[derive(Clone, Copy, PartialEq, Eq)] +enum Section { + Profile, + Outgoing, + Limits, + Members, +} + +/// The class a rail link wears: `active` on the section it points to when +/// that is the one showing, plain otherwise. +fn rail_class(current: Section, target: Section) -> &'static str { + if current == target { + "settings-section-link active" + } else { + "settings-section-link" + } +} + /// The settings screen. #[page("/settings")] #[allow(unused_variables)] @@ -822,6 +859,12 @@ async fn settings_page(cx: &Cx) -> Result { let lang = Lang::from_code(&user.language); let administers = user.role.can_administer(); let query = topcoat::router::request::uri(cx).query().unwrap_or(""); + let section = match query_value(query, "section") { + Some("outgoing") if administers => Section::Outgoing, + Some("limits") if administers => Section::Limits, + Some("members") if administers => Section::Members, + _ => Section::Profile, + }; let zone = izlek_core::detail::parse_zone(&user.timezone); let sender = if administers { @@ -852,6 +895,7 @@ async fn settings_page(cx: &Cx) -> Result { let (invite_refusal, _) = call_state(query, "invite_member"); let (role_refusal, _) = call_state(query, "set_role"); let member_refusal = resend_refusal.or(invite_refusal).or(role_refusal); + let (password_refusal, _) = call_state(query, "change_password"); let mailed = query_value(query, "mailed").map(decode_q); view! { @@ -867,20 +911,16 @@ async fn settings_page(cx: &Cx) -> Result {
+
-
-

(t(lang, Key::NavSettings))

- (user.role.as_str().to_string()) -
- - + if section == Section::Profile {

(t(lang, Key::YourProfile))

@@ -967,7 +1007,30 @@ async fn settings_page(cx: &Cx) -> Result { }
- if let Some(sender) = &sender { +
+
+

(t(lang, Key::ChangePassword))

+
+
+ + +
+ if let Some(refusal) = &password_refusal { + (refusal.message_in(lang)) + } + +
+
+
+ } + + if section == Section::Outgoing && let Some(sender) = &sender { let connected = sender.is_connected(); let password_set = sender.password_set;
@@ -1074,7 +1137,7 @@ async fn settings_page(cx: &Cx) -> Result {
} - if let Some((attachment_limit_mb, photo_limit_mb)) = limits { + if section == Section::Limits && let Some((attachment_limit_mb, photo_limit_mb)) = limits {

(t(lang, Key::WorkspaceLimits))

@@ -1130,7 +1193,7 @@ async fn settings_page(cx: &Cx) -> Result {
} - if let Some(members) = members { + if section == Section::Members && let Some(members) = members {

(t(lang, Key::Members))

diff --git a/crates/izlek-web/tests/http.rs b/crates/izlek-web/tests/http.rs index 97b1680..ae1b83c 100644 --- a/crates/izlek-web/tests/http.rs +++ b/crates/izlek-web/tests/http.rs @@ -2460,7 +2460,9 @@ async fn an_admin_sees_the_sender_and_never_a_password() { let admin_cookie = admin(&app).await; assert!(sender_saved(&app, &admin_cookie).await); - let page = app.get("/settings", Some(&admin_cookie)).await; + let page = app + .get("/settings?section=outgoing", Some(&admin_cookie)) + .await; assert_eq!(page.status, StatusCode::OK); let html = String::from_utf8_lossy(&page.bytes); assert!(html.contains("smtp.fastmail.com"), "{html}"); @@ -2504,7 +2506,7 @@ async fn an_admin_sees_who_has_a_password_and_never_a_hash() { .await; assert_eq!(answer.status, StatusCode::OK, "{}", answer.body); - let page = app.get("/settings", Some(&admin_cookie)).await; + let page = app.get("/settings?section=members", Some(&admin_cookie)).await; let html = String::from_utf8_lossy(&page.bytes); assert!(html.contains("mert@izlek.sh"), "{html}"); assert!( @@ -3901,7 +3903,7 @@ async fn an_unlisted_language_is_refused() { .await; assert_eq!( saved.location.as_deref(), - Some("/settings?refusal=bad-language&on=save_profile") + Some("/settings?refusal=bad-language&on=save_profile§ion=profile") ); } @@ -4041,14 +4043,76 @@ async fn the_topbar_nav_marks_the_active_page() { } } - // The settings section list keeps the panels' admin gating: a member - // sees only the Profile anchor. + // The settings rail keeps the panels' admin gating: a member sees only + // the Profile link, and an admin-only section in the query still renders + // Profile rather than the panel it asked for. let member = invited(&app, &admin_cookie, "deniz@izlek.sh", "Deniz", Role::Member).await; let page = app.get("/settings", Some(&member)).await; let html = String::from_utf8_lossy(&page.bytes); - assert!(html.contains(r##"href="#profile""##), "{html}"); - assert!(!html.contains("href=\"#limits\""), "{html}"); - assert!(!html.contains("href=\"#members\""), "{html}"); + assert!(html.contains(r#"href="/settings?section=profile""#), "{html}"); + assert!(!html.contains("href=\"/settings?section=limits\""), "{html}"); + assert!(!html.contains("href=\"/settings?section=members\""), "{html}"); + assert!(html.contains(r#"id="profile""#), "{html}"); + assert!(!html.contains(r#"id="limits""#), "{html}"); + + let page = app + .get("/settings?section=limits", Some(&member)) + .await; + let html = String::from_utf8_lossy(&page.bytes); + assert!(html.contains(r#"id="profile""#), "{html}"); + assert!(!html.contains(r#"id="limits""#), "{html}"); +} + +/// A wrong current password lands back on the rail section it was posted +/// from with a refusal; a right one changes nothing about the query but the +/// refusal — `carry_refusal_on_redirect` never writes a `saved=` for a call +/// nobody asked to see a note about. +#[tokio::test] +async fn a_password_change_carries_its_own_refusal_and_never_a_saved_note() { + let app = App::open().await; + let admin_cookie = admin(&app).await; + + let wrong = app + .post_without_script( + "/api/change_password", + Some(&admin_cookie), + "http://izlek.test/settings?section=profile", + &[ + ("current", "not the password"), + ("new", "a whole new passphrase"), + ], + ) + .await; + assert!( + wrong.location.as_deref().is_some_and(|location| { + location.contains("refusal=") + && location.contains("on=change_password") + && location.contains("section=profile") + }), + "{:?}", + wrong.location + ); + + let right = app + .post_without_script( + "/api/change_password", + Some(&admin_cookie), + "http://izlek.test/settings?section=profile", + &[ + ("current", "correct horse battery staple"), + ("new", "a whole new passphrase"), + ], + ) + .await; + assert_eq!(right.status, StatusCode::SEE_OTHER); + assert!( + right + .location + .as_deref() + .is_some_and(|location| !location.contains("saved=")), + "{:?}", + right.location + ); } /// Polls the store until a `Rule` send for `rule_id` addressed to `recipient` @@ -4351,7 +4415,7 @@ async fn a_profile_photo_round_trips_back_as_the_same_bytes() { assert_eq!(answer.status, StatusCode::SEE_OTHER); assert_eq!( answer.location.as_deref(), - Some("/settings?saved=profile_photo") + Some("/settings?saved=profile_photo§ion=profile") ); let photo = app.get(&format!("/photo/{admin_id}"), Some(&admin)).await; @@ -4379,7 +4443,7 @@ async fn text_uploaded_as_a_photo_is_refused_and_stores_nothing() { assert_eq!(answer.status, StatusCode::SEE_OTHER); assert_eq!( answer.location.as_deref(), - Some("/settings?refusal=not-an-image&on=profile_photo") + Some("/settings?refusal=not-an-image&on=profile_photo§ion=profile") ); let photo = app.get(&format!("/photo/{admin_id}"), Some(&admin)).await; @@ -4439,7 +4503,7 @@ async fn a_photo_over_the_workspace_limit_is_refused_and_stores_nothing() { assert_eq!(answer.status, StatusCode::SEE_OTHER); assert_eq!( answer.location.as_deref(), - Some("/settings?refusal=file-too-big&on=profile_photo") + Some("/settings?refusal=file-too-big&on=profile_photo§ion=profile") ); let photo = app.get(&format!("/photo/{admin_id}"), Some(&admin)).await; @@ -4465,7 +4529,7 @@ async fn a_photo_is_visible_to_other_workspace_members() { .await; assert_eq!( answer.location.as_deref(), - Some("/settings?saved=profile_photo") + Some("/settings?saved=profile_photo§ion=profile") ); let photo = app.get(&format!("/photo/{admin_id}"), Some(&member)).await; @@ -4493,7 +4557,7 @@ async fn an_unknown_photo_id_is_not_found_and_the_photo_revalidates_by_etag() { .await; assert_eq!( answer.location.as_deref(), - Some("/settings?saved=profile_photo") + Some("/settings?saved=profile_photo§ion=profile") ); let stranger = app.get("/photo/does-not-exist", Some(&admin)).await; diff --git a/style/_instrument.scss b/style/_instrument.scss index ef22e79..a9dc58d 100644 --- a/style/_instrument.scss +++ b/style/_instrument.scss @@ -158,6 +158,21 @@ // ruled columns and the square avatars above. Token values — control // heights, radii, shadows — already carry the rest.) + // --- Instrument skin: settings rail ----------------------------------------- + + .settings-sections { width: 200px; } + + .settings-section-link { + font-size: 13px; + letter-spacing: normal; + text-transform: none; + + &.active { + background: var(--row-hover); + box-shadow: inset 2px 0 0 var(--accent); + } + } + } // -- task detail: 560px side panel over the board ---------------------------- diff --git a/style/_ledger.scss b/style/_ledger.scss index 615bcf0..6afd7c5 100644 --- a/style/_ledger.scss +++ b/style/_ledger.scss @@ -420,3 +420,13 @@ [data-ui="ledger"] .comment-composer { padding: 20px 0 0; } + +// Settings rail: a narrower column, mono/uppercase stays, the active section +// marked with an ink rule rather than a fill. +[data-ui="ledger"] .settings-sections { + width: 170px; +} + +[data-ui="ledger"] .settings-section-link.active { + border-bottom: 2px solid var(--ink); +} diff --git a/style/main.scss b/style/main.scss index 5d46d96..970df7b 100644 --- a/style/main.scss +++ b/style/main.scss @@ -338,6 +338,16 @@ body:has(.board-stage) { > .board-stage { flex: 1; min-height: 0; } } +body:has(.settings-shell) { + height: 100vh; + overflow: hidden; + display: flex; + flex-direction: column; + + > * { flex: none; } + > .settings-shell { flex: 1; min-height: 0; } +} + a { color: var(--accent); transition: color var(--dur-fast) var(--ease); @@ -2138,18 +2148,19 @@ img.avatar { .settings-shell { display: flex; - flex-direction: column; - min-height: calc(100vh - var(--topbar-height)); } .settings-stage { - flex-grow: 1; + flex: 1; min-width: 0; padding: 24px 32px 40px; display: flex; flex-direction: column; gap: 20px; - max-width: 900px; + max-width: 860px; + overflow-y: auto; + scrollbar-width: none; + &::-webkit-scrollbar { display: none; } } .settings-head { @@ -2160,12 +2171,18 @@ img.avatar { } .settings-sections { + flex: none; + width: 200px; display: flex; - flex-wrap: wrap; - gap: 16px; + flex-direction: column; + gap: 2px; + padding: 16px 0; + border-right: 1px solid var(--border); } .settings-section-link { + display: block; + padding: 8px 16px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; @@ -2622,12 +2639,6 @@ input[type="radio"] { gap: 10px; } -// The logs pages reuse the rules list but bound its height. -.rule-list-scroll { - max-height: 360px; - overflow-y: auto; -} - .rule-row { display: flex; align-items: center;