the Connection card's ages read like ages: whole seconds grew a human shape — 45s stays, minutes fold to 2m, hours to 3h, each followed by ago — and the lines name their moments exactly, Last roster event and Last full pass, with the Turkish carrying the same precision (Son dizin olayı, Son tam geçiş); never stays a sentence of its own, spoken only before the first occurrence; the http assertions follow the new shapes; found uncommitted in the tree and riding along per the standing whole-tree rule
Browse files at this commitdc994c4a2e018c4b39b90f455a9dce4b0dc615b3Parent: 23a92ca4 changed files +87 -54
- crates/in-web/src/i18n.rs +4 -4
- crates/in-web/src/settings.rs +39 -33
- crates/in-web/tests/http.rs +13 -17
- style/main.scss +31 -0
crates/in-web/src/i18n.rsmodified+4 -4
| @@ -354,8 +354,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 354 | ConnectionStream => "Directory stream", | 354 | ConnectionStream => "Directory stream", |
| 355 | ConnectionConnected => "Connected", | 355 | ConnectionConnected => "Connected", |
| 356 | ConnectionReconnecting => "Reconnecting…", | 356 | ConnectionReconnecting => "Reconnecting…", |
| 357 | - ConnectionLastEvent => "Last event", | 357 | + ConnectionLastEvent => "Last roster event", |
| 358 | - ConnectionLastPass => "Last pass", | 358 | + ConnectionLastPass => "Last full pass", |
| 359 | Never => "never", | 359 | Never => "never", |
| 360 | QuotaUsage => "Storage used", | 360 | QuotaUsage => "Storage used", |
| 361 | QuotaOf => "of", | 361 | QuotaOf => "of", |
| @@ -529,8 +529,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 529 | ConnectionStream => "Dizin akışı", | 529 | ConnectionStream => "Dizin akışı", |
| 530 | ConnectionConnected => "Bağlı", | 530 | ConnectionConnected => "Bağlı", |
| 531 | ConnectionReconnecting => "Yeniden bağlanıyor…", | 531 | ConnectionReconnecting => "Yeniden bağlanıyor…", |
| 532 | - ConnectionLastEvent => "Son etkinlik", | 532 | + ConnectionLastEvent => "Son dizin olayı", |
| 533 | - ConnectionLastPass => "Son tarama", | 533 | + ConnectionLastPass => "Son tam geçiş", |
| 534 | Never => "hiç", | 534 | Never => "hiç", |
| 535 | AdminPanel => "Herkes", | 535 | AdminPanel => "Herkes", |
| 536 | AllUsers => "Herkes", | 536 | AllUsers => "Herkes", |
crates/in-web/src/settings.rsmodified+39 -33
| @@ -25,7 +25,7 @@ use crate::server::{ | |||
| 25 | Refusal, app, back_to, require_admin, require_user, share_link_url, share_origin, | 25 | Refusal, app, back_to, require_admin, require_user, share_link_url, share_origin, |
| 26 | }; | 26 | }; |
| 27 | use crate::share::{refusal_banner, refusal_of, share_copy_script}; | 27 | use crate::share::{refusal_banner, refusal_of, share_copy_script}; |
| 28 | -use crate::i18n::{Key, Lang, lang, t}; | 28 | +use crate::i18n::{Key, lang, t}; |
| 29 | use crate::layout::{NavPage, topbar}; | 29 | use crate::layout::{NavPage, topbar}; |
| 30 | 30 | ||
| 31 | /// Bytes in human units: `512 B`, `1.5 KiB`, `2.0 GiB`. One decimal past | 31 | /// Bytes in human units: `512 B`, `1.5 KiB`, `2.0 GiB`. One decimal past |
| @@ -45,13 +45,15 @@ pub fn human_bytes(bytes: u64) -> String { | |||
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | -/// The value half of a Connection card's age line: the seconds when the | 48 | +/// An age in whole seconds as the card prints it — a short number with |
| 49 | -/// moment is known, the `never` wording before its first occurrence — | 49 | +/// its unit, the same shape in every language: `45s`, `2m`, `3h`. Empty |
| 50 | -/// a card that went silent and a card that never spoke read differently. | 50 | +/// before the first occurrence; the caller sentences it. |
| 51 | -fn age_text(age: Option<i64>, language: Lang) -> String { | 51 | +fn age_text(age: Option<i64>) -> String { |
| 52 | match age { | 52 | match age { |
| 53 | - Some(age) => format!("{age}s"), | 53 | + Some(secs) if secs >= 3600 => format!("{}h", secs / 3600), |
| 54 | - None => t(language, Key::Never).to_string(), | 54 | + Some(secs) if secs >= 60 => format!("{}m", secs / 60), |
| 55 | + Some(secs) => format!("{secs}s"), | ||
| 56 | + None => String::new(), | ||
| 55 | } | 57 | } |
| 56 | } | 58 | } |
| 57 | 59 | ||
| @@ -313,15 +315,25 @@ async fn settings(cx: &Cx) -> Result { | |||
| 313 | let language = lang(cx).await; | 315 | let language = lang(cx).await; |
| 314 | let app = app(cx); | 316 | let app = app(cx); |
| 315 | let store = app.store; | 317 | let store = app.store; |
| 316 | - // The Connection card reads only what the config already carries and | ||
| 317 | - // the sync task's own atomics — the client secret is never touched on | ||
| 318 | - // any path that reaches this render. | ||
| 319 | let connected = app.health.stream_connected(); | 318 | let connected = app.health.stream_connected(); |
| 320 | let last_event = app.health.last_event_age_secs(); | 319 | let last_event = app.health.last_event_age_secs(); |
| 321 | let last_pass = app.health.last_pass_age_secs(); | 320 | let last_pass = app.health.last_pass_age_secs(); |
| 322 | - // Both ages share one shape: the seconds when the moment is known, | 321 | + // Both ages share one sentence shape: the humanized age and `ago`, |
| 323 | - // the `never` wording before the first occurrence — a card that went | 322 | + // or the `never` wording before the first occurrence — a card that |
| 324 | - // silent and a card that never spoke read differently. | 323 | + // went silent and a card that never spoke read differently. |
| 324 | + let age_line = |age: Option<i64>| { | ||
| 325 | + let text = age_text(age); | ||
| 326 | + if text.is_empty() { | ||
| 327 | + t(language, Key::Never).to_string() | ||
| 328 | + } else { | ||
| 329 | + format!("{text} ago") | ||
| 330 | + } | ||
| 331 | + }; | ||
| 332 | + let event_line = age_line(last_event); | ||
| 333 | + let pass_line = age_line(last_pass); | ||
| 334 | + // The Connection card reads only what the config already carries and | ||
| 335 | + // the sync task's own atomics — the client secret is never touched on | ||
| 336 | + // any path that reaches this render. | ||
| 325 | // Re-read the row so the quota bar never shows a stale number. | 337 | // Re-read the row so the quota bar never shows a stale number. |
| 326 | let fresh = store.user(&user.id).await?.unwrap_or_else(|| user.clone()); | 338 | let fresh = store.user(&user.id).await?.unwrap_or_else(|| user.clone()); |
| 327 | let administers = fresh.admin; | 339 | let administers = fresh.admin; |
| @@ -466,31 +478,25 @@ async fn settings(cx: &Cx) -> Result { | |||
| 466 | <h2 class="panel-title">(t(language, Key::Connection))</h2> | 478 | <h2 class="panel-title">(t(language, Key::Connection))</h2> |
| 467 | </div> | 479 | </div> |
| 468 | <div class="panel-body"> | 480 | <div class="panel-body"> |
| 469 | - <div class="field"> | 481 | + <dl class="connection-facts"> |
| 470 | - <span class="field-label">(t(language, Key::ConnectionIssuer))</span> | 482 | + <dt>(t(language, Key::ConnectionIssuer))</dt> |
| 471 | - <span class="field-static">(app.config.oidc.issuer.clone())</span> | 483 | + <dd>(app.config.oidc.issuer.clone())</dd> |
| 472 | - </div> | 484 | + <dt>(t(language, Key::ConnectionClientId))</dt> |
| 473 | - <div class="field"> | 485 | + <dd>(app.config.oidc.client_id.clone())</dd> |
| 474 | - <span class="field-label">(t(language, Key::ConnectionClientId))</span> | 486 | + <dt>(t(language, Key::ConnectionStream))</dt> |
| 475 | - <span class="field-static">(app.config.oidc.client_id.clone())</span> | 487 | + <dd> |
| 476 | - </div> | 488 | + <span class=(if connected { "connection-dot connection-on" } else { "connection-dot connection-wait" })></span> |
| 477 | - <div class="field"> | ||
| 478 | - <span class="field-label">(t(language, Key::ConnectionStream))</span> | ||
| 479 | - <span class="field-static"> | ||
| 480 | - <span class=(if connected { "status-dot status-dot-done" } else { "status-dot status-dot-warn" })></span> | ||
| 481 | if connected { | 489 | if connected { |
| 482 | (t(language, Key::ConnectionConnected)) | 490 | (t(language, Key::ConnectionConnected)) |
| 483 | } else { | 491 | } else { |
| 484 | (t(language, Key::ConnectionReconnecting)) | 492 | (t(language, Key::ConnectionReconnecting)) |
| 485 | } | 493 | } |
| 486 | - </span> | 494 | + </dd> |
| 487 | - <div class="field-note"> | 495 | + <dt>(t(language, Key::ConnectionLastEvent))</dt> |
| 488 | - (format!("{} · {}", t(language, Key::ConnectionLastEvent), age_text(last_event, language))) | 496 | + <dd>(event_line)</dd> |
| 489 | - </div> | 497 | + <dt>(t(language, Key::ConnectionLastPass))</dt> |
| 490 | - <div class="field-note"> | 498 | + <dd>(pass_line)</dd> |
| 491 | - (format!("{} · {}", t(language, Key::ConnectionLastPass), age_text(last_pass, language))) | 499 | + </dl> |
| 492 | - </div> | ||
| 493 | - </div> | ||
| 494 | </div> | 500 | </div> |
| 495 | </section> | 501 | </section> |
| 496 | } | 502 | } |
crates/in-web/tests/http.rsmodified+13 -17
| @@ -5300,16 +5300,14 @@ async fn connection_card_shows_issuer_client_id_and_stream_state() { | |||
| 5300 | "no client id: {body}" | 5300 | "no client id: {body}" |
| 5301 | ); | 5301 | ); |
| 5302 | assert!(body.contains("Reconnecting"), "no amber wording: {body}"); | 5302 | assert!(body.contains("Reconnecting"), "no amber wording: {body}"); |
| 5303 | - assert!(body.contains("status-dot-warn"), "no amber dot: {body}"); | 5303 | + assert!(body.contains("connection-wait"), "no amber dot: {body}"); |
| 5304 | - // Before the first occurrences both ages read never — the line is | 5304 | + // Before the first occurrences both ages read never — the row is |
| 5305 | // there, the number is not. | 5305 | // there, the number is not. |
| 5306 | + assert!(body.contains("Last roster event"), "no event row: {body}"); | ||
| 5307 | + assert!(body.contains("Last full pass"), "no pass row: {body}"); | ||
| 5306 | assert!( | 5308 | assert!( |
| 5307 | - body.contains("Last pass · never"), | 5309 | + body.matches("<dd>never</dd>").count() >= 2, |
| 5308 | - "no never wording on the pass line: {body}" | 5310 | + "both ages must read never: {body}" |
| 5309 | - ); | ||
| 5310 | - assert!( | ||
| 5311 | - body.contains("Last event · never"), | ||
| 5312 | - "no never wording on the event line: {body}" | ||
| 5313 | ); | 5311 | ); |
| 5314 | assert!( | 5312 | assert!( |
| 5315 | !body.contains("s3cr3t"), | 5313 | !body.contains("s3cr3t"), |
| @@ -5324,23 +5322,21 @@ async fn connection_card_shows_issuer_client_id_and_stream_state() { | |||
| 5324 | let page = app.get("/settings", Some(&cookie)).await; | 5322 | let page = app.get("/settings", Some(&cookie)).await; |
| 5325 | let body = page.text(); | 5323 | let body = page.text(); |
| 5326 | assert!(body.contains("Connected"), "no green wording: {body}"); | 5324 | assert!(body.contains("Connected"), "no green wording: {body}"); |
| 5327 | - assert!(body.contains("status-dot-done"), "no green dot: {body}"); | 5325 | + assert!(body.contains("connection-on"), "no green dot: {body}"); |
| 5328 | // An age, not never — the number itself races the second boundary | 5326 | // An age, not never — the number itself races the second boundary |
| 5329 | - // between the stamp and this render, so it is not asserted. | 5327 | + // between the stamp and this render, so only the sentence shape is |
| 5330 | - assert!( | 5328 | + // asserted. |
| 5331 | - body.contains("Last event · ") && !body.contains("Last event · never"), | ||
| 5332 | - "no event age: {body}" | ||
| 5333 | - ); | ||
| 5334 | assert!( | 5329 | assert!( |
| 5335 | - body.contains("Last pass · ") && !body.contains("Last pass · never"), | 5330 | + !body.contains("<dd>never</dd>"), |
| 5336 | - "no pass age: {body}" | 5331 | + "ages still read never after both stamps: {body}" |
| 5337 | ); | 5332 | ); |
| 5333 | + assert!(body.matches(" ago</dd>").count() >= 2, "ages not sentenced: {body}"); | ||
| 5338 | // The stream ends: amber again, no event line retraction needed — the | 5334 | // The stream ends: amber again, no event line retraction needed — the |
| 5339 | // last event stays but the wording names the truth. | 5335 | // last event stays but the wording names the truth. |
| 5340 | app.health.reconnecting(); | 5336 | app.health.reconnecting(); |
| 5341 | let page = app.get("/settings", Some(&cookie)).await; | 5337 | let page = app.get("/settings", Some(&cookie)).await; |
| 5342 | let body = page.text(); | 5338 | let body = page.text(); |
| 5343 | assert!(body.contains("Reconnecting"), "no amber return: {body}"); | 5339 | assert!(body.contains("Reconnecting"), "no amber return: {body}"); |
| 5344 | - assert!(!body.contains("status-dot-done"), "green lingered: {body}"); | 5340 | + assert!(!body.contains("connection-on"), "green lingered: {body}"); |
| 5345 | } | 5341 | } |
| 5346 | 5342 | ||
style/main.scssmodified+31 -0
| @@ -5484,3 +5484,34 @@ div.member-row + div.member-row { | |||
| 5484 | display: none; | 5484 | display: none; |
| 5485 | } | 5485 | } |
| 5486 | } | 5486 | } |
| 5487 | + | ||
| 5488 | +// The Connection card's label/value rows: two columns, labels bold and | ||
| 5489 | +// unbreaking, values free to wrap — the shape the identity card wears. | ||
| 5490 | +.connection-facts { | ||
| 5491 | + display: grid; | ||
| 5492 | + grid-template-columns: max-content 1fr; | ||
| 5493 | + gap: 0.4rem 1.5rem; | ||
| 5494 | + margin: 0; | ||
| 5495 | + | ||
| 5496 | + dt { | ||
| 5497 | + font-weight: 600; | ||
| 5498 | + white-space: nowrap; | ||
| 5499 | + } | ||
| 5500 | +} | ||
| 5501 | + | ||
| 5502 | +.connection-dot { | ||
| 5503 | + display: inline-block; | ||
| 5504 | + width: 0.55rem; | ||
| 5505 | + height: 0.55rem; | ||
| 5506 | + border-radius: 50%; | ||
| 5507 | + margin-right: 0.4rem; | ||
| 5508 | + vertical-align: baseline; | ||
| 5509 | + | ||
| 5510 | + &.connection-on { | ||
| 5511 | + background: #2e9e5b; | ||
| 5512 | + } | ||
| 5513 | + | ||
| 5514 | + &.connection-wait { | ||
| 5515 | + background: #d99a26; | ||
| 5516 | + } | ||
| 5517 | +} | ||