forge
Explore
Log in

Don't you dare go Hollow

Settings takes the rail — one section, no scrollbar, a password door

Browse files at this commit

f11db968d15532a23505680964c163092af97047Ahmet Kaan GümüşParent: aec6e70
  • feat
    • settings takes the rail — one section, no scrollbar, a password door
Show full message
✨ feat(web): settings takes the rail — one section, no scrollbar, a password door
crates/izlek-web/src/i18n.rsmodified+6 -0
@@ -166,6 +166,8 @@ pub enum Key {
166166 SigningInAsLabel,
167167 NewPasswordLabel,
168168 SetPasswordAndSignIn,
169+ CurrentPasswordLabel,
170+ ChangePassword,
169171
170172 // rules.rs
171173 MailRules,
@@ -562,6 +564,10 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
562564 (NewPasswordLabel, Tr) => "YENİ PAROLA",
563565 (SetPasswordAndSignIn, En) => "Set password and sign in",
564566 (SetPasswordAndSignIn, Tr) => "Parolayı ayarla ve giriş yap",
567+ (CurrentPasswordLabel, En) => "CURRENT PASSWORD",
568+ (CurrentPasswordLabel, Tr) => "MEVCUT PAROLA",
569+ (ChangePassword, En) => "Change password",
570+ (ChangePassword, Tr) => "Parolayı değiştir",
565571 (AdminMadeYouAnAccount, En) => "An admin made you an account.",
566572 (AdminMadeYouAnAccount, Tr) => "Bir yönetici sana hesap oluşturdu.",
567573
crates/izlek-web/src/logs.rsmodified+3 -3
@@ -422,7 +422,7 @@ async fn logs_screen(cx: &Cx, snapshot: LogsSnapshot) -> Result {
422422 <h2 class="panel-title">(t(lang, Key::MailQueue))</h2>
423423 </div>
424424 <div class="panel-body">
425- <div class="rule-list rule-list-scroll">
425+ <div class="rule-list">
426426 for line in queue {
427427 let is_failed_or_held = line.state_kind == "failed" || line.state_kind == "held";
428428 let state_note = if is_failed_or_held {
@@ -454,7 +454,7 @@ async fn logs_screen(cx: &Cx, snapshot: LogsSnapshot) -> Result {
454454 <h2 class="panel-title">(t(lang, Key::MailDecisions))</h2>
455455 </div>
456456 <div class="panel-body">
457- <div class="rule-list rule-list-scroll">
457+ <div class="rule-list">
458458 for group in decisions {
459459 let header = match group.happened {
460460 Some(happened) => format!("{} · {}", group.task, happened),
@@ -489,7 +489,7 @@ async fn logs_screen(cx: &Cx, snapshot: LogsSnapshot) -> Result {
489489 <h2 class="panel-title">(t(lang, Key::Activity))</h2>
490490 </div>
491491 <div class="panel-body">
492- <div class="rule-list rule-list-scroll">
492+ <div class="rule-list">
493493 for line in activity {
494494 <div class="rule-row">
495495 <div class="rule-sentence">
crates/izlek-web/src/settings.rsmodified+83 -20
@@ -182,23 +182,39 @@ fn redirect_to(query: &str) -> (StatusCode, HeaderMap, Vec<u8>) {
182182 (StatusCode::SEE_OTHER, headers, Vec::new())
183183 }
184184
185+/// Which rail section a call's redirect lands back on, so the reload shows
186+/// the panel the form it answers actually lives in.
187+fn section_of_call(call: &str) -> &'static str {
188+ match call {
189+ "save_sender" | "send_test_mail" => "outgoing",
190+ "save_limits" => "limits",
191+ "invite_member" | "set_role" | "resend_link" => "members",
192+ _ => "profile",
193+ }
194+}
195+
185196 /// Where a save lands: back on Settings, with the refusal (if any) on the
186197 /// query the same way `files.rs`'s upload carries one, or `saved=<call>`
187-/// when there was nothing to refuse.
198+/// when there was nothing to refuse — either way, on the rail section that
199+/// call belongs to.
188200 pub(crate) fn saved_or_refused(
189201 call: &str,
190202 refusal: Option<Refusal>,
191203 ) -> (StatusCode, HeaderMap, Vec<u8>) {
204+ let section = section_of_call(call);
192205 match refusal {
193206 // `BadSender`'s code collapses six different complaints into one
194207 // generic "bad-sender"; the sentence save time actually wrote rides
195208 // along as `why` so the redirect does not have to guess it back.
196209 Some(Refusal::BadSender(problem)) => redirect_to(&format!(
197- "refusal=bad-sender&on={call}&why={}",
210+ "refusal=bad-sender&on={call}&why={}&section={section}",
198211 qsencode(&problem)
199212 )),
200- Some(refusal) => redirect_to(&format!("refusal={}&on={call}", refusal.code())),
201- None => redirect_to(&format!("saved={call}")),
213+ Some(refusal) => redirect_to(&format!(
214+ "refusal={}&on={call}&section={section}",
215+ refusal.code()
216+ )),
217+ None => redirect_to(&format!("saved={call}&section={section}")),
202218 }
203219 }
204220
@@ -803,6 +819,27 @@ fn query_value<'q>(query: &'q str, key: &str) -> Option<&'q str> {
803819 })
804820 }
805821
822+/// Which rail section the page renders. Only one is drawn at a time; an
823+/// admin-only value asked for by anyone else falls back to `Profile`, same as
824+/// a section name it does not recognize at all.
825+#[derive(Clone, Copy, PartialEq, Eq)]
826+enum Section {
827+ Profile,
828+ Outgoing,
829+ Limits,
830+ Members,
831+}
832+
833+/// The class a rail link wears: `active` on the section it points to when
834+/// that is the one showing, plain otherwise.
835+fn rail_class(current: Section, target: Section) -> &'static str {
836+ if current == target {
837+ "settings-section-link active"
838+ } else {
839+ "settings-section-link"
840+ }
841+}
842+
806843 /// The settings screen.
807844 #[page("/settings")]
808845 #[allow(unused_variables)]
@@ -822,6 +859,12 @@ async fn settings_page(cx: &Cx) -> Result {
822859 let lang = Lang::from_code(&user.language);
823860 let administers = user.role.can_administer();
824861 let query = topcoat::router::request::uri(cx).query().unwrap_or("");
862+ let section = match query_value(query, "section") {
863+ Some("outgoing") if administers => Section::Outgoing,
864+ Some("limits") if administers => Section::Limits,
865+ Some("members") if administers => Section::Members,
866+ _ => Section::Profile,
867+ };
825868
826869 let zone = izlek_core::detail::parse_zone(&user.timezone);
827870 let sender = if administers {
@@ -852,6 +895,7 @@ async fn settings_page(cx: &Cx) -> Result {
852895 let (invite_refusal, _) = call_state(query, "invite_member");
853896 let (role_refusal, _) = call_state(query, "set_role");
854897 let member_refusal = resend_refusal.or(invite_refusal).or(role_refusal);
898+ let (password_refusal, _) = call_state(query, "change_password");
855899 let mailed = query_value(query, "mailed").map(decode_q);
856900
857901 view! {
@@ -867,20 +911,16 @@ async fn settings_page(cx: &Cx) -> Result {
867911 </header>
868912
869913 <div class="settings-shell">
914+ <nav class="settings-sections">
915+ <a class=(rail_class(section, Section::Profile)) href="/settings?section=profile">(t(lang, Key::YourProfile))</a>
916+ if administers {
917+ <a class=(rail_class(section, Section::Outgoing)) href="/settings?section=outgoing">(t(lang, Key::OutgoingMail))</a>
918+ <a class=(rail_class(section, Section::Limits)) href="/settings?section=limits">(t(lang, Key::WorkspaceLimits))</a>
919+ <a class=(rail_class(section, Section::Members)) href="/settings?section=members">(t(lang, Key::Members))</a>
920+ }
921+ </nav>
870922 <main class="settings-stage">
871- <div class="settings-head">
872- <h1 class="settings-title">(t(lang, Key::NavSettings))</h1>
873- <span class="chip chip-role">(user.role.as_str().to_string())</span>
874- </div>
875- <nav class="settings-sections">
876- <a class="settings-section-link" href="#profile">(t(lang, Key::YourProfile))</a>
877- if administers {
878- <a class="settings-section-link" href="#outgoing">(t(lang, Key::OutgoingMail))</a>
879- <a class="settings-section-link" href="#limits">(t(lang, Key::WorkspaceLimits))</a>
880- <a class="settings-section-link" href="#members">(t(lang, Key::Members))</a>
881- }
882- </nav>
883-
923+ if section == Section::Profile {
884924 <section class="panel" id="profile">
885925 <div class="panel-head">
886926 <h2 class="panel-title">(t(lang, Key::YourProfile))</h2>
@@ -967,7 +1007,30 @@ async fn settings_page(cx: &Cx) -> Result {
9671007 }
9681008 </section>
9691009
970- if let Some(sender) = &sender {
1010+ <section class="panel" id="password">
1011+ <div class="panel-head">
1012+ <h2 class="panel-title">(t(lang, Key::ChangePassword))</h2>
1013+ </div>
1014+ <form method="post" action="/api/change_password" class="panel-body">
1015+ <label class="field">
1016+ <span class="field-label">(t(lang, Key::CurrentPasswordLabel))</span>
1017+ <input class="field-input" type="password" name="current" autocomplete="current-password" required="">
1018+ </label>
1019+ <label class="field">
1020+ <span class="field-label">(t(lang, Key::NewPasswordLabel))</span>
1021+ <input class="field-input" type="password" name="new" autocomplete="new-password" required="">
1022+ </label>
1023+ <div class="panel-foot">
1024+ if let Some(refusal) = &password_refusal {
1025+ <span class="field-error">(refusal.message_in(lang))</span>
1026+ }
1027+ <button class="primary" type="submit">(t(lang, Key::ChangePassword))</button>
1028+ </div>
1029+ </form>
1030+ </section>
1031+ }
1032+
1033+ if section == Section::Outgoing && let Some(sender) = &sender {
9711034 let connected = sender.is_connected();
9721035 let password_set = sender.password_set;
9731036 <section class="panel" id="outgoing">
@@ -1074,7 +1137,7 @@ async fn settings_page(cx: &Cx) -> Result {
10741137 </section>
10751138 }
10761139
1077- if let Some((attachment_limit_mb, photo_limit_mb)) = limits {
1140+ if section == Section::Limits && let Some((attachment_limit_mb, photo_limit_mb)) = limits {
10781141 <section class="panel" id="limits">
10791142 <div class="panel-head">
10801143 <h2 class="panel-title">(t(lang, Key::WorkspaceLimits))</h2>
@@ -1130,7 +1193,7 @@ async fn settings_page(cx: &Cx) -> Result {
11301193 </section>
11311194 }
11321195
1133- if let Some(members) = members {
1196+ if section == Section::Members && let Some(members) = members {
11341197 <section class="panel" id="members">
11351198 <div class="panel-head">
11361199 <h2 class="panel-title">(t(lang, Key::Members))</h2>
crates/izlek-web/tests/http.rsmodified+77 -13
@@ -2460,7 +2460,9 @@ async fn an_admin_sees_the_sender_and_never_a_password() {
24602460 let admin_cookie = admin(&app).await;
24612461 assert!(sender_saved(&app, &admin_cookie).await);
24622462
2463- let page = app.get("/settings", Some(&admin_cookie)).await;
2463+ let page = app
2464+ .get("/settings?section=outgoing", Some(&admin_cookie))
2465+ .await;
24642466 assert_eq!(page.status, StatusCode::OK);
24652467 let html = String::from_utf8_lossy(&page.bytes);
24662468 assert!(html.contains("smtp.fastmail.com"), "{html}");
@@ -2504,7 +2506,7 @@ async fn an_admin_sees_who_has_a_password_and_never_a_hash() {
25042506 .await;
25052507 assert_eq!(answer.status, StatusCode::OK, "{}", answer.body);
25062508
2507- let page = app.get("/settings", Some(&admin_cookie)).await;
2509+ let page = app.get("/settings?section=members", Some(&admin_cookie)).await;
25082510 let html = String::from_utf8_lossy(&page.bytes);
25092511 assert!(html.contains("mert@izlek.sh"), "{html}");
25102512 assert!(
@@ -3901,7 +3903,7 @@ async fn an_unlisted_language_is_refused() {
39013903 .await;
39023904 assert_eq!(
39033905 saved.location.as_deref(),
3904- Some("/settings?refusal=bad-language&on=save_profile")
3906+ Some("/settings?refusal=bad-language&on=save_profile&section=profile")
39053907 );
39063908 }
39073909
@@ -4041,14 +4043,76 @@ async fn the_topbar_nav_marks_the_active_page() {
40414043 }
40424044 }
40434045
4044- // The settings section list keeps the panels' admin gating: a member
4045- // sees only the Profile anchor.
4046+ // The settings rail keeps the panels' admin gating: a member sees only
4047+ // the Profile link, and an admin-only section in the query still renders
4048+ // Profile rather than the panel it asked for.
40464049 let member = invited(&app, &admin_cookie, "deniz@izlek.sh", "Deniz", Role::Member).await;
40474050 let page = app.get("/settings", Some(&member)).await;
40484051 let html = String::from_utf8_lossy(&page.bytes);
4049- assert!(html.contains(r##"href="#profile""##), "{html}");
4050- assert!(!html.contains("href=\"#limits\""), "{html}");
4051- assert!(!html.contains("href=\"#members\""), "{html}");
4052+ assert!(html.contains(r#"href="/settings?section=profile""#), "{html}");
4053+ assert!(!html.contains("href=\"/settings?section=limits\""), "{html}");
4054+ assert!(!html.contains("href=\"/settings?section=members\""), "{html}");
4055+ assert!(html.contains(r#"id="profile""#), "{html}");
4056+ assert!(!html.contains(r#"id="limits""#), "{html}");
4057+
4058+ let page = app
4059+ .get("/settings?section=limits", Some(&member))
4060+ .await;
4061+ let html = String::from_utf8_lossy(&page.bytes);
4062+ assert!(html.contains(r#"id="profile""#), "{html}");
4063+ assert!(!html.contains(r#"id="limits""#), "{html}");
4064+}
4065+
4066+/// A wrong current password lands back on the rail section it was posted
4067+/// from with a refusal; a right one changes nothing about the query but the
4068+/// refusal — `carry_refusal_on_redirect` never writes a `saved=` for a call
4069+/// nobody asked to see a note about.
4070+#[tokio::test]
4071+async fn a_password_change_carries_its_own_refusal_and_never_a_saved_note() {
4072+ let app = App::open().await;
4073+ let admin_cookie = admin(&app).await;
4074+
4075+ let wrong = app
4076+ .post_without_script(
4077+ "/api/change_password",
4078+ Some(&admin_cookie),
4079+ "http://izlek.test/settings?section=profile",
4080+ &[
4081+ ("current", "not the password"),
4082+ ("new", "a whole new passphrase"),
4083+ ],
4084+ )
4085+ .await;
4086+ assert!(
4087+ wrong.location.as_deref().is_some_and(|location| {
4088+ location.contains("refusal=")
4089+ && location.contains("on=change_password")
4090+ && location.contains("section=profile")
4091+ }),
4092+ "{:?}",
4093+ wrong.location
4094+ );
4095+
4096+ let right = app
4097+ .post_without_script(
4098+ "/api/change_password",
4099+ Some(&admin_cookie),
4100+ "http://izlek.test/settings?section=profile",
4101+ &[
4102+ ("current", "correct horse battery staple"),
4103+ ("new", "a whole new passphrase"),
4104+ ],
4105+ )
4106+ .await;
4107+ assert_eq!(right.status, StatusCode::SEE_OTHER);
4108+ assert!(
4109+ right
4110+ .location
4111+ .as_deref()
4112+ .is_some_and(|location| !location.contains("saved=")),
4113+ "{:?}",
4114+ right.location
4115+ );
40524116 }
40534117
40544118 /// 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() {
43514415 assert_eq!(answer.status, StatusCode::SEE_OTHER);
43524416 assert_eq!(
43534417 answer.location.as_deref(),
4354- Some("/settings?saved=profile_photo")
4418+ Some("/settings?saved=profile_photo&section=profile")
43554419 );
43564420
43574421 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() {
43794443 assert_eq!(answer.status, StatusCode::SEE_OTHER);
43804444 assert_eq!(
43814445 answer.location.as_deref(),
4382- Some("/settings?refusal=not-an-image&on=profile_photo")
4446+ Some("/settings?refusal=not-an-image&on=profile_photo&section=profile")
43834447 );
43844448
43854449 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() {
44394503 assert_eq!(answer.status, StatusCode::SEE_OTHER);
44404504 assert_eq!(
44414505 answer.location.as_deref(),
4442- Some("/settings?refusal=file-too-big&on=profile_photo")
4506+ Some("/settings?refusal=file-too-big&on=profile_photo&section=profile")
44434507 );
44444508
44454509 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() {
44654529 .await;
44664530 assert_eq!(
44674531 answer.location.as_deref(),
4468- Some("/settings?saved=profile_photo")
4532+ Some("/settings?saved=profile_photo&section=profile")
44694533 );
44704534
44714535 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() {
44934557 .await;
44944558 assert_eq!(
44954559 answer.location.as_deref(),
4496- Some("/settings?saved=profile_photo")
4560+ Some("/settings?saved=profile_photo&section=profile")
44974561 );
44984562
44994563 let stranger = app.get("/photo/does-not-exist", Some(&admin)).await;
style/_instrument.scssmodified+15 -0
@@ -158,6 +158,21 @@
158158 // ruled columns and the square avatars above. Token values — control
159159 // heights, radii, shadows — already carry the rest.)
160160
161+ // --- Instrument skin: settings rail -----------------------------------------
162+
163+ .settings-sections { width: 200px; }
164+
165+ .settings-section-link {
166+ font-size: 13px;
167+ letter-spacing: normal;
168+ text-transform: none;
169+
170+ &.active {
171+ background: var(--row-hover);
172+ box-shadow: inset 2px 0 0 var(--accent);
173+ }
174+ }
175+
161176 }
162177
163178 // -- task detail: 560px side panel over the board ----------------------------
style/_ledger.scssmodified+10 -0
@@ -420,3 +420,13 @@
420420 [data-ui="ledger"] .comment-composer {
421421 padding: 20px 0 0;
422422 }
423+
424+// Settings rail: a narrower column, mono/uppercase stays, the active section
425+// marked with an ink rule rather than a fill.
426+[data-ui="ledger"] .settings-sections {
427+ width: 170px;
428+}
429+
430+[data-ui="ledger"] .settings-section-link.active {
431+ border-bottom: 2px solid var(--ink);
432+}
style/main.scssmodified+23 -12
@@ -338,6 +338,16 @@ body:has(.board-stage) {
338338 > .board-stage { flex: 1; min-height: 0; }
339339 }
340340
341+body:has(.settings-shell) {
342+ height: 100vh;
343+ overflow: hidden;
344+ display: flex;
345+ flex-direction: column;
346+
347+ > * { flex: none; }
348+ > .settings-shell { flex: 1; min-height: 0; }
349+}
350+
341351 a {
342352 color: var(--accent);
343353 transition: color var(--dur-fast) var(--ease);
@@ -2138,18 +2148,19 @@ img.avatar {
21382148
21392149 .settings-shell {
21402150 display: flex;
2141- flex-direction: column;
2142- min-height: calc(100vh - var(--topbar-height));
21432151 }
21442152
21452153 .settings-stage {
2146- flex-grow: 1;
2154+ flex: 1;
21472155 min-width: 0;
21482156 padding: 24px 32px 40px;
21492157 display: flex;
21502158 flex-direction: column;
21512159 gap: 20px;
2152- max-width: 900px;
2160+ max-width: 860px;
2161+ overflow-y: auto;
2162+ scrollbar-width: none;
2163+ &::-webkit-scrollbar { display: none; }
21532164 }
21542165
21552166 .settings-head {
@@ -2160,12 +2171,18 @@ img.avatar {
21602171 }
21612172
21622173 .settings-sections {
2174+ flex: none;
2175+ width: 200px;
21632176 display: flex;
2164- flex-wrap: wrap;
2165- gap: 16px;
2177+ flex-direction: column;
2178+ gap: 2px;
2179+ padding: 16px 0;
2180+ border-right: 1px solid var(--border);
21662181 }
21672182
21682183 .settings-section-link {
2184+ display: block;
2185+ padding: 8px 16px;
21692186 font-family: var(--font-mono);
21702187 font-size: 10px;
21712188 letter-spacing: 0.08em;
@@ -2622,12 +2639,6 @@ input[type="radio"] {
26222639 gap: 10px;
26232640 }
26242641
2625-// The logs pages reuse the rules list but bound its height.
2626-.rule-list-scroll {
2627- max-height: 360px;
2628- overflow-y: auto;
2629-}
2630-
26312642 .rule-row {
26322643 display: flex;
26332644 align-items: center;