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 | 354 | ConnectionStream => "Directory stream", |
| 355 | 355 | ConnectionConnected => "Connected", |
| 356 | 356 | ConnectionReconnecting => "Reconnecting…", |
| 357 | - ConnectionLastEvent => "Last event", | |
| 358 | - ConnectionLastPass => "Last pass", | |
| 357 | + ConnectionLastEvent => "Last roster event", | |
| 358 | + ConnectionLastPass => "Last full pass", | |
| 359 | 359 | Never => "never", |
| 360 | 360 | QuotaUsage => "Storage used", |
| 361 | 361 | QuotaOf => "of", |
| @@ -529,8 +529,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | ||
| 529 | 529 | ConnectionStream => "Dizin akışı", |
| 530 | 530 | ConnectionConnected => "Bağlı", |
| 531 | 531 | ConnectionReconnecting => "Yeniden bağlanıyor…", |
| 532 | - ConnectionLastEvent => "Son etkinlik", | |
| 533 | - ConnectionLastPass => "Son tarama", | |
| 532 | + ConnectionLastEvent => "Son dizin olayı", | |
| 533 | + ConnectionLastPass => "Son tam geçiş", | |
| 534 | 534 | Never => "hiç", |
| 535 | 535 | AdminPanel => "Herkes", |
| 536 | 536 | AllUsers => "Herkes", |
crates/in-web/src/settings.rsmodified+39 -33
| @@ -25,7 +25,7 @@ use crate::server::{ | ||
| 25 | 25 | Refusal, app, back_to, require_admin, require_user, share_link_url, share_origin, |
| 26 | 26 | }; |
| 27 | 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 | 29 | use crate::layout::{NavPage, topbar}; |
| 30 | 30 | |
| 31 | 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 | |
| 49 | -/// moment is known, the `never` wording before its first occurrence — | |
| 50 | -/// a card that went silent and a card that never spoke read differently. | |
| 51 | -fn age_text(age: Option<i64>, language: Lang) -> String { | |
| 48 | +/// An age in whole seconds as the card prints it — a short number with | |
| 49 | +/// its unit, the same shape in every language: `45s`, `2m`, `3h`. Empty | |
| 50 | +/// before the first occurrence; the caller sentences it. | |
| 51 | +fn age_text(age: Option<i64>) -> String { | |
| 52 | 52 | match age { |
| 53 | - Some(age) => format!("{age}s"), | |
| 54 | - None => t(language, Key::Never).to_string(), | |
| 53 | + Some(secs) if secs >= 3600 => format!("{}h", secs / 3600), | |
| 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 | 315 | let language = lang(cx).await; |
| 314 | 316 | let app = app(cx); |
| 315 | 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 | 318 | let connected = app.health.stream_connected(); |
| 320 | 319 | let last_event = app.health.last_event_age_secs(); |
| 321 | 320 | let last_pass = app.health.last_pass_age_secs(); |
| 322 | - // Both ages share one shape: the seconds when the moment is known, | |
| 323 | - // the `never` wording before the first occurrence — a card that went | |
| 324 | - // silent and a card that never spoke read differently. | |
| 321 | + // Both ages share one sentence shape: the humanized age and `ago`, | |
| 322 | + // or the `never` wording before the first occurrence — a card that | |
| 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 | 337 | // Re-read the row so the quota bar never shows a stale number. |
| 326 | 338 | let fresh = store.user(&user.id).await?.unwrap_or_else(|| user.clone()); |
| 327 | 339 | let administers = fresh.admin; |
| @@ -466,31 +478,25 @@ async fn settings(cx: &Cx) -> Result { | ||
| 466 | 478 | <h2 class="panel-title">(t(language, Key::Connection))</h2> |
| 467 | 479 | </div> |
| 468 | 480 | <div class="panel-body"> |
| 469 | - <div class="field"> | |
| 470 | - <span class="field-label">(t(language, Key::ConnectionIssuer))</span> | |
| 471 | - <span class="field-static">(app.config.oidc.issuer.clone())</span> | |
| 472 | - </div> | |
| 473 | - <div class="field"> | |
| 474 | - <span class="field-label">(t(language, Key::ConnectionClientId))</span> | |
| 475 | - <span class="field-static">(app.config.oidc.client_id.clone())</span> | |
| 476 | - </div> | |
| 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 | + <dl class="connection-facts"> | |
| 482 | + <dt>(t(language, Key::ConnectionIssuer))</dt> | |
| 483 | + <dd>(app.config.oidc.issuer.clone())</dd> | |
| 484 | + <dt>(t(language, Key::ConnectionClientId))</dt> | |
| 485 | + <dd>(app.config.oidc.client_id.clone())</dd> | |
| 486 | + <dt>(t(language, Key::ConnectionStream))</dt> | |
| 487 | + <dd> | |
| 488 | + <span class=(if connected { "connection-dot connection-on" } else { "connection-dot connection-wait" })></span> | |
| 481 | 489 | if connected { |
| 482 | 490 | (t(language, Key::ConnectionConnected)) |
| 483 | 491 | } else { |
| 484 | 492 | (t(language, Key::ConnectionReconnecting)) |
| 485 | 493 | } |
| 486 | - </span> | |
| 487 | - <div class="field-note"> | |
| 488 | - (format!("{} · {}", t(language, Key::ConnectionLastEvent), age_text(last_event, language))) | |
| 489 | - </div> | |
| 490 | - <div class="field-note"> | |
| 491 | - (format!("{} · {}", t(language, Key::ConnectionLastPass), age_text(last_pass, language))) | |
| 492 | - </div> | |
| 493 | - </div> | |
| 494 | + </dd> | |
| 495 | + <dt>(t(language, Key::ConnectionLastEvent))</dt> | |
| 496 | + <dd>(event_line)</dd> | |
| 497 | + <dt>(t(language, Key::ConnectionLastPass))</dt> | |
| 498 | + <dd>(pass_line)</dd> | |
| 499 | + </dl> | |
| 494 | 500 | </div> |
| 495 | 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 | 5300 | "no client id: {body}" |
| 5301 | 5301 | ); |
| 5302 | 5302 | assert!(body.contains("Reconnecting"), "no amber wording: {body}"); |
| 5303 | - assert!(body.contains("status-dot-warn"), "no amber dot: {body}"); | |
| 5304 | - // Before the first occurrences both ages read never — the line is | |
| 5303 | + assert!(body.contains("connection-wait"), "no amber dot: {body}"); | |
| 5304 | + // Before the first occurrences both ages read never — the row is | |
| 5305 | 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 | 5308 | assert!( |
| 5307 | - body.contains("Last pass · never"), | |
| 5308 | - "no never wording on the pass line: {body}" | |
| 5309 | - ); | |
| 5310 | - assert!( | |
| 5311 | - body.contains("Last event · never"), | |
| 5312 | - "no never wording on the event line: {body}" | |
| 5309 | + body.matches("<dd>never</dd>").count() >= 2, | |
| 5310 | + "both ages must read never: {body}" | |
| 5313 | 5311 | ); |
| 5314 | 5312 | assert!( |
| 5315 | 5313 | !body.contains("s3cr3t"), |
| @@ -5324,23 +5322,21 @@ async fn connection_card_shows_issuer_client_id_and_stream_state() { | ||
| 5324 | 5322 | let page = app.get("/settings", Some(&cookie)).await; |
| 5325 | 5323 | let body = page.text(); |
| 5326 | 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 | 5326 | // An age, not never — the number itself races the second boundary |
| 5329 | - // between the stamp and this render, so it is not asserted. | |
| 5330 | - assert!( | |
| 5331 | - body.contains("Last event · ") && !body.contains("Last event · never"), | |
| 5332 | - "no event age: {body}" | |
| 5333 | - ); | |
| 5327 | + // between the stamp and this render, so only the sentence shape is | |
| 5328 | + // asserted. | |
| 5334 | 5329 | assert!( |
| 5335 | - body.contains("Last pass · ") && !body.contains("Last pass · never"), | |
| 5336 | - "no pass age: {body}" | |
| 5330 | + !body.contains("<dd>never</dd>"), | |
| 5331 | + "ages still read never after both stamps: {body}" | |
| 5337 | 5332 | ); |
| 5333 | + assert!(body.matches(" ago</dd>").count() >= 2, "ages not sentenced: {body}"); | |
| 5338 | 5334 | // The stream ends: amber again, no event line retraction needed — the |
| 5339 | 5335 | // last event stays but the wording names the truth. |
| 5340 | 5336 | app.health.reconnecting(); |
| 5341 | 5337 | let page = app.get("/settings", Some(&cookie)).await; |
| 5342 | 5338 | let body = page.text(); |
| 5343 | 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 | 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 | +} |