diff --git a/crates/in-web/src/i18n.rs b/crates/in-web/src/i18n.rs index 13ab1d3..aba8370 100644 --- a/crates/in-web/src/i18n.rs +++ b/crates/in-web/src/i18n.rs @@ -354,8 +354,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { ConnectionStream => "Directory stream", ConnectionConnected => "Connected", ConnectionReconnecting => "Reconnecting…", - ConnectionLastEvent => "Last event", - ConnectionLastPass => "Last pass", + ConnectionLastEvent => "Last roster event", + ConnectionLastPass => "Last full pass", Never => "never", QuotaUsage => "Storage used", QuotaOf => "of", @@ -529,8 +529,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { ConnectionStream => "Dizin akışı", ConnectionConnected => "Bağlı", ConnectionReconnecting => "Yeniden bağlanıyor…", - ConnectionLastEvent => "Son etkinlik", - ConnectionLastPass => "Son tarama", + ConnectionLastEvent => "Son dizin olayı", + ConnectionLastPass => "Son tam geçiş", Never => "hiç", AdminPanel => "Herkes", AllUsers => "Herkes", diff --git a/crates/in-web/src/settings.rs b/crates/in-web/src/settings.rs index c16e937..d35814e 100644 --- a/crates/in-web/src/settings.rs +++ b/crates/in-web/src/settings.rs @@ -25,7 +25,7 @@ use crate::server::{ Refusal, app, back_to, require_admin, require_user, share_link_url, share_origin, }; use crate::share::{refusal_banner, refusal_of, share_copy_script}; -use crate::i18n::{Key, Lang, lang, t}; +use crate::i18n::{Key, lang, t}; use crate::layout::{NavPage, topbar}; /// 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 { } } -/// The value half of a Connection card's age line: the seconds when the -/// moment is known, the `never` wording before its first occurrence — -/// a card that went silent and a card that never spoke read differently. -fn age_text(age: Option, language: Lang) -> String { +/// An age in whole seconds as the card prints it — a short number with +/// its unit, the same shape in every language: `45s`, `2m`, `3h`. Empty +/// before the first occurrence; the caller sentences it. +fn age_text(age: Option) -> String { match age { - Some(age) => format!("{age}s"), - None => t(language, Key::Never).to_string(), + Some(secs) if secs >= 3600 => format!("{}h", secs / 3600), + Some(secs) if secs >= 60 => format!("{}m", secs / 60), + Some(secs) => format!("{secs}s"), + None => String::new(), } } @@ -313,15 +315,25 @@ async fn settings(cx: &Cx) -> Result { let language = lang(cx).await; let app = app(cx); let store = app.store; - // The Connection card reads only what the config already carries and - // the sync task's own atomics — the client secret is never touched on - // any path that reaches this render. let connected = app.health.stream_connected(); let last_event = app.health.last_event_age_secs(); let last_pass = app.health.last_pass_age_secs(); - // Both ages share one shape: the seconds when the moment is known, - // the `never` wording before the first occurrence — a card that went - // silent and a card that never spoke read differently. + // Both ages share one sentence shape: the humanized age and `ago`, + // or the `never` wording before the first occurrence — a card that + // went silent and a card that never spoke read differently. + let age_line = |age: Option| { + let text = age_text(age); + if text.is_empty() { + t(language, Key::Never).to_string() + } else { + format!("{text} ago") + } + }; + let event_line = age_line(last_event); + let pass_line = age_line(last_pass); + // The Connection card reads only what the config already carries and + // the sync task's own atomics — the client secret is never touched on + // any path that reaches this render. // Re-read the row so the quota bar never shows a stale number. let fresh = store.user(&user.id).await?.unwrap_or_else(|| user.clone()); let administers = fresh.admin; @@ -466,31 +478,25 @@ async fn settings(cx: &Cx) -> Result {

(t(language, Key::Connection))

-
- (t(language, Key::ConnectionIssuer)) - (app.config.oidc.issuer.clone()) -
-
- (t(language, Key::ConnectionClientId)) - (app.config.oidc.client_id.clone()) -
-
- (t(language, Key::ConnectionStream)) - - +
+
(t(language, Key::ConnectionIssuer))
+
(app.config.oidc.issuer.clone())
+
(t(language, Key::ConnectionClientId))
+
(app.config.oidc.client_id.clone())
+
(t(language, Key::ConnectionStream))
+
+ if connected { (t(language, Key::ConnectionConnected)) } else { (t(language, Key::ConnectionReconnecting)) } - -
- (format!("{} · {}", t(language, Key::ConnectionLastEvent), age_text(last_event, language))) -
-
- (format!("{} · {}", t(language, Key::ConnectionLastPass), age_text(last_pass, language))) -
-
+ +
(t(language, Key::ConnectionLastEvent))
+
(event_line)
+
(t(language, Key::ConnectionLastPass))
+
(pass_line)
+
} diff --git a/crates/in-web/tests/http.rs b/crates/in-web/tests/http.rs index dc6513f..bb2675a 100644 --- a/crates/in-web/tests/http.rs +++ b/crates/in-web/tests/http.rs @@ -5300,16 +5300,14 @@ async fn connection_card_shows_issuer_client_id_and_stream_state() { "no client id: {body}" ); assert!(body.contains("Reconnecting"), "no amber wording: {body}"); - assert!(body.contains("status-dot-warn"), "no amber dot: {body}"); - // Before the first occurrences both ages read never — the line is + assert!(body.contains("connection-wait"), "no amber dot: {body}"); + // Before the first occurrences both ages read never — the row is // there, the number is not. + assert!(body.contains("Last roster event"), "no event row: {body}"); + assert!(body.contains("Last full pass"), "no pass row: {body}"); assert!( - body.contains("Last pass · never"), - "no never wording on the pass line: {body}" - ); - assert!( - body.contains("Last event · never"), - "no never wording on the event line: {body}" + body.matches("
never
").count() >= 2, + "both ages must read never: {body}" ); assert!( !body.contains("s3cr3t"), @@ -5324,23 +5322,21 @@ async fn connection_card_shows_issuer_client_id_and_stream_state() { let page = app.get("/settings", Some(&cookie)).await; let body = page.text(); assert!(body.contains("Connected"), "no green wording: {body}"); - assert!(body.contains("status-dot-done"), "no green dot: {body}"); + assert!(body.contains("connection-on"), "no green dot: {body}"); // An age, not never — the number itself races the second boundary - // between the stamp and this render, so it is not asserted. - assert!( - body.contains("Last event · ") && !body.contains("Last event · never"), - "no event age: {body}" - ); + // between the stamp and this render, so only the sentence shape is + // asserted. assert!( - body.contains("Last pass · ") && !body.contains("Last pass · never"), - "no pass age: {body}" + !body.contains("
never
"), + "ages still read never after both stamps: {body}" ); + assert!(body.matches(" ago").count() >= 2, "ages not sentenced: {body}"); // The stream ends: amber again, no event line retraction needed — the // last event stays but the wording names the truth. app.health.reconnecting(); let page = app.get("/settings", Some(&cookie)).await; let body = page.text(); assert!(body.contains("Reconnecting"), "no amber return: {body}"); - assert!(!body.contains("status-dot-done"), "green lingered: {body}"); + assert!(!body.contains("connection-on"), "green lingered: {body}"); } diff --git a/style/main.scss b/style/main.scss index c6a6162..b967c76 100644 --- a/style/main.scss +++ b/style/main.scss @@ -5484,3 +5484,34 @@ div.member-row + div.member-row { display: none; } } + +// The Connection card's label/value rows: two columns, labels bold and +// unbreaking, values free to wrap — the shape the identity card wears. +.connection-facts { + display: grid; + grid-template-columns: max-content 1fr; + gap: 0.4rem 1.5rem; + margin: 0; + + dt { + font-weight: 600; + white-space: nowrap; + } +} + +.connection-dot { + display: inline-block; + width: 0.55rem; + height: 0.55rem; + border-radius: 50%; + margin-right: 0.4rem; + vertical-align: baseline; + + &.connection-on { + background: #2e9e5b; + } + + &.connection-wait { + background: #d99a26; + } +}