Admin user page gets a header, one facts row and action rows with reasons in place of refused buttons
Browse files at this commit24b6025f206662558093bc3d20802b98acb7bb8dParent: d42a435- style
- admin user page gets a header, one facts row and action rows with reasons in place of refused buttons
- mirrors, webhooks and replication become status-dot rows
- destructive row actions move into ⋯ menus
17 changed files +966 -325
- crates/forge-core/src/store/suspension.rs +13 -0
- crates/forge-web/src/i18n/accounts.rs +12 -3
- crates/forge-web/src/i18n/admin.rs +4 -12
- crates/forge-web/src/i18n/integrations.rs +0 -40
- crates/forge-web/src/pages/admin_mail.rs +11 -6
- crates/forge-web/src/pages/admin_replication.rs +49 -25
- crates/forge-web/src/pages/admin_user_detail.rs +166 -112
- crates/forge-web/src/pages/org_members.rs +12 -6
- crates/forge-web/src/pages/org_teams.rs +21 -10
- crates/forge-web/src/pages/repo_collaborators.rs +12 -6
- crates/forge-web/src/pages/repo_mirrors.rs +67 -45
- crates/forge-web/src/pages/repo_webhooks.rs +131 -45
- style/_account_admin.scss +241 -15
- style/_admin_rows.scss +94 -0
- style/_hooks.scss +70 -0
- style/_members.scss +60 -0
- style/main.scss +3 -0
crates/forge-core/src/store/suspension.rsmodified+13 -0
| @@ -113,6 +113,19 @@ impl Store { | |||
| 113 | Ok(n > 0) | 113 | Ok(n > 0) |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | + /// Administrators other than `user_id`: zero means `user_id` is the last one and cannot be demoted. | ||
| 117 | + pub async fn other_admin_count(&self, user_id: &str) -> Result<i64> { | ||
| 118 | + let conn = self.read_conn().await; | ||
| 119 | + Ok(fetch_opt( | ||
| 120 | + &conn, | ||
| 121 | + "SELECT COUNT(*) FROM users WHERE is_admin = 1 AND id != ?1 AND kind = 'user'", | ||
| 122 | + (user_id.to_string(),), | ||
| 123 | + |row| col_int(row, 0), | ||
| 124 | + ) | ||
| 125 | + .await? | ||
| 126 | + .unwrap_or(0)) | ||
| 127 | + } | ||
| 128 | + | ||
| 116 | /// Grants or revokes the admin flag. Revoking is refused for the last administrator. | 129 | /// Grants or revokes the admin flag. Revoking is refused for the last administrator. |
| 117 | pub async fn set_admin(&self, user_id: &str, admin: bool) -> Result<()> { | 130 | pub async fn set_admin(&self, user_id: &str, admin: bool) -> Result<()> { |
| 118 | let conn = self.inner.conn.lock().await; | 131 | let conn = self.inner.conn.lock().await; |
crates/forge-web/src/i18n/accounts.rsmodified+12 -3
| @@ -4,7 +4,6 @@ use super::Lang; | |||
| 4 | 4 | ||
| 5 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] | 5 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
| 6 | pub enum A { | 6 | pub enum A { |
| 7 | - Status, | ||
| 8 | Active, | 7 | Active, |
| 9 | Suspended, | 8 | Suspended, |
| 10 | LastLogin, | 9 | LastLogin, |
| @@ -59,14 +58,16 @@ pub enum A { | |||
| 59 | Services, | 58 | Services, |
| 60 | Fine, | 59 | Fine, |
| 61 | DiskUsed, | 60 | DiskUsed, |
| 61 | + Joined, | ||
| 62 | + NoPasskeysToRemove, | ||
| 63 | + TwoFactorNotOn, | ||
| 64 | + DeleteHelp, | ||
| 62 | } | 65 | } |
| 63 | 66 | ||
| 64 | pub fn t(lang: Lang, key: A) -> &'static str { | 67 | pub fn t(lang: Lang, key: A) -> &'static str { |
| 65 | use A::*; | 68 | use A::*; |
| 66 | use Lang::*; | 69 | use Lang::*; |
| 67 | match (key, lang) { | 70 | match (key, lang) { |
| 68 | - (Status, En) => "Status", | ||
| 69 | - (Status, Tr) => "Durum", | ||
| 70 | (Active, En) => "Active", | 71 | (Active, En) => "Active", |
| 71 | (Active, Tr) => "Etkin", | 72 | (Active, Tr) => "Etkin", |
| 72 | (Suspended, En) => "Suspended", | 73 | (Suspended, En) => "Suspended", |
| @@ -185,6 +186,14 @@ pub fn t(lang: Lang, key: A) -> &'static str { | |||
| 185 | (Fine, Tr) => "Her şey yolunda", | 186 | (Fine, Tr) => "Her şey yolunda", |
| 186 | (DiskUsed, En) => "used", | 187 | (DiskUsed, En) => "used", |
| 187 | (DiskUsed, Tr) => "kullanıldı", | 188 | (DiskUsed, Tr) => "kullanıldı", |
| 189 | + (Joined, En) => "Joined", | ||
| 190 | + (Joined, Tr) => "Katılım", | ||
| 191 | + (NoPasskeysToRemove, En) => "No passkeys to remove", | ||
| 192 | + (NoPasskeysToRemove, Tr) => "Kaldırılacak geçiş anahtarı yok", | ||
| 193 | + (TwoFactorNotOn, En) => "Two-factor is not on", | ||
| 194 | + (TwoFactorNotOn, Tr) => "İki adımlı doğrulama açık değil", | ||
| 195 | + (DeleteHelp, En) => "Removes the account, its sessions and keys. This cannot be undone.", | ||
| 196 | + (DeleteHelp, Tr) => "Hesabı, oturumlarını ve anahtarlarını siler. Bu işlem geri alınamaz.", | ||
| 188 | } | 197 | } |
| 189 | } | 198 | } |
| 190 | 199 | ||
crates/forge-web/src/i18n/admin.rsmodified+4 -12
| @@ -14,6 +14,7 @@ pub enum K { | |||
| 14 | AdminArea, | 14 | AdminArea, |
| 15 | Administrator, | 15 | Administrator, |
| 16 | AllActions, | 16 | AllActions, |
| 17 | + RowActions, | ||
| 17 | Anonymous, | 18 | Anonymous, |
| 18 | AtLeast12Chars, | 19 | AtLeast12Chars, |
| 19 | AuditIntro, | 20 | AuditIntro, |
| @@ -156,16 +157,13 @@ pub enum K { | |||
| 156 | TableActor, | 157 | TableActor, |
| 157 | TableDetails, | 158 | TableDetails, |
| 158 | TableDuration, | 159 | TableDuration, |
| 159 | - TableError, | ||
| 160 | TableKind, | 160 | TableKind, |
| 161 | TableLastError, | 161 | TableLastError, |
| 162 | TableQueued, | 162 | TableQueued, |
| 163 | - TableRepo, | ||
| 164 | TableResult, | 163 | TableResult, |
| 165 | TableSize, | 164 | TableSize, |
| 166 | TableStarted, | 165 | TableStarted, |
| 167 | TableState, | 166 | TableState, |
| 168 | - TableStatus, | ||
| 169 | TableSubject, | 167 | TableSubject, |
| 170 | TableTarget, | 168 | TableTarget, |
| 171 | TableTo, | 169 | TableTo, |
| @@ -197,6 +195,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 197 | (Administrator, Tr) => "Yönetici", | 195 | (Administrator, Tr) => "Yönetici", |
| 198 | (AllActions, En) => "All actions", | 196 | (AllActions, En) => "All actions", |
| 199 | (AllActions, Tr) => "Tüm işlemler", | 197 | (AllActions, Tr) => "Tüm işlemler", |
| 198 | + (RowActions, En) => "Actions", | ||
| 199 | + (RowActions, Tr) => "İşlemler", | ||
| 200 | (Anonymous, En) => "anonymous", | 200 | (Anonymous, En) => "anonymous", |
| 201 | (Anonymous, Tr) => "anonim", | 201 | (Anonymous, Tr) => "anonim", |
| 202 | (AtLeast12Chars, En) => "At least 12 characters.", | 202 | (AtLeast12Chars, En) => "At least 12 characters.", |
| @@ -545,16 +545,12 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 545 | (TableDetails, Tr) => "Ayrıntılar", | 545 | (TableDetails, Tr) => "Ayrıntılar", |
| 546 | (TableDuration, En) => "Duration", | 546 | (TableDuration, En) => "Duration", |
| 547 | (TableDuration, Tr) => "Süre", | 547 | (TableDuration, Tr) => "Süre", |
| 548 | - (TableError, En) => "Error", | ||
| 549 | - (TableError, Tr) => "Hata", | ||
| 550 | (TableKind, En) => "Kind", | 548 | (TableKind, En) => "Kind", |
| 551 | (TableKind, Tr) => "Tür", | 549 | (TableKind, Tr) => "Tür", |
| 552 | (TableLastError, En) => "Last error", | 550 | (TableLastError, En) => "Last error", |
| 553 | (TableLastError, Tr) => "Son hata", | 551 | (TableLastError, Tr) => "Son hata", |
| 554 | (TableQueued, En) => "Queued", | 552 | (TableQueued, En) => "Queued", |
| 555 | (TableQueued, Tr) => "Kuyruğa alındı", | 553 | (TableQueued, Tr) => "Kuyruğa alındı", |
| 556 | - (TableRepo, En) => "Repo", | ||
| 557 | - (TableRepo, Tr) => "Depo", | ||
| 558 | (TableResult, En) => "Result", | 554 | (TableResult, En) => "Result", |
| 559 | (TableResult, Tr) => "Sonuç", | 555 | (TableResult, Tr) => "Sonuç", |
| 560 | (TableSize, En) => "Size", | 556 | (TableSize, En) => "Size", |
| @@ -563,8 +559,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 563 | (TableStarted, Tr) => "Başlangıç", | 559 | (TableStarted, Tr) => "Başlangıç", |
| 564 | (TableState, En) => "State", | 560 | (TableState, En) => "State", |
| 565 | (TableState, Tr) => "Durum", | 561 | (TableState, Tr) => "Durum", |
| 566 | - (TableStatus, En) => "Status", | ||
| 567 | - (TableStatus, Tr) => "Durum", | ||
| 568 | (TableSubject, En) => "Subject", | 562 | (TableSubject, En) => "Subject", |
| 569 | (TableSubject, Tr) => "Konu", | 563 | (TableSubject, Tr) => "Konu", |
| 570 | (TableTarget, En) => "Target", | 564 | (TableTarget, En) => "Target", |
| @@ -800,6 +794,7 @@ mod tests { | |||
| 800 | K::AdminArea, | 794 | K::AdminArea, |
| 801 | K::Administrator, | 795 | K::Administrator, |
| 802 | K::AllActions, | 796 | K::AllActions, |
| 797 | + K::RowActions, | ||
| 803 | K::Anonymous, | 798 | K::Anonymous, |
| 804 | K::AtLeast12Chars, | 799 | K::AtLeast12Chars, |
| 805 | K::AuditIntro, | 800 | K::AuditIntro, |
| @@ -942,16 +937,13 @@ mod tests { | |||
| 942 | K::TableActor, | 937 | K::TableActor, |
| 943 | K::TableDetails, | 938 | K::TableDetails, |
| 944 | K::TableDuration, | 939 | K::TableDuration, |
| 945 | - K::TableError, | ||
| 946 | K::TableKind, | 940 | K::TableKind, |
| 947 | K::TableLastError, | 941 | K::TableLastError, |
| 948 | K::TableQueued, | 942 | K::TableQueued, |
| 949 | - K::TableRepo, | ||
| 950 | K::TableResult, | 943 | K::TableResult, |
| 951 | K::TableSize, | 944 | K::TableSize, |
| 952 | K::TableStarted, | 945 | K::TableStarted, |
| 953 | K::TableState, | 946 | K::TableState, |
| 954 | - K::TableStatus, | ||
| 955 | K::TableSubject, | 947 | K::TableSubject, |
| 956 | K::TableTarget, | 948 | K::TableTarget, |
| 957 | K::TableTo, | 949 | K::TableTo, |
crates/forge-web/src/i18n/integrations.rsmodified+0 -40
| @@ -15,14 +15,6 @@ pub enum K { | |||
| 15 | ArchivedNotice, | 15 | ArchivedNotice, |
| 16 | BackToWebhooks, | 16 | BackToWebhooks, |
| 17 | ClearSecret, | 17 | ClearSecret, |
| 18 | - ColActive, | ||
| 19 | - ColDirection, | ||
| 20 | - ColEnabled, | ||
| 21 | - ColEvents, | ||
| 22 | - ColInterval, | ||
| 23 | - ColLastDelivery, | ||
| 24 | - ColLastSync, | ||
| 25 | - ColResult, | ||
| 26 | CreateWebhook, | 18 | CreateWebhook, |
| 27 | CurrentUrl, | 19 | CurrentUrl, |
| 28 | DeleteConfirm, | 20 | DeleteConfirm, |
| @@ -63,7 +55,6 @@ pub enum K { | |||
| 63 | Mirrors, | 55 | Mirrors, |
| 64 | MirrorsIntro, | 56 | MirrorsIntro, |
| 65 | Never, | 57 | Never, |
| 66 | - No, | ||
| 67 | NoDeliveries, | 58 | NoDeliveries, |
| 68 | NoMirrors, | 59 | NoMirrors, |
| 69 | NoWebhooks, | 60 | NoWebhooks, |
| @@ -118,7 +109,6 @@ pub enum K { | |||
| 118 | UsernameOptional, | 109 | UsernameOptional, |
| 119 | Webhooks, | 110 | Webhooks, |
| 120 | WebhooksIntro, | 111 | WebhooksIntro, |
| 121 | - Yes, | ||
| 122 | } | 112 | } |
| 123 | 113 | ||
| 124 | /// Every key, so the tests can walk them. | 114 | /// Every key, so the tests can walk them. |
| @@ -135,14 +125,6 @@ pub const ALL: &[K] = &[ | |||
| 135 | K::ArchivedNotice, | 125 | K::ArchivedNotice, |
| 136 | K::BackToWebhooks, | 126 | K::BackToWebhooks, |
| 137 | K::ClearSecret, | 127 | K::ClearSecret, |
| 138 | - K::ColActive, | ||
| 139 | - K::ColDirection, | ||
| 140 | - K::ColEnabled, | ||
| 141 | - K::ColEvents, | ||
| 142 | - K::ColInterval, | ||
| 143 | - K::ColLastDelivery, | ||
| 144 | - K::ColLastSync, | ||
| 145 | - K::ColResult, | ||
| 146 | K::CreateWebhook, | 128 | K::CreateWebhook, |
| 147 | K::CurrentUrl, | 129 | K::CurrentUrl, |
| 148 | K::DeleteConfirm, | 130 | K::DeleteConfirm, |
| @@ -183,7 +165,6 @@ pub const ALL: &[K] = &[ | |||
| 183 | K::Mirrors, | 165 | K::Mirrors, |
| 184 | K::MirrorsIntro, | 166 | K::MirrorsIntro, |
| 185 | K::Never, | 167 | K::Never, |
| 186 | - K::No, | ||
| 187 | K::NoDeliveries, | 168 | K::NoDeliveries, |
| 188 | K::NoMirrors, | 169 | K::NoMirrors, |
| 189 | K::NoWebhooks, | 170 | K::NoWebhooks, |
| @@ -238,7 +219,6 @@ pub const ALL: &[K] = &[ | |||
| 238 | K::UsernameOptional, | 219 | K::UsernameOptional, |
| 239 | K::Webhooks, | 220 | K::Webhooks, |
| 240 | K::WebhooksIntro, | 221 | K::WebhooksIntro, |
| 241 | - K::Yes, | ||
| 242 | ]; | 222 | ]; |
| 243 | 223 | ||
| 244 | /// The phrase a key names, in a user's language. | 224 | /// The phrase a key names, in a user's language. |
| @@ -284,22 +264,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 284 | (BackToWebhooks, Tr) => "Web kancalarına dön", | 264 | (BackToWebhooks, Tr) => "Web kancalarına dön", |
| 285 | (ClearSecret, En) => "Clear the stored password or token", | 265 | (ClearSecret, En) => "Clear the stored password or token", |
| 286 | (ClearSecret, Tr) => "Kayıtlı parola veya belirteci temizle", | 266 | (ClearSecret, Tr) => "Kayıtlı parola veya belirteci temizle", |
| 287 | - (ColActive, En) => "Active", | ||
| 288 | - (ColActive, Tr) => "Etkin", | ||
| 289 | - (ColDirection, En) => "Direction", | ||
| 290 | - (ColDirection, Tr) => "Yön", | ||
| 291 | - (ColEnabled, En) => "Enabled", | ||
| 292 | - (ColEnabled, Tr) => "Etkin", | ||
| 293 | - (ColEvents, En) => "Events", | ||
| 294 | - (ColEvents, Tr) => "Olaylar", | ||
| 295 | - (ColInterval, En) => "Interval", | ||
| 296 | - (ColInterval, Tr) => "Aralık", | ||
| 297 | - (ColLastDelivery, En) => "Last delivery", | ||
| 298 | - (ColLastDelivery, Tr) => "Son teslimat", | ||
| 299 | - (ColLastSync, En) => "Last sync", | ||
| 300 | - (ColLastSync, Tr) => "Son eşitleme", | ||
| 301 | - (ColResult, En) => "Result", | ||
| 302 | - (ColResult, Tr) => "Sonuç", | ||
| 303 | (CreateWebhook, En) => "Create webhook", | 267 | (CreateWebhook, En) => "Create webhook", |
| 304 | (CreateWebhook, Tr) => "Web kancası oluştur", | 268 | (CreateWebhook, Tr) => "Web kancası oluştur", |
| 305 | (CurrentUrl, En) => "Current URL:", | 269 | (CurrentUrl, En) => "Current URL:", |
| @@ -406,8 +370,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 406 | } | 370 | } |
| 407 | (Never, En) => "never", | 371 | (Never, En) => "never", |
| 408 | (Never, Tr) => "hiç", | 372 | (Never, Tr) => "hiç", |
| 409 | - (No, En) => "no", | ||
| 410 | - (No, Tr) => "hayır", | ||
| 411 | (NoDeliveries, En) => "No deliveries yet.", | 373 | (NoDeliveries, En) => "No deliveries yet.", |
| 412 | (NoDeliveries, Tr) => "Henüz teslimat yok.", | 374 | (NoDeliveries, Tr) => "Henüz teslimat yok.", |
| 413 | (NoMirrors, En) => "No mirrors yet.", | 375 | (NoMirrors, En) => "No mirrors yet.", |
| @@ -554,8 +516,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 554 | (WebhooksIntro, Tr) => { | 516 | (WebhooksIntro, Tr) => { |
| 555 | "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." | 517 | "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." |
| 556 | } | 518 | } |
| 557 | - (Yes, En) => "yes", | ||
| 558 | - (Yes, Tr) => "evet", | ||
| 559 | } | 519 | } |
| 560 | } | 520 | } |
| 561 | 521 | ||
crates/forge-web/src/pages/admin_mail.rsmodified+11 -6
| @@ -332,12 +332,17 @@ async fn mail_view( | |||
| 332 | <input type="hidden" name="state" value=(filter_param.as_str())> | 332 | <input type="hidden" name="state" value=(filter_param.as_str())> |
| 333 | <button type="submit">(g::t(lang, K::MailRetryNow))</button> | 333 | <button type="submit">(g::t(lang, K::MailRetryNow))</button> |
| 334 | </form> | 334 | </form> |
| 335 | - <form method="post" action="/admin/mail/queue/discard"> | 335 | + <details class="row-menu"> |
| 336 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 336 | + <summary class="button row-menu-btn" aria-label=(g::t(lang, K::RowActions)) aria-haspopup="menu">"⋯"</summary> |
| 337 | - <input type="hidden" name="id" value=(row.id.as_str())> | 337 | + <div class="row-menu-panel" role="menu"> |
| 338 | - <input type="hidden" name="state" value=(filter_param.as_str())> | 338 | + <form method="post" action="/admin/mail/queue/discard" class="inline-form"> |
| 339 | - <button type="submit">(g::t(lang, K::MailDiscard))</button> | 339 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 340 | - </form> | 340 | + <input type="hidden" name="id" value=(row.id.as_str())> |
| 341 | + <input type="hidden" name="state" value=(filter_param.as_str())> | ||
| 342 | + <button type="submit" class="danger">(g::t(lang, K::MailDiscard))</button> | ||
| 343 | + </form> | ||
| 344 | + </div> | ||
| 345 | + </details> | ||
| 341 | } | 346 | } |
| 342 | </td> | 347 | </td> |
| 343 | </tr> | 348 | </tr> |
crates/forge-web/src/pages/admin_replication.rsmodified+49 -25
| @@ -46,6 +46,25 @@ enum Health { | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | impl Health { | 48 | impl Health { |
| 49 | + /// The status dot: the health page's colours, muted for a copy that never ran. | ||
| 50 | + fn dot(self) -> &'static str { | ||
| 51 | + match self { | ||
| 52 | + Health::Ok => "health-dot ok", | ||
| 53 | + Health::Lagging => "health-dot warn", | ||
| 54 | + Health::Error => "health-dot bad", | ||
| 55 | + Health::Never => "health-dot", | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /// The status word's tone: only a lagging or failing copy is coloured. | ||
| 60 | + fn tone(self) -> &'static str { | ||
| 61 | + match self { | ||
| 62 | + Health::Ok | Health::Never => "", | ||
| 63 | + Health::Lagging => "warn", | ||
| 64 | + Health::Error => "bad", | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + | ||
| 49 | fn label(self, lang: Lang) -> &'static str { | 68 | fn label(self, lang: Lang) -> &'static str { |
| 50 | match self { | 69 | match self { |
| 51 | Health::Ok => g::t(lang, K::HealthOk), | 70 | Health::Ok => g::t(lang, K::HealthOk), |
| @@ -73,6 +92,8 @@ fn health(status: Option<&ReplicationStatus>, cutoff: &str) -> Health { | |||
| 73 | /// One line of the repos table, already formatted. | 92 | /// One line of the repos table, already formatted. |
| 74 | struct RepoRow { | 93 | struct RepoRow { |
| 75 | name: String, | 94 | name: String, |
| 95 | + dot: &'static str, | ||
| 96 | + tone: &'static str, | ||
| 76 | health: &'static str, | 97 | health: &'static str, |
| 77 | last_ok: String, | 98 | last_ok: String, |
| 78 | error: String, | 99 | error: String, |
| @@ -82,6 +103,7 @@ struct RepoRow { | |||
| 82 | struct PageData { | 103 | struct PageData { |
| 83 | enabled: bool, | 104 | enabled: bool, |
| 84 | target: String, | 105 | target: String, |
| 106 | + db_dot: &'static str, | ||
| 85 | db_health: &'static str, | 107 | db_health: &'static str, |
| 86 | db_last_ok: String, | 108 | db_last_ok: String, |
| 87 | db_last_attempt: String, | 109 | db_last_attempt: String, |
| @@ -121,9 +143,12 @@ async fn page_data(state: &AppState, tz: &str, lang: Lang) -> forge_core::Result | |||
| 121 | Some(repo) => format!("{}/{}", repo.owner_name, repo.name), | 143 | Some(repo) => format!("{}/{}", repo.owner_name, repo.name), |
| 122 | None => id.clone(), | 144 | None => id.clone(), |
| 123 | }; | 145 | }; |
| 146 | + let h = health(status, &repo_cutoff); | ||
| 124 | repos.push(RepoRow { | 147 | repos.push(RepoRow { |
| 125 | name, | 148 | name, |
| 126 | - health: health(status, &repo_cutoff).label(lang), | 149 | + dot: h.dot(), |
| 150 | + tone: h.tone(), | ||
| 151 | + health: h.label(lang), | ||
| 127 | last_ok: ok_text(status.and_then(|s| s.last_ok_at.as_deref()), tz, lang), | 152 | last_ok: ok_text(status.and_then(|s| s.last_ok_at.as_deref()), tz, lang), |
| 128 | error: status | 153 | error: status |
| 129 | .and_then(|s| s.last_error.clone()) | 154 | .and_then(|s| s.last_error.clone()) |
| @@ -133,9 +158,12 @@ async fn page_data(state: &AppState, tz: &str, lang: Lang) -> forge_core::Result | |||
| 133 | // Repos deleted since their last push: their standby copy is removed at the next reconcile. | 158 | // Repos deleted since their last push: their standby copy is removed at the next reconcile. |
| 134 | for status in statuses.values() { | 159 | for status in statuses.values() { |
| 135 | if status.subject != DB_SUBJECT && !ids.contains(&status.subject) { | 160 | if status.subject != DB_SUBJECT && !ids.contains(&status.subject) { |
| 161 | + let h = health(Some(status), &repo_cutoff); | ||
| 136 | repos.push(RepoRow { | 162 | repos.push(RepoRow { |
| 137 | name: g::deleted_repo_name(lang, &status.subject), | 163 | name: g::deleted_repo_name(lang, &status.subject), |
| 138 | - health: health(Some(status), &repo_cutoff).label(lang), | 164 | + dot: h.dot(), |
| 165 | + tone: h.tone(), | ||
| 166 | + health: h.label(lang), | ||
| 139 | last_ok: ok_text(status.last_ok_at.as_deref(), tz, lang), | 167 | last_ok: ok_text(status.last_ok_at.as_deref(), tz, lang), |
| 140 | error: status.last_error.clone().unwrap_or_default(), | 168 | error: status.last_error.clone().unwrap_or_default(), |
| 141 | }); | 169 | }); |
| @@ -145,6 +173,7 @@ async fn page_data(state: &AppState, tz: &str, lang: Lang) -> forge_core::Result | |||
| 145 | Ok(PageData { | 173 | Ok(PageData { |
| 146 | enabled: config.enabled(), | 174 | enabled: config.enabled(), |
| 147 | target: config.target.clone(), | 175 | target: config.target.clone(), |
| 176 | + db_dot: health(db, &db_cutoff).dot(), | ||
| 148 | db_health: health(db, &db_cutoff).label(lang), | 177 | db_health: health(db, &db_cutoff).label(lang), |
| 149 | db_last_ok: ok_text(db.and_then(|s| s.last_ok_at.as_deref()), tz, lang), | 178 | db_last_ok: ok_text(db.and_then(|s| s.last_ok_at.as_deref()), tz, lang), |
| 150 | db_last_attempt: ok_text(db.and_then(|s| s.last_attempt_at.as_deref()), tz, lang), | 179 | 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( | |||
| 184 | <dt>(g::t(lang, K::ReplicationTarget))</dt><dd><code>(data.target.as_str())</code></dd> | 213 | <dt>(g::t(lang, K::ReplicationTarget))</dt><dd><code>(data.target.as_str())</code></dd> |
| 185 | <dt>(g::t(lang, K::Interval))</dt><dd>(data.interval.as_str())</dd> | 214 | <dt>(g::t(lang, K::Interval))</dt><dd>(data.interval.as_str())</dd> |
| 186 | <dt>(g::t(lang, K::Healthcheck))</dt><dd>(data.healthcheck)</dd> | 215 | <dt>(g::t(lang, K::Healthcheck))</dt><dd>(data.healthcheck)</dd> |
| 187 | - <dt>(g::t(lang, K::Database))</dt><dd>(data.db_health)</dd> | 216 | + <dt>(g::t(lang, K::Database))</dt><dd><span class="admin-status"><span class=(data.db_dot) aria-hidden="true"></span>(data.db_health)</span></dd> |
| 188 | <dt>(g::t(lang, K::LastDbSnapshotShipped))</dt><dd class="small">(data.db_last_ok.as_str())</dd> | 217 | <dt>(g::t(lang, K::LastDbSnapshotShipped))</dt><dd class="small">(data.db_last_ok.as_str())</dd> |
| 189 | <dt>(g::t(lang, K::LastDbAttempt))</dt><dd class="small">(data.db_last_attempt.as_str())</dd> | 218 | <dt>(g::t(lang, K::LastDbAttempt))</dt><dd class="small">(data.db_last_attempt.as_str())</dd> |
| 190 | </dl> | 219 | </dl> |
| @@ -206,28 +235,23 @@ async fn replication_view( | |||
| 206 | if data.repos.is_empty() { | 235 | if data.repos.is_empty() { |
| 207 | <p class="muted">(g::t(lang, K::NoReposYet))</p> | 236 | <p class="muted">(g::t(lang, K::NoReposYet))</p> |
| 208 | } else { | 237 | } else { |
| 209 | - <div class="table-wrap"> | 238 | + <ul class="admin-rows"> |
| 210 | - <table class="table queue-table"> | 239 | + for row in data.repos.into_iter() { |
| 211 | - <thead> | 240 | + <li class="admin-row"> |
| 212 | - <tr> | 241 | + <div class="admin-row-main"> |
| 213 | - <th>(g::t(lang, K::TableRepo))</th> | 242 | + <div class="runner-title"> |
| 214 | - <th>(g::t(lang, K::TableStatus))</th> | 243 | + <span class=(row.dot) aria-hidden="true"></span> |
| 215 | - <th>(g::t(lang, K::LastSuccess))</th> | 244 | + <span class="admin-row-name">(row.name.as_str())</span> |
| 216 | - <th>(g::t(lang, K::TableError))</th> | 245 | + </div> |
| 217 | - </tr> | 246 | + <p class="runner-meta muted">(g::t(lang, K::LastSuccess))": "(row.last_ok.as_str())</p> |
| 218 | - </thead> | 247 | + if !row.error.is_empty() { |
| 219 | - <tbody> | 248 | + <p class="admin-row-error">(row.error.as_str())</p> |
| 220 | - for row in data.repos.into_iter() { | 249 | + } |
| 221 | - <tr> | 250 | + </div> |
| 222 | - <td data-label=(g::t(lang, K::TableRepo))>(row.name.as_str())</td> | 251 | + <span class=(format!("admin-row-state {}", row.tone))>(row.health)</span> |
| 223 | - <td data-label=(g::t(lang, K::TableStatus))>(row.health)</td> | 252 | + </li> |
| 224 | - <td class="small" data-label=(g::t(lang, K::LastSuccess))>(row.last_ok.as_str())</td> | 253 | + } |
| 225 | - <td class="small" data-label=(g::t(lang, K::TableError))>(row.error.as_str())</td> | 254 | + </ul> |
| 226 | - </tr> | ||
| 227 | - } | ||
| 228 | - </tbody> | ||
| 229 | - </table> | ||
| 230 | - </div> | ||
| 231 | } | 255 | } |
| 232 | </section> | 256 | </section> |
| 233 | </div> | 257 | </div> |
crates/forge-web/src/pages/admin_user_detail.rsmodified+166 -112
| @@ -26,7 +26,7 @@ use crate::pages::admin_users::admin_only; | |||
| 26 | use crate::pages::issues_list::stamp_unix; | 26 | use crate::pages::issues_list::stamp_unix; |
| 27 | use crate::pages::passkeys::s; | 27 | use crate::pages::passkeys::s; |
| 28 | use crate::state::AppState; | 28 | use crate::state::AppState; |
| 29 | -use crate::views::{alert, enc, shell, user_facing_message}; | 29 | +use crate::views::{alert, avatar_url, enc, rel_time_or_never, shell, user_facing_message}; |
| 30 | 30 | ||
| 31 | #[query_params(error = bad_request)] | 31 | #[query_params(error = bad_request)] |
| 32 | pub(crate) struct DoneQuery { | 32 | pub(crate) struct DoneQuery { |
| @@ -49,6 +49,8 @@ struct Detail { | |||
| 49 | facts: AccountFacts, | 49 | facts: AccountFacts, |
| 50 | suspension: Option<Suspension>, | 50 | suspension: Option<Suspension>, |
| 51 | passkeys: i64, | 51 | passkeys: i64, |
| 52 | + /// An administrator with no other administrator beside them: demoting is refused. | ||
| 53 | + last_admin: bool, | ||
| 52 | } | 54 | } |
| 53 | 55 | ||
| 54 | /// What the page says above the facts after an action. | 56 | /// What the page says above the facts after an action. |
| @@ -86,6 +88,7 @@ async fn load(cx: &Cx) -> Result<Detail> { | |||
| 86 | facts: store.account_facts(&target.id).await?, | 88 | facts: store.account_facts(&target.id).await?, |
| 87 | suspension: store.suspension(&target.id).await?, | 89 | suspension: store.suspension(&target.id).await?, |
| 88 | passkeys: store.passkey_count(&target.id).await?, | 90 | passkeys: store.passkey_count(&target.id).await?, |
| 91 | + last_admin: target.is_admin && store.other_admin_count(&target.id).await? == 0, | ||
| 89 | target, | 92 | target, |
| 90 | }) | 93 | }) |
| 91 | } | 94 | } |
| @@ -106,13 +109,6 @@ fn done_text(lang: Lang, done: &str) -> Option<&'static str> { | |||
| 106 | }) | 109 | }) |
| 107 | } | 110 | } |
| 108 | 111 | ||
| 109 | -fn when(stamp: Option<&str>, tz: &str, lang: Lang) -> String { | ||
| 110 | - match stamp { | ||
| 111 | - Some(s) => format_in_tz(stamp_unix(s), tz), | ||
| 112 | - None => at(lang, A::Never).to_owned(), | ||
| 113 | - } | ||
| 114 | -} | ||
| 115 | - | ||
| 116 | #[component] | 112 | #[component] |
| 117 | async fn detail_body( | 113 | async fn detail_body( |
| 118 | lang: Lang, | 114 | lang: Lang, |
| @@ -127,11 +123,12 @@ async fn detail_body( | |||
| 127 | facts, | 123 | facts, |
| 128 | suspension, | 124 | suspension, |
| 129 | passkeys, | 125 | passkeys, |
| 126 | + last_admin, | ||
| 130 | } = detail; | 127 | } = detail; |
| 131 | let base = format!("/admin/users/{}", enc(&target.id)); | 128 | let base = format!("/admin/users/{}", enc(&target.id)); |
| 132 | let own = target.id == viewer_id; | 129 | let own = target.id == viewer_id; |
| 133 | let created = format_in_tz(stamp_unix(&target.created_at), tz); | 130 | let created = format_in_tz(stamp_unix(&target.created_at), tz); |
| 134 | - let last_login = when(facts.last_login.as_deref(), tz, lang); | 131 | + let last_login = facts.last_login.clone(); |
| 135 | let repos = facts.repo_count.to_string(); | 132 | let repos = facts.repo_count.to_string(); |
| 136 | let suspended = suspension.is_some(); | 133 | let suspended = suspension.is_some(); |
| 137 | let status = if suspended { | 134 | let status = if suspended { |
| @@ -139,23 +136,20 @@ async fn detail_body( | |||
| 139 | } else { | 136 | } else { |
| 140 | at(lang, A::Active) | 137 | at(lang, A::Active) |
| 141 | }; | 138 | }; |
| 142 | - let tfa = if facts.two_factor { | 139 | + let dot_class = if suspended { |
| 143 | - at(lang, A::On) | 140 | + "user-dot is-suspended" |
| 144 | } else { | 141 | } else { |
| 145 | - at(lang, A::Off) | 142 | + "user-dot is-active" |
| 146 | }; | 143 | }; |
| 147 | - let role = if target.is_admin { | 144 | + let tfa_on = facts.two_factor; |
| 148 | - at(lang, A::Administrator) | 145 | + let tfa = if tfa_on { at(lang, A::On) } else { at(lang, A::Off) }; |
| 149 | - } else { | 146 | + let is_admin = target.is_admin; |
| 150 | - g::t(lang, K::RoleUser) | 147 | + let suspended_note = match suspension.as_ref().map(|s| s.reason.clone()) { |
| 148 | + Some(reason) if !reason.is_empty() => reason, | ||
| 149 | + _ => at(lang, A::AccountSuspended).to_owned(), | ||
| 151 | }; | 150 | }; |
| 152 | - let reason = suspension | ||
| 153 | - .as_ref() | ||
| 154 | - .map(|s| s.reason.clone()) | ||
| 155 | - .unwrap_or_default(); | ||
| 156 | let email = target.email.clone().unwrap_or_default(); | 151 | let email = target.email.clone().unwrap_or_default(); |
| 157 | - let is_admin = target.is_admin; | 152 | + let avatar = avatar_url(&target.username, target.avatar_hash.as_deref()); |
| 158 | - let tfa_on = facts.two_factor; | ||
| 159 | let suspend_action = format!("{base}/suspend"); | 153 | let suspend_action = format!("{base}/suspend"); |
| 160 | let unsuspend_action = format!("{base}/unsuspend"); | 154 | let unsuspend_action = format!("{base}/unsuspend"); |
| 161 | let admin_action = format!("{base}/admin"); | 155 | let admin_action = format!("{base}/admin"); |
| @@ -168,10 +162,37 @@ async fn detail_body( | |||
| 168 | let Notice { done, error, link } = notice; | 162 | let Notice { done, error, link } = notice; |
| 169 | Ok(view! { | 163 | Ok(view! { |
| 170 | <div data-live=(live.as_str())> | 164 | <div data-live=(live.as_str())> |
| 171 | - <section class="page-head"> | 165 | + <section class="user-head"> |
| 172 | - <h1>(target.username.as_str())</h1> | 166 | + <a class="user-back small" href="/admin/users">"← "(g::t(lang, K::Users))</a> |
| 167 | + <div class="user-id"> | ||
| 168 | + <img class="avatar user-avatar" src=(avatar.as_str()) alt="" width="56" height="56"> | ||
| 169 | + <div class="user-id-text"> | ||
| 170 | + <h1 class="user-name"> | ||
| 171 | + <span class=(dot_class) role="img" aria-label=(status) title=(status)></span> | ||
| 172 | + (target.username.as_str()) | ||
| 173 | + if suspended { | ||
| 174 | + <span class="user-off">(at(lang, A::Suspended))</span> | ||
| 175 | + } | ||
| 176 | + if is_admin { | ||
| 177 | + <span class="badge user-role">(at(lang, A::Administrator))</span> | ||
| 178 | + } | ||
| 179 | + </h1> | ||
| 180 | + <p class="user-meta muted small"> | ||
| 181 | + if !email.is_empty() { | ||
| 182 | + (email.as_str()) " · " | ||
| 183 | + } | ||
| 184 | + (at(lang, A::Joined)) " " (created.as_str()) " · " (at(lang, A::LastLogin)) " " rel_time_or_never(lang: lang, stamp: last_login.as_deref()) | ||
| 185 | + </p> | ||
| 186 | + </div> | ||
| 187 | + </div> | ||
| 188 | + <dl class="user-stats"> | ||
| 189 | + <div><dt>(at(lang, A::Repositories))</dt><dd>(repos.as_str())</dd></div> | ||
| 190 | + <div><dt>(at(lang, A::TwoFactor))</dt><dd>(tfa)</dd></div> | ||
| 191 | + <div><dt>(s(lang, "Passkeys", "Geçiş anahtarları"))</dt><dd>(passkey_count.as_str())</dd></div> | ||
| 192 | + </dl> | ||
| 173 | </section> | 193 | </section> |
| 174 | - <section class="card"> | 194 | + <section class="card user-actions"> |
| 195 | + <h2>(at(lang, A::Actions))</h2> | ||
| 175 | if let Some(message) = done { | 196 | if let Some(message) = done { |
| 176 | <p class="notice" role="status">(message)</p> | 197 | <p class="notice" role="status">(message)</p> |
| 177 | } | 198 | } |
| @@ -182,97 +203,128 @@ async fn detail_body( | |||
| 182 | <p>(at(lang, A::ResetLinkReady))</p> | 203 | <p>(at(lang, A::ResetLinkReady))</p> |
| 183 | <code class="reset-link">(link.as_str())</code> | 204 | <code class="reset-link">(link.as_str())</code> |
| 184 | } | 205 | } |
| 185 | - <dl class="kv-grid"> | 206 | + <ul class="action-list"> |
| 186 | - <div><dt>(at(lang, A::Status))</dt><dd>(status)</dd></div> | 207 | + if suspended { |
| 187 | - <div><dt>(i18n::t(lang, Key::Email))</dt><dd>(email.as_str())</dd></div> | 208 | + <li class="action-row"> |
| 188 | - <div><dt>(g::t(lang, K::Role))</dt><dd>(role)</dd></div> | 209 | + <div class="action-text"> |
| 189 | - <div><dt>(i18n::t(lang, Key::Created))</dt><dd>(created.as_str())</dd></div> | 210 | + <h3>(at(lang, A::Unsuspend))</h3> |
| 190 | - <div><dt>(at(lang, A::LastLogin))</dt><dd>(last_login.as_str())</dd></div> | 211 | + <p class="muted small">(suspended_note.as_str())</p> |
| 191 | - <div><dt>(at(lang, A::Repositories))</dt><dd>(repos.as_str())</dd></div> | 212 | + </div> |
| 192 | - <div><dt>(at(lang, A::TwoFactor))</dt><dd>(tfa)</dd></div> | 213 | + <div class="action-control"> |
| 193 | - <div><dt>(s(lang, "Passkeys", "Geçiş anahtarları"))</dt><dd>(passkey_count.as_str())</dd></div> | 214 | + <form method="post" action=(unsuspend_action.as_str())> |
| 194 | - </dl> | 215 | + <input type="hidden" name="csrf" value=(csrf)> |
| 195 | - </section> | 216 | + <button type="submit">(at(lang, A::Unsuspend))</button> |
| 196 | - <section class="card"> | 217 | + </form> |
| 197 | - <h2>(at(lang, A::Actions))</h2> | 218 | + </div> |
| 198 | - <div class="action-grid"> | 219 | + </li> |
| 199 | - <div class="action-box"> | 220 | + } |
| 200 | - <h3>(if suspended { at(lang, A::Unsuspend) } else { at(lang, A::Suspend) })</h3> | 221 | + <li class="action-row"> |
| 201 | - if suspended { | 222 | + <div class="action-text"> |
| 202 | - <p class="muted small">(reason.as_str())</p> | 223 | + <h3>(at(lang, A::Administrator))</h3> |
| 203 | - <form method="post" action=(unsuspend_action.as_str())> | 224 | + <p class="muted small">(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ı."))</p> |
| 204 | - <input type="hidden" name="csrf" value=(csrf)> | 225 | + </div> |
| 205 | - <button type="submit">(at(lang, A::Unsuspend))</button> | 226 | + <div class="action-control"> |
| 206 | - </form> | 227 | + if last_admin { |
| 207 | - } else if own { | 228 | + <p class="muted small">(at(lang, A::AdminHelp))</p> |
| 208 | - <p class="muted small">(at(lang, A::ErrSelf))</p> | 229 | + } else { |
| 209 | - } else { | 230 | + <form method="post" action=(admin_action.as_str())> |
| 210 | - <p class="muted small">(at(lang, A::SuspendHelp))</p> | 231 | + <input type="hidden" name="csrf" value=(csrf)> |
| 211 | - <form method="post" action=(suspend_action.as_str())> | 232 | + <input type="hidden" name="admin" value=(if is_admin { "0" } else { "1" })> |
| 212 | - <input type="hidden" name="csrf" value=(csrf)> | 233 | + <button type="submit">(if is_admin { at(lang, A::RevokeAdmin) } else { at(lang, A::GrantAdmin) })</button> |
| 213 | - <label> | 234 | + </form> |
| 214 | - <span>(at(lang, A::SuspendReason))</span> | 235 | + } |
| 215 | - <input type="text" name="reason" maxlength="300" autocomplete="off"> | 236 | + </div> |
| 216 | - </label> | 237 | + </li> |
| 217 | - <button type="submit" class="danger">(at(lang, A::Suspend))</button> | 238 | + <li class="action-row"> |
| 218 | - </form> | 239 | + <div class="action-text"> |
| 219 | - } | 240 | + <h3>(at(lang, A::ResetPassword))</h3> |
| 220 | - </div> | 241 | + <p class="muted small">(at(lang, A::ResetHelp))</p> |
| 221 | - <div class="action-box"> | 242 | + </div> |
| 222 | - <h3>(at(lang, A::Administrator))</h3> | 243 | + <div class="action-control"> |
| 223 | - <p class="muted small">(at(lang, A::AdminHelp))</p> | 244 | + <form method="post" action=(reset_action.as_str())> |
| 224 | - <form method="post" action=(admin_action.as_str())> | ||
| 225 | - <input type="hidden" name="csrf" value=(csrf)> | ||
| 226 | - <input type="hidden" name="admin" value=(if is_admin { "0" } else { "1" })> | ||
| 227 | - <button type="submit">(if is_admin { at(lang, A::RevokeAdmin) } else { at(lang, A::GrantAdmin) })</button> | ||
| 228 | - </form> | ||
| 229 | - </div> | ||
| 230 | - <div class="action-box"> | ||
| 231 | - <h3>(at(lang, A::ResetPassword))</h3> | ||
| 232 | - <p class="muted small">(at(lang, A::ResetHelp))</p> | ||
| 233 | - <form method="post" action=(reset_action.as_str())> | ||
| 234 | - <input type="hidden" name="csrf" value=(csrf)> | ||
| 235 | - <button type="submit">(at(lang, A::GenerateLink))</button> | ||
| 236 | - </form> | ||
| 237 | - </div> | ||
| 238 | - <div class="action-box"> | ||
| 239 | - <h3>(at(lang, A::Disable2fa))</h3> | ||
| 240 | - <p class="muted small">(at(lang, A::Disable2faHelp))</p> | ||
| 241 | - if tfa_on { | ||
| 242 | - <form method="post" action=(tfa_action.as_str())> | ||
| 243 | <input type="hidden" name="csrf" value=(csrf)> | 245 | <input type="hidden" name="csrf" value=(csrf)> |
| 244 | - <button type="submit" class="danger">(at(lang, A::Disable2fa))</button> | 246 | + <button type="submit">(at(lang, A::GenerateLink))</button> |
| 245 | </form> | 247 | </form> |
| 246 | - } else { | 248 | + </div> |
| 247 | - <p class="small">(at(lang, A::Off))</p> | 249 | + </li> |
| 248 | - } | 250 | + </ul> |
| 249 | - </div> | 251 | + </section> |
| 250 | - <div class="action-box"> | 252 | + <section class="card user-danger"> |
| 251 | - <h3>(s(lang, "Remove all passkeys", "Tüm geçiş anahtarlarını kaldır"))</h3> | 253 | + <h2>(i18n::t(lang, Key::DangerZone))</h2> |
| 252 | - <p class="muted small">(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."))</p> | 254 | + <ul class="action-list"> |
| 253 | - if passkeys > 0 { | 255 | + if !suspended { |
| 254 | - <details class="confirm-inline"> | 256 | + <li class="action-row"> |
| 255 | - <summary class="button danger">(s(lang, "Remove all passkeys", "Tüm geçiş anahtarlarını kaldır"))</summary> | 257 | + <div class="action-text"> |
| 256 | - <div class="confirm-pop"> | 258 | + <h3>(at(lang, A::Suspend))</h3> |
| 257 | - <p>(s(lang, "Remove every passkey of this user?", "Bu kullanıcının tüm geçiş anahtarları kaldırılsın mı?"))</p> | 259 | + <p class="muted small">(at(lang, A::SuspendHelp))</p> |
| 258 | - <form method="post" action=(passkeys_action.as_str())> | 260 | + </div> |
| 261 | + <div class="action-control"> | ||
| 262 | + if own { | ||
| 263 | + <p class="action-note muted small">(at(lang, A::ErrSelf))</p> | ||
| 264 | + } else { | ||
| 265 | + <form method="post" action=(suspend_action.as_str()) class="action-form"> | ||
| 259 | <input type="hidden" name="csrf" value=(csrf)> | 266 | <input type="hidden" name="csrf" value=(csrf)> |
| 260 | - <button type="submit" class="danger">(s(lang, "Remove all", "Hepsini kaldır"))</button> | 267 | + <label class="action-field"> |
| 261 | - <button type="button" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> | 268 | + <span>(at(lang, A::SuspendReason))</span> |
| 269 | + <input type="text" name="reason" maxlength="300" autocomplete="off"> | ||
| 270 | + </label> | ||
| 271 | + <button type="submit" class="danger">(at(lang, A::Suspend))</button> | ||
| 262 | </form> | 272 | </form> |
| 263 | - </div> | 273 | + } |
| 264 | - </details> | 274 | + </div> |
| 265 | - } else { | 275 | + </li> |
| 266 | - <p class="small">(at(lang, A::Off))</p> | 276 | + } |
| 267 | - } | 277 | + <li class="action-row"> |
| 268 | - </div> | 278 | + <div class="action-text"> |
| 269 | - </div> | 279 | + <h3>(at(lang, A::Disable2fa))</h3> |
| 270 | - <p class="link-row"> | 280 | + <p class="muted small">(at(lang, A::Disable2faHelp))</p> |
| 271 | - <a href="/admin/users">(g::t(lang, K::BackToUsers))</a> | 281 | + </div> |
| 282 | + <div class="action-control"> | ||
| 283 | + if tfa_on { | ||
| 284 | + <form method="post" action=(tfa_action.as_str())> | ||
| 285 | + <input type="hidden" name="csrf" value=(csrf)> | ||
| 286 | + <button type="submit" class="danger">(g::t(lang, K::Disable))</button> | ||
| 287 | + </form> | ||
| 288 | + } else { | ||
| 289 | + <p class="action-note muted small">(at(lang, A::TwoFactorNotOn))</p> | ||
| 290 | + } | ||
| 291 | + </div> | ||
| 292 | + </li> | ||
| 293 | + <li class="action-row"> | ||
| 294 | + <div class="action-text"> | ||
| 295 | + <h3>(s(lang, "Remove all passkeys", "Tüm geçiş anahtarlarını kaldır"))</h3> | ||
| 296 | + <p class="muted small">(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."))</p> | ||
| 297 | + </div> | ||
| 298 | + <div class="action-control"> | ||
| 299 | + if passkeys > 0 { | ||
| 300 | + <details class="confirm-inline"> | ||
| 301 | + <summary class="button danger">(s(lang, "Remove", "Kaldır"))</summary> | ||
| 302 | + <div class="confirm-pop"> | ||
| 303 | + <p>(s(lang, "Remove every passkey of this user?", "Bu kullanıcının tüm geçiş anahtarları kaldırılsın mı?"))</p> | ||
| 304 | + <form method="post" action=(passkeys_action.as_str())> | ||
| 305 | + <input type="hidden" name="csrf" value=(csrf)> | ||
| 306 | + <button type="submit" class="danger">(s(lang, "Remove all", "Hepsini kaldır"))</button> | ||
| 307 | + <button type="button" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> | ||
| 308 | + </form> | ||
| 309 | + </div> | ||
| 310 | + </details> | ||
| 311 | + } else { | ||
| 312 | + <p class="action-note muted small">(at(lang, A::NoPasskeysToRemove))</p> | ||
| 313 | + } | ||
| 314 | + </div> | ||
| 315 | + </li> | ||
| 272 | if !own { | 316 | if !own { |
| 273 | - <a class="danger" href=(delete_href.as_str())>(i18n::t(lang, Key::Delete))</a> | 317 | + <li class="action-row"> |
| 318 | + <div class="action-text"> | ||
| 319 | + <h3>(g::t(lang, K::DeleteUser))</h3> | ||
| 320 | + <p class="muted small">(at(lang, A::DeleteHelp))</p> | ||
| 321 | + </div> | ||
| 322 | + <div class="action-control"> | ||
| 323 | + <a class="button danger" href=(delete_href.as_str())>(i18n::t(lang, Key::Delete))</a> | ||
| 324 | + </div> | ||
| 325 | + </li> | ||
| 274 | } | 326 | } |
| 275 | - </p> | 327 | + </ul> |
| 276 | </section> | 328 | </section> |
| 277 | </div> | 329 | </div> |
| 278 | }) | 330 | }) |
| @@ -289,15 +341,17 @@ async fn account_fingerprint(store: &Store, user_id: &str) -> Result<String> { | |||
| 289 | let facts = store.account_facts(user_id).await?; | 341 | let facts = store.account_facts(user_id).await?; |
| 290 | let suspension = store.suspension(user_id).await?; | 342 | let suspension = store.suspension(user_id).await?; |
| 291 | let passkeys = store.passkey_count(user_id).await?; | 343 | let passkeys = store.passkey_count(user_id).await?; |
| 344 | + let other_admins = store.other_admin_count(user_id).await?; | ||
| 292 | Ok(format!( | 345 | Ok(format!( |
| 293 | - "{}|{}|{}|{}|{:?}|{:?}|{}", | 346 | + "{}|{}|{}|{}|{:?}|{:?}|{}|{}", |
| 294 | target.username, | 347 | target.username, |
| 295 | target.email.as_deref().unwrap_or(""), | 348 | target.email.as_deref().unwrap_or(""), |
| 296 | target.is_admin, | 349 | target.is_admin, |
| 297 | target.created_at, | 350 | target.created_at, |
| 298 | facts, | 351 | facts, |
| 299 | suspension, | 352 | suspension, |
| 300 | - passkeys | 353 | + passkeys, |
| 354 | + other_admins | ||
| 301 | )) | 355 | )) |
| 302 | } | 356 | } |
| 303 | 357 | ||
crates/forge-web/src/pages/org_members.rsmodified+12 -6
| @@ -22,6 +22,7 @@ use crate::pages::org_ctx::{ | |||
| 22 | load_org, member_role_word, notice_href, org_head, org_notice, parse_member_role, | 22 | load_org, member_role_word, notice_href, org_head, org_notice, parse_member_role, |
| 23 | require_form_csrf, require_member, require_owner, take_notice, | 23 | require_form_csrf, require_member, require_owner, take_notice, |
| 24 | }; | 24 | }; |
| 25 | +use crate::pages::passkeys; | ||
| 25 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| 26 | use crate::views::{avatar_url, display_name, shell}; | 27 | use crate::views::{avatar_url, display_name, shell}; |
| 27 | 28 | ||
| @@ -89,7 +90,7 @@ async fn members_body( | |||
| 89 | <section class="card"> | 90 | <section class="card"> |
| 90 | <h2>(g::t(lang, K::Members))</h2> | 91 | <h2>(g::t(lang, K::Members))</h2> |
| 91 | <div class="table-wrap"> | 92 | <div class="table-wrap"> |
| 92 | - <table class="table collaborators"> | 93 | + <table class="table collaborators members-table"> |
| 93 | <thead> | 94 | <thead> |
| 94 | <tr> | 95 | <tr> |
| 95 | <th>(g::t(lang, K::MemberHeader))</th> | 96 | <th>(g::t(lang, K::MemberHeader))</th> |
| @@ -123,11 +124,16 @@ async fn members_body( | |||
| 123 | </td> | 124 | </td> |
| 124 | <td> | 125 | <td> |
| 125 | if owner || row.is_self { | 126 | if owner || row.is_self { |
| 126 | - <form method="post" action=(remove_action.as_str()) class="remove-form"> | 127 | + <details class="row-menu"> |
| 127 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 128 | + <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> |
| 128 | - <input type="hidden" name="user_id" value=(row.user_id.as_str())> | 129 | + <div class="row-menu-panel" role="menu"> |
| 129 | - <button type="submit">(if row.is_self { g::t(lang, K::Leave) } else { g::t(lang, K::Remove) })</button> | 130 | + <form method="post" action=(remove_action.as_str()) class="inline-form"> |
| 130 | - </form> | 131 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 132 | + <input type="hidden" name="user_id" value=(row.user_id.as_str())> | ||
| 133 | + <button type="submit" class="danger">(if row.is_self { g::t(lang, K::Leave) } else { g::t(lang, K::Remove) })</button> | ||
| 134 | + </form> | ||
| 135 | + </div> | ||
| 136 | + </details> | ||
| 131 | } | 137 | } |
| 132 | </td> | 138 | </td> |
| 133 | </tr> | 139 | </tr> |
crates/forge-web/src/pages/org_teams.rsmodified+21 -10
| @@ -22,6 +22,7 @@ use crate::pages::org_ctx::{ | |||
| 22 | OrgCtx, TEAM_ROLES, load_org, notice_href, org_head, org_notice, require_form_csrf, | 22 | OrgCtx, TEAM_ROLES, load_org, notice_href, org_head, org_notice, require_form_csrf, |
| 23 | require_member, require_owner, take_notice, | 23 | require_member, require_owner, take_notice, |
| 24 | }; | 24 | }; |
| 25 | +use crate::pages::passkeys; | ||
| 25 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| 26 | use crate::views::{avatar_url, display_name, repo_href, shell}; | 27 | use crate::views::{avatar_url, display_name, repo_href, shell}; |
| 27 | 28 | ||
| @@ -358,11 +359,16 @@ async fn team_body( | |||
| 358 | </a> | 359 | </a> |
| 359 | </div> | 360 | </div> |
| 360 | if owner { | 361 | if owner { |
| 361 | - <form method="post" action=(remove_member_action.as_str()) class="remove-form"> | 362 | + <details class="row-menu"> |
| 362 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 363 | + <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> |
| 363 | - <input type="hidden" name="user_id" value=(member.user_id.as_str())> | 364 | + <div class="row-menu-panel" role="menu"> |
| 364 | - <button type="submit">(g::t(lang, K::Remove))</button> | 365 | + <form method="post" action=(remove_member_action.as_str()) class="inline-form"> |
| 365 | - </form> | 366 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 367 | + <input type="hidden" name="user_id" value=(member.user_id.as_str())> | ||
| 368 | + <button type="submit" class="danger">(g::t(lang, K::Remove))</button> | ||
| 369 | + </form> | ||
| 370 | + </div> | ||
| 371 | + </details> | ||
| 366 | } | 372 | } |
| 367 | </li> | 373 | </li> |
| 368 | } | 374 | } |
| @@ -388,11 +394,16 @@ async fn team_body( | |||
| 388 | <a href=(repo.href.as_str())>(repo.title.as_str())</a> | 394 | <a href=(repo.href.as_str())>(repo.title.as_str())</a> |
| 389 | </div> | 395 | </div> |
| 390 | if owner { | 396 | if owner { |
| 391 | - <form method="post" action=(remove_repo_action.as_str()) class="remove-form"> | 397 | + <details class="row-menu"> |
| 392 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 398 | + <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> |
| 393 | - <input type="hidden" name="repo_id" value=(repo.repo_id.as_str())> | 399 | + <div class="row-menu-panel" role="menu"> |
| 394 | - <button type="submit">(g::t(lang, K::Unlink))</button> | 400 | + <form method="post" action=(remove_repo_action.as_str()) class="inline-form"> |
| 395 | - </form> | 401 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 402 | + <input type="hidden" name="repo_id" value=(repo.repo_id.as_str())> | ||
| 403 | + <button type="submit" class="danger">(g::t(lang, K::Unlink))</button> | ||
| 404 | + </form> | ||
| 405 | + </div> | ||
| 406 | + </details> | ||
| 396 | } | 407 | } |
| 397 | </li> | 408 | </li> |
| 398 | } | 409 | } |
crates/forge-web/src/pages/repo_collaborators.rsmodified+12 -6
| @@ -25,6 +25,7 @@ use crate::audit::{self, Actor, Target}; | |||
| 25 | use crate::auth::{require_csrf, require_user}; | 25 | use crate::auth::{require_csrf, require_user}; |
| 26 | use crate::i18n::repo_admin::{self as g, K}; | 26 | use crate::i18n::repo_admin::{self as g, K}; |
| 27 | use crate::i18n::{self, Lang}; | 27 | use crate::i18n::{self, Lang}; |
| 28 | +use crate::pages::passkeys; | ||
| 28 | use crate::pages::repo::repo_head; | 29 | use crate::pages::repo::repo_head; |
| 29 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | 30 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 30 | use crate::pages::repo_settings::settings_nav_for; | 31 | use crate::pages::repo_settings::settings_nav_for; |
| @@ -185,7 +186,7 @@ async fn collaborators_table( | |||
| 185 | <p class="muted">(g::t(lang, K::NoCollaborators))</p> | 186 | <p class="muted">(g::t(lang, K::NoCollaborators))</p> |
| 186 | } else { | 187 | } else { |
| 187 | <div class="table-wrap"> | 188 | <div class="table-wrap"> |
| 188 | - <table class="table collaborators"> | 189 | + <table class="table collaborators members-table"> |
| 189 | <thead> | 190 | <thead> |
| 190 | <tr> | 191 | <tr> |
| 191 | <th>(g::t(lang, K::ColUser))</th> | 192 | <th>(g::t(lang, K::ColUser))</th> |
| @@ -222,11 +223,16 @@ async fn collaborators_table( | |||
| 222 | </form> | 223 | </form> |
| 223 | </td> | 224 | </td> |
| 224 | <td> | 225 | <td> |
| 225 | - <form method="post" action=(remove_action.as_str()) class="remove-form"> | 226 | + <details class="row-menu"> |
| 226 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 227 | + <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> |
| 227 | - <input type="hidden" name="user_id" value=(row.user_id.as_str())> | 228 | + <div class="row-menu-panel" role="menu"> |
| 228 | - <button type="submit">(g::t(lang, K::Remove))</button> | 229 | + <form method="post" action=(remove_action.as_str()) class="inline-form"> |
| 229 | - </form> | 230 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 231 | + <input type="hidden" name="user_id" value=(row.user_id.as_str())> | ||
| 232 | + <button type="submit" class="danger">(g::t(lang, K::Remove))</button> | ||
| 233 | + </form> | ||
| 234 | + </div> | ||
| 235 | + </details> | ||
| 230 | </td> | 236 | </td> |
| 231 | </tr> | 237 | </tr> |
| 232 | } | 238 | } |
crates/forge-web/src/pages/repo_mirrors.rsmodified+67 -45
| @@ -25,6 +25,7 @@ use topcoat::view::{View, component, view}; | |||
| 25 | 25 | ||
| 26 | use crate::audit::{self, Actor, Target}; | 26 | use crate::audit::{self, Actor, Target}; |
| 27 | use crate::auth::{require_csrf, require_user}; | 27 | use crate::auth::{require_csrf, require_user}; |
| 28 | +use crate::i18n::admin as adm; | ||
| 28 | use crate::i18n::{ | 29 | use crate::i18n::{ |
| 29 | self, Lang, | 30 | self, Lang, |
| 30 | integrations::{self as g, K}, | 31 | integrations::{self as g, K}, |
| @@ -35,7 +36,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | |||
| 35 | use crate::pages::repo_settings::settings_nav_for; | 36 | use crate::pages::repo_settings::settings_nav_for; |
| 36 | use crate::pages::repo_settings_live::settings_head; | 37 | use crate::pages::repo_settings_live::settings_head; |
| 37 | use crate::state::AppState; | 38 | use crate::state::AppState; |
| 38 | -use crate::views::{alert, enc, shell, user_facing_message}; | 39 | +use crate::views::{alert, enc, now_unix, relative_time, shell, user_facing_message}; |
| 39 | use crate::webhooks::client::{WebhookPolicy, validate_url}; | 40 | use crate::webhooks::client::{WebhookPolicy, validate_url}; |
| 40 | 41 | ||
| 41 | path_param!(owner); | 42 | path_param!(owner); |
| @@ -318,14 +319,38 @@ struct MirrorRow { | |||
| 318 | url: String, | 319 | url: String, |
| 319 | interval: String, | 320 | interval: String, |
| 320 | enabled: bool, | 321 | enabled: bool, |
| 322 | + /// The last sync in the viewer's zone, for the `title` tooltip. Empty when never synced. | ||
| 321 | last_sync: String, | 323 | last_sync: String, |
| 322 | - status_class: &'static str, | 324 | + /// The raw last-sync stamp, for the `<time>` element. Empty when never synced. |
| 325 | + last_sync_at: String, | ||
| 326 | + /// "5 minutes ago", or empty when never synced. | ||
| 327 | + last_sync_rel: String, | ||
| 328 | + /// Words around the relative time: "synced " before it in English, " eşitlendi" after it in Turkish. | ||
| 329 | + sync_prefix: &'static str, | ||
| 330 | + sync_suffix: &'static str, | ||
| 331 | + /// The status dot's class: green when the last sync worked, danger when it failed, muted otherwise. | ||
| 332 | + dot_class: &'static str, | ||
| 323 | status_text: &'static str, | 333 | status_text: &'static str, |
| 324 | error: String, | 334 | error: String, |
| 325 | } | 335 | } |
| 326 | 336 | ||
| 327 | fn mirror_row(lang: Lang, mirror: &Mirror, title: &str, tz: &str) -> MirrorRow { | 337 | fn mirror_row(lang: Lang, mirror: &Mirror, title: &str, tz: &str) -> MirrorRow { |
| 328 | let (status_class, status_text) = status_of(lang, mirror); | 338 | let (status_class, status_text) = status_of(lang, mirror); |
| 339 | + let dot_class = match (mirror.enabled, status_class) { | ||
| 340 | + (true, "ok") => "runner-dot is-online", | ||
| 341 | + (true, "failed") => "runner-dot is-failed", | ||
| 342 | + _ => "runner-dot", | ||
| 343 | + }; | ||
| 344 | + let (sync_prefix, sync_suffix) = match lang { | ||
| 345 | + Lang::En => ("synced ", ""), | ||
| 346 | + Lang::Tr => ("", " eşitlendi"), | ||
| 347 | + }; | ||
| 348 | + let last_sync_rel = mirror | ||
| 349 | + .last_sync_at | ||
| 350 | + .as_deref() | ||
| 351 | + .and_then(forge_core::time::stamp_to_unix) | ||
| 352 | + .map(|unix| relative_time(lang, unix, now_unix())) | ||
| 353 | + .unwrap_or_default(); | ||
| 329 | MirrorRow { | 354 | MirrorRow { |
| 330 | href: mirror_href(title, &mirror.id), | 355 | href: mirror_href(title, &mirror.id), |
| 331 | sync_action: format!("{}/sync", mirror_href(title, &mirror.id)), | 356 | sync_action: format!("{}/sync", mirror_href(title, &mirror.id)), |
| @@ -338,7 +363,11 @@ fn mirror_row(lang: Lang, mirror: &Mirror, title: &str, tz: &str) -> MirrorRow { | |||
| 338 | .as_deref() | 363 | .as_deref() |
| 339 | .map(|stamp| stamp_in_tz(stamp, tz)) | 364 | .map(|stamp| stamp_in_tz(stamp, tz)) |
| 340 | .unwrap_or_default(), | 365 | .unwrap_or_default(), |
| 341 | - status_class, | 366 | + last_sync_at: mirror.last_sync_at.clone().unwrap_or_default(), |
| 367 | + last_sync_rel, | ||
| 368 | + sync_prefix, | ||
| 369 | + sync_suffix, | ||
| 370 | + dot_class, | ||
| 342 | status_text, | 371 | status_text, |
| 343 | error: mirror.last_error.clone().unwrap_or_default(), | 372 | error: mirror.last_error.clone().unwrap_or_default(), |
| 344 | } | 373 | } |
| @@ -483,49 +512,42 @@ async fn mirrors_list_body( | |||
| 483 | if rows.is_empty() { | 512 | if rows.is_empty() { |
| 484 | <p class="muted">(g::t(lang, K::NoMirrors))</p> | 513 | <p class="muted">(g::t(lang, K::NoMirrors))</p> |
| 485 | } else { | 514 | } else { |
| 486 | - <div class="table-wrap"> | 515 | + <ul class="runner-list mirror-list"> |
| 487 | - <table class="table mirrors"> | 516 | + for row in rows.iter() { |
| 488 | - <thead> | 517 | + <li class="runner-row"> |
| 489 | - <tr> | 518 | + <div class="runner-id"> |
| 490 | - <th>(g::t(lang, K::ColDirection))</th> | 519 | + <div class="runner-title"> |
| 491 | - <th>"URL"</th> | 520 | + <span class=(row.dot_class) role="img" aria-label=(row.status_text) title=(row.status_text)></span> |
| 492 | - <th>(g::t(lang, K::ColInterval))</th> | 521 | + <a class="runner-name mirror-url" href=(row.href.as_str())>(row.url.as_str())</a> |
| 493 | - <th>(g::t(lang, K::ColEnabled))</th> | 522 | + </div> |
| 494 | - <th>(g::t(lang, K::ColLastSync))</th> | 523 | + <p class="runner-meta muted"> |
| 495 | - <th>(g::t(lang, K::ColResult))</th> | 524 | + (row.direction)" · "(row.interval.as_str()) |
| 496 | - <th></th> | 525 | + if !row.enabled { |
| 497 | - </tr> | 526 | + " · "(adm::t(lang, adm::K::Disabled)) |
| 498 | - </thead> | 527 | + } |
| 499 | - <tbody> | 528 | + " · " |
| 500 | - for row in rows.iter() { | 529 | + if row.last_sync_at.is_empty() { |
| 501 | - <tr> | 530 | + (g::t(lang, K::StatusNotRun)) |
| 502 | - <td>(row.direction)</td> | 531 | + } else { |
| 503 | - <td><a href=(row.href.as_str())><code>(row.url.as_str())</code></a></td> | 532 | + (row.sync_prefix)<time data-rel="true" datetime=(row.last_sync_at.as_str()) title=(row.last_sync.as_str())>(row.last_sync_rel.as_str())</time>(row.sync_suffix) |
| 504 | - <td>(row.interval.as_str())</td> | 533 | + } |
| 505 | - <td>(if row.enabled { g::t(lang, K::Yes) } else { g::t(lang, K::No) })</td> | 534 | + </p> |
| 506 | - <td>(row.last_sync.as_str())</td> | 535 | + if !row.error.is_empty() { |
| 507 | - <td> | 536 | + <details class="mirror-failure"> |
| 508 | - <span class=(format!("hook-state {}", row.status_class))>(row.status_text)</span> | 537 | + <summary>(g::t(lang, K::ErrorLabel))</summary> |
| 509 | - if !row.error.is_empty() { | 538 | + <pre class="mirror-error">(row.error.as_str())</pre> |
| 510 | - <details> | 539 | + </details> |
| 511 | - <summary>(g::t(lang, K::ErrorLabel))</summary> | 540 | + } |
| 512 | - <pre class="mirror-error">(row.error.as_str())</pre> | 541 | + </div> |
| 513 | - </details> | 542 | + if !archived { |
| 514 | - } | 543 | + <form method="post" action=(row.sync_action.as_str()) class="inline-form"> |
| 515 | - </td> | 544 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 516 | - <td> | 545 | + <button type="submit" class="hook-sync">(g::t(lang, K::SyncNow))</button> |
| 517 | - if !archived { | 546 | + </form> |
| 518 | - <form method="post" action=(row.sync_action.as_str()) class="inline-form"> | ||
| 519 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 520 | - <button type="submit">(g::t(lang, K::SyncNow))</button> | ||
| 521 | - </form> | ||
| 522 | - } | ||
| 523 | - </td> | ||
| 524 | - </tr> | ||
| 525 | } | 547 | } |
| 526 | - </tbody> | 548 | + </li> |
| 527 | - </table> | 549 | + } |
| 528 | - </div> | 550 | + </ul> |
| 529 | } | 551 | } |
| 530 | </section> | 552 | </section> |
| 531 | if !archived { | 553 | if !archived { |
crates/forge-web/src/pages/repo_webhooks.rsmodified+131 -45
| @@ -31,7 +31,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | |||
| 31 | use crate::pages::repo_settings::settings_nav_for; | 31 | use crate::pages::repo_settings::settings_nav_for; |
| 32 | use crate::pages::repo_settings_live::settings_head; | 32 | use crate::pages::repo_settings_live::settings_head; |
| 33 | use crate::state::AppState; | 33 | use crate::state::AppState; |
| 34 | -use crate::views::{alert, enc, shell}; | 34 | +use crate::views::{alert, enc, now_unix, relative_time, shell}; |
| 35 | use crate::webhooks::client::{WebhookPolicy, validate_url}; | 35 | use crate::webhooks::client::{WebhookPolicy, validate_url}; |
| 36 | use crate::webhooks::emit::emit_ping; | 36 | use crate::webhooks::emit::emit_ping; |
| 37 | 37 | ||
| @@ -306,13 +306,96 @@ fn state_label(lang: Lang, state: DeliveryState) -> (&'static str, &'static str) | |||
| 306 | } | 306 | } |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | -/// One hook row on the list page. | 309 | +/// One hook row on the list page, formatted for display. |
| 310 | struct HookRow { | 310 | struct HookRow { |
| 311 | href: String, | 311 | href: String, |
| 312 | url: String, | 312 | url: String, |
| 313 | + /// The subscribed events, joined with ", ". | ||
| 313 | events: String, | 314 | events: String, |
| 314 | active: bool, | 315 | active: bool, |
| 316 | + /// The status dot's class: green when the last delivery was ok, danger when it failed, muted otherwise. | ||
| 317 | + dot_class: &'static str, | ||
| 318 | + /// The dot's accessible name and tooltip: the last delivery's state, or "none yet". | ||
| 319 | + dot_text: &'static str, | ||
| 320 | + /// "last delivery " before the time in English, "son teslimat " in Turkish, or the whole | ||
| 321 | + /// "no delivery yet" text when the hook has never delivered. | ||
| 322 | + last_text: &'static str, | ||
| 323 | + /// The last delivery's stamp, for the `<time>`. Empty when there was none. | ||
| 324 | + last_at: String, | ||
| 325 | + /// The absolute time in the viewer's zone, for the `title` tooltip. | ||
| 326 | + last_full: String, | ||
| 327 | + /// "2 minutes ago", or empty when there was no delivery. | ||
| 328 | + last_rel: String, | ||
| 329 | + /// The last delivery's state when it was not ok, in a danger colour; empty otherwise. | ||
| 330 | + problem: &'static str, | ||
| 331 | + /// "inactive" or "etkin değil" for a hook that is switched off. | ||
| 332 | + inactive_text: &'static str, | ||
| 333 | +} | ||
| 334 | + | ||
| 335 | +/// One row of the webhooks list: the hook, its last delivery state and that delivery's stamp. | ||
| 336 | +fn hook_row( | ||
| 337 | + lang: Lang, | ||
| 338 | + tz: &str, | ||
| 339 | + title: &str, | ||
| 340 | + hook: Webhook, | ||
| 315 | last: Option<(&'static str, &'static str)>, | 341 | last: Option<(&'static str, &'static str)>, |
| 342 | + last_stamp: &str, | ||
| 343 | +) -> HookRow { | ||
| 344 | + let (dot_class, dot_text) = match last { | ||
| 345 | + Some(("ok", text)) if hook.active => ("runner-dot is-online", text), | ||
| 346 | + Some(("failed" | "gave_up", text)) if hook.active => ("runner-dot is-failed", text), | ||
| 347 | + Some((_, text)) => ("runner-dot", text), | ||
| 348 | + None => ("runner-dot", g::t(lang, K::NoneYet)), | ||
| 349 | + }; | ||
| 350 | + let (last_text, last_rel) = match (last, last_stamp) { | ||
| 351 | + (Some(_), stamp) if !stamp.is_empty() => { | ||
| 352 | + let rel = OffsetDateTime::parse(stamp, &Rfc3339) | ||
| 353 | + .map(|at| relative_time(lang, at.unix_timestamp(), now_unix())) | ||
| 354 | + .unwrap_or_default(); | ||
| 355 | + (last_label(lang), rel) | ||
| 356 | + } | ||
| 357 | + (Some(_), _) => (last_label(lang), String::new()), | ||
| 358 | + (None, _) => ( | ||
| 359 | + match lang { | ||
| 360 | + Lang::En => "no delivery yet", | ||
| 361 | + Lang::Tr => "henüz teslimat yok", | ||
| 362 | + }, | ||
| 363 | + String::new(), | ||
| 364 | + ), | ||
| 365 | + }; | ||
| 366 | + HookRow { | ||
| 367 | + href: hook_href(title, &hook.id), | ||
| 368 | + url: hook.url, | ||
| 369 | + events: hook | ||
| 370 | + .events | ||
| 371 | + .iter() | ||
| 372 | + .map(|e| e.as_str()) | ||
| 373 | + .collect::<Vec<_>>() | ||
| 374 | + .join(", "), | ||
| 375 | + active: hook.active, | ||
| 376 | + dot_class, | ||
| 377 | + dot_text, | ||
| 378 | + last_text, | ||
| 379 | + last_at: last_stamp.to_owned(), | ||
| 380 | + last_full: local_stamp(last_stamp, tz), | ||
| 381 | + last_rel, | ||
| 382 | + problem: match last { | ||
| 383 | + Some(("ok", _)) | None => "", | ||
| 384 | + Some((_, text)) => text, | ||
| 385 | + }, | ||
| 386 | + inactive_text: match lang { | ||
| 387 | + Lang::En => "inactive", | ||
| 388 | + Lang::Tr => "etkin değil", | ||
| 389 | + }, | ||
| 390 | + } | ||
| 391 | +} | ||
| 392 | + | ||
| 393 | +/// The words before a hook's last-delivery time. | ||
| 394 | +fn last_label(lang: Lang) -> &'static str { | ||
| 395 | + match lang { | ||
| 396 | + Lang::En => "last delivery ", | ||
| 397 | + Lang::Tr => "son teslimat ", | ||
| 398 | + } | ||
| 316 | } | 399 | } |
| 317 | 400 | ||
| 318 | /// One delivery on the hook page, with every value already formatted for display. | 401 | /// One delivery on the hook page, with every value already formatted for display. |
| @@ -491,34 +574,34 @@ async fn hooks_list_body( | |||
| 491 | if rows.is_empty() { | 574 | if rows.is_empty() { |
| 492 | <p class="muted">(g::t(lang, K::NoWebhooks))</p> | 575 | <p class="muted">(g::t(lang, K::NoWebhooks))</p> |
| 493 | } else { | 576 | } else { |
| 494 | - <div class="table-wrap"> | 577 | + <ul class="runner-list hook-list"> |
| 495 | - <table class="table webhooks"> | 578 | + for row in rows.iter() { |
| 496 | - <thead> | 579 | + <li class="runner-row"> |
| 497 | - <tr> | 580 | + <div class="runner-id"> |
| 498 | - <th>"URL"</th> | 581 | + <div class="runner-title"> |
| 499 | - <th>(g::t(lang, K::ColEvents))</th> | 582 | + <span class=(row.dot_class) role="img" aria-label=(row.dot_text) title=(row.dot_text)></span> |
| 500 | - <th>(g::t(lang, K::ColActive))</th> | 583 | + <a class="runner-name hook-url" href=(row.href.as_str())>(row.url.as_str())</a> |
| 501 | - <th>(g::t(lang, K::ColLastDelivery))</th> | 584 | + </div> |
| 502 | - </tr> | 585 | + <p class="runner-meta muted"> |
| 503 | - </thead> | 586 | + if !row.events.is_empty() { |
| 504 | - <tbody> | 587 | + (row.events.as_str())" · " |
| 505 | - for row in rows.iter() { | 588 | + } |
| 506 | - <tr> | 589 | + if row.last_at.is_empty() { |
| 507 | - <td><a href=(row.href.as_str())><code>(row.url.as_str())</code></a></td> | 590 | + (row.last_text) |
| 508 | - <td>(row.events.as_str())</td> | 591 | + } else { |
| 509 | - <td>(if row.active { g::t(lang, K::Yes) } else { g::t(lang, K::No) })</td> | 592 | + (row.last_text)<time data-rel="true" datetime=(row.last_at.as_str()) title=(row.last_full.as_str())>(row.last_rel.as_str())</time> |
| 510 | - <td> | 593 | + } |
| 511 | - if let Some((class, text)) = row.last { | 594 | + if !row.problem.is_empty() { |
| 512 | - <span class=(format!("hook-state {class}"))>(text)</span> | 595 | + " · "<span class="hook-problem">(row.problem)</span> |
| 513 | - } else { | 596 | + } |
| 514 | - <span class="muted">(g::t(lang, K::NoneYet))</span> | 597 | + if !row.active { |
| 515 | - } | 598 | + " · "(row.inactive_text) |
| 516 | - </td> | 599 | + } |
| 517 | - </tr> | 600 | + </p> |
| 518 | - } | 601 | + </div> |
| 519 | - </tbody> | 602 | + </li> |
| 520 | - </table> | 603 | + } |
| 521 | - </div> | 604 | + </ul> |
| 522 | } | 605 | } |
| 523 | </section> | 606 | </section> |
| 524 | }) | 607 | }) |
| @@ -653,21 +736,24 @@ async fn hooks_list_page(cx: &Cx) -> Result<impl View> { | |||
| 653 | let hooks = state.store.list_webhooks(&ctx.repo.id).await?; | 736 | let hooks = state.store.list_webhooks(&ctx.repo.id).await?; |
| 654 | let lang = lang_of(cx, &ctx); | 737 | let lang = lang_of(cx, &ctx); |
| 655 | let frame = Frame::new(&ctx, state, lang).await?; | 738 | let frame = Frame::new(&ctx, state, lang).await?; |
| 656 | - let rows: Vec<HookRow> = hooks | 739 | + let tz = ctx.viewer_tz(); |
| 657 | - .into_iter() | 740 | + let mut rows: Vec<HookRow> = Vec::with_capacity(hooks.len()); |
| 658 | - .map(|(hook, last)| HookRow { | 741 | + for (hook, last) in hooks { |
| 659 | - href: hook_href(&frame.title, &hook.id), | 742 | + // The list shows when the newest delivery happened, so it reads the one latest delivery per hook. |
| 660 | - url: hook.url, | 743 | + let last_stamp = if last.is_some() { |
| 661 | - events: hook | 744 | + state |
| 662 | - .events | 745 | + .store |
| 663 | - .iter() | 746 | + .list_deliveries(&hook.id, 1) |
| 664 | - .map(|e| e.as_str()) | 747 | + .await? |
| 665 | - .collect::<Vec<_>>() | 748 | + .first() |
| 666 | - .join(", "), | 749 | + .map(|d| d.created_at.clone()) |
| 667 | - active: hook.active, | 750 | + .unwrap_or_default() |
| 668 | - last: last.map(|last| state_label(lang, last)), | 751 | + } else { |
| 669 | - }) | 752 | + String::new() |
| 670 | - .collect(); | 753 | + }; |
| 754 | + let last = last.map(|last| state_label(lang, last)); | ||
| 755 | + rows.push(hook_row(lang, tz, &frame.title, hook, last, &last_stamp)); | ||
| 756 | + } | ||
| 671 | let notice = notice_from_query(cx, lang); | 757 | let notice = notice_from_query(cx, lang); |
| 672 | Ok(view! { | 758 | Ok(view! { |
| 673 | shell(title: frame.page_title.as_str(), viewer: ctx.viewer.as_ref(), | 759 | shell(title: frame.page_title.as_str(), viewer: ctx.viewer.as_ref(), |
style/_account_admin.scssmodified+241 -15
| @@ -51,38 +51,264 @@ | |||
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | -.action-grid { | 54 | +// Admin user detail. The header: a back link, the avatar, the name with a status dot and a role |
| 55 | - display: grid; | 55 | +// badge, one muted meta line, then one row of small facts. Under it the actions are hairline rows |
| 56 | - grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); | 56 | +// (title and one line of help on the left, the button on the right); the destructive ones sit in |
| 57 | +// their own danger card at the bottom. | ||
| 58 | +.user-head { | ||
| 59 | + margin-bottom: 16px; | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +.user-back { | ||
| 63 | + display: inline-block; | ||
| 64 | + margin-bottom: 12px; | ||
| 65 | + color: var(--muted); | ||
| 66 | + text-decoration: none; | ||
| 67 | + | ||
| 68 | + &:hover { | ||
| 69 | + color: var(--text); | ||
| 70 | + text-decoration: underline; | ||
| 71 | + } | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +.user-id { | ||
| 75 | + display: flex; | ||
| 76 | + align-items: center; | ||
| 57 | gap: 16px; | 77 | gap: 16px; |
| 78 | + min-width: 0; | ||
| 79 | +} | ||
| 58 | 80 | ||
| 59 | - .action-box { | 81 | +.user-avatar { |
| 60 | - border: 1px solid var(--border); | 82 | + flex: none; |
| 61 | - border-radius: var(--radius-lg); | 83 | + width: 56px; |
| 62 | - padding: 14px; | 84 | + height: 56px; |
| 85 | + border: 1px solid var(--border); | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +.user-id-text { | ||
| 89 | + min-width: 0; | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +.user-name { | ||
| 93 | + display: flex; | ||
| 94 | + flex-wrap: wrap; | ||
| 95 | + align-items: center; | ||
| 96 | + gap: 4px 10px; | ||
| 97 | + margin: 0; | ||
| 98 | + overflow-wrap: anywhere; | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +// The status dot: green when active, red when suspended. | ||
| 102 | +.user-dot { | ||
| 103 | + flex: none; | ||
| 104 | + width: 8px; | ||
| 105 | + height: 8px; | ||
| 106 | + border-radius: 50%; | ||
| 107 | + background: var(--muted); | ||
| 108 | + | ||
| 109 | + &.is-active { | ||
| 110 | + background: var(--ok); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + &.is-suspended { | ||
| 114 | + background: var(--danger); | ||
| 115 | + } | ||
| 116 | +} | ||
| 117 | + | ||
| 118 | +.user-off { | ||
| 119 | + color: var(--danger); | ||
| 120 | + font-size: 0.75rem; | ||
| 121 | + font-weight: 500; | ||
| 122 | +} | ||
| 123 | + | ||
| 124 | +.user-role { | ||
| 125 | + margin-left: 0; | ||
| 126 | + border-color: transparent; | ||
| 127 | + background: var(--accent-soft, var(--surface-2)); | ||
| 128 | + color: var(--accent-ink, var(--text)); | ||
| 129 | +} | ||
| 130 | + | ||
| 131 | +.user-meta { | ||
| 132 | + margin: 4px 0 0; | ||
| 133 | + overflow-wrap: anywhere; | ||
| 134 | +} | ||
| 135 | + | ||
| 136 | +// The facts: one row of small stat items between two hairlines. | ||
| 137 | +.user-stats { | ||
| 138 | + display: flex; | ||
| 139 | + flex-wrap: wrap; | ||
| 140 | + gap: 8px 28px; | ||
| 141 | + margin: 16px 0 0; | ||
| 142 | + padding: 12px 0; | ||
| 143 | + border-top: 1px solid var(--border); | ||
| 144 | + border-bottom: 1px solid var(--border); | ||
| 145 | + | ||
| 146 | + > div { | ||
| 63 | display: flex; | 147 | display: flex; |
| 64 | - flex-direction: column; | 148 | + align-items: baseline; |
| 65 | gap: 8px; | 149 | gap: 8px; |
| 66 | min-width: 0; | 150 | min-width: 0; |
| 151 | + } | ||
| 67 | 152 | ||
| 68 | - h3 { | 153 | + dt { |
| 69 | - margin: 0; | 154 | + color: var(--muted); |
| 70 | - font-size: 1rem; | 155 | + font-size: 0.8125rem; |
| 71 | - } | 156 | + } |
| 157 | + | ||
| 158 | + dd { | ||
| 159 | + margin: 0; | ||
| 160 | + font-weight: 600; | ||
| 161 | + font-variant-numeric: tabular-nums; | ||
| 162 | + } | ||
| 163 | +} | ||
| 164 | + | ||
| 165 | +.user-actions, | ||
| 166 | +.user-danger { | ||
| 167 | + h2 { | ||
| 168 | + margin: 0 0 4px; | ||
| 169 | + font-size: 0.9375rem; | ||
| 170 | + } | ||
| 171 | +} | ||
| 172 | + | ||
| 173 | +.user-danger { | ||
| 174 | + border-color: var(--danger); | ||
| 175 | + | ||
| 176 | + h2 { | ||
| 177 | + color: var(--danger); | ||
| 178 | + } | ||
| 179 | +} | ||
| 180 | + | ||
| 181 | +.action-list { | ||
| 182 | + list-style: none; | ||
| 183 | + margin: 0; | ||
| 184 | + padding: 0; | ||
| 185 | +} | ||
| 186 | + | ||
| 187 | +.action-row { | ||
| 188 | + display: grid; | ||
| 189 | + grid-template-columns: minmax(0, 1fr) auto; | ||
| 190 | + align-items: center; | ||
| 191 | + gap: 8px 24px; | ||
| 192 | + padding: 14px 0; | ||
| 193 | + | ||
| 194 | + h3 { | ||
| 195 | + margin: 0; | ||
| 196 | + font-size: 0.9375rem; | ||
| 197 | + font-weight: 600; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + p { | ||
| 201 | + margin: 2px 0 0; | ||
| 202 | + } | ||
| 203 | +} | ||
| 204 | + | ||
| 205 | +.action-list > .action-row + .action-row { | ||
| 206 | + border-top: 1px solid var(--border); | ||
| 207 | +} | ||
| 208 | + | ||
| 209 | +.action-text { | ||
| 210 | + min-width: 0; | ||
| 211 | +} | ||
| 212 | + | ||
| 213 | +.action-control { | ||
| 214 | + display: flex; | ||
| 215 | + align-items: center; | ||
| 216 | + justify-content: flex-end; | ||
| 217 | + min-width: 0; | ||
| 218 | + | ||
| 219 | + form { | ||
| 220 | + margin: 0; | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + // The passkey confirm opens under its button, right-aligned, as in the row menus. | ||
| 224 | + > .confirm-inline { | ||
| 225 | + position: relative; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + .confirm-pop { | ||
| 229 | + position: absolute; | ||
| 230 | + right: 0; | ||
| 231 | + top: calc(100% + 6px); | ||
| 232 | + z-index: 10; | ||
| 233 | + width: min(300px, calc(100vw - 32px)); | ||
| 234 | + padding: 12px 14px; | ||
| 235 | + border: 1px solid var(--border); | ||
| 236 | + border-radius: var(--radius-lg); | ||
| 237 | + background: var(--surface); | ||
| 238 | + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); | ||
| 239 | + text-align: left; | ||
| 72 | 240 | ||
| 73 | p { | 241 | p { |
| 74 | - margin: 0; | 242 | + margin: 0 0 10px; |
| 75 | } | 243 | } |
| 76 | 244 | ||
| 77 | form { | 245 | form { |
| 78 | display: flex; | 246 | display: flex; |
| 79 | - flex-direction: column; | 247 | + flex-wrap: wrap; |
| 80 | gap: 8px; | 248 | gap: 8px; |
| 81 | - margin-top: auto; | ||
| 82 | } | 249 | } |
| 83 | } | 250 | } |
| 84 | } | 251 | } |
| 85 | 252 | ||
| 253 | +.action-note { | ||
| 254 | + margin: 0; | ||
| 255 | + text-align: right; | ||
| 256 | +} | ||
| 257 | + | ||
| 258 | +// The suspend reason: a small caption over its input, then the button, bottom-aligned. | ||
| 259 | +.action-form { | ||
| 260 | + display: flex; | ||
| 261 | + flex-wrap: wrap; | ||
| 262 | + align-items: flex-end; | ||
| 263 | + justify-content: flex-end; | ||
| 264 | + gap: 8px; | ||
| 265 | +} | ||
| 266 | + | ||
| 267 | +.action-field { | ||
| 268 | + display: flex; | ||
| 269 | + flex-direction: column; | ||
| 270 | + gap: 2px; | ||
| 271 | + min-width: 0; | ||
| 272 | + | ||
| 273 | + span { | ||
| 274 | + color: var(--muted); | ||
| 275 | + font-size: 0.8125rem; | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + input[type="text"] { | ||
| 279 | + width: 220px; | ||
| 280 | + max-width: 100%; | ||
| 281 | + } | ||
| 282 | +} | ||
| 283 | + | ||
| 284 | +@media (max-width: 600px) { | ||
| 285 | + .action-row { | ||
| 286 | + grid-template-columns: minmax(0, 1fr); | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + .action-control { | ||
| 290 | + justify-content: flex-start; | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + .action-note { | ||
| 294 | + text-align: left; | ||
| 295 | + } | ||
| 296 | + | ||
| 297 | + .action-form { | ||
| 298 | + justify-content: flex-start; | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + .action-field input[type="text"] { | ||
| 302 | + width: 100%; | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + .action-control .confirm-pop { | ||
| 306 | + position: static; | ||
| 307 | + width: 100%; | ||
| 308 | + margin-top: 8px; | ||
| 309 | + } | ||
| 310 | +} | ||
| 311 | + | ||
| 86 | .reset-link { | 312 | .reset-link { |
| 87 | display: block; | 313 | display: block; |
| 88 | padding: 8px 10px; | 314 | padding: 8px 10px; |
style/_admin_rows.scssadded+94 -0
| @@ -0,0 +1,94 @@ | |||
| 1 | +// Admin lists as rows: a status dot, the name, a muted meta line, and a status word on the right. | ||
| 2 | +// The dots reuse `.health-dot` (_account_admin.scss) and the row title and meta reuse the runners | ||
| 3 | +// list classes (`.runner-title`, `.runner-meta`); the ⋯ menu is `.row-menu`. Only the layout and the | ||
| 4 | +// warning dot are new here. | ||
| 5 | + | ||
| 6 | +// The warning dot: a lagging copy. `.health-dot` has the ok and bad colours already. | ||
| 7 | +.health-dot.warn { | ||
| 8 | + background: var(--warn); | ||
| 9 | +} | ||
| 10 | + | ||
| 11 | +.admin-rows { | ||
| 12 | + margin: 0; | ||
| 13 | + padding: 0; | ||
| 14 | + list-style: none; | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +.admin-row { | ||
| 18 | + display: grid; | ||
| 19 | + grid-template-columns: minmax(0, 1fr) auto; | ||
| 20 | + align-items: center; | ||
| 21 | + column-gap: 28px; | ||
| 22 | + padding: 12px 0; | ||
| 23 | + | ||
| 24 | + & + .admin-row { | ||
| 25 | + border-top: 1px solid var(--border); | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +.admin-row-main { | ||
| 30 | + min-width: 0; | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +.admin-row-name { | ||
| 34 | + min-width: 0; | ||
| 35 | + overflow: hidden; | ||
| 36 | + color: var(--text); | ||
| 37 | + font-size: 0.9375rem; | ||
| 38 | + font-weight: 600; | ||
| 39 | + text-overflow: ellipsis; | ||
| 40 | + white-space: nowrap; | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +// The status word on the right: muted, with the warning or danger colour when the copy is lagging or failing. | ||
| 44 | +.admin-row-state { | ||
| 45 | + color: var(--muted); | ||
| 46 | + font-size: 0.8125rem; | ||
| 47 | + white-space: nowrap; | ||
| 48 | + | ||
| 49 | + &.warn { | ||
| 50 | + color: var(--warn); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + &.bad { | ||
| 54 | + color: var(--bad); | ||
| 55 | + } | ||
| 56 | +} | ||
| 57 | + | ||
| 58 | +// The last error, under the meta line. It lines up under the name, like the meta. | ||
| 59 | +.admin-row-error { | ||
| 60 | + margin: 4px 0 0 16px; | ||
| 61 | + color: var(--bad); | ||
| 62 | + font-size: 0.75rem; | ||
| 63 | + overflow-wrap: anywhere; | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +// A status fact: the dot, then its word, on one line. | ||
| 67 | +.admin-status { | ||
| 68 | + display: inline-flex; | ||
| 69 | + align-items: center; | ||
| 70 | + gap: 6px; | ||
| 71 | +} | ||
| 72 | + | ||
| 73 | +// Phone: the status word goes under the name, indented to line up with it. | ||
| 74 | +@media (max-width: 600px) { | ||
| 75 | + .admin-row { | ||
| 76 | + grid-template-columns: minmax(0, 1fr); | ||
| 77 | + row-gap: 6px; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + .admin-row-state { | ||
| 81 | + padding-left: 16px; | ||
| 82 | + } | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +// A small-range number on the server settings page steps like the runner's Max: the pill keeps its | ||
| 86 | +// own width instead of stretching across the column, at the height of the fields beside it. | ||
| 87 | +.srv-field .runner-pill { | ||
| 88 | + align-self: flex-start; | ||
| 89 | + height: var(--control-h); | ||
| 90 | + | ||
| 91 | + input[type="number"] { | ||
| 92 | + width: 52px; | ||
| 93 | + } | ||
| 94 | +} | ||
style/_hooks.scssadded+70 -0
| @@ -0,0 +1,70 @@ | |||
| 1 | +// Repo mirrors and webhooks: both lists use the runner list layout (a dot, the name, a muted meta | ||
| 2 | +// line under it, one compact action on the right). Only what differs from .runner-row is here. | ||
| 3 | + | ||
| 4 | +// A last sync or delivery that failed: the danger colour. The green and muted dots are the runners'. | ||
| 5 | +.runner-dot.is-failed { | ||
| 6 | + background: var(--danger); | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +// The URL is the row's name: a monospace identifier that truncates with an ellipsis. | ||
| 10 | +.runner-name.mirror-url, | ||
| 11 | +.runner-name.hook-url { | ||
| 12 | + font-family: var(--mono); | ||
| 13 | + font-size: 0.875rem; | ||
| 14 | + font-weight: 500; | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +// Mirrors: the name column, then the Sync now button. | ||
| 18 | +.mirror-list .runner-row { | ||
| 19 | + grid-template-columns: minmax(0, 1fr) auto; | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +// Webhooks: the name column alone; the row links to the hook's page. | ||
| 23 | +.hook-list .runner-row { | ||
| 24 | + grid-template-columns: minmax(0, 1fr); | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +// Sync now: a compact button that sits level with the name. | ||
| 28 | +.hook-sync { | ||
| 29 | + box-sizing: border-box; | ||
| 30 | + height: 28px; | ||
| 31 | + padding: 0 10px; | ||
| 32 | + font-size: 0.8125rem; | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +// The failure disclosure sits under the meta line, indented to line up with the name. | ||
| 36 | +.mirror-failure { | ||
| 37 | + margin: 4px 0 0 16px; | ||
| 38 | + font-size: 0.75rem; | ||
| 39 | + | ||
| 40 | + summary { | ||
| 41 | + color: var(--danger); | ||
| 42 | + cursor: pointer; | ||
| 43 | + width: fit-content; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + .mirror-error { | ||
| 47 | + margin: 6px 0 0; | ||
| 48 | + font-family: var(--mono); | ||
| 49 | + font-size: 0.8125rem; | ||
| 50 | + overflow-wrap: anywhere; | ||
| 51 | + white-space: pre-wrap; | ||
| 52 | + } | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +// The last delivery's state when it was not ok. | ||
| 56 | +.hook-problem { | ||
| 57 | + color: var(--danger); | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | +// Phone: the sync button goes under the name, the rows stack. | ||
| 61 | +@media (max-width: 600px) { | ||
| 62 | + .mirror-list .runner-row { | ||
| 63 | + grid-template-columns: minmax(0, 1fr); | ||
| 64 | + row-gap: 10px; | ||
| 65 | + | ||
| 66 | + > form { | ||
| 67 | + justify-self: start; | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | +} | ||
style/_members.scssadded+60 -0
| @@ -0,0 +1,60 @@ | |||
| 1 | +// Members, collaborators and team rows: the row's actions sit in a `.row-menu` (the ⋯ menu the admin | ||
| 2 | +// runners use). The role select and its Save stay in the row. | ||
| 3 | + | ||
| 4 | +// The required approvals stepper: a row like the other switch rows, but the control is the joined | ||
| 5 | +// `− n +` pill rather than a toggle, so the row is not a label and does not take a pointer. | ||
| 6 | +.switch-row.stepper-row { | ||
| 7 | + cursor: default; | ||
| 8 | + | ||
| 9 | + > .runner-pill { | ||
| 10 | + flex: none; | ||
| 11 | + align-self: center; | ||
| 12 | + } | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +// Phone: each member row stacks. The name takes the first line; the role select and the menu share | ||
| 16 | +// the second. The header row is hidden, as the cells carry no labels there. | ||
| 17 | +@media (max-width: 600px) { | ||
| 18 | + .members-table { | ||
| 19 | + display: block; | ||
| 20 | + | ||
| 21 | + thead { | ||
| 22 | + display: none; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + tbody, | ||
| 26 | + tr { | ||
| 27 | + display: block; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + tr { | ||
| 31 | + display: flex; | ||
| 32 | + flex-wrap: wrap; | ||
| 33 | + align-items: center; | ||
| 34 | + gap: 8px 12px; | ||
| 35 | + padding: 12px 0; | ||
| 36 | + border-bottom: 1px solid var(--border); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + td { | ||
| 40 | + display: block; | ||
| 41 | + width: auto; | ||
| 42 | + padding: 0; | ||
| 43 | + border: 0; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + td:first-child { | ||
| 47 | + flex: 1 1 100%; | ||
| 48 | + min-width: 0; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + td:nth-child(2) { | ||
| 52 | + flex: 1 1 auto; | ||
| 53 | + min-width: 0; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + td:last-child { | ||
| 57 | + flex: none; | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | +} | ||
style/main.scssmodified+3 -0
| @@ -7751,6 +7751,9 @@ button.ci-job-last { | |||
| 7751 | 7751 | ||
| 7752 | @import "account_admin"; | 7752 | @import "account_admin"; |
| 7753 | @import "link"; | 7753 | @import "link"; |
| 7754 | +@import "members"; | ||
| 7755 | +@import "hooks"; | ||
| 7756 | +@import "admin_rows"; | ||
| 7754 | 7757 | ||
| 7755 | // A monospace value with its Copy button on the right; long values wrap inside the box. | 7758 | // A monospace value with its Copy button on the right; long values wrap inside the box. |
| 7756 | .copy-box { | 7759 | .copy-box { |