diff --git a/crates/forge-core/src/store/suspension.rs b/crates/forge-core/src/store/suspension.rs index 98b6db2..decb981 100644 --- a/crates/forge-core/src/store/suspension.rs +++ b/crates/forge-core/src/store/suspension.rs @@ -113,6 +113,19 @@ impl Store { Ok(n > 0) } + /// Administrators other than `user_id`: zero means `user_id` is the last one and cannot be demoted. + pub async fn other_admin_count(&self, user_id: &str) -> Result { + let conn = self.read_conn().await; + Ok(fetch_opt( + &conn, + "SELECT COUNT(*) FROM users WHERE is_admin = 1 AND id != ?1 AND kind = 'user'", + (user_id.to_string(),), + |row| col_int(row, 0), + ) + .await? + .unwrap_or(0)) + } + /// Grants or revokes the admin flag. Revoking is refused for the last administrator. pub async fn set_admin(&self, user_id: &str, admin: bool) -> Result<()> { let conn = self.inner.conn.lock().await; diff --git a/crates/forge-web/src/i18n/accounts.rs b/crates/forge-web/src/i18n/accounts.rs index 9f972eb..2fa5892 100644 --- a/crates/forge-web/src/i18n/accounts.rs +++ b/crates/forge-web/src/i18n/accounts.rs @@ -4,7 +4,6 @@ use super::Lang; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum A { - Status, Active, Suspended, LastLogin, @@ -59,14 +58,16 @@ pub enum A { Services, Fine, DiskUsed, + Joined, + NoPasskeysToRemove, + TwoFactorNotOn, + DeleteHelp, } pub fn t(lang: Lang, key: A) -> &'static str { use A::*; use Lang::*; match (key, lang) { - (Status, En) => "Status", - (Status, Tr) => "Durum", (Active, En) => "Active", (Active, Tr) => "Etkin", (Suspended, En) => "Suspended", @@ -185,6 +186,14 @@ pub fn t(lang: Lang, key: A) -> &'static str { (Fine, Tr) => "Her şey yolunda", (DiskUsed, En) => "used", (DiskUsed, Tr) => "kullanıldı", + (Joined, En) => "Joined", + (Joined, Tr) => "Katılım", + (NoPasskeysToRemove, En) => "No passkeys to remove", + (NoPasskeysToRemove, Tr) => "Kaldırılacak geçiş anahtarı yok", + (TwoFactorNotOn, En) => "Two-factor is not on", + (TwoFactorNotOn, Tr) => "İki adımlı doğrulama açık değil", + (DeleteHelp, En) => "Removes the account, its sessions and keys. This cannot be undone.", + (DeleteHelp, Tr) => "Hesabı, oturumlarını ve anahtarlarını siler. Bu işlem geri alınamaz.", } } diff --git a/crates/forge-web/src/i18n/admin.rs b/crates/forge-web/src/i18n/admin.rs index 476fb21..96b2180 100644 --- a/crates/forge-web/src/i18n/admin.rs +++ b/crates/forge-web/src/i18n/admin.rs @@ -14,6 +14,7 @@ pub enum K { AdminArea, Administrator, AllActions, + RowActions, Anonymous, AtLeast12Chars, AuditIntro, @@ -156,16 +157,13 @@ pub enum K { TableActor, TableDetails, TableDuration, - TableError, TableKind, TableLastError, TableQueued, - TableRepo, TableResult, TableSize, TableStarted, TableState, - TableStatus, TableSubject, TableTarget, TableTo, @@ -197,6 +195,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { (Administrator, Tr) => "Yönetici", (AllActions, En) => "All actions", (AllActions, Tr) => "Tüm işlemler", + (RowActions, En) => "Actions", + (RowActions, Tr) => "İşlemler", (Anonymous, En) => "anonymous", (Anonymous, Tr) => "anonim", (AtLeast12Chars, En) => "At least 12 characters.", @@ -545,16 +545,12 @@ pub fn t(lang: Lang, key: K) -> &'static str { (TableDetails, Tr) => "Ayrıntılar", (TableDuration, En) => "Duration", (TableDuration, Tr) => "Süre", - (TableError, En) => "Error", - (TableError, Tr) => "Hata", (TableKind, En) => "Kind", (TableKind, Tr) => "Tür", (TableLastError, En) => "Last error", (TableLastError, Tr) => "Son hata", (TableQueued, En) => "Queued", (TableQueued, Tr) => "Kuyruğa alındı", - (TableRepo, En) => "Repo", - (TableRepo, Tr) => "Depo", (TableResult, En) => "Result", (TableResult, Tr) => "Sonuç", (TableSize, En) => "Size", @@ -563,8 +559,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { (TableStarted, Tr) => "Başlangıç", (TableState, En) => "State", (TableState, Tr) => "Durum", - (TableStatus, En) => "Status", - (TableStatus, Tr) => "Durum", (TableSubject, En) => "Subject", (TableSubject, Tr) => "Konu", (TableTarget, En) => "Target", @@ -800,6 +794,7 @@ mod tests { K::AdminArea, K::Administrator, K::AllActions, + K::RowActions, K::Anonymous, K::AtLeast12Chars, K::AuditIntro, @@ -942,16 +937,13 @@ mod tests { K::TableActor, K::TableDetails, K::TableDuration, - K::TableError, K::TableKind, K::TableLastError, K::TableQueued, - K::TableRepo, K::TableResult, K::TableSize, K::TableStarted, K::TableState, - K::TableStatus, K::TableSubject, K::TableTarget, K::TableTo, diff --git a/crates/forge-web/src/i18n/integrations.rs b/crates/forge-web/src/i18n/integrations.rs index 6358665..8b21e25 100644 --- a/crates/forge-web/src/i18n/integrations.rs +++ b/crates/forge-web/src/i18n/integrations.rs @@ -15,14 +15,6 @@ pub enum K { ArchivedNotice, BackToWebhooks, ClearSecret, - ColActive, - ColDirection, - ColEnabled, - ColEvents, - ColInterval, - ColLastDelivery, - ColLastSync, - ColResult, CreateWebhook, CurrentUrl, DeleteConfirm, @@ -63,7 +55,6 @@ pub enum K { Mirrors, MirrorsIntro, Never, - No, NoDeliveries, NoMirrors, NoWebhooks, @@ -118,7 +109,6 @@ pub enum K { UsernameOptional, Webhooks, WebhooksIntro, - Yes, } /// Every key, so the tests can walk them. @@ -135,14 +125,6 @@ pub const ALL: &[K] = &[ K::ArchivedNotice, K::BackToWebhooks, K::ClearSecret, - K::ColActive, - K::ColDirection, - K::ColEnabled, - K::ColEvents, - K::ColInterval, - K::ColLastDelivery, - K::ColLastSync, - K::ColResult, K::CreateWebhook, K::CurrentUrl, K::DeleteConfirm, @@ -183,7 +165,6 @@ pub const ALL: &[K] = &[ K::Mirrors, K::MirrorsIntro, K::Never, - K::No, K::NoDeliveries, K::NoMirrors, K::NoWebhooks, @@ -238,7 +219,6 @@ pub const ALL: &[K] = &[ K::UsernameOptional, K::Webhooks, K::WebhooksIntro, - K::Yes, ]; /// The phrase a key names, in a user's language. @@ -284,22 +264,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { (BackToWebhooks, Tr) => "Web kancalarına dön", (ClearSecret, En) => "Clear the stored password or token", (ClearSecret, Tr) => "Kayıtlı parola veya belirteci temizle", - (ColActive, En) => "Active", - (ColActive, Tr) => "Etkin", - (ColDirection, En) => "Direction", - (ColDirection, Tr) => "Yön", - (ColEnabled, En) => "Enabled", - (ColEnabled, Tr) => "Etkin", - (ColEvents, En) => "Events", - (ColEvents, Tr) => "Olaylar", - (ColInterval, En) => "Interval", - (ColInterval, Tr) => "Aralık", - (ColLastDelivery, En) => "Last delivery", - (ColLastDelivery, Tr) => "Son teslimat", - (ColLastSync, En) => "Last sync", - (ColLastSync, Tr) => "Son eşitleme", - (ColResult, En) => "Result", - (ColResult, Tr) => "Sonuç", (CreateWebhook, En) => "Create webhook", (CreateWebhook, Tr) => "Web kancası oluştur", (CurrentUrl, En) => "Current URL:", @@ -406,8 +370,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { } (Never, En) => "never", (Never, Tr) => "hiç", - (No, En) => "no", - (No, Tr) => "hayır", (NoDeliveries, En) => "No deliveries yet.", (NoDeliveries, Tr) => "Henüz teslimat yok.", (NoMirrors, En) => "No mirrors yet.", @@ -554,8 +516,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { (WebhooksIntro, Tr) => { "Etkin her web kancası, abone olduğu olayları imzalı JSON POST istekleri olarak alır. Son teslimat, alıcının 2xx durumuyla yanıt verip vermediğini gösterir." } - (Yes, En) => "yes", - (Yes, Tr) => "evet", } } diff --git a/crates/forge-web/src/pages/admin_mail.rs b/crates/forge-web/src/pages/admin_mail.rs index 189aff9..46e079f 100644 --- a/crates/forge-web/src/pages/admin_mail.rs +++ b/crates/forge-web/src/pages/admin_mail.rs @@ -332,12 +332,17 @@ async fn mail_view( -
- - - - -
+
+ "⋯" + +
} diff --git a/crates/forge-web/src/pages/admin_replication.rs b/crates/forge-web/src/pages/admin_replication.rs index 15e0584..45919d9 100644 --- a/crates/forge-web/src/pages/admin_replication.rs +++ b/crates/forge-web/src/pages/admin_replication.rs @@ -46,6 +46,25 @@ enum Health { } impl Health { + /// The status dot: the health page's colours, muted for a copy that never ran. + fn dot(self) -> &'static str { + match self { + Health::Ok => "health-dot ok", + Health::Lagging => "health-dot warn", + Health::Error => "health-dot bad", + Health::Never => "health-dot", + } + } + + /// The status word's tone: only a lagging or failing copy is coloured. + fn tone(self) -> &'static str { + match self { + Health::Ok | Health::Never => "", + Health::Lagging => "warn", + Health::Error => "bad", + } + } + fn label(self, lang: Lang) -> &'static str { match self { Health::Ok => g::t(lang, K::HealthOk), @@ -73,6 +92,8 @@ fn health(status: Option<&ReplicationStatus>, cutoff: &str) -> Health { /// One line of the repos table, already formatted. struct RepoRow { name: String, + dot: &'static str, + tone: &'static str, health: &'static str, last_ok: String, error: String, @@ -82,6 +103,7 @@ struct RepoRow { struct PageData { enabled: bool, target: String, + db_dot: &'static str, db_health: &'static str, db_last_ok: String, db_last_attempt: String, @@ -121,9 +143,12 @@ async fn page_data(state: &AppState, tz: &str, lang: Lang) -> forge_core::Result Some(repo) => format!("{}/{}", repo.owner_name, repo.name), None => id.clone(), }; + let h = health(status, &repo_cutoff); repos.push(RepoRow { name, - health: health(status, &repo_cutoff).label(lang), + dot: h.dot(), + tone: h.tone(), + health: h.label(lang), last_ok: ok_text(status.and_then(|s| s.last_ok_at.as_deref()), tz, lang), error: status .and_then(|s| s.last_error.clone()) @@ -133,9 +158,12 @@ async fn page_data(state: &AppState, tz: &str, lang: Lang) -> forge_core::Result // Repos deleted since their last push: their standby copy is removed at the next reconcile. for status in statuses.values() { if status.subject != DB_SUBJECT && !ids.contains(&status.subject) { + let h = health(Some(status), &repo_cutoff); repos.push(RepoRow { name: g::deleted_repo_name(lang, &status.subject), - health: health(Some(status), &repo_cutoff).label(lang), + dot: h.dot(), + tone: h.tone(), + health: h.label(lang), last_ok: ok_text(status.last_ok_at.as_deref(), tz, lang), error: status.last_error.clone().unwrap_or_default(), }); @@ -145,6 +173,7 @@ async fn page_data(state: &AppState, tz: &str, lang: Lang) -> forge_core::Result Ok(PageData { enabled: config.enabled(), target: config.target.clone(), + db_dot: health(db, &db_cutoff).dot(), db_health: health(db, &db_cutoff).label(lang), db_last_ok: ok_text(db.and_then(|s| s.last_ok_at.as_deref()), tz, lang), db_last_attempt: ok_text(db.and_then(|s| s.last_attempt_at.as_deref()), tz, lang), @@ -184,7 +213,7 @@ async fn replication_view(
(g::t(lang, K::ReplicationTarget))
(data.target.as_str())
(g::t(lang, K::Interval))
(data.interval.as_str())
(g::t(lang, K::Healthcheck))
(data.healthcheck)
-
(g::t(lang, K::Database))
(data.db_health)
+
(g::t(lang, K::Database))
(data.db_health)
(g::t(lang, K::LastDbSnapshotShipped))
(data.db_last_ok.as_str())
(g::t(lang, K::LastDbAttempt))
(data.db_last_attempt.as_str())
@@ -206,28 +235,23 @@ async fn replication_view( if data.repos.is_empty() {

(g::t(lang, K::NoReposYet))

} else { -
- - - - - - - - - - - for row in data.repos.into_iter() { - - - - - - - } - -
(g::t(lang, K::TableRepo))(g::t(lang, K::TableStatus))(g::t(lang, K::LastSuccess))(g::t(lang, K::TableError))
(row.name.as_str())(row.health)(row.last_ok.as_str())(row.error.as_str())
-
+ } diff --git a/crates/forge-web/src/pages/admin_user_detail.rs b/crates/forge-web/src/pages/admin_user_detail.rs index 49d1f35..5027d51 100644 --- a/crates/forge-web/src/pages/admin_user_detail.rs +++ b/crates/forge-web/src/pages/admin_user_detail.rs @@ -26,7 +26,7 @@ use crate::pages::admin_users::admin_only; use crate::pages::issues_list::stamp_unix; use crate::pages::passkeys::s; use crate::state::AppState; -use crate::views::{alert, enc, shell, user_facing_message}; +use crate::views::{alert, avatar_url, enc, rel_time_or_never, shell, user_facing_message}; #[query_params(error = bad_request)] pub(crate) struct DoneQuery { @@ -49,6 +49,8 @@ struct Detail { facts: AccountFacts, suspension: Option, passkeys: i64, + /// An administrator with no other administrator beside them: demoting is refused. + last_admin: bool, } /// What the page says above the facts after an action. @@ -86,6 +88,7 @@ async fn load(cx: &Cx) -> Result { facts: store.account_facts(&target.id).await?, suspension: store.suspension(&target.id).await?, passkeys: store.passkey_count(&target.id).await?, + last_admin: target.is_admin && store.other_admin_count(&target.id).await? == 0, target, }) } @@ -106,13 +109,6 @@ fn done_text(lang: Lang, done: &str) -> Option<&'static str> { }) } -fn when(stamp: Option<&str>, tz: &str, lang: Lang) -> String { - match stamp { - Some(s) => format_in_tz(stamp_unix(s), tz), - None => at(lang, A::Never).to_owned(), - } -} - #[component] async fn detail_body( lang: Lang, @@ -127,11 +123,12 @@ async fn detail_body( facts, suspension, passkeys, + last_admin, } = detail; let base = format!("/admin/users/{}", enc(&target.id)); let own = target.id == viewer_id; let created = format_in_tz(stamp_unix(&target.created_at), tz); - let last_login = when(facts.last_login.as_deref(), tz, lang); + let last_login = facts.last_login.clone(); let repos = facts.repo_count.to_string(); let suspended = suspension.is_some(); let status = if suspended { @@ -139,23 +136,20 @@ async fn detail_body( } else { at(lang, A::Active) }; - let tfa = if facts.two_factor { - at(lang, A::On) + let dot_class = if suspended { + "user-dot is-suspended" } else { - at(lang, A::Off) + "user-dot is-active" }; - let role = if target.is_admin { - at(lang, A::Administrator) - } else { - g::t(lang, K::RoleUser) + let tfa_on = facts.two_factor; + let tfa = if tfa_on { at(lang, A::On) } else { at(lang, A::Off) }; + let is_admin = target.is_admin; + let suspended_note = match suspension.as_ref().map(|s| s.reason.clone()) { + Some(reason) if !reason.is_empty() => reason, + _ => at(lang, A::AccountSuspended).to_owned(), }; - let reason = suspension - .as_ref() - .map(|s| s.reason.clone()) - .unwrap_or_default(); let email = target.email.clone().unwrap_or_default(); - let is_admin = target.is_admin; - let tfa_on = facts.two_factor; + let avatar = avatar_url(&target.username, target.avatar_hash.as_deref()); let suspend_action = format!("{base}/suspend"); let unsuspend_action = format!("{base}/unsuspend"); let admin_action = format!("{base}/admin"); @@ -168,10 +162,37 @@ async fn detail_body( let Notice { done, error, link } = notice; Ok(view! {
-
-

(target.username.as_str())

+
+ "← "(g::t(lang, K::Users)) +
+ +
+

+ + (target.username.as_str()) + if suspended { + (at(lang, A::Suspended)) + } + if is_admin { + (at(lang, A::Administrator)) + } +

+

+ if !email.is_empty() { + (email.as_str()) " · " + } + (at(lang, A::Joined)) " " (created.as_str()) " · " (at(lang, A::LastLogin)) " " rel_time_or_never(lang: lang, stamp: last_login.as_deref()) +

+
+
+
+
(at(lang, A::Repositories))
(repos.as_str())
+
(at(lang, A::TwoFactor))
(tfa)
+
(s(lang, "Passkeys", "Geçiş anahtarları"))
(passkey_count.as_str())
+
-
+ -
-

(at(lang, A::Actions))

-
-
-

(if suspended { at(lang, A::Unsuspend) } else { at(lang, A::Suspend) })

- if suspended { -

(reason.as_str())

-
- - -
- } else if own { -

(at(lang, A::ErrSelf))

- } else { -

(at(lang, A::SuspendHelp))

-
- - - -
- } -
-
-

(at(lang, A::Administrator))

-

(at(lang, A::AdminHelp))

-
- - - -
-
-
-

(at(lang, A::ResetPassword))

-

(at(lang, A::ResetHelp))

-
- - -
-
-
-

(at(lang, A::Disable2fa))

-

(at(lang, A::Disable2faHelp))

- if tfa_on { -
+
    + if suspended { +
  • +
    +

    (at(lang, A::Unsuspend))

    +

    (suspended_note.as_str())

    +
    +
    + + + + +
    +
  • + } +
  • +
    +

    (at(lang, A::Administrator))

    +

    (s(lang, "Opens the admin area: accounts, runners and server settings.", "Yönetim alanını açar: hesaplar, çalıştırıcılar ve sunucu ayarları."))

    +
    +
    + if last_admin { +

    (at(lang, A::AdminHelp))

    + } else { +
    + + + +
    + } +
    +
  • +
  • +
    +

    (at(lang, A::ResetPassword))

    +

    (at(lang, A::ResetHelp))

    +
    +
    +
    - +
    - } else { -

    (at(lang, A::Off))

    - } -
    -
    -

    (s(lang, "Remove all passkeys", "Tüm geçiş anahtarlarını kaldır"))

    -

    (s(lang, "For a user who lost their devices. They can still sign in with a password.", "Cihazlarını kaybeden kullanıcı için. Parolayla girmeye devam edebilir."))

    - if passkeys > 0 { -
    - (s(lang, "Remove all passkeys", "Tüm geçiş anahtarlarını kaldır")) -
    -

    (s(lang, "Remove every passkey of this user?", "Bu kullanıcının tüm geçiş anahtarları kaldırılsın mı?"))

    -
    +
    +
  • +
+
+
+

(i18n::t(lang, Key::DangerZone))

+
    + if !suspended { +
  • +
    +

    (at(lang, A::Suspend))

    +

    (at(lang, A::SuspendHelp))

    +
    +
    + if own { +

    (at(lang, A::ErrSelf))

    + } else { + - - + + -
    - - } else { -

    (at(lang, A::Off))

    - } -
- -
  • +
    +

    (at(lang, A::Disable2fa))

    +

    (at(lang, A::Disable2faHelp))

    +
    +
    + if tfa_on { +
    + + +
    + } else { +

    (at(lang, A::TwoFactorNotOn))

    + } +
    +
  • +
  • +
    +

    (s(lang, "Remove all passkeys", "Tüm geçiş anahtarlarını kaldır"))

    +

    (s(lang, "For a user who lost their devices. They can still sign in with a password.", "Cihazlarını kaybeden kullanıcı için. Parolayla girmeye devam edebilir."))

    +
    +
    + if passkeys > 0 { +
    + (s(lang, "Remove", "Kaldır")) +
    +

    (s(lang, "Remove every passkey of this user?", "Bu kullanıcının tüm geçiş anahtarları kaldırılsın mı?"))

    +
    + + + +
    +
    +
    + } else { +

    (at(lang, A::NoPasskeysToRemove))

    + } +
    +
  • if !own { - (i18n::t(lang, Key::Delete)) +
  • +
    +

    (g::t(lang, K::DeleteUser))

    +

    (at(lang, A::DeleteHelp))

    +
    + +
  • } -

    + }) @@ -289,15 +341,17 @@ async fn account_fingerprint(store: &Store, user_id: &str) -> Result { let facts = store.account_facts(user_id).await?; let suspension = store.suspension(user_id).await?; let passkeys = store.passkey_count(user_id).await?; + let other_admins = store.other_admin_count(user_id).await?; Ok(format!( - "{}|{}|{}|{}|{:?}|{:?}|{}", + "{}|{}|{}|{}|{:?}|{:?}|{}|{}", target.username, target.email.as_deref().unwrap_or(""), target.is_admin, target.created_at, facts, suspension, - passkeys + passkeys, + other_admins )) } diff --git a/crates/forge-web/src/pages/org_members.rs b/crates/forge-web/src/pages/org_members.rs index 45307ef..e21f644 100644 --- a/crates/forge-web/src/pages/org_members.rs +++ b/crates/forge-web/src/pages/org_members.rs @@ -22,6 +22,7 @@ use crate::pages::org_ctx::{ load_org, member_role_word, notice_href, org_head, org_notice, parse_member_role, require_form_csrf, require_member, require_owner, take_notice, }; +use crate::pages::passkeys; use crate::state::AppState; use crate::views::{avatar_url, display_name, shell}; @@ -89,7 +90,7 @@ async fn members_body(

    (g::t(lang, K::Members))

    - +
    @@ -123,11 +124,16 @@ async fn members_body( diff --git a/crates/forge-web/src/pages/org_teams.rs b/crates/forge-web/src/pages/org_teams.rs index 1ce8d60..d6092a1 100644 --- a/crates/forge-web/src/pages/org_teams.rs +++ b/crates/forge-web/src/pages/org_teams.rs @@ -22,6 +22,7 @@ use crate::pages::org_ctx::{ OrgCtx, TEAM_ROLES, load_org, notice_href, org_head, org_notice, require_form_csrf, require_member, require_owner, take_notice, }; +use crate::pages::passkeys; use crate::state::AppState; use crate::views::{avatar_url, display_name, repo_href, shell}; @@ -358,11 +359,16 @@ async fn team_body( if owner { - - - - - +
    + "⋯" + +
    } } @@ -388,11 +394,16 @@ async fn team_body( (repo.title.as_str()) if owner { - - - - - +
    + "⋯" + +
    } } diff --git a/crates/forge-web/src/pages/repo_collaborators.rs b/crates/forge-web/src/pages/repo_collaborators.rs index 64e0d1a..268ae00 100644 --- a/crates/forge-web/src/pages/repo_collaborators.rs +++ b/crates/forge-web/src/pages/repo_collaborators.rs @@ -25,6 +25,7 @@ use crate::audit::{self, Actor, Target}; use crate::auth::{require_csrf, require_user}; use crate::i18n::repo_admin::{self as g, K}; use crate::i18n::{self, Lang}; +use crate::pages::passkeys; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; use crate::pages::repo_settings::settings_nav_for; @@ -185,7 +186,7 @@ async fn collaborators_table(

    (g::t(lang, K::NoCollaborators))

    } else {
    -
    (g::t(lang, K::MemberHeader)) if owner || row.is_self { -
    - - - -
    +
    + "⋯" + +
    }
    +
    @@ -222,11 +223,16 @@ async fn collaborators_table( } diff --git a/crates/forge-web/src/pages/repo_mirrors.rs b/crates/forge-web/src/pages/repo_mirrors.rs index b40b782..e4f60cb 100644 --- a/crates/forge-web/src/pages/repo_mirrors.rs +++ b/crates/forge-web/src/pages/repo_mirrors.rs @@ -25,6 +25,7 @@ use topcoat::view::{View, component, view}; use crate::audit::{self, Actor, Target}; use crate::auth::{require_csrf, require_user}; +use crate::i18n::admin as adm; use crate::i18n::{ self, Lang, integrations::{self as g, K}, @@ -35,7 +36,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; use crate::pages::repo_settings::settings_nav_for; use crate::pages::repo_settings_live::settings_head; use crate::state::AppState; -use crate::views::{alert, enc, shell, user_facing_message}; +use crate::views::{alert, enc, now_unix, relative_time, shell, user_facing_message}; use crate::webhooks::client::{WebhookPolicy, validate_url}; path_param!(owner); @@ -318,14 +319,38 @@ struct MirrorRow { url: String, interval: String, enabled: bool, + /// The last sync in the viewer's zone, for the `title` tooltip. Empty when never synced. last_sync: String, - status_class: &'static str, + /// The raw last-sync stamp, for the `
    (g::t(lang, K::ColUser)) -
    - - - -
    +
    + "⋯" + +
    - - - - - - - - - - - - - for row in rows.iter() { - - - - - - - - - +
      + for row in rows.iter() { +
    • +
      + +

      + (row.direction)" · "(row.interval.as_str()) + if !row.enabled { + " · "(adm::t(lang, adm::K::Disabled)) + } + " · " + if row.last_sync_at.is_empty() { + (g::t(lang, K::StatusNotRun)) + } else { + (row.sync_prefix)(row.sync_suffix) + } +

      + if !row.error.is_empty() { +
      + (g::t(lang, K::ErrorLabel)) +
      (row.error.as_str())
      +
      + } +
      + if !archived { +
      + + + } -
    -
    (g::t(lang, K::ColDirection))"URL"(g::t(lang, K::ColInterval))(g::t(lang, K::ColEnabled))(g::t(lang, K::ColLastSync))(g::t(lang, K::ColResult))
    (row.direction)(row.url.as_str())(row.interval.as_str())(if row.enabled { g::t(lang, K::Yes) } else { g::t(lang, K::No) })(row.last_sync.as_str()) - (row.status_text) - if !row.error.is_empty() { -
    - (g::t(lang, K::ErrorLabel)) -
    (row.error.as_str())
    -
    - } -
    - if !archived { -
    - - -
    - } -
    -
    + + } + }
    if !archived { diff --git a/crates/forge-web/src/pages/repo_webhooks.rs b/crates/forge-web/src/pages/repo_webhooks.rs index 114e8cd..7bd1ac8 100644 --- a/crates/forge-web/src/pages/repo_webhooks.rs +++ b/crates/forge-web/src/pages/repo_webhooks.rs @@ -31,7 +31,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; use crate::pages::repo_settings::settings_nav_for; use crate::pages::repo_settings_live::settings_head; use crate::state::AppState; -use crate::views::{alert, enc, shell}; +use crate::views::{alert, enc, now_unix, relative_time, shell}; use crate::webhooks::client::{WebhookPolicy, validate_url}; use crate::webhooks::emit::emit_ping; @@ -306,13 +306,96 @@ fn state_label(lang: Lang, state: DeliveryState) -> (&'static str, &'static str) } } -/// One hook row on the list page. +/// One hook row on the list page, formatted for display. struct HookRow { href: String, url: String, + /// The subscribed events, joined with ", ". events: String, active: bool, + /// The status dot's class: green when the last delivery was ok, danger when it failed, muted otherwise. + dot_class: &'static str, + /// The dot's accessible name and tooltip: the last delivery's state, or "none yet". + dot_text: &'static str, + /// "last delivery " before the time in English, "son teslimat " in Turkish, or the whole + /// "no delivery yet" text when the hook has never delivered. + last_text: &'static str, + /// The last delivery's stamp, for the `