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 | 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 | 129 | /// Grants or revokes the admin flag. Revoking is refused for the last administrator. |
| 117 | 130 | pub async fn set_admin(&self, user_id: &str, admin: bool) -> Result<()> { |
| 118 | 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 | 5 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
| 6 | 6 | pub enum A { |
| 7 | - Status, | |
| 8 | 7 | Active, |
| 9 | 8 | Suspended, |
| 10 | 9 | LastLogin, |
| @@ -59,14 +58,16 @@ pub enum A { | ||
| 59 | 58 | Services, |
| 60 | 59 | Fine, |
| 61 | 60 | DiskUsed, |
| 61 | + Joined, | |
| 62 | + NoPasskeysToRemove, | |
| 63 | + TwoFactorNotOn, | |
| 64 | + DeleteHelp, | |
| 62 | 65 | } |
| 63 | 66 | |
| 64 | 67 | pub fn t(lang: Lang, key: A) -> &'static str { |
| 65 | 68 | use A::*; |
| 66 | 69 | use Lang::*; |
| 67 | 70 | match (key, lang) { |
| 68 | - (Status, En) => "Status", | |
| 69 | - (Status, Tr) => "Durum", | |
| 70 | 71 | (Active, En) => "Active", |
| 71 | 72 | (Active, Tr) => "Etkin", |
| 72 | 73 | (Suspended, En) => "Suspended", |
| @@ -185,6 +186,14 @@ pub fn t(lang: Lang, key: A) -> &'static str { | ||
| 185 | 186 | (Fine, Tr) => "Her şey yolunda", |
| 186 | 187 | (DiskUsed, En) => "used", |
| 187 | 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 | 14 | AdminArea, |
| 15 | 15 | Administrator, |
| 16 | 16 | AllActions, |
| 17 | + RowActions, | |
| 17 | 18 | Anonymous, |
| 18 | 19 | AtLeast12Chars, |
| 19 | 20 | AuditIntro, |
| @@ -156,16 +157,13 @@ pub enum K { | ||
| 156 | 157 | TableActor, |
| 157 | 158 | TableDetails, |
| 158 | 159 | TableDuration, |
| 159 | - TableError, | |
| 160 | 160 | TableKind, |
| 161 | 161 | TableLastError, |
| 162 | 162 | TableQueued, |
| 163 | - TableRepo, | |
| 164 | 163 | TableResult, |
| 165 | 164 | TableSize, |
| 166 | 165 | TableStarted, |
| 167 | 166 | TableState, |
| 168 | - TableStatus, | |
| 169 | 167 | TableSubject, |
| 170 | 168 | TableTarget, |
| 171 | 169 | TableTo, |
| @@ -197,6 +195,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { | ||
| 197 | 195 | (Administrator, Tr) => "Yönetici", |
| 198 | 196 | (AllActions, En) => "All actions", |
| 199 | 197 | (AllActions, Tr) => "Tüm işlemler", |
| 198 | + (RowActions, En) => "Actions", | |
| 199 | + (RowActions, Tr) => "İşlemler", | |
| 200 | 200 | (Anonymous, En) => "anonymous", |
| 201 | 201 | (Anonymous, Tr) => "anonim", |
| 202 | 202 | (AtLeast12Chars, En) => "At least 12 characters.", |
| @@ -545,16 +545,12 @@ pub fn t(lang: Lang, key: K) -> &'static str { | ||
| 545 | 545 | (TableDetails, Tr) => "Ayrıntılar", |
| 546 | 546 | (TableDuration, En) => "Duration", |
| 547 | 547 | (TableDuration, Tr) => "Süre", |
| 548 | - (TableError, En) => "Error", | |
| 549 | - (TableError, Tr) => "Hata", | |
| 550 | 548 | (TableKind, En) => "Kind", |
| 551 | 549 | (TableKind, Tr) => "Tür", |
| 552 | 550 | (TableLastError, En) => "Last error", |
| 553 | 551 | (TableLastError, Tr) => "Son hata", |
| 554 | 552 | (TableQueued, En) => "Queued", |
| 555 | 553 | (TableQueued, Tr) => "Kuyruğa alındı", |
| 556 | - (TableRepo, En) => "Repo", | |
| 557 | - (TableRepo, Tr) => "Depo", | |
| 558 | 554 | (TableResult, En) => "Result", |
| 559 | 555 | (TableResult, Tr) => "Sonuç", |
| 560 | 556 | (TableSize, En) => "Size", |
| @@ -563,8 +559,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { | ||
| 563 | 559 | (TableStarted, Tr) => "Başlangıç", |
| 564 | 560 | (TableState, En) => "State", |
| 565 | 561 | (TableState, Tr) => "Durum", |
| 566 | - (TableStatus, En) => "Status", | |
| 567 | - (TableStatus, Tr) => "Durum", | |
| 568 | 562 | (TableSubject, En) => "Subject", |
| 569 | 563 | (TableSubject, Tr) => "Konu", |
| 570 | 564 | (TableTarget, En) => "Target", |
| @@ -800,6 +794,7 @@ mod tests { | ||
| 800 | 794 | K::AdminArea, |
| 801 | 795 | K::Administrator, |
| 802 | 796 | K::AllActions, |
| 797 | + K::RowActions, | |
| 803 | 798 | K::Anonymous, |
| 804 | 799 | K::AtLeast12Chars, |
| 805 | 800 | K::AuditIntro, |
| @@ -942,16 +937,13 @@ mod tests { | ||
| 942 | 937 | K::TableActor, |
| 943 | 938 | K::TableDetails, |
| 944 | 939 | K::TableDuration, |
| 945 | - K::TableError, | |
| 946 | 940 | K::TableKind, |
| 947 | 941 | K::TableLastError, |
| 948 | 942 | K::TableQueued, |
| 949 | - K::TableRepo, | |
| 950 | 943 | K::TableResult, |
| 951 | 944 | K::TableSize, |
| 952 | 945 | K::TableStarted, |
| 953 | 946 | K::TableState, |
| 954 | - K::TableStatus, | |
| 955 | 947 | K::TableSubject, |
| 956 | 948 | K::TableTarget, |
| 957 | 949 | K::TableTo, |
crates/forge-web/src/i18n/integrations.rsmodified+0 -40
| @@ -15,14 +15,6 @@ pub enum K { | ||
| 15 | 15 | ArchivedNotice, |
| 16 | 16 | BackToWebhooks, |
| 17 | 17 | ClearSecret, |
| 18 | - ColActive, | |
| 19 | - ColDirection, | |
| 20 | - ColEnabled, | |
| 21 | - ColEvents, | |
| 22 | - ColInterval, | |
| 23 | - ColLastDelivery, | |
| 24 | - ColLastSync, | |
| 25 | - ColResult, | |
| 26 | 18 | CreateWebhook, |
| 27 | 19 | CurrentUrl, |
| 28 | 20 | DeleteConfirm, |
| @@ -63,7 +55,6 @@ pub enum K { | ||
| 63 | 55 | Mirrors, |
| 64 | 56 | MirrorsIntro, |
| 65 | 57 | Never, |
| 66 | - No, | |
| 67 | 58 | NoDeliveries, |
| 68 | 59 | NoMirrors, |
| 69 | 60 | NoWebhooks, |
| @@ -118,7 +109,6 @@ pub enum K { | ||
| 118 | 109 | UsernameOptional, |
| 119 | 110 | Webhooks, |
| 120 | 111 | WebhooksIntro, |
| 121 | - Yes, | |
| 122 | 112 | } |
| 123 | 113 | |
| 124 | 114 | /// Every key, so the tests can walk them. |
| @@ -135,14 +125,6 @@ pub const ALL: &[K] = &[ | ||
| 135 | 125 | K::ArchivedNotice, |
| 136 | 126 | K::BackToWebhooks, |
| 137 | 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 | 128 | K::CreateWebhook, |
| 147 | 129 | K::CurrentUrl, |
| 148 | 130 | K::DeleteConfirm, |
| @@ -183,7 +165,6 @@ pub const ALL: &[K] = &[ | ||
| 183 | 165 | K::Mirrors, |
| 184 | 166 | K::MirrorsIntro, |
| 185 | 167 | K::Never, |
| 186 | - K::No, | |
| 187 | 168 | K::NoDeliveries, |
| 188 | 169 | K::NoMirrors, |
| 189 | 170 | K::NoWebhooks, |
| @@ -238,7 +219,6 @@ pub const ALL: &[K] = &[ | ||
| 238 | 219 | K::UsernameOptional, |
| 239 | 220 | K::Webhooks, |
| 240 | 221 | K::WebhooksIntro, |
| 241 | - K::Yes, | |
| 242 | 222 | ]; |
| 243 | 223 | |
| 244 | 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 | 264 | (BackToWebhooks, Tr) => "Web kancalarına dön", |
| 285 | 265 | (ClearSecret, En) => "Clear the stored password or token", |
| 286 | 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 | 267 | (CreateWebhook, En) => "Create webhook", |
| 304 | 268 | (CreateWebhook, Tr) => "Web kancası oluştur", |
| 305 | 269 | (CurrentUrl, En) => "Current URL:", |
| @@ -406,8 +370,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { | ||
| 406 | 370 | } |
| 407 | 371 | (Never, En) => "never", |
| 408 | 372 | (Never, Tr) => "hiç", |
| 409 | - (No, En) => "no", | |
| 410 | - (No, Tr) => "hayır", | |
| 411 | 373 | (NoDeliveries, En) => "No deliveries yet.", |
| 412 | 374 | (NoDeliveries, Tr) => "Henüz teslimat yok.", |
| 413 | 375 | (NoMirrors, En) => "No mirrors yet.", |
| @@ -554,8 +516,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { | ||
| 554 | 516 | (WebhooksIntro, Tr) => { |
| 555 | 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 | 332 | <input type="hidden" name="state" value=(filter_param.as_str())> |
| 333 | 333 | <button type="submit">(g::t(lang, K::MailRetryNow))</button> |
| 334 | 334 | </form> |
| 335 | - <form method="post" action="/admin/mail/queue/discard"> | |
| 336 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | |
| 337 | - <input type="hidden" name="id" value=(row.id.as_str())> | |
| 338 | - <input type="hidden" name="state" value=(filter_param.as_str())> | |
| 339 | - <button type="submit">(g::t(lang, K::MailDiscard))</button> | |
| 340 | - </form> | |
| 335 | + <details class="row-menu"> | |
| 336 | + <summary class="button row-menu-btn" aria-label=(g::t(lang, K::RowActions)) aria-haspopup="menu">"⋯"</summary> | |
| 337 | + <div class="row-menu-panel" role="menu"> | |
| 338 | + <form method="post" action="/admin/mail/queue/discard" class="inline-form"> | |
| 339 | + <input type="hidden" name="csrf" value=(csrf.as_str())> | |
| 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 | 347 | </td> |
| 343 | 348 | </tr> |
crates/forge-web/src/pages/admin_replication.rsmodified+49 -25
| @@ -46,6 +46,25 @@ enum Health { | ||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 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 | 68 | fn label(self, lang: Lang) -> &'static str { |
| 50 | 69 | match self { |
| 51 | 70 | Health::Ok => g::t(lang, K::HealthOk), |
| @@ -73,6 +92,8 @@ fn health(status: Option<&ReplicationStatus>, cutoff: &str) -> Health { | ||
| 73 | 92 | /// One line of the repos table, already formatted. |
| 74 | 93 | struct RepoRow { |
| 75 | 94 | name: String, |
| 95 | + dot: &'static str, | |
| 96 | + tone: &'static str, | |
| 76 | 97 | health: &'static str, |
| 77 | 98 | last_ok: String, |
| 78 | 99 | error: String, |
| @@ -82,6 +103,7 @@ struct RepoRow { | ||
| 82 | 103 | struct PageData { |
| 83 | 104 | enabled: bool, |
| 84 | 105 | target: String, |
| 106 | + db_dot: &'static str, | |
| 85 | 107 | db_health: &'static str, |
| 86 | 108 | db_last_ok: String, |
| 87 | 109 | db_last_attempt: String, |
| @@ -121,9 +143,12 @@ async fn page_data(state: &AppState, tz: &str, lang: Lang) -> forge_core::Result | ||
| 121 | 143 | Some(repo) => format!("{}/{}", repo.owner_name, repo.name), |
| 122 | 144 | None => id.clone(), |
| 123 | 145 | }; |
| 146 | + let h = health(status, &repo_cutoff); | |
| 124 | 147 | repos.push(RepoRow { |
| 125 | 148 | name, |
| 126 | - health: health(status, &repo_cutoff).label(lang), | |
| 149 | + dot: h.dot(), | |
| 150 | + tone: h.tone(), | |
| 151 | + health: h.label(lang), | |
| 127 | 152 | last_ok: ok_text(status.and_then(|s| s.last_ok_at.as_deref()), tz, lang), |
| 128 | 153 | error: status |
| 129 | 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 | 158 | // Repos deleted since their last push: their standby copy is removed at the next reconcile. |
| 134 | 159 | for status in statuses.values() { |
| 135 | 160 | if status.subject != DB_SUBJECT && !ids.contains(&status.subject) { |
| 161 | + let h = health(Some(status), &repo_cutoff); | |
| 136 | 162 | repos.push(RepoRow { |
| 137 | 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 | 167 | last_ok: ok_text(status.last_ok_at.as_deref(), tz, lang), |
| 140 | 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 | 173 | Ok(PageData { |
| 146 | 174 | enabled: config.enabled(), |
| 147 | 175 | target: config.target.clone(), |
| 176 | + db_dot: health(db, &db_cutoff).dot(), | |
| 148 | 177 | db_health: health(db, &db_cutoff).label(lang), |
| 149 | 178 | db_last_ok: ok_text(db.and_then(|s| s.last_ok_at.as_deref()), tz, lang), |
| 150 | 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 | 213 | <dt>(g::t(lang, K::ReplicationTarget))</dt><dd><code>(data.target.as_str())</code></dd> |
| 185 | 214 | <dt>(g::t(lang, K::Interval))</dt><dd>(data.interval.as_str())</dd> |
| 186 | 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 | 217 | <dt>(g::t(lang, K::LastDbSnapshotShipped))</dt><dd class="small">(data.db_last_ok.as_str())</dd> |
| 189 | 218 | <dt>(g::t(lang, K::LastDbAttempt))</dt><dd class="small">(data.db_last_attempt.as_str())</dd> |
| 190 | 219 | </dl> |
| @@ -206,28 +235,23 @@ async fn replication_view( | ||
| 206 | 235 | if data.repos.is_empty() { |
| 207 | 236 | <p class="muted">(g::t(lang, K::NoReposYet))</p> |
| 208 | 237 | } else { |
| 209 | - <div class="table-wrap"> | |
| 210 | - <table class="table queue-table"> | |
| 211 | - <thead> | |
| 212 | - <tr> | |
| 213 | - <th>(g::t(lang, K::TableRepo))</th> | |
| 214 | - <th>(g::t(lang, K::TableStatus))</th> | |
| 215 | - <th>(g::t(lang, K::LastSuccess))</th> | |
| 216 | - <th>(g::t(lang, K::TableError))</th> | |
| 217 | - </tr> | |
| 218 | - </thead> | |
| 219 | - <tbody> | |
| 220 | - for row in data.repos.into_iter() { | |
| 221 | - <tr> | |
| 222 | - <td data-label=(g::t(lang, K::TableRepo))>(row.name.as_str())</td> | |
| 223 | - <td data-label=(g::t(lang, K::TableStatus))>(row.health)</td> | |
| 224 | - <td class="small" data-label=(g::t(lang, K::LastSuccess))>(row.last_ok.as_str())</td> | |
| 225 | - <td class="small" data-label=(g::t(lang, K::TableError))>(row.error.as_str())</td> | |
| 226 | - </tr> | |
| 227 | - } | |
| 228 | - </tbody> | |
| 229 | - </table> | |
| 230 | - </div> | |
| 238 | + <ul class="admin-rows"> | |
| 239 | + for row in data.repos.into_iter() { | |
| 240 | + <li class="admin-row"> | |
| 241 | + <div class="admin-row-main"> | |
| 242 | + <div class="runner-title"> | |
| 243 | + <span class=(row.dot) aria-hidden="true"></span> | |
| 244 | + <span class="admin-row-name">(row.name.as_str())</span> | |
| 245 | + </div> | |
| 246 | + <p class="runner-meta muted">(g::t(lang, K::LastSuccess))": "(row.last_ok.as_str())</p> | |
| 247 | + if !row.error.is_empty() { | |
| 248 | + <p class="admin-row-error">(row.error.as_str())</p> | |
| 249 | + } | |
| 250 | + </div> | |
| 251 | + <span class=(format!("admin-row-state {}", row.tone))>(row.health)</span> | |
| 252 | + </li> | |
| 253 | + } | |
| 254 | + </ul> | |
| 231 | 255 | } |
| 232 | 256 | </section> |
| 233 | 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 | 26 | use crate::pages::issues_list::stamp_unix; |
| 27 | 27 | use crate::pages::passkeys::s; |
| 28 | 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 | 31 | #[query_params(error = bad_request)] |
| 32 | 32 | pub(crate) struct DoneQuery { |
| @@ -49,6 +49,8 @@ struct Detail { | ||
| 49 | 49 | facts: AccountFacts, |
| 50 | 50 | suspension: Option<Suspension>, |
| 51 | 51 | passkeys: i64, |
| 52 | + /// An administrator with no other administrator beside them: demoting is refused. | |
| 53 | + last_admin: bool, | |
| 52 | 54 | } |
| 53 | 55 | |
| 54 | 56 | /// What the page says above the facts after an action. |
| @@ -86,6 +88,7 @@ async fn load(cx: &Cx) -> Result<Detail> { | ||
| 86 | 88 | facts: store.account_facts(&target.id).await?, |
| 87 | 89 | suspension: store.suspension(&target.id).await?, |
| 88 | 90 | passkeys: store.passkey_count(&target.id).await?, |
| 91 | + last_admin: target.is_admin && store.other_admin_count(&target.id).await? == 0, | |
| 89 | 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 | 112 | #[component] |
| 117 | 113 | async fn detail_body( |
| 118 | 114 | lang: Lang, |
| @@ -127,11 +123,12 @@ async fn detail_body( | ||
| 127 | 123 | facts, |
| 128 | 124 | suspension, |
| 129 | 125 | passkeys, |
| 126 | + last_admin, | |
| 130 | 127 | } = detail; |
| 131 | 128 | let base = format!("/admin/users/{}", enc(&target.id)); |
| 132 | 129 | let own = target.id == viewer_id; |
| 133 | 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 | 132 | let repos = facts.repo_count.to_string(); |
| 136 | 133 | let suspended = suspension.is_some(); |
| 137 | 134 | let status = if suspended { |
| @@ -139,23 +136,20 @@ async fn detail_body( | ||
| 139 | 136 | } else { |
| 140 | 137 | at(lang, A::Active) |
| 141 | 138 | }; |
| 142 | - let tfa = if facts.two_factor { | |
| 143 | - at(lang, A::On) | |
| 139 | + let dot_class = if suspended { | |
| 140 | + "user-dot is-suspended" | |
| 144 | 141 | } else { |
| 145 | - at(lang, A::Off) | |
| 142 | + "user-dot is-active" | |
| 146 | 143 | }; |
| 147 | - let role = if target.is_admin { | |
| 148 | - at(lang, A::Administrator) | |
| 149 | - } else { | |
| 150 | - g::t(lang, K::RoleUser) | |
| 144 | + let tfa_on = facts.two_factor; | |
| 145 | + let tfa = if tfa_on { at(lang, A::On) } else { at(lang, A::Off) }; | |
| 146 | + let is_admin = target.is_admin; | |
| 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 | 151 | let email = target.email.clone().unwrap_or_default(); |
| 157 | - let is_admin = target.is_admin; | |
| 158 | - let tfa_on = facts.two_factor; | |
| 152 | + let avatar = avatar_url(&target.username, target.avatar_hash.as_deref()); | |
| 159 | 153 | let suspend_action = format!("{base}/suspend"); |
| 160 | 154 | let unsuspend_action = format!("{base}/unsuspend"); |
| 161 | 155 | let admin_action = format!("{base}/admin"); |
| @@ -168,10 +162,37 @@ async fn detail_body( | ||
| 168 | 162 | let Notice { done, error, link } = notice; |
| 169 | 163 | Ok(view! { |
| 170 | 164 | <div data-live=(live.as_str())> |
| 171 | - <section class="page-head"> | |
| 172 | - <h1>(target.username.as_str())</h1> | |
| 165 | + <section class="user-head"> | |
| 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 | 193 | </section> |
| 174 | - <section class="card"> | |
| 194 | + <section class="card user-actions"> | |
| 195 | + <h2>(at(lang, A::Actions))</h2> | |
| 175 | 196 | if let Some(message) = done { |
| 176 | 197 | <p class="notice" role="status">(message)</p> |
| 177 | 198 | } |
| @@ -182,97 +203,128 @@ async fn detail_body( | ||
| 182 | 203 | <p>(at(lang, A::ResetLinkReady))</p> |
| 183 | 204 | <code class="reset-link">(link.as_str())</code> |
| 184 | 205 | } |
| 185 | - <dl class="kv-grid"> | |
| 186 | - <div><dt>(at(lang, A::Status))</dt><dd>(status)</dd></div> | |
| 187 | - <div><dt>(i18n::t(lang, Key::Email))</dt><dd>(email.as_str())</dd></div> | |
| 188 | - <div><dt>(g::t(lang, K::Role))</dt><dd>(role)</dd></div> | |
| 189 | - <div><dt>(i18n::t(lang, Key::Created))</dt><dd>(created.as_str())</dd></div> | |
| 190 | - <div><dt>(at(lang, A::LastLogin))</dt><dd>(last_login.as_str())</dd></div> | |
| 191 | - <div><dt>(at(lang, A::Repositories))</dt><dd>(repos.as_str())</dd></div> | |
| 192 | - <div><dt>(at(lang, A::TwoFactor))</dt><dd>(tfa)</dd></div> | |
| 193 | - <div><dt>(s(lang, "Passkeys", "Geçiş anahtarları"))</dt><dd>(passkey_count.as_str())</dd></div> | |
| 194 | - </dl> | |
| 195 | - </section> | |
| 196 | - <section class="card"> | |
| 197 | - <h2>(at(lang, A::Actions))</h2> | |
| 198 | - <div class="action-grid"> | |
| 199 | - <div class="action-box"> | |
| 200 | - <h3>(if suspended { at(lang, A::Unsuspend) } else { at(lang, A::Suspend) })</h3> | |
| 201 | - if suspended { | |
| 202 | - <p class="muted small">(reason.as_str())</p> | |
| 203 | - <form method="post" action=(unsuspend_action.as_str())> | |
| 204 | - <input type="hidden" name="csrf" value=(csrf)> | |
| 205 | - <button type="submit">(at(lang, A::Unsuspend))</button> | |
| 206 | - </form> | |
| 207 | - } else if own { | |
| 208 | - <p class="muted small">(at(lang, A::ErrSelf))</p> | |
| 209 | - } else { | |
| 210 | - <p class="muted small">(at(lang, A::SuspendHelp))</p> | |
| 211 | - <form method="post" action=(suspend_action.as_str())> | |
| 212 | - <input type="hidden" name="csrf" value=(csrf)> | |
| 213 | - <label> | |
| 214 | - <span>(at(lang, A::SuspendReason))</span> | |
| 215 | - <input type="text" name="reason" maxlength="300" autocomplete="off"> | |
| 216 | - </label> | |
| 217 | - <button type="submit" class="danger">(at(lang, A::Suspend))</button> | |
| 218 | - </form> | |
| 219 | - } | |
| 220 | - </div> | |
| 221 | - <div class="action-box"> | |
| 222 | - <h3>(at(lang, A::Administrator))</h3> | |
| 223 | - <p class="muted small">(at(lang, A::AdminHelp))</p> | |
| 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())> | |
| 206 | + <ul class="action-list"> | |
| 207 | + if suspended { | |
| 208 | + <li class="action-row"> | |
| 209 | + <div class="action-text"> | |
| 210 | + <h3>(at(lang, A::Unsuspend))</h3> | |
| 211 | + <p class="muted small">(suspended_note.as_str())</p> | |
| 212 | + </div> | |
| 213 | + <div class="action-control"> | |
| 214 | + <form method="post" action=(unsuspend_action.as_str())> | |
| 215 | + <input type="hidden" name="csrf" value=(csrf)> | |
| 216 | + <button type="submit">(at(lang, A::Unsuspend))</button> | |
| 217 | + </form> | |
| 218 | + </div> | |
| 219 | + </li> | |
| 220 | + } | |
| 221 | + <li class="action-row"> | |
| 222 | + <div class="action-text"> | |
| 223 | + <h3>(at(lang, A::Administrator))</h3> | |
| 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> | |
| 225 | + </div> | |
| 226 | + <div class="action-control"> | |
| 227 | + if last_admin { | |
| 228 | + <p class="muted small">(at(lang, A::AdminHelp))</p> | |
| 229 | + } else { | |
| 230 | + <form method="post" action=(admin_action.as_str())> | |
| 231 | + <input type="hidden" name="csrf" value=(csrf)> | |
| 232 | + <input type="hidden" name="admin" value=(if is_admin { "0" } else { "1" })> | |
| 233 | + <button type="submit">(if is_admin { at(lang, A::RevokeAdmin) } else { at(lang, A::GrantAdmin) })</button> | |
| 234 | + </form> | |
| 235 | + } | |
| 236 | + </div> | |
| 237 | + </li> | |
| 238 | + <li class="action-row"> | |
| 239 | + <div class="action-text"> | |
| 240 | + <h3>(at(lang, A::ResetPassword))</h3> | |
| 241 | + <p class="muted small">(at(lang, A::ResetHelp))</p> | |
| 242 | + </div> | |
| 243 | + <div class="action-control"> | |
| 244 | + <form method="post" action=(reset_action.as_str())> | |
| 243 | 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 | 247 | </form> |
| 246 | - } else { | |
| 247 | - <p class="small">(at(lang, A::Off))</p> | |
| 248 | - } | |
| 249 | - </div> | |
| 250 | - <div class="action-box"> | |
| 251 | - <h3>(s(lang, "Remove all passkeys", "Tüm geçiş anahtarlarını kaldır"))</h3> | |
| 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> | |
| 253 | - if passkeys > 0 { | |
| 254 | - <details class="confirm-inline"> | |
| 255 | - <summary class="button danger">(s(lang, "Remove all passkeys", "Tüm geçiş anahtarlarını kaldır"))</summary> | |
| 256 | - <div class="confirm-pop"> | |
| 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> | |
| 258 | - <form method="post" action=(passkeys_action.as_str())> | |
| 248 | + </div> | |
| 249 | + </li> | |
| 250 | + </ul> | |
| 251 | + </section> | |
| 252 | + <section class="card user-danger"> | |
| 253 | + <h2>(i18n::t(lang, Key::DangerZone))</h2> | |
| 254 | + <ul class="action-list"> | |
| 255 | + if !suspended { | |
| 256 | + <li class="action-row"> | |
| 257 | + <div class="action-text"> | |
| 258 | + <h3>(at(lang, A::Suspend))</h3> | |
| 259 | + <p class="muted small">(at(lang, A::SuspendHelp))</p> | |
| 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 | 266 | <input type="hidden" name="csrf" value=(csrf)> |
| 260 | - <button type="submit" class="danger">(s(lang, "Remove all", "Hepsini kaldır"))</button> | |
| 261 | - <button type="button" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> | |
| 267 | + <label class="action-field"> | |
| 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 | 272 | </form> |
| 263 | - </div> | |
| 264 | - </details> | |
| 265 | - } else { | |
| 266 | - <p class="small">(at(lang, A::Off))</p> | |
| 267 | - } | |
| 268 | - </div> | |
| 269 | - </div> | |
| 270 | - <p class="link-row"> | |
| 271 | - <a href="/admin/users">(g::t(lang, K::BackToUsers))</a> | |
| 273 | + } | |
| 274 | + </div> | |
| 275 | + </li> | |
| 276 | + } | |
| 277 | + <li class="action-row"> | |
| 278 | + <div class="action-text"> | |
| 279 | + <h3>(at(lang, A::Disable2fa))</h3> | |
| 280 | + <p class="muted small">(at(lang, A::Disable2faHelp))</p> | |
| 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 | 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 | 328 | </section> |
| 277 | 329 | </div> |
| 278 | 330 | }) |
| @@ -289,15 +341,17 @@ async fn account_fingerprint(store: &Store, user_id: &str) -> Result<String> { | ||
| 289 | 341 | let facts = store.account_facts(user_id).await?; |
| 290 | 342 | let suspension = store.suspension(user_id).await?; |
| 291 | 343 | let passkeys = store.passkey_count(user_id).await?; |
| 344 | + let other_admins = store.other_admin_count(user_id).await?; | |
| 292 | 345 | Ok(format!( |
| 293 | - "{}|{}|{}|{}|{:?}|{:?}|{}", | |
| 346 | + "{}|{}|{}|{}|{:?}|{:?}|{}|{}", | |
| 294 | 347 | target.username, |
| 295 | 348 | target.email.as_deref().unwrap_or(""), |
| 296 | 349 | target.is_admin, |
| 297 | 350 | target.created_at, |
| 298 | 351 | facts, |
| 299 | 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 | 22 | load_org, member_role_word, notice_href, org_head, org_notice, parse_member_role, |
| 23 | 23 | require_form_csrf, require_member, require_owner, take_notice, |
| 24 | 24 | }; |
| 25 | +use crate::pages::passkeys; | |
| 25 | 26 | use crate::state::AppState; |
| 26 | 27 | use crate::views::{avatar_url, display_name, shell}; |
| 27 | 28 | |
| @@ -89,7 +90,7 @@ async fn members_body( | ||
| 89 | 90 | <section class="card"> |
| 90 | 91 | <h2>(g::t(lang, K::Members))</h2> |
| 91 | 92 | <div class="table-wrap"> |
| 92 | - <table class="table collaborators"> | |
| 93 | + <table class="table collaborators members-table"> | |
| 93 | 94 | <thead> |
| 94 | 95 | <tr> |
| 95 | 96 | <th>(g::t(lang, K::MemberHeader))</th> |
| @@ -123,11 +124,16 @@ async fn members_body( | ||
| 123 | 124 | </td> |
| 124 | 125 | <td> |
| 125 | 126 | if owner || row.is_self { |
| 126 | - <form method="post" action=(remove_action.as_str()) class="remove-form"> | |
| 127 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | |
| 128 | - <input type="hidden" name="user_id" value=(row.user_id.as_str())> | |
| 129 | - <button type="submit">(if row.is_self { g::t(lang, K::Leave) } else { g::t(lang, K::Remove) })</button> | |
| 130 | - </form> | |
| 127 | + <details class="row-menu"> | |
| 128 | + <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> | |
| 129 | + <div class="row-menu-panel" role="menu"> | |
| 130 | + <form method="post" action=(remove_action.as_str()) class="inline-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 | 138 | </td> |
| 133 | 139 | </tr> |
crates/forge-web/src/pages/org_teams.rsmodified+21 -10
| @@ -22,6 +22,7 @@ use crate::pages::org_ctx::{ | ||
| 22 | 22 | OrgCtx, TEAM_ROLES, load_org, notice_href, org_head, org_notice, require_form_csrf, |
| 23 | 23 | require_member, require_owner, take_notice, |
| 24 | 24 | }; |
| 25 | +use crate::pages::passkeys; | |
| 25 | 26 | use crate::state::AppState; |
| 26 | 27 | use crate::views::{avatar_url, display_name, repo_href, shell}; |
| 27 | 28 | |
| @@ -358,11 +359,16 @@ async fn team_body( | ||
| 358 | 359 | </a> |
| 359 | 360 | </div> |
| 360 | 361 | if owner { |
| 361 | - <form method="post" action=(remove_member_action.as_str()) class="remove-form"> | |
| 362 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | |
| 363 | - <input type="hidden" name="user_id" value=(member.user_id.as_str())> | |
| 364 | - <button type="submit">(g::t(lang, K::Remove))</button> | |
| 365 | - </form> | |
| 362 | + <details class="row-menu"> | |
| 363 | + <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> | |
| 364 | + <div class="row-menu-panel" role="menu"> | |
| 365 | + <form method="post" action=(remove_member_action.as_str()) class="inline-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 | 373 | </li> |
| 368 | 374 | } |
| @@ -388,11 +394,16 @@ async fn team_body( | ||
| 388 | 394 | <a href=(repo.href.as_str())>(repo.title.as_str())</a> |
| 389 | 395 | </div> |
| 390 | 396 | if owner { |
| 391 | - <form method="post" action=(remove_repo_action.as_str()) class="remove-form"> | |
| 392 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | |
| 393 | - <input type="hidden" name="repo_id" value=(repo.repo_id.as_str())> | |
| 394 | - <button type="submit">(g::t(lang, K::Unlink))</button> | |
| 395 | - </form> | |
| 397 | + <details class="row-menu"> | |
| 398 | + <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> | |
| 399 | + <div class="row-menu-panel" role="menu"> | |
| 400 | + <form method="post" action=(remove_repo_action.as_str()) class="inline-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 | 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 | 25 | use crate::auth::{require_csrf, require_user}; |
| 26 | 26 | use crate::i18n::repo_admin::{self as g, K}; |
| 27 | 27 | use crate::i18n::{self, Lang}; |
| 28 | +use crate::pages::passkeys; | |
| 28 | 29 | use crate::pages::repo::repo_head; |
| 29 | 30 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 30 | 31 | use crate::pages::repo_settings::settings_nav_for; |
| @@ -185,7 +186,7 @@ async fn collaborators_table( | ||
| 185 | 186 | <p class="muted">(g::t(lang, K::NoCollaborators))</p> |
| 186 | 187 | } else { |
| 187 | 188 | <div class="table-wrap"> |
| 188 | - <table class="table collaborators"> | |
| 189 | + <table class="table collaborators members-table"> | |
| 189 | 190 | <thead> |
| 190 | 191 | <tr> |
| 191 | 192 | <th>(g::t(lang, K::ColUser))</th> |
| @@ -222,11 +223,16 @@ async fn collaborators_table( | ||
| 222 | 223 | </form> |
| 223 | 224 | </td> |
| 224 | 225 | <td> |
| 225 | - <form method="post" action=(remove_action.as_str()) class="remove-form"> | |
| 226 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | |
| 227 | - <input type="hidden" name="user_id" value=(row.user_id.as_str())> | |
| 228 | - <button type="submit">(g::t(lang, K::Remove))</button> | |
| 229 | - </form> | |
| 226 | + <details class="row-menu"> | |
| 227 | + <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> | |
| 228 | + <div class="row-menu-panel" role="menu"> | |
| 229 | + <form method="post" action=(remove_action.as_str()) class="inline-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 | 236 | </td> |
| 231 | 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 | 26 | use crate::audit::{self, Actor, Target}; |
| 27 | 27 | use crate::auth::{require_csrf, require_user}; |
| 28 | +use crate::i18n::admin as adm; | |
| 28 | 29 | use crate::i18n::{ |
| 29 | 30 | self, Lang, |
| 30 | 31 | integrations::{self as g, K}, |
| @@ -35,7 +36,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | ||
| 35 | 36 | use crate::pages::repo_settings::settings_nav_for; |
| 36 | 37 | use crate::pages::repo_settings_live::settings_head; |
| 37 | 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 | 40 | use crate::webhooks::client::{WebhookPolicy, validate_url}; |
| 40 | 41 | |
| 41 | 42 | path_param!(owner); |
| @@ -318,14 +319,38 @@ struct MirrorRow { | ||
| 318 | 319 | url: String, |
| 319 | 320 | interval: String, |
| 320 | 321 | enabled: bool, |
| 322 | + /// The last sync in the viewer's zone, for the `title` tooltip. Empty when never synced. | |
| 321 | 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 | 333 | status_text: &'static str, |
| 324 | 334 | error: String, |
| 325 | 335 | } |
| 326 | 336 | |
| 327 | 337 | fn mirror_row(lang: Lang, mirror: &Mirror, title: &str, tz: &str) -> MirrorRow { |
| 328 | 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 | 354 | MirrorRow { |
| 330 | 355 | href: mirror_href(title, &mirror.id), |
| 331 | 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 | 363 | .as_deref() |
| 339 | 364 | .map(|stamp| stamp_in_tz(stamp, tz)) |
| 340 | 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 | 371 | status_text, |
| 343 | 372 | error: mirror.last_error.clone().unwrap_or_default(), |
| 344 | 373 | } |
| @@ -483,49 +512,42 @@ async fn mirrors_list_body( | ||
| 483 | 512 | if rows.is_empty() { |
| 484 | 513 | <p class="muted">(g::t(lang, K::NoMirrors))</p> |
| 485 | 514 | } else { |
| 486 | - <div class="table-wrap"> | |
| 487 | - <table class="table mirrors"> | |
| 488 | - <thead> | |
| 489 | - <tr> | |
| 490 | - <th>(g::t(lang, K::ColDirection))</th> | |
| 491 | - <th>"URL"</th> | |
| 492 | - <th>(g::t(lang, K::ColInterval))</th> | |
| 493 | - <th>(g::t(lang, K::ColEnabled))</th> | |
| 494 | - <th>(g::t(lang, K::ColLastSync))</th> | |
| 495 | - <th>(g::t(lang, K::ColResult))</th> | |
| 496 | - <th></th> | |
| 497 | - </tr> | |
| 498 | - </thead> | |
| 499 | - <tbody> | |
| 500 | - for row in rows.iter() { | |
| 501 | - <tr> | |
| 502 | - <td>(row.direction)</td> | |
| 503 | - <td><a href=(row.href.as_str())><code>(row.url.as_str())</code></a></td> | |
| 504 | - <td>(row.interval.as_str())</td> | |
| 505 | - <td>(if row.enabled { g::t(lang, K::Yes) } else { g::t(lang, K::No) })</td> | |
| 506 | - <td>(row.last_sync.as_str())</td> | |
| 507 | - <td> | |
| 508 | - <span class=(format!("hook-state {}", row.status_class))>(row.status_text)</span> | |
| 509 | - if !row.error.is_empty() { | |
| 510 | - <details> | |
| 511 | - <summary>(g::t(lang, K::ErrorLabel))</summary> | |
| 512 | - <pre class="mirror-error">(row.error.as_str())</pre> | |
| 513 | - </details> | |
| 514 | - } | |
| 515 | - </td> | |
| 516 | - <td> | |
| 517 | - if !archived { | |
| 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> | |
| 515 | + <ul class="runner-list mirror-list"> | |
| 516 | + for row in rows.iter() { | |
| 517 | + <li class="runner-row"> | |
| 518 | + <div class="runner-id"> | |
| 519 | + <div class="runner-title"> | |
| 520 | + <span class=(row.dot_class) role="img" aria-label=(row.status_text) title=(row.status_text)></span> | |
| 521 | + <a class="runner-name mirror-url" href=(row.href.as_str())>(row.url.as_str())</a> | |
| 522 | + </div> | |
| 523 | + <p class="runner-meta muted"> | |
| 524 | + (row.direction)" · "(row.interval.as_str()) | |
| 525 | + if !row.enabled { | |
| 526 | + " · "(adm::t(lang, adm::K::Disabled)) | |
| 527 | + } | |
| 528 | + " · " | |
| 529 | + if row.last_sync_at.is_empty() { | |
| 530 | + (g::t(lang, K::StatusNotRun)) | |
| 531 | + } else { | |
| 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) | |
| 533 | + } | |
| 534 | + </p> | |
| 535 | + if !row.error.is_empty() { | |
| 536 | + <details class="mirror-failure"> | |
| 537 | + <summary>(g::t(lang, K::ErrorLabel))</summary> | |
| 538 | + <pre class="mirror-error">(row.error.as_str())</pre> | |
| 539 | + </details> | |
| 540 | + } | |
| 541 | + </div> | |
| 542 | + if !archived { | |
| 543 | + <form method="post" action=(row.sync_action.as_str()) class="inline-form"> | |
| 544 | + <input type="hidden" name="csrf" value=(csrf.as_str())> | |
| 545 | + <button type="submit" class="hook-sync">(g::t(lang, K::SyncNow))</button> | |
| 546 | + </form> | |
| 525 | 547 | } |
| 526 | - </tbody> | |
| 527 | - </table> | |
| 528 | - </div> | |
| 548 | + </li> | |
| 549 | + } | |
| 550 | + </ul> | |
| 529 | 551 | } |
| 530 | 552 | </section> |
| 531 | 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 | 31 | use crate::pages::repo_settings::settings_nav_for; |
| 32 | 32 | use crate::pages::repo_settings_live::settings_head; |
| 33 | 33 | use crate::state::AppState; |
| 34 | -use crate::views::{alert, enc, shell}; | |
| 34 | +use crate::views::{alert, enc, now_unix, relative_time, shell}; | |
| 35 | 35 | use crate::webhooks::client::{WebhookPolicy, validate_url}; |
| 36 | 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 | 310 | struct HookRow { |
| 311 | 311 | href: String, |
| 312 | 312 | url: String, |
| 313 | + /// The subscribed events, joined with ", ". | |
| 313 | 314 | events: String, |
| 314 | 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 | 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 | 401 | /// One delivery on the hook page, with every value already formatted for display. |
| @@ -491,34 +574,34 @@ async fn hooks_list_body( | ||
| 491 | 574 | if rows.is_empty() { |
| 492 | 575 | <p class="muted">(g::t(lang, K::NoWebhooks))</p> |
| 493 | 576 | } else { |
| 494 | - <div class="table-wrap"> | |
| 495 | - <table class="table webhooks"> | |
| 496 | - <thead> | |
| 497 | - <tr> | |
| 498 | - <th>"URL"</th> | |
| 499 | - <th>(g::t(lang, K::ColEvents))</th> | |
| 500 | - <th>(g::t(lang, K::ColActive))</th> | |
| 501 | - <th>(g::t(lang, K::ColLastDelivery))</th> | |
| 502 | - </tr> | |
| 503 | - </thead> | |
| 504 | - <tbody> | |
| 505 | - for row in rows.iter() { | |
| 506 | - <tr> | |
| 507 | - <td><a href=(row.href.as_str())><code>(row.url.as_str())</code></a></td> | |
| 508 | - <td>(row.events.as_str())</td> | |
| 509 | - <td>(if row.active { g::t(lang, K::Yes) } else { g::t(lang, K::No) })</td> | |
| 510 | - <td> | |
| 511 | - if let Some((class, text)) = row.last { | |
| 512 | - <span class=(format!("hook-state {class}"))>(text)</span> | |
| 513 | - } else { | |
| 514 | - <span class="muted">(g::t(lang, K::NoneYet))</span> | |
| 515 | - } | |
| 516 | - </td> | |
| 517 | - </tr> | |
| 518 | - } | |
| 519 | - </tbody> | |
| 520 | - </table> | |
| 521 | - </div> | |
| 577 | + <ul class="runner-list hook-list"> | |
| 578 | + for row in rows.iter() { | |
| 579 | + <li class="runner-row"> | |
| 580 | + <div class="runner-id"> | |
| 581 | + <div class="runner-title"> | |
| 582 | + <span class=(row.dot_class) role="img" aria-label=(row.dot_text) title=(row.dot_text)></span> | |
| 583 | + <a class="runner-name hook-url" href=(row.href.as_str())>(row.url.as_str())</a> | |
| 584 | + </div> | |
| 585 | + <p class="runner-meta muted"> | |
| 586 | + if !row.events.is_empty() { | |
| 587 | + (row.events.as_str())" · " | |
| 588 | + } | |
| 589 | + if row.last_at.is_empty() { | |
| 590 | + (row.last_text) | |
| 591 | + } else { | |
| 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> | |
| 593 | + } | |
| 594 | + if !row.problem.is_empty() { | |
| 595 | + " · "<span class="hook-problem">(row.problem)</span> | |
| 596 | + } | |
| 597 | + if !row.active { | |
| 598 | + " · "(row.inactive_text) | |
| 599 | + } | |
| 600 | + </p> | |
| 601 | + </div> | |
| 602 | + </li> | |
| 603 | + } | |
| 604 | + </ul> | |
| 522 | 605 | } |
| 523 | 606 | </section> |
| 524 | 607 | }) |
| @@ -653,21 +736,24 @@ async fn hooks_list_page(cx: &Cx) -> Result<impl View> { | ||
| 653 | 736 | let hooks = state.store.list_webhooks(&ctx.repo.id).await?; |
| 654 | 737 | let lang = lang_of(cx, &ctx); |
| 655 | 738 | let frame = Frame::new(&ctx, state, lang).await?; |
| 656 | - let rows: Vec<HookRow> = hooks | |
| 657 | - .into_iter() | |
| 658 | - .map(|(hook, last)| HookRow { | |
| 659 | - href: hook_href(&frame.title, &hook.id), | |
| 660 | - url: hook.url, | |
| 661 | - events: hook | |
| 662 | - .events | |
| 663 | - .iter() | |
| 664 | - .map(|e| e.as_str()) | |
| 665 | - .collect::<Vec<_>>() | |
| 666 | - .join(", "), | |
| 667 | - active: hook.active, | |
| 668 | - last: last.map(|last| state_label(lang, last)), | |
| 669 | - }) | |
| 670 | - .collect(); | |
| 739 | + let tz = ctx.viewer_tz(); | |
| 740 | + let mut rows: Vec<HookRow> = Vec::with_capacity(hooks.len()); | |
| 741 | + for (hook, last) in hooks { | |
| 742 | + // The list shows when the newest delivery happened, so it reads the one latest delivery per hook. | |
| 743 | + let last_stamp = if last.is_some() { | |
| 744 | + state | |
| 745 | + .store | |
| 746 | + .list_deliveries(&hook.id, 1) | |
| 747 | + .await? | |
| 748 | + .first() | |
| 749 | + .map(|d| d.created_at.clone()) | |
| 750 | + .unwrap_or_default() | |
| 751 | + } else { | |
| 752 | + String::new() | |
| 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 | 757 | let notice = notice_from_query(cx, lang); |
| 672 | 758 | Ok(view! { |
| 673 | 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 { | |
| 55 | - display: grid; | |
| 56 | - grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); | |
| 54 | +// Admin user detail. The header: a back link, the avatar, the name with a status dot and a role | |
| 55 | +// badge, one muted meta line, then one row of small facts. Under it the actions are hairline rows | |
| 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 | 77 | gap: 16px; |
| 78 | + min-width: 0; | |
| 79 | +} | |
| 58 | 80 | |
| 59 | - .action-box { | |
| 60 | - border: 1px solid var(--border); | |
| 61 | - border-radius: var(--radius-lg); | |
| 62 | - padding: 14px; | |
| 81 | +.user-avatar { | |
| 82 | + flex: none; | |
| 83 | + width: 56px; | |
| 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 | 147 | display: flex; |
| 64 | - flex-direction: column; | |
| 148 | + align-items: baseline; | |
| 65 | 149 | gap: 8px; |
| 66 | 150 | min-width: 0; |
| 151 | + } | |
| 67 | 152 | |
| 68 | - h3 { | |
| 69 | - margin: 0; | |
| 70 | - font-size: 1rem; | |
| 71 | - } | |
| 153 | + dt { | |
| 154 | + color: var(--muted); | |
| 155 | + font-size: 0.8125rem; | |
| 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 | 241 | p { |
| 74 | - margin: 0; | |
| 242 | + margin: 0 0 10px; | |
| 75 | 243 | } |
| 76 | 244 | |
| 77 | 245 | form { |
| 78 | 246 | display: flex; |
| 79 | - flex-direction: column; | |
| 247 | + flex-wrap: wrap; | |
| 80 | 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 | 312 | .reset-link { |
| 87 | 313 | display: block; |
| 88 | 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 | 7752 | @import "account_admin"; |
| 7753 | 7753 | @import "link"; |
| 7754 | +@import "members"; | |
| 7755 | +@import "hooks"; | |
| 7756 | +@import "admin_rows"; | |
| 7754 | 7757 | |
| 7755 | 7758 | // A monospace value with its Copy button on the right; long values wrap inside the box. |
| 7756 | 7759 | .copy-box { |