A profile's head action follows its tab: Edit profile on Overview, New repository on Repositories, New snippet on Snippets, New organization on Organizations, and the lists drop their own New line
Browse files at this commit24d3e506cb9b93b797978bcb27caa78f7acfec39Parent: 9b600b7All checks have passed
Show checks
ci/buildSucceededDetails
- style
- a profile's head action follows its tab: Edit profile on Overview, New repository on Repositories, New snippet on Snippets, New organization on Organizations, and the lists drop their own New line
- the admin account and organization pages read as compact fact lines (a label, its value, and the action for it on the same line), with no hints stacked under headings, and on a phone every label sits over its value
- recent imports leave the import form for an Import history tab beside Create and Import ✨ feat: every log has a When filter (last hour, 24 hours, 7 days, 30 days, today, or From and To days in your timezone) and its tools row starts with how many entries match
- the admin account page shows email and whether it is verified, joined and last sign-in with date, time and address, time zone and language, what the account owns, its organizations, sessions, keys and tokens
- the organization page shows when it was created, its repositories, members with owners, and teams
- profile repositories, stars and snippets and the import history page ten at a time
8 changed files +602 -191
- crates/forge-core/src/audit.rs +4 -0
- crates/forge-core/src/store/audit.rs +8 -0
- crates/forge-web/src/pages/admin_user_detail.rs +307 -111
- crates/forge-web/src/pages/audit_log.rs +131 -6
- crates/forge-web/src/pages/import.rs +41 -46
- crates/forge-web/src/pages/profile.rs +38 -28
- docs/ui-language.md +10 -0
- style/_one.scss +63 -0
crates/forge-core/src/audit.rsmodified+4 -0
| @@ -390,6 +390,10 @@ pub struct AuditFilter { | ||
| 390 | 390 | pub target_id: Option<String>, |
| 391 | 391 | /// Matches entries where this user is the actor, or the `user` target. |
| 392 | 392 | pub involving_user: Option<String>, |
| 393 | + /// Entries stamped at or after this stamp. | |
| 394 | + pub since: Option<String>, | |
| 395 | + /// Entries stamped before this stamp. | |
| 396 | + pub until: Option<String>, | |
| 393 | 397 | } |
| 394 | 398 | |
| 395 | 399 | /// Position in the newest-first listing: the last entry of the previous page. |
crates/forge-core/src/store/audit.rsmodified+8 -0
| @@ -54,6 +54,14 @@ fn audit_where(filter: &AuditFilter, before: Option<&AuditCursor>) -> (String, V | ||
| 54 | 54 | params.push(Value::Text(user.clone())); |
| 55 | 55 | params.push(Value::Text(user.clone())); |
| 56 | 56 | } |
| 57 | + if let Some(since) = &filter.since { | |
| 58 | + clauses.push("at >= ?"); | |
| 59 | + params.push(Value::Text(since.clone())); | |
| 60 | + } | |
| 61 | + if let Some(until) = &filter.until { | |
| 62 | + clauses.push("at < ?"); | |
| 63 | + params.push(Value::Text(until.clone())); | |
| 64 | + } | |
| 57 | 65 | if let Some(cursor) = before { |
| 58 | 66 | clauses.push("(at < ? OR (at = ? AND id < ?))"); |
| 59 | 67 | params.push(Value::Text(cursor.at.clone())); |
crates/forge-web/src/pages/admin_user_detail.rsmodified+307 -111
| @@ -27,7 +27,7 @@ use crate::live::{Topic, stream_changes}; | ||
| 27 | 27 | use crate::pages::admin_users::admin_only; |
| 28 | 28 | use crate::pages::passkeys::s; |
| 29 | 29 | use crate::state::AppState; |
| 30 | -use crate::views::parts::{SubPart, confirm_act, head, post_act, reveal}; | |
| 30 | +use crate::views::parts::{SubPart, confirm_act, head, post_act}; | |
| 31 | 31 | use crate::views::{alert, enc, rel_time, rel_time_or_never, shell, user_facing_message}; |
| 32 | 32 | |
| 33 | 33 | #[query_params(error = bad_request)] |
| @@ -53,6 +53,16 @@ struct Detail { | ||
| 53 | 53 | passkeys: i64, |
| 54 | 54 | /// An administrator with no other administrator beside them: demoting is refused. |
| 55 | 55 | last_admin: bool, |
| 56 | + email_verified: bool, | |
| 57 | + /// The last sign-in's stamp and address. | |
| 58 | + last_login: Option<(String, String)>, | |
| 59 | + sessions: usize, | |
| 60 | + ssh_keys: usize, | |
| 61 | + gpg_keys: usize, | |
| 62 | + tokens: usize, | |
| 63 | + snippets: usize, | |
| 64 | + /// The organizations the account belongs to: name, admin page, role. | |
| 65 | + orgs: Vec<(String, String, OrgMemberRole)>, | |
| 56 | 66 | } |
| 57 | 67 | |
| 58 | 68 | /// What the page says above the facts after an action. |
| @@ -86,7 +96,38 @@ async fn load(cx: &Cx) -> Result<Detail> { | ||
| 86 | 96 | if target.is_org() || is_ghost(&target) { |
| 87 | 97 | return Err(not_found().into()); |
| 88 | 98 | } |
| 99 | + let login_filter = forge_core::AuditFilter { | |
| 100 | + actor_id: Some(target.id.clone()), | |
| 101 | + action: Some(AuditAction::LoginSuccess), | |
| 102 | + ..Default::default() | |
| 103 | + }; | |
| 104 | + let last_login = store | |
| 105 | + .list_audit_page(&login_filter, 0, 1) | |
| 106 | + .await? | |
| 107 | + .into_iter() | |
| 108 | + .next() | |
| 109 | + .map(|entry| (entry.at, entry.ip)); | |
| 110 | + let orgs = store | |
| 111 | + .orgs_for_user(&target.id) | |
| 112 | + .await? | |
| 113 | + .into_iter() | |
| 114 | + .map(|(org, role)| { | |
| 115 | + let href = format!("/admin/users/{}", enc(&org.id)); | |
| 116 | + (org.username, href, role) | |
| 117 | + }) | |
| 118 | + .collect(); | |
| 89 | 119 | Ok(Detail { |
| 120 | + email_verified: store.email_is_verified(&target.id).await?, | |
| 121 | + last_login, | |
| 122 | + sessions: store.list_sessions(&target.id).await?.len(), | |
| 123 | + ssh_keys: store.list_ssh_keys(&target.id).await?.len(), | |
| 124 | + gpg_keys: store.list_gpg_keys(&target.id).await?.len(), | |
| 125 | + tokens: store.list_tokens(&target.id).await?.len(), | |
| 126 | + snippets: store | |
| 127 | + .list_owner_snippets(&target.id, Some(&target.id)) | |
| 128 | + .await? | |
| 129 | + .len(), | |
| 130 | + orgs, | |
| 90 | 131 | facts: store.account_facts(&target.id).await?, |
| 91 | 132 | suspension: store.suspension(&target.id).await?, |
| 92 | 133 | passkeys: store.passkey_count(&target.id).await?, |
| @@ -111,11 +152,19 @@ fn done_text(lang: Lang, done: &str) -> Option<&'static str> { | ||
| 111 | 152 | }) |
| 112 | 153 | } |
| 113 | 154 | |
| 155 | +/// A date and clock time in the viewer's timezone, from a stamp. | |
| 156 | +fn local_stamp(stamp: &str, tz: &str) -> String { | |
| 157 | + forge_core::time::stamp_to_unix(stamp) | |
| 158 | + .map(|unix| forge_core::tz::format_in_tz(unix, tz)) | |
| 159 | + .unwrap_or_default() | |
| 160 | +} | |
| 161 | + | |
| 114 | 162 | #[component] |
| 115 | 163 | async fn detail_body( |
| 116 | 164 | lang: Lang, |
| 117 | 165 | csrf: &str, |
| 118 | 166 | viewer_id: &str, |
| 167 | + tz: String, | |
| 119 | 168 | detail: Detail, |
| 120 | 169 | notice: Notice, |
| 121 | 170 | ) -> Result<impl View> { |
| @@ -125,11 +174,17 @@ async fn detail_body( | ||
| 125 | 174 | suspension, |
| 126 | 175 | passkeys, |
| 127 | 176 | last_admin, |
| 177 | + email_verified, | |
| 178 | + last_login, | |
| 179 | + sessions, | |
| 180 | + ssh_keys, | |
| 181 | + gpg_keys, | |
| 182 | + tokens, | |
| 183 | + snippets, | |
| 184 | + orgs, | |
| 128 | 185 | } = detail; |
| 129 | 186 | let base = format!("/admin/users/{}", enc(&target.id)); |
| 130 | 187 | let own = target.id == viewer_id; |
| 131 | - let last_login = facts.last_login.clone(); | |
| 132 | - let repos = facts.repo_count.to_string(); | |
| 133 | 188 | let suspended = suspension.is_some(); |
| 134 | 189 | let status = if suspended { |
| 135 | 190 | at(lang, A::Suspended) |
| @@ -146,34 +201,52 @@ async fn detail_body( | ||
| 146 | 201 | let role = if is_admin { |
| 147 | 202 | at(lang, A::Administrator) |
| 148 | 203 | } else { |
| 149 | - g::t(lang, K::RoleUser) | |
| 204 | + s(lang, "User", "Kullanıcı") | |
| 150 | 205 | }; |
| 151 | 206 | let suspended_note = match suspension.as_ref().map(|s| s.reason.clone()) { |
| 152 | 207 | Some(reason) if !reason.is_empty() => reason, |
| 153 | 208 | _ => at(lang, A::AccountSuspended).to_owned(), |
| 154 | 209 | }; |
| 210 | + let suspended_since = suspension | |
| 211 | + .as_ref() | |
| 212 | + .map(|s| local_stamp(&s.suspended_at, &tz)) | |
| 213 | + .unwrap_or_default(); | |
| 155 | 214 | let email = target.email.clone().unwrap_or_default(); |
| 215 | + let email_state = if email.is_empty() { | |
| 216 | + s(lang, "none", "yok") | |
| 217 | + } else if email_verified { | |
| 218 | + s(lang, "verified", "doğrulandı") | |
| 219 | + } else { | |
| 220 | + s(lang, "not verified", "doğrulanmadı") | |
| 221 | + }; | |
| 222 | + let display_name = target.display_name.clone().unwrap_or_default(); | |
| 223 | + let joined_at = local_stamp(&target.created_at, &tz); | |
| 224 | + let (login_at, login_ip) = match last_login { | |
| 225 | + Some((stamp, ip)) => (Some(stamp), ip), | |
| 226 | + None => (None, String::new()), | |
| 227 | + }; | |
| 228 | + let login_local = login_at | |
| 229 | + .as_deref() | |
| 230 | + .map(|stamp| local_stamp(stamp, &tz)) | |
| 231 | + .unwrap_or_default(); | |
| 232 | + let language = match target.language.as_str() { | |
| 233 | + "en" => "English".to_owned(), | |
| 234 | + "tr" => "Türkçe".to_owned(), | |
| 235 | + "auto" | "" => s(lang, "Server default", "Sunucu varsayılanı").to_owned(), | |
| 236 | + other => other.to_owned(), | |
| 237 | + }; | |
| 238 | + let timezone = target.timezone.clone(); | |
| 156 | 239 | let suspend_action = format!("{base}/suspend"); |
| 157 | 240 | let unsuspend_action = format!("{base}/unsuspend"); |
| 158 | 241 | let admin_action = format!("{base}/admin"); |
| 159 | 242 | let reset_action = format!("{base}/reset-link"); |
| 160 | 243 | let tfa_action = format!("{base}/disable-2fa"); |
| 161 | 244 | let passkeys_action = format!("{base}/remove-passkeys"); |
| 162 | - let passkey_count = passkeys.to_string(); | |
| 163 | 245 | let delete_href = format!("{base}/delete"); |
| 164 | 246 | let live = format!("{base}/events"); |
| 165 | 247 | let profile = format!("/{}", enc(&target.username)); |
| 166 | - let access_state = format!("{status} · {role}"); | |
| 167 | - let admin_help = s( | |
| 168 | - lang, | |
| 169 | - "Opens the admin area: accounts, runners and server settings.", | |
| 170 | - "Yönetim alanını açar: hesaplar, çalıştırıcılar ve sunucu ayarları.", | |
| 171 | - ); | |
| 172 | - let passkeys_help = s( | |
| 173 | - lang, | |
| 174 | - "For a user who lost their devices. They can still sign in with a password.", | |
| 175 | - "Cihazlarını kaybeden kullanıcı için. Parolayla girmeye devam edebilir.", | |
| 176 | - ); | |
| 248 | + let repos_href = format!("/{}?tab=repositories", enc(&target.username)); | |
| 249 | + let snippets_href = format!("/{}?tab=snippets", enc(&target.username)); | |
| 177 | 250 | let reset_note = s( |
| 178 | 251 | lang, |
| 179 | 252 | "Their sessions end at once.", |
| @@ -184,113 +257,193 @@ async fn detail_body( | ||
| 184 | 257 | "Remove every passkey of this user?", |
| 185 | 258 | "Bu kullanıcının tüm geçiş anahtarları kaldırılsın mı?", |
| 186 | 259 | ); |
| 187 | - let profile_label = s(lang, "Open profile", "Profili aç"); | |
| 188 | - let access_title = s(lang, "Access", "Erişim"); | |
| 189 | - let recovery_title = s(lang, "Recovery", "Kurtarma"); | |
| 190 | - let passkeys_label = s(lang, "Passkeys", "Geçiş anahtarları"); | |
| 191 | - let remove_label = s(lang, "Remove all", "Hepsini kaldır"); | |
| 192 | 260 | let suspend_title = at(lang, A::Suspend); |
| 261 | + let suspend_open = format!("{suspend_title}\u{2026}"); | |
| 262 | + let reason_hint = at(lang, A::SuspendReason); | |
| 263 | + let owner_word = s(lang, "owner", "sahip"); | |
| 264 | + let member_word = s(lang, "member", "üye"); | |
| 265 | + let has_orgs = !orgs.is_empty(); | |
| 266 | + let org_rows: Vec<(String, String, &str)> = orgs | |
| 267 | + .into_iter() | |
| 268 | + .map(|(name, href, role)| { | |
| 269 | + let role = match role { | |
| 270 | + OrgMemberRole::Owner => owner_word, | |
| 271 | + OrgMemberRole::Member => member_word, | |
| 272 | + }; | |
| 273 | + (name, href, role) | |
| 274 | + }) | |
| 275 | + .collect(); | |
| 276 | + let keys_line = match lang { | |
| 277 | + Lang::Tr => format!( | |
| 278 | + "{sessions} oturum · {ssh_keys} SSH anahtarı · {gpg_keys} GPG anahtarı · {tokens} belirteç" | |
| 279 | + ), | |
| 280 | + _ => format!( | |
| 281 | + "{sessions} {} · {ssh_keys} SSH {} · {gpg_keys} GPG {} · {tokens} {}", | |
| 282 | + if sessions == 1 { "session" } else { "sessions" }, | |
| 283 | + if ssh_keys == 1 { "key" } else { "keys" }, | |
| 284 | + if gpg_keys == 1 { "key" } else { "keys" }, | |
| 285 | + if tokens == 1 { "token" } else { "tokens" }, | |
| 286 | + ), | |
| 287 | + }; | |
| 288 | + let repos_text = match (lang, facts.repo_count) { | |
| 289 | + (Lang::Tr, n) => format!("{n} depo"), | |
| 290 | + (_, 1) => "1 repository".to_owned(), | |
| 291 | + (_, n) => format!("{n} repositories"), | |
| 292 | + }; | |
| 293 | + let snippets_text = match (lang, snippets) { | |
| 294 | + (Lang::Tr, n) => format!("{n} parçacık"), | |
| 295 | + (_, 1) => "1 snippet".to_owned(), | |
| 296 | + (_, n) => format!("{n} snippets"), | |
| 297 | + }; | |
| 193 | 298 | let Notice { done, error, link } = notice; |
| 194 | - let recovery_state = format!( | |
| 195 | - "{}: {} · {}: {}", | |
| 196 | - at(lang, A::TwoFactor), | |
| 197 | - tfa, | |
| 198 | - passkeys_label, | |
| 199 | - passkey_count | |
| 200 | - ); | |
| 299 | + let mut sub = Vec::new(); | |
| 300 | + if !display_name.is_empty() { | |
| 301 | + sub.push(SubPart::text(display_name.clone())); | |
| 302 | + } | |
| 303 | + sub.push(SubPart::text(format!("{status} · {role}"))); | |
| 201 | 304 | Ok(view! { |
| 202 | - head(title: target.username.as_str(), | |
| 203 | - <a class="button" href=(profile.as_str())>(profile_label)</a> | |
| 305 | + head(title: target.username.as_str(), sub: sub, | |
| 306 | + <a class="button" href=(profile.as_str())>(s(lang, "Open profile", "Profili aç"))</a> | |
| 204 | 307 | ) |
| 205 | 308 | <div class="sheet" data-live=(live.as_str())> |
| 206 | - <p class="hint"> | |
| 207 | - if !email.is_empty() { | |
| 208 | - (email.as_str()) " · " | |
| 209 | - } | |
| 210 | - (at(lang, A::Joined)) " " rel_time(lang: lang, stamp: target.created_at.as_str()) " · " (at(lang, A::LastLogin)) " " rel_time_or_never(lang: lang, stamp: last_login.as_deref()) " · " (at(lang, A::Repositories)) " " (repos.as_str()) | |
| 211 | - </p> | |
| 212 | 309 | if let Some(message) = done { |
| 213 | 310 | <p class="state" role="status">(message)</p> |
| 214 | 311 | } |
| 215 | 312 | if let Some(message) = error { |
| 216 | 313 | alert(message: message.as_str()) |
| 217 | 314 | } |
| 218 | - <section class="sec"> | |
| 219 | - <h2>(access_title)</h2> | |
| 220 | - <p class="state">(access_state.as_str())</p> | |
| 221 | - if suspended { | |
| 222 | - <p class="hint">(suspended_note.as_str())</p> | |
| 223 | - <div class="acts"> | |
| 315 | + if let Some(link) = link { | |
| 316 | + <p class="state">(at(lang, A::ResetLinkReady))</p> | |
| 317 | + <code class="reset-link">(link.as_str())</code> | |
| 318 | + } | |
| 319 | + <section class="sec facts"> | |
| 320 | + <h2>(s(lang, "Account", "Hesap"))</h2> | |
| 321 | + <div class="line"> | |
| 322 | + <span class="key">(s(lang, "Email", "E-posta"))</span> | |
| 323 | + <span class="val"> | |
| 324 | + if !email.is_empty() { | |
| 325 | + (email.as_str()) " · " | |
| 326 | + } | |
| 327 | + (email_state) | |
| 328 | + </span> | |
| 329 | + </div> | |
| 330 | + <div class="line"> | |
| 331 | + <span class="key">(at(lang, A::Joined))</span> | |
| 332 | + <span class="val">(joined_at.as_str()) " · " rel_time(lang: lang, stamp: target.created_at.as_str())</span> | |
| 333 | + </div> | |
| 334 | + <div class="line"> | |
| 335 | + <span class="key">(at(lang, A::LastLogin))</span> | |
| 336 | + <span class="val"> | |
| 337 | + if login_at.is_some() { | |
| 338 | + (login_local.as_str()) " · " | |
| 339 | + } | |
| 340 | + rel_time_or_never(lang: lang, stamp: login_at.as_deref()) | |
| 341 | + if !login_ip.is_empty() { | |
| 342 | + " · IP " (login_ip.as_str()) | |
| 343 | + } | |
| 344 | + </span> | |
| 345 | + </div> | |
| 346 | + <div class="line"> | |
| 347 | + <span class="key">(s(lang, "Time zone", "Saat dilimi"))</span> | |
| 348 | + <span class="val">(timezone.as_str()) " · " (language.as_str())</span> | |
| 349 | + </div> | |
| 350 | + <div class="line"> | |
| 351 | + <span class="key">(s(lang, "Owns", "Sahip olduğu"))</span> | |
| 352 | + <span class="val"><a href=(repos_href.as_str())>(repos_text.as_str())</a> " · " <a href=(snippets_href.as_str())>(snippets_text.as_str())</a></span> | |
| 353 | + </div> | |
| 354 | + <div class="line"> | |
| 355 | + <span class="key">(s(lang, "Organizations", "Kuruluşlar"))</span> | |
| 356 | + <span class="val"> | |
| 357 | + if has_orgs { | |
| 358 | + for (i, (name, href, role)) in org_rows.iter().enumerate() { | |
| 359 | + if i > 0 { | |
| 360 | + ", " | |
| 361 | + } | |
| 362 | + <a href=(href.as_str())>(name.as_str())</a> " (" (*role) ")" | |
| 363 | + } | |
| 364 | + } else { | |
| 365 | + (s(lang, "none", "yok")) | |
| 366 | + } | |
| 367 | + </span> | |
| 368 | + </div> | |
| 369 | + </section> | |
| 370 | + <section class="sec facts"> | |
| 371 | + <h2>(s(lang, "Access", "Erişim"))</h2> | |
| 372 | + <div class="line"> | |
| 373 | + <span class="key">(s(lang, "Status", "Durum"))</span> | |
| 374 | + <span class="val">(status) | |
| 375 | + if suspended { | |
| 376 | + " · " (suspended_since.as_str()) " · " (suspended_note.as_str()) | |
| 377 | + } | |
| 378 | + if !suspended && own { | |
| 379 | + " · " (at(lang, A::ErrSelf)) | |
| 380 | + } | |
| 381 | + </span> | |
| 382 | + if suspended { | |
| 224 | 383 | post_act(label: at(lang, A::Unsuspend), action: unsuspend_action.as_str(), csrf: csrf) |
| 225 | - </div> | |
| 226 | - } else { | |
| 227 | - <p class="hint">(at(lang, A::SuspendHelp))</p> | |
| 228 | - if own { | |
| 229 | - <p class="hint">(at(lang, A::ErrSelf))</p> | |
| 230 | 384 | } |
| 231 | - if !own { | |
| 232 | - <div class="acts"> | |
| 233 | - reveal(label: suspend_title, id: Some("suspend"), open: false, | |
| 234 | - <form method="post" action=(suspend_action.as_str()) class="fields"> | |
| 235 | - <input type="hidden" name="csrf" value=(csrf)> | |
| 236 | - <div class="field"> | |
| 237 | - <label for="suspend-reason">(at(lang, A::SuspendReason))</label> | |
| 238 | - <input id="suspend-reason" type="text" name="reason" maxlength="300" autocomplete="off"> | |
| 239 | - </div> | |
| 240 | - <button type="submit" class="danger small">(suspend_title)</button> | |
| 241 | - </form> | |
| 242 | - ) | |
| 243 | - </div> | |
| 385 | + if !suspended && !own { | |
| 386 | + <details class="reveal" id="suspend" title=(at(lang, A::SuspendHelp))> | |
| 387 | + <summary class="act danger">(suspend_open.as_str())</summary> | |
| 388 | + <form class="opened" method="post" action=(suspend_action.as_str())> | |
| 389 | + <input type="hidden" name="csrf" value=(csrf)> | |
| 390 | + <input type="text" name="reason" maxlength="300" autocomplete="off" placeholder=(reason_hint) aria-label=(reason_hint)> | |
| 391 | + <button type="submit" class="danger small">(suspend_title)</button> | |
| 392 | + </form> | |
| 393 | + </details> | |
| 244 | 394 | } |
| 245 | - } | |
| 246 | - <p class="hint">(admin_help)</p> | |
| 247 | - if last_admin { | |
| 248 | - <p class="hint">(at(lang, A::AdminHelp))</p> | |
| 249 | - } | |
| 250 | - if !last_admin && is_admin { | |
| 251 | - <div class="acts"> | |
| 395 | + </div> | |
| 396 | + <div class="line"> | |
| 397 | + <span class="key">(s(lang, "Role", "Rol"))</span> | |
| 398 | + <span class="val">(role) | |
| 399 | + if last_admin { | |
| 400 | + " · " (at(lang, A::AdminHelp)) | |
| 401 | + } | |
| 402 | + </span> | |
| 403 | + if !last_admin && is_admin { | |
| 252 | 404 | confirm_act(lang: lang, label: at(lang, A::RevokeAdmin), action: admin_action.as_str(), csrf: csrf, fields: vec![("admin".to_owned(), "0".to_owned())]) |
| 253 | - </div> | |
| 254 | - } | |
| 255 | - if !last_admin && !is_admin { | |
| 256 | - <div class="acts"> | |
| 405 | + } | |
| 406 | + if !last_admin && !is_admin { | |
| 257 | 407 | post_act(label: at(lang, A::GrantAdmin), action: admin_action.as_str(), csrf: csrf, fields: vec![("admin".to_owned(), "1".to_owned())]) |
| 258 | - </div> | |
| 259 | - } | |
| 408 | + } | |
| 409 | + </div> | |
| 410 | + <div class="line"> | |
| 411 | + <span class="key">(s(lang, "Signed in with", "Giriş araçları"))</span> | |
| 412 | + <span class="val">(keys_line.as_str())</span> | |
| 413 | + </div> | |
| 260 | 414 | </section> |
| 261 | - <section class="sec"> | |
| 262 | - <h2>(recovery_title)</h2> | |
| 263 | - <p class="state">(recovery_state.as_str())</p> | |
| 264 | - <p class="hint">(at(lang, A::ResetHelp))</p> | |
| 265 | - if let Some(link) = link { | |
| 266 | - <p class="state">(at(lang, A::ResetLinkReady))</p> | |
| 267 | - <code class="reset-link">(link.as_str())</code> | |
| 268 | - } | |
| 269 | - <div class="acts"> | |
| 415 | + <section class="sec facts"> | |
| 416 | + <h2>(s(lang, "Recovery", "Kurtarma"))</h2> | |
| 417 | + <div class="line"> | |
| 418 | + <span class="key">(s(lang, "Password", "Parola"))</span> | |
| 419 | + <span class="val">(at(lang, A::ResetHelp))</span> | |
| 270 | 420 | confirm_act(lang: lang, label: at(lang, A::GenerateLink), action: reset_action.as_str(), csrf: csrf, note: Some(reset_note.to_owned())) |
| 271 | 421 | </div> |
| 272 | - if tfa_on { | |
| 273 | - <p class="hint">(at(lang, A::Disable2faHelp))</p> | |
| 274 | - <div class="acts"> | |
| 422 | + <div class="line"> | |
| 423 | + <span class="key">(at(lang, A::TwoFactor))</span> | |
| 424 | + <span class="val">(tfa) | |
| 425 | + if tfa_on { | |
| 426 | + " · " (at(lang, A::Disable2faHelp)) | |
| 427 | + } | |
| 428 | + </span> | |
| 429 | + if tfa_on { | |
| 275 | 430 | confirm_act(lang: lang, label: g::t(lang, K::Disable), action: tfa_action.as_str(), csrf: csrf) |
| 276 | - </div> | |
| 277 | - } else { | |
| 278 | - <p class="hint">(at(lang, A::TwoFactorNotOn))</p> | |
| 279 | - } | |
| 280 | - if passkeys > 0 { | |
| 281 | - <p class="hint">(passkeys_help)</p> | |
| 282 | - <div class="acts"> | |
| 283 | - confirm_act(lang: lang, label: remove_label, action: passkeys_action.as_str(), csrf: csrf, note: Some(passkeys_question.to_owned())) | |
| 284 | - </div> | |
| 285 | - } else { | |
| 286 | - <p class="hint">(at(lang, A::NoPasskeysToRemove))</p> | |
| 287 | - } | |
| 431 | + } | |
| 432 | + </div> | |
| 433 | + <div class="line"> | |
| 434 | + <span class="key">(s(lang, "Passkeys", "Geçiş anahtarları"))</span> | |
| 435 | + <span class="val">(passkeys.to_string())</span> | |
| 436 | + if passkeys > 0 { | |
| 437 | + confirm_act(lang: lang, label: s(lang, "Remove all", "Hepsini kaldır"), action: passkeys_action.as_str(), csrf: csrf, note: Some(passkeys_question.to_owned())) | |
| 438 | + } | |
| 439 | + </div> | |
| 288 | 440 | </section> |
| 289 | 441 | if !own { |
| 290 | - <section class="sec"> | |
| 442 | + <section class="sec facts"> | |
| 291 | 443 | <h2>(i18n::t(lang, Key::DangerZone))</h2> |
| 292 | - <p class="hint">(at(lang, A::DeleteHelp))</p> | |
| 293 | - <div class="acts"> | |
| 444 | + <div class="line"> | |
| 445 | + <span class="key">(i18n::t(lang, Key::Delete))</span> | |
| 446 | + <span class="val">(at(lang, A::DeleteHelp))</span> | |
| 294 | 447 | <a class="act danger" href=(delete_href.as_str())>(i18n::t(lang, Key::Delete))</a> |
| 295 | 448 | </div> |
| 296 | 449 | </section> |
| @@ -300,14 +453,28 @@ async fn detail_body( | ||
| 300 | 453 | } |
| 301 | 454 | |
| 302 | 455 | /// An organization's page: its name, its members with a link to each account, its profile, and its |
| 303 | -/// delete. An organization is not a person, so the delete goes through the same POST as a user's. | |
| 456 | +/// delete, which opens the page that says what goes with it. | |
| 304 | 457 | #[component] |
| 305 | 458 | async fn org_body( |
| 306 | 459 | lang: Lang, |
| 307 | - csrf: &str, | |
| 308 | 460 | org: User, |
| 309 | 461 | members: Vec<(User, OrgMemberRole)>, |
| 462 | + repos: usize, | |
| 463 | + teams: usize, | |
| 464 | + tz: String, | |
| 310 | 465 | ) -> Result<impl View> { |
| 466 | + let created = local_stamp(&org.created_at, &tz); | |
| 467 | + let owners = members | |
| 468 | + .iter() | |
| 469 | + .filter(|(_, role)| *role == OrgMemberRole::Owner) | |
| 470 | + .count(); | |
| 471 | + let display_name = org.display_name.clone().unwrap_or_default(); | |
| 472 | + let repos_href = format!("/{}?tab=repositories", enc(&org.username)); | |
| 473 | + let people = format!( | |
| 474 | + "{} · {} {owners}", | |
| 475 | + members.len(), | |
| 476 | + s(lang, "owners", "sahip") | |
| 477 | + ); | |
| 311 | 478 | let base = format!("/admin/users/{}", enc(&org.id)); |
| 312 | 479 | let delete_action = format!("{base}/delete"); |
| 313 | 480 | let profile = format!("/{}", enc(&org.username)); |
| @@ -335,16 +502,43 @@ async fn org_body( | ||
| 335 | 502 | <a class="button" href=(profile.as_str())>(profile_label)</a> |
| 336 | 503 | ) |
| 337 | 504 | <div class="sheet"> |
| 338 | - <section class="sec"> | |
| 505 | + <section class="sec facts"> | |
| 506 | + <h2>(s(lang, "Organization", "Kuruluş"))</h2> | |
| 507 | + if !display_name.is_empty() { | |
| 508 | + <div class="line"> | |
| 509 | + <span class="key">(s(lang, "Display name", "Görünen ad"))</span> | |
| 510 | + <span class="val">(display_name.as_str())</span> | |
| 511 | + </div> | |
| 512 | + } | |
| 513 | + <div class="line"> | |
| 514 | + <span class="key">(s(lang, "Created", "Oluşturuldu"))</span> | |
| 515 | + <span class="val">(created.as_str()) " · " rel_time(lang: lang, stamp: org.created_at.as_str())</span> | |
| 516 | + </div> | |
| 517 | + <div class="line"> | |
| 518 | + <span class="key">(s(lang, "Repositories", "Depolar"))</span> | |
| 519 | + <span class="val"><a href=(repos_href.as_str())>(repos.to_string())</a></span> | |
| 520 | + </div> | |
| 521 | + <div class="line"> | |
| 522 | + <span class="key">(og::t(lang, OG::Members))</span> | |
| 523 | + <span class="val">(people.as_str())</span> | |
| 524 | + </div> | |
| 525 | + <div class="line"> | |
| 526 | + <span class="key">(s(lang, "Teams", "Takımlar"))</span> | |
| 527 | + <span class="val">(teams.to_string())</span> | |
| 528 | + </div> | |
| 529 | + </section> | |
| 530 | + <section class="sec facts"> | |
| 339 | 531 | <h2>(og::t(lang, OG::Members))</h2> |
| 340 | 532 | for (href, name, role) in rows.iter() { |
| 341 | 533 | <a class="line" href=(href.as_str())><span class="name">(name.as_str())</span><span class="val">(*role)</span></a> |
| 342 | 534 | } |
| 343 | 535 | </section> |
| 344 | - <section class="sec"> | |
| 536 | + <section class="sec facts"> | |
| 345 | 537 | <h2>(i18n::t(lang, Key::DangerZone))</h2> |
| 346 | - <div class="acts"> | |
| 347 | - confirm_act(lang: lang, label: g::t(lang, K::DeleteOrgTitle), action: delete_action.as_str(), csrf: csrf) | |
| 538 | + <div class="line"> | |
| 539 | + <span class="key">(i18n::t(lang, Key::Delete))</span> | |
| 540 | + <span class="val">(s(lang, "Shows what goes with it before anything is removed.", "Bir şey silinmeden önce neyin gideceğini gösterir."))</span> | |
| 541 | + <a class="act danger" href=(delete_action.as_str())>(g::t(lang, K::DeleteOrgTitle))</a> | |
| 348 | 542 | </div> |
| 349 | 543 | </section> |
| 350 | 544 | </div> |
| @@ -402,7 +596,9 @@ async fn detail_page(cx: &Cx) -> Result<impl View> { | ||
| 402 | 596 | let org = match store.user_by_id(&id).await? { |
| 403 | 597 | Some(user) if user.is_org() => { |
| 404 | 598 | let members = store.org_members(&user.id).await?; |
| 405 | - Some((user, members)) | |
| 599 | + let repos = store.list_repos_by_owner(&user.id).await?.len(); | |
| 600 | + let teams = store.teams_for_org(&user.id).await?.len(); | |
| 601 | + Some((user, members, repos, teams)) | |
| 406 | 602 | } |
| 407 | 603 | _ => None, |
| 408 | 604 | }; |
| @@ -413,7 +609,7 @@ async fn detail_page(cx: &Cx) -> Result<impl View> { | ||
| 413 | 609 | }; |
| 414 | 610 | let title = org |
| 415 | 611 | .as_ref() |
| 416 | - .map(|(user, _)| user.username.clone()) | |
| 612 | + .map(|(user, ..)| user.username.clone()) | |
| 417 | 613 | .or_else(|| detail.as_ref().map(|d| d.target.username.clone())) |
| 418 | 614 | .unwrap_or_default(); |
| 419 | 615 | let notice = Notice { |
| @@ -423,8 +619,8 @@ async fn detail_page(cx: &Cx) -> Result<impl View> { | ||
| 423 | 619 | let csrf = viewer.1.csrf_token.clone(); |
| 424 | 620 | Ok(view! { |
| 425 | 621 | shell(title: title.as_str(), viewer: Some(&viewer), |
| 426 | - if let Some((user, members)) = org { org_body(lang: lang, csrf: csrf.as_str(), org: user, members: members) } | |
| 427 | - if let Some(detail) = detail { detail_body(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), detail: detail, notice: notice) }) | |
| 622 | + if let Some((user, members, repos, teams)) = org { org_body(lang: lang, org: user, members: members, repos: repos, teams: teams, tz: viewer.0.timezone.clone()) } | |
| 623 | + if let Some(detail) = detail { detail_body(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), tz: viewer.0.timezone.clone(), detail: detail, notice: notice) }) | |
| 428 | 624 | }) |
| 429 | 625 | } |
| 430 | 626 | |
| @@ -586,7 +782,7 @@ async fn respond(cx: &Cx, form: ActionForm, action: Action) -> Result<impl View> | ||
| 586 | 782 | let csrf = viewer.1.csrf_token.clone(); |
| 587 | 783 | let title = detail.target.username.clone(); |
| 588 | 784 | Ok(view! { |
| 589 | - shell(title: title.as_str(), viewer: Some(&viewer), detail_body(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), detail: detail, notice: notice)) | |
| 785 | + shell(title: title.as_str(), viewer: Some(&viewer), detail_body(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), tz: viewer.0.timezone.clone(), detail: detail, notice: notice)) | |
| 590 | 786 | }) |
| 591 | 787 | } |
| 592 | 788 |
crates/forge-web/src/pages/audit_log.rsmodified+131 -6
| @@ -42,6 +42,12 @@ pub(crate) struct AuditQuery { | ||
| 42 | 42 | /// still filter by it. |
| 43 | 43 | actor: Option<String>, |
| 44 | 44 | q: Option<String>, |
| 45 | + /// The time range: "1h", "24h", "7d", "30d", "today" or "custom" (with `from` and `to`). | |
| 46 | + when: Option<String>, | |
| 47 | + /// The first day of a custom range, `YYYY-MM-DD` in the viewer's timezone. | |
| 48 | + from: Option<String>, | |
| 49 | + /// The last day of a custom range, `YYYY-MM-DD` in the viewer's timezone. | |
| 50 | + to: Option<String>, | |
| 45 | 51 | exact: Option<String>, |
| 46 | 52 | case: Option<String>, |
| 47 | 53 | /// Old cursor links. Still accepted so old bookmarks load, and ignored. |
| @@ -51,6 +57,89 @@ pub(crate) struct AuditQuery { | ||
| 51 | 57 | page: Option<String>, |
| 52 | 58 | } |
| 53 | 59 | |
| 60 | +/// The time range a query asks for, as the form shows it and as stamps for the filter. | |
| 61 | +#[derive(Clone, Default)] | |
| 62 | +struct Span { | |
| 63 | + when: String, | |
| 64 | + from: String, | |
| 65 | + to: String, | |
| 66 | +} | |
| 67 | + | |
| 68 | +/// The time ranges the When menu offers, after Any time. | |
| 69 | +const WHENS: [&str; 6] = ["1h", "24h", "7d", "30d", "today", "custom"]; | |
| 70 | + | |
| 71 | +fn when_label(lang: Lang, when: &str) -> &'static str { | |
| 72 | + match when { | |
| 73 | + "1h" => s(lang, "Last hour", "Son bir saat"), | |
| 74 | + "24h" => s(lang, "Last 24 hours", "Son 24 saat"), | |
| 75 | + "7d" => s(lang, "Last 7 days", "Son 7 gün"), | |
| 76 | + "30d" => s(lang, "Last 30 days", "Son 30 gün"), | |
| 77 | + "today" => s(lang, "Today", "Bugün"), | |
| 78 | + "custom" => s(lang, "Dates…", "Tarihler…"), | |
| 79 | + _ => s(lang, "Any time", "Her zaman"), | |
| 80 | + } | |
| 81 | +} | |
| 82 | + | |
| 83 | +impl Span { | |
| 84 | + fn from_query(query: &AuditQuery) -> Span { | |
| 85 | + let clean = |v: &Option<String>| v.clone().unwrap_or_default().trim().to_owned(); | |
| 86 | + let when = clean(&query.when); | |
| 87 | + let when = if WHENS.contains(&when.as_str()) { when } else { String::new() }; | |
| 88 | + let (from, to) = if when == "custom" { | |
| 89 | + (clean(&query.from), clean(&query.to)) | |
| 90 | + } else { | |
| 91 | + (String::new(), String::new()) | |
| 92 | + }; | |
| 93 | + Span { when, from, to } | |
| 94 | + } | |
| 95 | + | |
| 96 | + /// Sets the filter's bounds. Days are read in `tz`; an unreadable date leaves its side open. | |
| 97 | + fn apply(&self, filter: &mut AuditFilter, tz: &str) { | |
| 98 | + use forge_core::time::{stamp_ago, stamp_from_unix}; | |
| 99 | + use std::time::Duration; | |
| 100 | + let hours = |h: u64| Some(stamp_ago(Duration::from_secs(h * 3600))); | |
| 101 | + let day = |text: &str| { | |
| 102 | + text.parse::<jiff::civil::Date>() | |
| 103 | + .ok() | |
| 104 | + .and_then(|date| forge_core::tz::day_span(date, tz)) | |
| 105 | + }; | |
| 106 | + match self.when.as_str() { | |
| 107 | + "1h" => filter.since = hours(1), | |
| 108 | + "24h" => filter.since = hours(24), | |
| 109 | + "7d" => filter.since = hours(24 * 7), | |
| 110 | + "30d" => filter.since = hours(24 * 30), | |
| 111 | + "today" => { | |
| 112 | + let today = forge_core::tz::local_date(jiff::Timestamp::now(), tz); | |
| 113 | + filter.since = forge_core::tz::day_span(today, tz) | |
| 114 | + .and_then(|(start, _)| stamp_from_unix(start)); | |
| 115 | + } | |
| 116 | + "custom" => { | |
| 117 | + filter.since = day(&self.from).and_then(|(start, _)| stamp_from_unix(start)); | |
| 118 | + filter.until = day(&self.to).and_then(|(_, end)| stamp_from_unix(end)); | |
| 119 | + } | |
| 120 | + _ => {} | |
| 121 | + } | |
| 122 | + } | |
| 123 | + | |
| 124 | + /// The link params that keep the range. | |
| 125 | + fn params(&self) -> Vec<(&str, &str)> { | |
| 126 | + vec![ | |
| 127 | + ("when", self.when.as_str()), | |
| 128 | + ("from", self.from.as_str()), | |
| 129 | + ("to", self.to.as_str()), | |
| 130 | + ] | |
| 131 | + } | |
| 132 | +} | |
| 133 | + | |
| 134 | +/// "12 entries" in the viewer's language. | |
| 135 | +fn entry_count(lang: Lang, n: usize) -> String { | |
| 136 | + match (lang, n) { | |
| 137 | + (Lang::Tr, _) => format!("{n} kayıt"), | |
| 138 | + (_, 1) => "1 entry".to_owned(), | |
| 139 | + _ => format!("{n} entries"), | |
| 140 | + } | |
| 141 | +} | |
| 142 | + | |
| 54 | 143 | /// One entry, already formatted for display. |
| 55 | 144 | struct RowView { |
| 56 | 145 | when: String, |
| @@ -312,10 +401,15 @@ async fn log_tools( | ||
| 312 | 401 | finder: Finder, |
| 313 | 402 | action: String, |
| 314 | 403 | actor: String, |
| 404 | + span: Span, | |
| 405 | + total: usize, | |
| 315 | 406 | ) -> Result<impl View> { |
| 316 | 407 | let placeholder = s(lang, "Search the log", "Günlükte ara"); |
| 408 | + let count = entry_count(lang, total); | |
| 409 | + let custom = span.when == "custom"; | |
| 317 | 410 | Ok(view! { |
| 318 | 411 | <div class="sheet-tools"> |
| 412 | + <strong>(count.as_str())</strong> | |
| 319 | 413 | <form method="get" action=(form_action)> |
| 320 | 414 | finder_field(lang: lang, finder: finder, placeholder: placeholder, id: Some("log-q")) |
| 321 | 415 | <label class="find-filter"> |
| @@ -327,6 +421,25 @@ async fn log_tools( | ||
| 327 | 421 | } |
| 328 | 422 | </select> |
| 329 | 423 | </label> |
| 424 | + <label class="find-filter"> | |
| 425 | + (s(lang, "When", "Zaman")) " " | |
| 426 | + <select name="when" data-autosubmit="true"> | |
| 427 | + <option value="" selected=(span.when.is_empty())>(when_label(lang, ""))</option> | |
| 428 | + for known in WHENS.iter().copied() { | |
| 429 | + <option value=(known) selected=(known == span.when.as_str())>(when_label(lang, known))</option> | |
| 430 | + } | |
| 431 | + </select> | |
| 432 | + </label> | |
| 433 | + if custom { | |
| 434 | + <label class="find-filter"> | |
| 435 | + (s(lang, "From", "Başlangıç")) " " | |
| 436 | + <input type="date" name="from" value=(span.from.as_str()) data-autosubmit="true"> | |
| 437 | + </label> | |
| 438 | + <label class="find-filter"> | |
| 439 | + (s(lang, "To", "Bitiş")) " " | |
| 440 | + <input type="date" name="to" value=(span.to.as_str()) data-autosubmit="true"> | |
| 441 | + </label> | |
| 442 | + } | |
| 330 | 443 | if !actor.is_empty() { |
| 331 | 444 | <input type="hidden" name="actor" value=(actor.as_str())> |
| 332 | 445 | } |
| @@ -478,6 +591,8 @@ async fn admin_audit_view( | ||
| 478 | 591 | action: String, |
| 479 | 592 | actor: String, |
| 480 | 593 | notice: Option<String>, |
| 594 | + span: Span, | |
| 595 | + total: usize, | |
| 481 | 596 | groups: Vec<Group>, |
| 482 | 597 | page: u64, |
| 483 | 598 | pages: u64, |
| @@ -488,7 +603,7 @@ async fn admin_audit_view( | ||
| 488 | 603 | Ok(view! { |
| 489 | 604 | head(title: g::t(lang, K::AuditLog), sub: sub) |
| 490 | 605 | <div class="sheet" data-live=(live.as_str())> |
| 491 | - log_tools(lang: lang, form_action: "/admin/audit", finder: finder, action: action, actor: actor) | |
| 606 | + log_tools(lang: lang, form_action: "/admin/audit", finder: finder, action: action, actor: actor, span: span, total: total) | |
| 492 | 607 | if let Some(message) = notice { |
| 493 | 608 | <p class="state" role="status">(message.as_str())</p> |
| 494 | 609 | } |
| @@ -504,6 +619,8 @@ async fn own_log_view( | ||
| 504 | 619 | items: Vec<RailItem>, |
| 505 | 620 | finder: Finder, |
| 506 | 621 | action: String, |
| 622 | + span: Span, | |
| 623 | + total: usize, | |
| 507 | 624 | groups: Vec<Group>, |
| 508 | 625 | page: u64, |
| 509 | 626 | pages: u64, |
| @@ -516,7 +633,7 @@ async fn own_log_view( | ||
| 516 | 633 | <div class="work"> |
| 517 | 634 | rail(label: i18n::t(lang, i18n::Key::Security), items: items) |
| 518 | 635 | <div class="sheet"> |
| 519 | - log_tools(lang: lang, form_action: "/settings/security/log", finder: finder, action: action, actor: String::new()) | |
| 636 | + log_tools(lang: lang, form_action: "/settings/security/log", finder: finder, action: action, actor: String::new(), span: span, total: total) | |
| 520 | 637 | audit_table(lang: lang, groups: groups, show_actor: false) |
| 521 | 638 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 522 | 639 | </div> |
| @@ -551,8 +668,10 @@ async fn admin_audit_page(cx: &Cx) -> Result<impl View> { | ||
| 551 | 668 | let query = query_params::<AuditQuery>(cx)?; |
| 552 | 669 | let store = &app_context::<AppState>(cx).store; |
| 553 | 670 | let (finder, action, actor) = query_parts(query); |
| 671 | + let span = Span::from_query(query); | |
| 554 | 672 | |
| 555 | 673 | let mut filter = AuditFilter::default(); |
| 674 | + span.apply(&mut filter, &viewer.0.timezone); | |
| 556 | 675 | let mut notice: Option<String> = None; |
| 557 | 676 | if !action.is_empty() { |
| 558 | 677 | match AuditAction::parse(&action) { |
| @@ -573,8 +692,10 @@ async fn admin_audit_page(cx: &Cx) -> Result<impl View> { | ||
| 573 | 692 | fetch_entries(store, &filter).await? |
| 574 | 693 | }; |
| 575 | 694 | let groups = fold_groups(&entries, lang, &finder); |
| 695 | + let total = groups.iter().map(|group| group.rows.len()).sum(); | |
| 576 | 696 | let (groups, page, pages) = page_of(groups, requested_page(query)); |
| 577 | - let params = keep_params(&finder, &action, &actor); | |
| 697 | + let mut params = keep_params(&finder, &action, &actor); | |
| 698 | + params.extend(span.params()); | |
| 578 | 699 | let nav = nav_for(page, pages, "/admin/audit", ¶ms); |
| 579 | 700 | let live = list_href( |
| 580 | 701 | "/admin/audit/events", |
| @@ -582,7 +703,7 @@ async fn admin_audit_page(cx: &Cx) -> Result<impl View> { | ||
| 582 | 703 | ); |
| 583 | 704 | let title = g::t(lang, K::AuditLog); |
| 584 | 705 | Ok(view! { |
| 585 | - shell(title: title, viewer: Some(&viewer), admin_audit_view(lang: lang, live: live, finder: finder.clone(), action: action.clone(), actor: actor.clone(), notice: notice, groups: groups, page: page, pages: pages, nav: nav)) | |
| 706 | + shell(title: title, viewer: Some(&viewer), admin_audit_view(lang: lang, live: live, finder: finder.clone(), action: action.clone(), actor: actor.clone(), notice: notice, span: span.clone(), total: total, groups: groups, page: page, pages: pages, nav: nav)) | |
| 586 | 707 | }) |
| 587 | 708 | } |
| 588 | 709 | |
| @@ -634,23 +755,27 @@ async fn own_log_page(cx: &Cx) -> Result<impl View> { | ||
| 634 | 755 | let query = query_params::<AuditQuery>(cx)?; |
| 635 | 756 | let store = &app_context::<AppState>(cx).store; |
| 636 | 757 | let (finder, action, _) = query_parts(query); |
| 758 | + let span = Span::from_query(query); | |
| 637 | 759 | let mut filter = AuditFilter { |
| 638 | 760 | involving_user: Some(viewer.0.id.clone()), |
| 639 | 761 | ..Default::default() |
| 640 | 762 | }; |
| 763 | + span.apply(&mut filter, &viewer.0.timezone); | |
| 641 | 764 | // An unknown action is ignored here: the menu only offers known ones. |
| 642 | 765 | if let Some(known) = AuditAction::parse(&action) { |
| 643 | 766 | filter.action = Some(known); |
| 644 | 767 | } |
| 645 | 768 | let entries = fetch_entries(store, &filter).await?; |
| 646 | 769 | let groups = fold_groups(&entries, lang, &finder); |
| 770 | + let total = groups.iter().map(|group| group.rows.len()).sum(); | |
| 647 | 771 | let (groups, page, pages) = page_of(groups, requested_page(query)); |
| 648 | - let params = keep_params(&finder, &action, ""); | |
| 772 | + let mut params = keep_params(&finder, &action, ""); | |
| 773 | + params.extend(span.params()); | |
| 649 | 774 | let nav = nav_for(page, pages, "/settings/security/log", ¶ms); |
| 650 | 775 | let items = security_rail_for(app_context::<AppState>(cx), lang, &viewer, "log").await?; |
| 651 | 776 | let title = g::t(lang, K::SecurityLogTitle); |
| 652 | 777 | Ok(view! { |
| 653 | - shell(title: title, viewer: Some(&viewer), own_log_view(lang: lang, items: items, finder: finder.clone(), action: action.clone(), groups: groups, page: page, pages: pages, nav: nav)) | |
| 778 | + shell(title: title, viewer: Some(&viewer), own_log_view(lang: lang, items: items, finder: finder.clone(), action: action.clone(), span: span.clone(), total: total, groups: groups, page: page, pages: pages, nav: nav)) | |
| 654 | 779 | }) |
| 655 | 780 | } |
| 656 | 781 |
crates/forge-web/src/pages/import.rsmodified+41 -46
| @@ -32,6 +32,7 @@ use crate::pages::new_repo::{owner_choices, repo_owner}; | ||
| 32 | 32 | use crate::pages::repo_ctx::still_readable; |
| 33 | 33 | use crate::state::AppState; |
| 34 | 34 | use crate::views::parts::{SubPart, head}; |
| 35 | +use crate::views::repo_list::{PageLink, pager, pager_links}; | |
| 35 | 36 | use crate::views::{alert, csrf_field, rel_time, shell, user_facing_message}; |
| 36 | 37 | |
| 37 | 38 | path_param!(job_id); |
| @@ -113,6 +114,8 @@ struct SourceQuery { | ||
| 113 | 114 | struct JobsQuery { |
| 114 | 115 | /// The repositories a bulk import left out, with why, as one line. |
| 115 | 116 | skipped: Option<String>, |
| 117 | + /// The 1-based page of the history. | |
| 118 | + page: Option<String>, | |
| 116 | 119 | } |
| 117 | 120 | |
| 118 | 121 | #[query_params(error = bad_request)] |
| @@ -165,10 +168,12 @@ fn token_of(raw: &str) -> Option<String> { | ||
| 165 | 168 | pub(crate) async fn newrepo_tabs(lang: Lang, active: &str) -> Result<impl View> { |
| 166 | 169 | let create = active == "create"; |
| 167 | 170 | let import = active == "import"; |
| 171 | + let history = active == "history"; | |
| 168 | 172 | Ok(view! { |
| 169 | 173 | <nav class="tabs" aria-label=(g::t(lang, K::ImportTitle))> |
| 170 | 174 | <a href="/new" aria-current=(create.then_some("page"))>(g::t(lang, K::TabCreate))</a> |
| 171 | 175 | <a href="/new/import" aria-current=(import.then_some("page"))>(g::t(lang, K::TabImport))</a> |
| 176 | + <a href="/import" aria-current=(history.then_some("page"))>(crate::pages::passkeys::s(lang, "Import history", "İçe aktarma geçmişi"))</a> | |
| 172 | 177 | </nav> |
| 173 | 178 | }) |
| 174 | 179 | } |
| @@ -388,10 +393,7 @@ async fn import_form( | ||
| 388 | 393 | }) |
| 389 | 394 | } |
| 390 | 395 | |
| 391 | -/// How many imports the Import tab lists under the form. | |
| 392 | -const RECENT_IMPORTS: usize = 5; | |
| 393 | - | |
| 394 | -/// The GET import page: the form, then the recent imports under it. | |
| 396 | +/// The GET import page: the form. Past imports are on the Import history tab. | |
| 395 | 397 | #[component] |
| 396 | 398 | async fn import_home( |
| 397 | 399 | lang: Lang, |
| @@ -399,12 +401,9 @@ async fn import_home( | ||
| 399 | 401 | csrf: String, |
| 400 | 402 | draft: Draft, |
| 401 | 403 | owners: Vec<String>, |
| 402 | - jobs: Vec<(ImportJob, Option<Repo>)>, | |
| 403 | - more: bool, | |
| 404 | 404 | ) -> Result<impl View> { |
| 405 | 405 | Ok(view! { |
| 406 | 406 | import_form(lang: lang, username: username, csrf: csrf.as_str(), draft: draft, error: None, owners: owners) |
| 407 | - recent_imports(lang: lang, jobs: jobs, more: more) | |
| 408 | 407 | }) |
| 409 | 408 | } |
| 410 | 409 | |
| @@ -432,13 +431,9 @@ async fn import_page(cx: &Cx) -> Result<impl View> { | ||
| 432 | 431 | let state = app_context::<AppState>(cx); |
| 433 | 432 | let owners = owner_choices(state, &viewer.0).await?; |
| 434 | 433 | let csrf = viewer.1.csrf_token.clone(); |
| 435 | - // One more than the list shows, so the page knows whether to offer "View all". | |
| 436 | - let mut jobs = load_job_rows(state, &viewer.0.id, 6).await?; | |
| 437 | - let more = jobs.len() > RECENT_IMPORTS; | |
| 438 | - jobs.truncate(RECENT_IMPORTS); | |
| 439 | 434 | Ok(view! { cx => |
| 440 | 435 | shell(title: g::t(lang, K::ImportTitle), viewer: Some(&viewer), |
| 441 | - import_home(lang: lang, username: viewer.0.username.clone(), csrf: csrf, draft: Draft::fresh(source), owners: owners, jobs: jobs, more: more)) | |
| 436 | + import_home(lang: lang, username: viewer.0.username.clone(), csrf: csrf, draft: Draft::fresh(source), owners: owners)) | |
| 442 | 437 | }) |
| 443 | 438 | } |
| 444 | 439 | |
| @@ -1056,47 +1051,23 @@ async fn job_rows(lang: Lang, jobs: Vec<(ImportJob, Option<Repo>)>) -> Result<im | ||
| 1056 | 1051 | }) |
| 1057 | 1052 | } |
| 1058 | 1053 | |
| 1059 | -/// The few most recent imports, listed under the import form. Nothing renders without any. | |
| 1060 | -/// `more` says there are older ones, which the "View all" link opens. | |
| 1061 | -#[component] | |
| 1062 | -async fn recent_imports( | |
| 1063 | - lang: Lang, | |
| 1064 | - jobs: Vec<(ImportJob, Option<Repo>)>, | |
| 1065 | - more: bool, | |
| 1066 | -) -> Result<impl View> { | |
| 1067 | - let empty = jobs.is_empty(); | |
| 1068 | - let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); | |
| 1069 | - Ok(view! { | |
| 1070 | - if !empty { | |
| 1071 | - <div class="sheet"> | |
| 1072 | - <div class="sheet-tools"> | |
| 1073 | - <strong>(g::t(lang, K::RecentImports))</strong> | |
| 1074 | - if more { | |
| 1075 | - <a class="act" href="/import">(g::t(lang, K::ViewAll))</a> | |
| 1076 | - } | |
| 1077 | - if retry { | |
| 1078 | - <a class="act" href="/import/retry">(g::t(lang, K::RetryFailedTitle))</a> | |
| 1079 | - } | |
| 1080 | - </div> | |
| 1081 | - job_rows(lang: lang, jobs: jobs) | |
| 1082 | - </div> | |
| 1083 | - } | |
| 1084 | - }) | |
| 1085 | -} | |
| 1086 | - | |
| 1087 | 1054 | #[component] |
| 1088 | 1055 | async fn jobs_list( |
| 1089 | 1056 | lang: Lang, |
| 1090 | 1057 | username: String, |
| 1091 | 1058 | jobs: Vec<(ImportJob, Option<Repo>)>, |
| 1092 | 1059 | skipped: Option<String>, |
| 1060 | + page: u64, | |
| 1061 | + pages: u64, | |
| 1062 | + nav: (Vec<PageLink>, Option<String>, Option<String>), | |
| 1093 | 1063 | ) -> Result<impl View> { |
| 1064 | + let (links, prev, next) = nav; | |
| 1094 | 1065 | let empty = jobs.is_empty(); |
| 1095 | 1066 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); |
| 1096 | 1067 | Ok(view! { |
| 1097 | 1068 | head(title: g::t(lang, K::JobsTitle), live: Some("/import/events")) |
| 1098 | 1069 | crate::pages::profile::own_profile_tabs(lang: lang, username: username, current: "repositories".to_owned()) |
| 1099 | - newrepo_tabs(lang: lang, active: "import") | |
| 1070 | + newrepo_tabs(lang: lang, active: "history") | |
| 1100 | 1071 | <div class="sheet"> |
| 1101 | 1072 | if retry { |
| 1102 | 1073 | <div class="sheet-tools"> |
| @@ -1114,6 +1085,7 @@ async fn jobs_list( | ||
| 1114 | 1085 | } else { |
| 1115 | 1086 | job_rows(lang: lang, jobs: jobs) |
| 1116 | 1087 | } |
| 1088 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | |
| 1117 | 1089 | </div> |
| 1118 | 1090 | }) |
| 1119 | 1091 | } |
| @@ -1158,19 +1130,42 @@ async fn jobs_events(cx: &Cx) -> Result<Response> { | ||
| 1158 | 1130 | .await |
| 1159 | 1131 | } |
| 1160 | 1132 | |
| 1133 | +/// Imports per page of the history. | |
| 1134 | +const HISTORY_ROWS: u64 = 10; | |
| 1135 | + | |
| 1161 | 1136 | #[page("/import")] |
| 1162 | 1137 | async fn jobs_page(cx: &Cx) -> Result<impl View> { |
| 1163 | 1138 | let viewer = require_user(cx).await?; |
| 1164 | 1139 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 1165 | 1140 | let state = app_context::<AppState>(cx); |
| 1166 | - let rows = load_job_rows(state, &viewer.0.id, 50).await?; | |
| 1167 | - let skipped = query_params::<JobsQuery>(cx)? | |
| 1141 | + let query = query_params::<JobsQuery>(cx)?; | |
| 1142 | + let all = state.store.list_import_jobs(&viewer.0.id, 1000).await?; | |
| 1143 | + let pages = (all.len() as u64).div_ceil(HISTORY_ROWS).max(1); | |
| 1144 | + let page = query | |
| 1145 | + .page | |
| 1146 | + .as_deref() | |
| 1147 | + .and_then(|p| p.parse::<u64>().ok()) | |
| 1148 | + .unwrap_or(1) | |
| 1149 | + .clamp(1, pages); | |
| 1150 | + // Only the shown page's repos are looked up. | |
| 1151 | + let user = state.store.user_by_id(&viewer.0.id).await?; | |
| 1152 | + let mut rows = Vec::new(); | |
| 1153 | + for job in all | |
| 1154 | + .into_iter() | |
| 1155 | + .skip(((page - 1) * HISTORY_ROWS) as usize) | |
| 1156 | + .take(HISTORY_ROWS as usize) | |
| 1157 | + { | |
| 1158 | + let repo = job_repo(state, user.as_ref(), &job).await?; | |
| 1159 | + rows.push((job, repo)); | |
| 1160 | + } | |
| 1161 | + let nav = pager_links(page, pages, |n| format!("/import?page={n}")); | |
| 1162 | + let skipped = query | |
| 1168 | 1163 | .skipped |
| 1169 | 1164 | .clone() |
| 1170 | 1165 | .filter(|s| !s.is_empty() && s.len() < 2000) |
| 1171 | 1166 | .map(|s| g::bulk_skipped(lang, &s)); |
| 1172 | 1167 | Ok(view! { cx => |
| 1173 | - shell(title: g::t(lang, K::JobsTitle), viewer: Some(&viewer), jobs_list(lang: lang, username: viewer.0.username.clone(), jobs: rows, skipped: skipped)) | |
| 1168 | + shell(title: g::t(lang, K::JobsTitle), viewer: Some(&viewer), jobs_list(lang: lang, username: viewer.0.username.clone(), jobs: rows, skipped: skipped, page: page, pages: pages, nav: nav)) | |
| 1174 | 1169 | }) |
| 1175 | 1170 | } |
| 1176 | 1171 | |
| @@ -1211,7 +1206,7 @@ async fn job_view( | ||
| 1211 | 1206 | Ok(view! { |
| 1212 | 1207 | head(title: job.source_ref.as_str(), sub: sub, live: live.as_deref()) |
| 1213 | 1208 | crate::pages::profile::own_profile_tabs(lang: lang, username: username, current: "repositories".to_owned()) |
| 1214 | - newrepo_tabs(lang: lang, active: "import") | |
| 1209 | + newrepo_tabs(lang: lang, active: "history") | |
| 1215 | 1210 | <div class="sheet import-job" data-live-state=(state_word)> |
| 1216 | 1211 | <section class="sec"> |
| 1217 | 1212 | if !stage.is_empty() { |
| @@ -1433,7 +1428,7 @@ async fn retry_list(lang: Lang, username: String, csrf: &str, rows: Vec<(ImportJ | ||
| 1433 | 1428 | Ok(view! { |
| 1434 | 1429 | head(title: g::t(lang, K::RetryFailedTitle)) |
| 1435 | 1430 | crate::pages::profile::own_profile_tabs(lang: lang, username: username, current: "repositories".to_owned()) |
| 1436 | - newrepo_tabs(lang: lang, active: "import") | |
| 1431 | + newrepo_tabs(lang: lang, active: "history") | |
| 1437 | 1432 | <div class="sheet"> |
| 1438 | 1433 | <form method="post" action="/import/retry" class="fields"> |
| 1439 | 1434 | csrf_field(token: csrf) |
crates/forge-web/src/pages/profile.rsmodified+38 -28
| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | //! the tabs: `overview` (pinned repos, or the most recently active ones when nothing is pinned, |
| 3 | 3 | //! plus a person's contribution calendar, or an organization's members and teams), `repositories`, |
| 4 | 4 | //! `snippets` (people only), `stars`, `packages` and `organizations` (the viewer's own only). The |
| 5 | -//! repo tabs list what the viewer is allowed to read, 30 per page, with a name filter and three | |
| 5 | +//! repo tabs list what the viewer is allowed to read, 10 per page, so a page fits the screen,, with a name filter and three | |
| 6 | 6 | //! sort orders; the filtering, sorting and paging run in the database. Fixed single-segment routes |
| 7 | 7 | //! are registered statically, so they win over this parameter route. |
| 8 | 8 | |
| @@ -48,7 +48,7 @@ use crate::views::{ | ||
| 48 | 48 | path_param!(username); |
| 49 | 49 | |
| 50 | 50 | /// Repos per page on the repositories and stars tabs. |
| 51 | -const PER_PAGE: u64 = 30; | |
| 51 | +const PER_PAGE: u64 = 10; | |
| 52 | 52 | /// What the pin menu needs: shown to whoever may edit the pins, on the overview. |
| 53 | 53 | struct PinsMenu { |
| 54 | 54 | action: String, |
| @@ -229,6 +229,18 @@ async fn profile_page(cx: &Cx) -> Result<impl View> { | ||
| 229 | 229 | .map(|summary| list_row(lang, summary)) |
| 230 | 230 | .collect() |
| 231 | 231 | }; |
| 232 | + // Snippets page like the repo tabs, so the tab fits the screen however many there are. | |
| 233 | + let snippet_total = snippets.len() as u64; | |
| 234 | + let snippet_pages = snippet_total.div_ceil(PER_PAGE).max(1); | |
| 235 | + let snippet_page = page.min(snippet_pages); | |
| 236 | + let snippet_pager = pager_links(snippet_page, snippet_pages, |n| { | |
| 237 | + profile_href(&user.username, "snippets", &Finder::default(), SORTS[0].0, n) | |
| 238 | + }); | |
| 239 | + let snippets: Vec<ListRow> = snippets | |
| 240 | + .into_iter() | |
| 241 | + .skip(((snippet_page - 1) * PER_PAGE) as usize) | |
| 242 | + .take(PER_PAGE as usize) | |
| 243 | + .collect(); | |
| 232 | 244 | |
| 233 | 245 | // The viewer's Organizations tab lists the organizations they belong to, and whether the |
| 234 | 246 | // instance lets them create one. |
| @@ -367,7 +379,8 @@ async fn profile_page(cx: &Cx) -> Result<impl View> { | ||
| 367 | 379 | pins_menu_data: pins_menu_data, pins_error: pins_error, edit_profile: own, listing: listing, |
| 368 | 380 | packages_on: packages_on, package_rows: package_rows, |
| 369 | 381 | org_member: org_member, org_owner: org_owner, org_can_create: org_can_create, |
| 370 | - heat: heat, snippets: snippets, orgs: orgs, org_create_allowed: org_create_allowed, | |
| 382 | + heat: heat, snippets: snippets, snippet_total: snippet_total, | |
| 383 | + snippet_paging: (snippet_page, snippet_pages, snippet_pager), orgs: orgs, org_create_allowed: org_create_allowed, | |
| 371 | 384 | own_profile: own)) |
| 372 | 385 | }) |
| 373 | 386 | } |
| @@ -612,11 +625,14 @@ async fn profile_card( | ||
| 612 | 625 | org_can_create: bool, |
| 613 | 626 | heat: Option<(Calendar, Option<DayDetail>)>, |
| 614 | 627 | snippets: Vec<ListRow>, |
| 628 | + snippet_total: u64, | |
| 629 | + snippet_paging: (u64, u64, (Vec<PageLink>, Option<String>, Option<String>)), | |
| 615 | 630 | own_profile: bool, |
| 616 | 631 | orgs: Vec<OrgCard>, |
| 617 | 632 | org_create_allowed: bool, |
| 618 | 633 | ) -> Result<impl View> { |
| 619 | 634 | let has_snippets = !snippets.is_empty(); |
| 635 | + let (snippet_page, snippet_pages, (snippet_links, snippet_prev, snippet_next)) = snippet_paging; | |
| 620 | 636 | let snippets_on = tab == "snippets"; |
| 621 | 637 | let orgs_on = tab == "organizations"; |
| 622 | 638 | let has_orgs = !orgs.is_empty(); |
| @@ -637,7 +653,7 @@ async fn profile_card( | ||
| 637 | 653 | profile_items(lang, &user.username, is_org, own_profile, org_member); |
| 638 | 654 | let tab_counts = vec![ |
| 639 | 655 | ("repositories", repo_total.to_string()), |
| 640 | - ("snippets", snippets.len().to_string()), | |
| 656 | + ("snippets", snippet_total.to_string()), | |
| 641 | 657 | ("stars", star_total.to_string()), |
| 642 | 658 | ("packages", package_rows.len().to_string()), |
| 643 | 659 | ]; |
| @@ -695,14 +711,20 @@ async fn profile_card( | ||
| 695 | 711 | Ok(view! { |
| 696 | 712 | head(title: heading.as_str(), sub: sub, |
| 697 | 713 | <img class=(avatar_class) src=(src) alt="" width=(avatar_px) height=(avatar_px)> |
| 698 | - if edit_profile { | |
| 714 | + if edit_profile && overview_on { | |
| 699 | 715 | <a class="button" href="/settings/profile">(edit_label)</a> |
| 700 | 716 | } |
| 701 | - if org_owner { | |
| 717 | + if org_owner && overview_on { | |
| 702 | 718 | <a class="button" href=(settings_href.as_str())>(org_edit_label)</a> |
| 703 | 719 | } |
| 704 | - if org_can_create { | |
| 705 | - <a class="button primary" href=(new_repo_href.as_str())>(g::t(lang, K::NewRepository))</a> | |
| 720 | + if (org_can_create || own_profile) && repos_on { | |
| 721 | + <a class="button" href=(new_repo_href.as_str())>(g::t(lang, K::NewRepository))</a> | |
| 722 | + } | |
| 723 | + if own_profile && snippets_on { | |
| 724 | + <a class="button" href="/snippets/new">(cm::t(lang, CK::NewSnippet))</a> | |
| 725 | + } | |
| 726 | + if org_create_allowed && orgs_on { | |
| 727 | + <a class="button" href="/org/new">(g::t(lang, K::NewOrganization))</a> | |
| 706 | 728 | } |
| 707 | 729 | ) |
| 708 | 730 | profile_tabs(username: user.username.clone(), items: tab_items, current: tab.clone(), counts: tab_counts) |
| @@ -784,11 +806,6 @@ async fn profile_card( | ||
| 784 | 806 | } else { |
| 785 | 807 | <p class="state">(empty)</p> |
| 786 | 808 | } |
| 787 | - if own_profile && repos_on { | |
| 788 | - <div class="acts"> | |
| 789 | - <a class="act" href="/new">(g::t(lang, K::NewRepository))</a> | |
| 790 | - </div> | |
| 791 | - } | |
| 792 | 809 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 793 | 810 | </section> |
| 794 | 811 | } |
| @@ -821,26 +838,17 @@ async fn profile_card( | ||
| 821 | 838 | if snippets_on { |
| 822 | 839 | <section class="sec snippet-listing"> |
| 823 | 840 | <h2>(cm::t(lang, CK::Snippets))</h2> |
| 824 | - if own_profile { | |
| 825 | - <div class="acts"> | |
| 826 | - <a class="act" href="/snippets/new">(cm::t(lang, CK::NewSnippet))</a> | |
| 827 | - </div> | |
| 828 | - } | |
| 829 | 841 | if has_snippets { |
| 830 | 842 | snippet_rows(lang: lang, rows: snippets) |
| 831 | 843 | } else { |
| 832 | 844 | <p class="state">(cm::t(lang, CK::NoSnippets))</p> |
| 833 | 845 | } |
| 846 | + pager(page: snippet_page, pages: snippet_pages, links: snippet_links, prev: snippet_prev, next: snippet_next, lang: lang) | |
| 834 | 847 | </section> |
| 835 | 848 | } |
| 836 | 849 | if orgs_on { |
| 837 | 850 | <section class="sec profile-orgs"> |
| 838 | 851 | <h2>(g::t(lang, K::Organizations))</h2> |
| 839 | - if org_create_allowed { | |
| 840 | - <div class="acts"> | |
| 841 | - <a class="act" href="/org/new">(g::t(lang, K::NewOrganization))</a> | |
| 842 | - </div> | |
| 843 | - } | |
| 844 | 852 | if has_orgs { |
| 845 | 853 | for org in orgs.into_iter() { |
| 846 | 854 | <div class="line" data-kb-row=""> |
| @@ -1269,10 +1277,12 @@ mod tests { | ||
| 1269 | 1277 | !anon.contains("Customize pins"), |
| 1270 | 1278 | "org pins: anonymous has no edit link" |
| 1271 | 1279 | ); |
| 1280 | + let (_, owner_repos) = | |
| 1281 | + get(&site.router, "/acme?tab=repositories", Some(&owner_cookie)).await; | |
| 1272 | 1282 | assert!( |
| 1273 | 1283 | owner.contains("class=\"button\" href=\"/org/acme/settings\"") |
| 1274 | - && owner.contains("/new?owner=acme"), | |
| 1275 | - "org profile: owner sees Edit organization and New repository" | |
| 1284 | + && owner_repos.contains("/new?owner=acme"), | |
| 1285 | + "org profile: Edit organization on the overview, New repository on Repositories" | |
| 1276 | 1286 | ); |
| 1277 | 1287 | assert!( |
| 1278 | 1288 | !anon.contains("/org/acme/members"), |
| @@ -1434,19 +1444,19 @@ mod tests { | ||
| 1434 | 1444 | async fn repositories_tab_paging_and_name_filter() { |
| 1435 | 1445 | let site = bulk_site().await; |
| 1436 | 1446 | |
| 1437 | - // Thirty repos per page, the rest on page two. | |
| 1447 | + // Ten repos per page, the last five on page four. | |
| 1438 | 1448 | let (status, first) = get(&site.router, "/tahinli?tab=repositories&sort=name", None).await; |
| 1439 | 1449 | assert_eq!(status, 200, "paging: first page"); |
| 1440 | 1450 | assert_eq!( |
| 1441 | 1451 | count(&first, "class=\"name repo-name\""), |
| 1442 | - 30, | |
| 1452 | + 10, | |
| 1443 | 1453 | "paging: first page size" |
| 1444 | 1454 | ); |
| 1445 | 1455 | assert!(first.contains("page=2"), "paging: next link: {first}"); |
| 1446 | 1456 | |
| 1447 | 1457 | let (_, second) = get( |
| 1448 | 1458 | &site.router, |
| 1449 | - "/tahinli?tab=repositories&sort=name&page=2", | |
| 1459 | + "/tahinli?tab=repositories&sort=name&page=4", | |
| 1450 | 1460 | None, |
| 1451 | 1461 | ) |
| 1452 | 1462 | .await; |
docs/ui-language.mdmodified+10 -0
| @@ -70,6 +70,16 @@ no `margin-left:auto`, no `justify-content:space-between`, no second column at t | ||
| 70 | 70 | `a.button` for a link that acts like one. Every action beside a title is that soft pill (or the filled |
| 71 | 71 | one), whatever it is made of: an `a.act`, a form's `button.act` or a reveal's `summary.act` in the head |
| 72 | 72 | takes the pill's look, so no head shows a bare word beside a button. |
| 73 | + On a tabbed page the head's action follows the tab: a profile shows Edit profile on Overview, New | |
| 74 | + repository on Repositories, New snippet on Snippets and New organization on Organizations, and the | |
| 75 | + list itself carries no second "New ..." line under it. | |
| 76 | +- **Facts**: a page that describes one thing (an account, an organization) lists it as `.sec.facts`: | |
| 77 | + compact 34px lines of a `.key` on the label column, the `.val`, and the action for that fact on the | |
| 78 | + same line. No hints stacked under a heading: what a fact means or why its action is missing goes in | |
| 79 | + its value. | |
| 80 | +- **Time range**: every log has a When filter (Any time, Last hour, Last 24 hours, Last 7 days, Last | |
| 81 | + 30 days, Today, Dates…). Dates… shows From and To day fields in the viewer's timezone, and the tools | |
| 82 | + row starts with the count of entries that match, so "how many sign-ins last week" is one glance. | |
| 73 | 83 | - **Tool**: `.act`, a quiet word (14px, dim, radius 12). `.act.danger` for destructive. This is what goes in |
| 74 | 84 | tools rows, in rows and in `.acts`. |
| 75 | 85 | - `reveal(label, id, open)`: a tool that opens its form in place. `open` when a form came back with an error. |
style/_one.scssmodified+63 -0
| @@ -3426,6 +3426,15 @@ nav.pager.pager-numbered { | ||
| 3426 | 3426 | border-radius: 16px; |
| 3427 | 3427 | font-size: 14px; |
| 3428 | 3428 | } |
| 3429 | + | |
| 3430 | + input[type="date"] { | |
| 3431 | + width: auto; | |
| 3432 | + height: 32px; | |
| 3433 | + min-height: 0; | |
| 3434 | + padding: 0 12px; | |
| 3435 | + border-radius: 16px; | |
| 3436 | + font-size: 14px; | |
| 3437 | + } | |
| 3429 | 3438 | } |
| 3430 | 3439 | |
| 3431 | 3440 | // A list's search inside a topic: the same row as a sheet's tools, on the topic's edge. |
| @@ -3573,3 +3582,57 @@ details.log-group { | ||
| 3573 | 3582 | width: auto; |
| 3574 | 3583 | } |
| 3575 | 3584 | } |
| 3585 | + | |
| 3586 | +// A facts topic: each line is a label on the label column, its value, and the action for it. | |
| 3587 | +// Facts read as a short table: compact lines with no rules or gaps between them. | |
| 3588 | +.sec.facts { | |
| 3589 | + gap: 0; | |
| 3590 | + | |
| 3591 | + > h2 { | |
| 3592 | + margin-bottom: 6px; | |
| 3593 | + } | |
| 3594 | +} | |
| 3595 | + | |
| 3596 | +.sec.facts > .line { | |
| 3597 | + min-height: 34px; | |
| 3598 | + padding-top: 2px; | |
| 3599 | + padding-bottom: 2px; | |
| 3600 | + border-bottom: 0; | |
| 3601 | +} | |
| 3602 | + | |
| 3603 | +// An opened action in a fact line keeps its field and button on the line. | |
| 3604 | +.sec.facts .line > details.reveal > form.opened { | |
| 3605 | + flex-wrap: nowrap; | |
| 3606 | + | |
| 3607 | + > input[type="text"] { | |
| 3608 | + flex: none; | |
| 3609 | + width: 280px; | |
| 3610 | + } | |
| 3611 | + | |
| 3612 | + @media (max-width: 640px) { | |
| 3613 | + flex-wrap: wrap; | |
| 3614 | + | |
| 3615 | + > input[type="text"] { | |
| 3616 | + width: 100%; | |
| 3617 | + } | |
| 3618 | + } | |
| 3619 | +} | |
| 3620 | + | |
| 3621 | +.sec.facts .line > .key { | |
| 3622 | + flex: 0 0 136px; | |
| 3623 | + color: var(--muted); | |
| 3624 | + font-size: 14px; | |
| 3625 | + | |
| 3626 | + // On a phone every label sits over its value, so no line differs from the next. | |
| 3627 | + @media (max-width: 640px) { | |
| 3628 | + flex-basis: 100%; | |
| 3629 | + } | |
| 3630 | +} | |
| 3631 | + | |
| 3632 | +@media (max-width: 640px) { | |
| 3633 | + .sec.facts > .line { | |
| 3634 | + row-gap: 0; | |
| 3635 | + padding-top: 4px; | |
| 3636 | + padding-bottom: 4px; | |
| 3637 | + } | |
| 3638 | +} |