The columns are named, and only the address is elastic
Browse files at this commit2258902789cf7ac465b4120c299aabb5a162f610Parent: f121bd5- fix
- the columns are named, and only the address is elastic
4 changed files +101 -15
- crates/izlek-web/src/detail.rs +10 -1
- crates/izlek-web/src/settings.rs +8 -8
- crates/izlek-web/tests/http.rs +47 -0
- style/main.scss +36 -6
crates/izlek-web/src/detail.rsmodified+10 -1
| @@ -98,6 +98,15 @@ pub struct SendLine { | |||
| 98 | /// The chip's tone — see `logs.rs`'s `QueueLine::state_kind`. | 98 | /// The chip's tone — see `logs.rs`'s `QueueLine::state_kind`. |
| 99 | pub state_kind: String, | 99 | pub state_kind: String, |
| 100 | pub attempts: u32, | 100 | pub attempts: u32, |
| 101 | + /// What the mail server said when it refused, and `None` for anyone who | ||
| 102 | + /// may not administer — the same gate `rule_name` gets, for the same | ||
| 103 | + /// reason. Which people a task mailed, and whether it arrived, is a fact | ||
| 104 | + /// about the task and belongs to everyone who can read it. *Why the mail | ||
| 105 | + /// server refused* is a fact about the workspace's sender — a host, an | ||
| 106 | + /// account, a rejected credential — and this app keeps that admin-only | ||
| 107 | + /// everywhere else (`/api/current_logs` is admin-gated; the live channel | ||
| 108 | + /// will not even name `Topic::Queue` to a member). Gated here, where the | ||
| 109 | + /// line is built, so no view can print what it was never given. | ||
| 101 | pub last_error: Option<String>, | 110 | pub last_error: Option<String>, |
| 102 | pub sent_at: Option<String>, | 111 | pub sent_at: Option<String>, |
| 103 | } | 112 | } |
| @@ -397,7 +406,7 @@ async fn load_snapshot( | |||
| 397 | state: state.to_string(), | 406 | state: state.to_string(), |
| 398 | state_kind: state_kind.to_string(), | 407 | state_kind: state_kind.to_string(), |
| 399 | attempts: send.attempts, | 408 | attempts: send.attempts, |
| 400 | - last_error: send.last_error.clone(), | 409 | + last_error: may_administer.then(|| send.last_error.clone()).flatten(), |
| 401 | sent_at: send.sent_at.map(|at| moment_label_in(at, zone)), | 410 | sent_at: send.sent_at.map(|at| moment_label_in(at, zone)), |
| 402 | } | 411 | } |
| 403 | }) | 412 | }) |
crates/izlek-web/src/settings.rsmodified+8 -8
| @@ -1532,10 +1532,10 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1532 | <table class="member-table"> | 1532 | <table class="member-table"> |
| 1533 | <thead> | 1533 | <thead> |
| 1534 | <tr> | 1534 | <tr> |
| 1535 | - <th>(t(lang, Key::NameCol))</th> | 1535 | + <th class="member-col-name">(t(lang, Key::NameCol))</th> |
| 1536 | - <th>(t(lang, Key::AddressCol))</th> | 1536 | + <th class="member-col-address">(t(lang, Key::AddressCol))</th> |
| 1537 | - <th>(t(lang, Key::RoleCol))</th> | 1537 | + <th class="member-col-role">(t(lang, Key::RoleCol))</th> |
| 1538 | - <th>(t(lang, Key::AccountCol))</th> | 1538 | + <th class="member-col-account">(t(lang, Key::AccountCol))</th> |
| 1539 | </tr> | 1539 | </tr> |
| 1540 | </thead> | 1540 | </thead> |
| 1541 | <tbody> | 1541 | <tbody> |
| @@ -1555,7 +1555,7 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1555 | has_photo: member.has_photo, | 1555 | has_photo: member.has_photo, |
| 1556 | }; | 1556 | }; |
| 1557 | <tr class="member-row"> | 1557 | <tr class="member-row"> |
| 1558 | - <td class="member-name"> | 1558 | + <td class="member-col-name member-name"> |
| 1559 | <span class="member-name-row"> | 1559 | <span class="member-name-row"> |
| 1560 | (crate::layout::avatar(cx, &member_person, "avatar-sm").await?) | 1560 | (crate::layout::avatar(cx, &member_person, "avatar-sm").await?) |
| 1561 | (member.display_name.clone()) | 1561 | (member.display_name.clone()) |
| @@ -1564,8 +1564,8 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1564 | } | 1564 | } |
| 1565 | </span> | 1565 | </span> |
| 1566 | </td> | 1566 | </td> |
| 1567 | - <td class="member-address">(member.email.clone())</td> | 1567 | + <td class="member-col-address member-address">(member.email.clone())</td> |
| 1568 | - <td> | 1568 | + <td class="member-col-role"> |
| 1569 | if member.is_owner || member.is_you { | 1569 | if member.is_owner || member.is_you { |
| 1570 | <span class="chip chip-role">(member.role.as_str().to_string())</span> | 1570 | <span class="chip chip-role">(member.role.as_str().to_string())</span> |
| 1571 | } else { | 1571 | } else { |
| @@ -1580,7 +1580,7 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1580 | </form> | 1580 | </form> |
| 1581 | } | 1581 | } |
| 1582 | </td> | 1582 | </td> |
| 1583 | - <td class="member-account"> | 1583 | + <td class="member-col-account member-account"> |
| 1584 | <span class="member-account-row"> | 1584 | <span class="member-account-row"> |
| 1585 | <span class="member-status">(account)</span> | 1585 | <span class="member-status">(account)</span> |
| 1586 | if !member.has_password { | 1586 | if !member.has_password { |
crates/izlek-web/tests/http.rsmodified+47 -0
| @@ -6076,6 +6076,53 @@ async fn a_tasks_notifications_show_the_recipient_and_the_rule_name_is_admin_onl | |||
| 6076 | assert!(admin_html.contains("Wraps up the sprint"), "{admin_html}"); | 6076 | assert!(admin_html.contains("Wraps up the sprint"), "{admin_html}"); |
| 6077 | } | 6077 | } |
| 6078 | 6078 | ||
| 6079 | +/// Who a task mailed and whether it arrived belongs to everyone who can read | ||
| 6080 | +/// the task. Why the mail server refused belongs to the people who can do | ||
| 6081 | +/// something about it. | ||
| 6082 | +#[tokio::test] | ||
| 6083 | +async fn the_mail_servers_own_words_are_admin_only() { | ||
| 6084 | + let app = App::open().await; | ||
| 6085 | + let admin_cookie = admin(&app).await; | ||
| 6086 | + let member = invited(&app, &admin_cookie, "emre@izlek.sh", "Emre", Role::Member).await; | ||
| 6087 | + let (task, send_id) = a_task_with_a_notification(&app, &admin_cookie, "Sprint wrap").await; | ||
| 6088 | + | ||
| 6089 | + // The send failed, and the server said something about the account it | ||
| 6090 | + // failed to authenticate. | ||
| 6091 | + let now = time::OffsetDateTime::now_utc(); | ||
| 6092 | + app.store | ||
| 6093 | + .record_send_refused( | ||
| 6094 | + &send_id, | ||
| 6095 | + "535 5.7.8 Username and Password not accepted for postmaster@dizey.sh", | ||
| 6096 | + None, | ||
| 6097 | + now, | ||
| 6098 | + ) | ||
| 6099 | + .await | ||
| 6100 | + .unwrap(); | ||
| 6101 | + | ||
| 6102 | + let member_page = app | ||
| 6103 | + .get(&format!("/?task={task}&tab=mail"), Some(&member)) | ||
| 6104 | + .await; | ||
| 6105 | + let member_html = String::from_utf8_lossy(&member_page.bytes); | ||
| 6106 | + // The fact of the failure is theirs to see. | ||
| 6107 | + assert!( | ||
| 6108 | + member_html.contains("ada@izlek.sh"), | ||
| 6109 | + "the member lost the recipient too: {member_html}" | ||
| 6110 | + ); | ||
| 6111 | + assert!( | ||
| 6112 | + !member_html.contains("postmaster@dizey.sh") && !member_html.contains("535"), | ||
| 6113 | + "a member was shown what the mail server said: {member_html}" | ||
| 6114 | + ); | ||
| 6115 | + | ||
| 6116 | + let admin_page = app | ||
| 6117 | + .get(&format!("/?task={task}&tab=mail"), Some(&admin_cookie)) | ||
| 6118 | + .await; | ||
| 6119 | + let admin_html = String::from_utf8_lossy(&admin_page.bytes); | ||
| 6120 | + assert!( | ||
| 6121 | + admin_html.contains("postmaster@dizey.sh"), | ||
| 6122 | + "the admin cannot see why it failed either: {admin_html}" | ||
| 6123 | + ); | ||
| 6124 | +} | ||
| 6125 | + | ||
| 6079 | /// A task with no mail at all renders the same quiet empty line the other | 6126 | /// A task with no mail at all renders the same quiet empty line the other |
| 6080 | /// blocks use, under the notifications heading. | 6127 | /// blocks use, under the notifications heading. |
| 6081 | #[tokio::test] | 6128 | #[tokio::test] |
style/main.scssmodified+36 -6
| @@ -2982,10 +2982,21 @@ input[type="radio"] { | |||
| 2982 | 2982 | ||
| 2983 | // -- the member list -------------------------------------------------------- | 2983 | // -- the member list -------------------------------------------------------- |
| 2984 | 2984 | ||
| 2985 | +// The columns are named, not counted, and only one of them is elastic. | ||
| 2986 | +// | ||
| 2987 | +// This was `table-layout: fixed` with a single hardcoded `width: 30%` on the | ||
| 2988 | +// last column, which made the other three exactly a third of the rest each — | ||
| 2989 | +// a geometry decided without reference to anything that would be in it. A | ||
| 2990 | +// mono-spaced address longer than a third of the table simply ran out from | ||
| 2991 | +// under its own cell and printed across the role select next to it. Auto | ||
| 2992 | +// layout asks the content instead: every column takes the width it needs, | ||
| 2993 | +// and the address — the one column whose length is somebody else's decision | ||
| 2994 | +// — absorbs what is left and ends in an ellipsis rather than in the | ||
| 2995 | +// neighbouring column. | ||
| 2985 | .member-table { | 2996 | .member-table { |
| 2986 | width: 100%; | 2997 | width: 100%; |
| 2987 | border-collapse: collapse; | 2998 | border-collapse: collapse; |
| 2988 | - table-layout: fixed; | 2999 | + table-layout: auto; |
| 2989 | font-size: 13px; | 3000 | font-size: 13px; |
| 2990 | 3001 | ||
| 2991 | th { | 3002 | th { |
| @@ -2999,14 +3010,33 @@ input[type="radio"] { | |||
| 2999 | border-bottom: 1px solid var(--border); | 3010 | border-bottom: 1px solid var(--border); |
| 3000 | } | 3011 | } |
| 3001 | 3012 | ||
| 3002 | - th:last-child, td:last-child { width: 30%; } | 3013 | + // Row height comes from the tallest thing in the row. A fixed 48px was a |
| 3003 | - | 3014 | + // guess that held until a cell had two things in it, and then the second |
| 3015 | + // one hung out over the row's own border. | ||
| 3004 | td { | 3016 | td { |
| 3005 | - height: 48px; | 3017 | + padding: 10px 12px 10px 0; |
| 3006 | - padding: 0 12px 0 0; | ||
| 3007 | vertical-align: middle; | 3018 | vertical-align: middle; |
| 3008 | } | 3019 | } |
| 3009 | 3020 | ||
| 3021 | + // Everything but the address is as wide as its content and no wider: | ||
| 3022 | + // `width: 1%` is how a table cell asks for its intrinsic width. | ||
| 3023 | + .member-col-name, | ||
| 3024 | + .member-col-role, | ||
| 3025 | + .member-col-account { | ||
| 3026 | + width: 1%; | ||
| 3027 | + white-space: nowrap; | ||
| 3028 | + } | ||
| 3029 | + | ||
| 3030 | + // The elastic one. `max-width: 0` with `width: 100%` is what lets a table | ||
| 3031 | + // cell be told "take the slack, and clip rather than overflow". | ||
| 3032 | + .member-col-address { | ||
| 3033 | + width: 100%; | ||
| 3034 | + max-width: 0; | ||
| 3035 | + overflow: hidden; | ||
| 3036 | + text-overflow: ellipsis; | ||
| 3037 | + white-space: nowrap; | ||
| 3038 | + } | ||
| 3039 | + | ||
| 3010 | .member-row { | 3040 | .member-row { |
| 3011 | border-bottom: 1px solid var(--border); | 3041 | border-bottom: 1px solid var(--border); |
| 3012 | } | 3042 | } |
| @@ -3043,7 +3073,7 @@ input[type="radio"] { | |||
| 3043 | } | 3073 | } |
| 3044 | 3074 | ||
| 3045 | .member-account { color: var(--muted); } | 3075 | .member-account { color: var(--muted); } |
| 3046 | -.member-account-row { flex-direction: column; align-items: flex-start; gap: 6px; } | 3076 | +.member-account-row { gap: 10px; } |
| 3047 | .member-status { flex: none; white-space: nowrap; } | 3077 | .member-status { flex: none; white-space: nowrap; } |
| 3048 | 3078 | ||
| 3049 | .member-resend { display: inline-flex; flex: none; } | 3079 | .member-resend { display: inline-flex; flex: none; } |