forge
Explore
Log in

Don't you dare go Hollow

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 commit

24d3e506cb9b93b797978bcb27caa78f7acfec39Ahmet Kaan GümüşParent: 9b600b7
All checks have passed
Show checks
  • 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
Show full message
💄 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
crates/forge-core/src/audit.rsmodified+4 -0
@@ -390,6 +390,10 @@ pub struct AuditFilter {
390390 pub target_id: Option<String>,
391391 /// Matches entries where this user is the actor, or the `user` target.
392392 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>,
393397 }
394398
395399 /// 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
5454 params.push(Value::Text(user.clone()));
5555 params.push(Value::Text(user.clone()));
5656 }
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+ }
5765 if let Some(cursor) = before {
5866 clauses.push("(at < ? OR (at = ? AND id < ?))");
5967 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};
2727 use crate::pages::admin_users::admin_only;
2828 use crate::pages::passkeys::s;
2929 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};
3131 use crate::views::{alert, enc, rel_time, rel_time_or_never, shell, user_facing_message};
3232
3333 #[query_params(error = bad_request)]
@@ -53,6 +53,16 @@ struct Detail {
5353 passkeys: i64,
5454 /// An administrator with no other administrator beside them: demoting is refused.
5555 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)>,
5666 }
5767
5868 /// What the page says above the facts after an action.
@@ -86,7 +96,38 @@ async fn load(cx: &Cx) -> Result<Detail> {
8696 if target.is_org() || is_ghost(&target) {
8797 return Err(not_found().into());
8898 }
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();
89119 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,
90131 facts: store.account_facts(&target.id).await?,
91132 suspension: store.suspension(&target.id).await?,
92133 passkeys: store.passkey_count(&target.id).await?,
@@ -111,11 +152,19 @@ fn done_text(lang: Lang, done: &str) -> Option<&'static str> {
111152 })
112153 }
113154
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+
114162 #[component]
115163 async fn detail_body(
116164 lang: Lang,
117165 csrf: &str,
118166 viewer_id: &str,
167+ tz: String,
119168 detail: Detail,
120169 notice: Notice,
121170 ) -> Result<impl View> {
@@ -125,11 +174,17 @@ async fn detail_body(
125174 suspension,
126175 passkeys,
127176 last_admin,
177+ email_verified,
178+ last_login,
179+ sessions,
180+ ssh_keys,
181+ gpg_keys,
182+ tokens,
183+ snippets,
184+ orgs,
128185 } = detail;
129186 let base = format!("/admin/users/{}", enc(&target.id));
130187 let own = target.id == viewer_id;
131- let last_login = facts.last_login.clone();
132- let repos = facts.repo_count.to_string();
133188 let suspended = suspension.is_some();
134189 let status = if suspended {
135190 at(lang, A::Suspended)
@@ -146,34 +201,52 @@ async fn detail_body(
146201 let role = if is_admin {
147202 at(lang, A::Administrator)
148203 } else {
149- g::t(lang, K::RoleUser)
204+ s(lang, "User", "Kullanıcı")
150205 };
151206 let suspended_note = match suspension.as_ref().map(|s| s.reason.clone()) {
152207 Some(reason) if !reason.is_empty() => reason,
153208 _ => at(lang, A::AccountSuspended).to_owned(),
154209 };
210+ let suspended_since = suspension
211+ .as_ref()
212+ .map(|s| local_stamp(&s.suspended_at, &tz))
213+ .unwrap_or_default();
155214 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();
156239 let suspend_action = format!("{base}/suspend");
157240 let unsuspend_action = format!("{base}/unsuspend");
158241 let admin_action = format!("{base}/admin");
159242 let reset_action = format!("{base}/reset-link");
160243 let tfa_action = format!("{base}/disable-2fa");
161244 let passkeys_action = format!("{base}/remove-passkeys");
162- let passkey_count = passkeys.to_string();
163245 let delete_href = format!("{base}/delete");
164246 let live = format!("{base}/events");
165247 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));
177250 let reset_note = s(
178251 lang,
179252 "Their sessions end at once.",
@@ -184,113 +257,193 @@ async fn detail_body(
184257 "Remove every passkey of this user?",
185258 "Bu kullanıcının tüm geçiş anahtarları kaldırılsın mı?",
186259 );
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");
192260 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+ };
193298 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}")));
201304 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>
204307 )
205308 <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>
212309 if let Some(message) = done {
213310 <p class="state" role="status">(message)</p>
214311 }
215312 if let Some(message) = error {
216313 alert(message: message.as_str())
217314 }
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 {
224383 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>
230384 }
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>
244394 }
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 {
252404 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 {
257407 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>
260414 </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>
270420 confirm_act(lang: lang, label: at(lang, A::GenerateLink), action: reset_action.as_str(), csrf: csrf, note: Some(reset_note.to_owned()))
271421 </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 {
275430 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>
288440 </section>
289441 if !own {
290- <section class="sec">
442+ <section class="sec facts">
291443 <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>
294447 <a class="act danger" href=(delete_href.as_str())>(i18n::t(lang, Key::Delete))</a>
295448 </div>
296449 </section>
@@ -300,14 +453,28 @@ async fn detail_body(
300453 }
301454
302455 /// 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.
304457 #[component]
305458 async fn org_body(
306459 lang: Lang,
307- csrf: &str,
308460 org: User,
309461 members: Vec<(User, OrgMemberRole)>,
462+ repos: usize,
463+ teams: usize,
464+ tz: String,
310465 ) -> 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+ );
311478 let base = format!("/admin/users/{}", enc(&org.id));
312479 let delete_action = format!("{base}/delete");
313480 let profile = format!("/{}", enc(&org.username));
@@ -335,16 +502,43 @@ async fn org_body(
335502 <a class="button" href=(profile.as_str())>(profile_label)</a>
336503 )
337504 <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">
339531 <h2>(og::t(lang, OG::Members))</h2>
340532 for (href, name, role) in rows.iter() {
341533 <a class="line" href=(href.as_str())><span class="name">(name.as_str())</span><span class="val">(*role)</span></a>
342534 }
343535 </section>
344- <section class="sec">
536+ <section class="sec facts">
345537 <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>
348542 </div>
349543 </section>
350544 </div>
@@ -402,7 +596,9 @@ async fn detail_page(cx: &Cx) -> Result<impl View> {
402596 let org = match store.user_by_id(&id).await? {
403597 Some(user) if user.is_org() => {
404598 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))
406602 }
407603 _ => None,
408604 };
@@ -413,7 +609,7 @@ async fn detail_page(cx: &Cx) -> Result<impl View> {
413609 };
414610 let title = org
415611 .as_ref()
416- .map(|(user, _)| user.username.clone())
612+ .map(|(user, ..)| user.username.clone())
417613 .or_else(|| detail.as_ref().map(|d| d.target.username.clone()))
418614 .unwrap_or_default();
419615 let notice = Notice {
@@ -423,8 +619,8 @@ async fn detail_page(cx: &Cx) -> Result<impl View> {
423619 let csrf = viewer.1.csrf_token.clone();
424620 Ok(view! {
425621 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) })
428624 })
429625 }
430626
@@ -586,7 +782,7 @@ async fn respond(cx: &Cx, form: ActionForm, action: Action) -> Result<impl View>
586782 let csrf = viewer.1.csrf_token.clone();
587783 let title = detail.target.username.clone();
588784 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))
590786 })
591787 }
592788
crates/forge-web/src/pages/audit_log.rsmodified+131 -6
@@ -42,6 +42,12 @@ pub(crate) struct AuditQuery {
4242 /// still filter by it.
4343 actor: Option<String>,
4444 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>,
4551 exact: Option<String>,
4652 case: Option<String>,
4753 /// Old cursor links. Still accepted so old bookmarks load, and ignored.
@@ -51,6 +57,89 @@ pub(crate) struct AuditQuery {
5157 page: Option<String>,
5258 }
5359
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+
54143 /// One entry, already formatted for display.
55144 struct RowView {
56145 when: String,
@@ -312,10 +401,15 @@ async fn log_tools(
312401 finder: Finder,
313402 action: String,
314403 actor: String,
404+ span: Span,
405+ total: usize,
315406 ) -> Result<impl View> {
316407 let placeholder = s(lang, "Search the log", "Günlükte ara");
408+ let count = entry_count(lang, total);
409+ let custom = span.when == "custom";
317410 Ok(view! {
318411 <div class="sheet-tools">
412+ <strong>(count.as_str())</strong>
319413 <form method="get" action=(form_action)>
320414 finder_field(lang: lang, finder: finder, placeholder: placeholder, id: Some("log-q"))
321415 <label class="find-filter">
@@ -327,6 +421,25 @@ async fn log_tools(
327421 }
328422 </select>
329423 </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+ }
330443 if !actor.is_empty() {
331444 <input type="hidden" name="actor" value=(actor.as_str())>
332445 }
@@ -478,6 +591,8 @@ async fn admin_audit_view(
478591 action: String,
479592 actor: String,
480593 notice: Option<String>,
594+ span: Span,
595+ total: usize,
481596 groups: Vec<Group>,
482597 page: u64,
483598 pages: u64,
@@ -488,7 +603,7 @@ async fn admin_audit_view(
488603 Ok(view! {
489604 head(title: g::t(lang, K::AuditLog), sub: sub)
490605 <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)
492607 if let Some(message) = notice {
493608 <p class="state" role="status">(message.as_str())</p>
494609 }
@@ -504,6 +619,8 @@ async fn own_log_view(
504619 items: Vec<RailItem>,
505620 finder: Finder,
506621 action: String,
622+ span: Span,
623+ total: usize,
507624 groups: Vec<Group>,
508625 page: u64,
509626 pages: u64,
@@ -516,7 +633,7 @@ async fn own_log_view(
516633 <div class="work">
517634 rail(label: i18n::t(lang, i18n::Key::Security), items: items)
518635 <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)
520637 audit_table(lang: lang, groups: groups, show_actor: false)
521638 pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang)
522639 </div>
@@ -551,8 +668,10 @@ async fn admin_audit_page(cx: &Cx) -> Result<impl View> {
551668 let query = query_params::<AuditQuery>(cx)?;
552669 let store = &app_context::<AppState>(cx).store;
553670 let (finder, action, actor) = query_parts(query);
671+ let span = Span::from_query(query);
554672
555673 let mut filter = AuditFilter::default();
674+ span.apply(&mut filter, &viewer.0.timezone);
556675 let mut notice: Option<String> = None;
557676 if !action.is_empty() {
558677 match AuditAction::parse(&action) {
@@ -573,8 +692,10 @@ async fn admin_audit_page(cx: &Cx) -> Result<impl View> {
573692 fetch_entries(store, &filter).await?
574693 };
575694 let groups = fold_groups(&entries, lang, &finder);
695+ let total = groups.iter().map(|group| group.rows.len()).sum();
576696 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());
578699 let nav = nav_for(page, pages, "/admin/audit", &params);
579700 let live = list_href(
580701 "/admin/audit/events",
@@ -582,7 +703,7 @@ async fn admin_audit_page(cx: &Cx) -> Result<impl View> {
582703 );
583704 let title = g::t(lang, K::AuditLog);
584705 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))
586707 })
587708 }
588709
@@ -634,23 +755,27 @@ async fn own_log_page(cx: &Cx) -> Result<impl View> {
634755 let query = query_params::<AuditQuery>(cx)?;
635756 let store = &app_context::<AppState>(cx).store;
636757 let (finder, action, _) = query_parts(query);
758+ let span = Span::from_query(query);
637759 let mut filter = AuditFilter {
638760 involving_user: Some(viewer.0.id.clone()),
639761 ..Default::default()
640762 };
763+ span.apply(&mut filter, &viewer.0.timezone);
641764 // An unknown action is ignored here: the menu only offers known ones.
642765 if let Some(known) = AuditAction::parse(&action) {
643766 filter.action = Some(known);
644767 }
645768 let entries = fetch_entries(store, &filter).await?;
646769 let groups = fold_groups(&entries, lang, &finder);
770+ let total = groups.iter().map(|group| group.rows.len()).sum();
647771 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());
649774 let nav = nav_for(page, pages, "/settings/security/log", &params);
650775 let items = security_rail_for(app_context::<AppState>(cx), lang, &viewer, "log").await?;
651776 let title = g::t(lang, K::SecurityLogTitle);
652777 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))
654779 })
655780 }
656781
crates/forge-web/src/pages/import.rsmodified+41 -46
@@ -32,6 +32,7 @@ use crate::pages::new_repo::{owner_choices, repo_owner};
3232 use crate::pages::repo_ctx::still_readable;
3333 use crate::state::AppState;
3434 use crate::views::parts::{SubPart, head};
35+use crate::views::repo_list::{PageLink, pager, pager_links};
3536 use crate::views::{alert, csrf_field, rel_time, shell, user_facing_message};
3637
3738 path_param!(job_id);
@@ -113,6 +114,8 @@ struct SourceQuery {
113114 struct JobsQuery {
114115 /// The repositories a bulk import left out, with why, as one line.
115116 skipped: Option<String>,
117+ /// The 1-based page of the history.
118+ page: Option<String>,
116119 }
117120
118121 #[query_params(error = bad_request)]
@@ -165,10 +168,12 @@ fn token_of(raw: &str) -> Option<String> {
165168 pub(crate) async fn newrepo_tabs(lang: Lang, active: &str) -> Result<impl View> {
166169 let create = active == "create";
167170 let import = active == "import";
171+ let history = active == "history";
168172 Ok(view! {
169173 <nav class="tabs" aria-label=(g::t(lang, K::ImportTitle))>
170174 <a href="/new" aria-current=(create.then_some("page"))>(g::t(lang, K::TabCreate))</a>
171175 <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>
172177 </nav>
173178 })
174179 }
@@ -388,10 +393,7 @@ async fn import_form(
388393 })
389394 }
390395
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.
395397 #[component]
396398 async fn import_home(
397399 lang: Lang,
@@ -399,12 +401,9 @@ async fn import_home(
399401 csrf: String,
400402 draft: Draft,
401403 owners: Vec<String>,
402- jobs: Vec<(ImportJob, Option<Repo>)>,
403- more: bool,
404404 ) -> Result<impl View> {
405405 Ok(view! {
406406 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)
408407 })
409408 }
410409
@@ -432,13 +431,9 @@ async fn import_page(cx: &Cx) -> Result<impl View> {
432431 let state = app_context::<AppState>(cx);
433432 let owners = owner_choices(state, &viewer.0).await?;
434433 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);
439434 Ok(view! { cx =>
440435 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))
442437 })
443438 }
444439
@@ -1056,47 +1051,23 @@ async fn job_rows(lang: Lang, jobs: Vec<(ImportJob, Option<Repo>)>) -> Result<im
10561051 })
10571052 }
10581053
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-
10871054 #[component]
10881055 async fn jobs_list(
10891056 lang: Lang,
10901057 username: String,
10911058 jobs: Vec<(ImportJob, Option<Repo>)>,
10921059 skipped: Option<String>,
1060+ page: u64,
1061+ pages: u64,
1062+ nav: (Vec<PageLink>, Option<String>, Option<String>),
10931063 ) -> Result<impl View> {
1064+ let (links, prev, next) = nav;
10941065 let empty = jobs.is_empty();
10951066 let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed);
10961067 Ok(view! {
10971068 head(title: g::t(lang, K::JobsTitle), live: Some("/import/events"))
10981069 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")
11001071 <div class="sheet">
11011072 if retry {
11021073 <div class="sheet-tools">
@@ -1114,6 +1085,7 @@ async fn jobs_list(
11141085 } else {
11151086 job_rows(lang: lang, jobs: jobs)
11161087 }
1088+ pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang)
11171089 </div>
11181090 })
11191091 }
@@ -1158,19 +1130,42 @@ async fn jobs_events(cx: &Cx) -> Result<Response> {
11581130 .await
11591131 }
11601132
1133+/// Imports per page of the history.
1134+const HISTORY_ROWS: u64 = 10;
1135+
11611136 #[page("/import")]
11621137 async fn jobs_page(cx: &Cx) -> Result<impl View> {
11631138 let viewer = require_user(cx).await?;
11641139 let lang = i18n::lang(cx, Some(&viewer.0));
11651140 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
11681163 .skipped
11691164 .clone()
11701165 .filter(|s| !s.is_empty() && s.len() < 2000)
11711166 .map(|s| g::bulk_skipped(lang, &s));
11721167 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))
11741169 })
11751170 }
11761171
@@ -1211,7 +1206,7 @@ async fn job_view(
12111206 Ok(view! {
12121207 head(title: job.source_ref.as_str(), sub: sub, live: live.as_deref())
12131208 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")
12151210 <div class="sheet import-job" data-live-state=(state_word)>
12161211 <section class="sec">
12171212 if !stage.is_empty() {
@@ -1433,7 +1428,7 @@ async fn retry_list(lang: Lang, username: String, csrf: &str, rows: Vec<(ImportJ
14331428 Ok(view! {
14341429 head(title: g::t(lang, K::RetryFailedTitle))
14351430 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")
14371432 <div class="sheet">
14381433 <form method="post" action="/import/retry" class="fields">
14391434 csrf_field(token: csrf)
crates/forge-web/src/pages/profile.rsmodified+38 -28
@@ -2,7 +2,7 @@
22 //! the tabs: `overview` (pinned repos, or the most recently active ones when nothing is pinned,
33 //! plus a person's contribution calendar, or an organization's members and teams), `repositories`,
44 //! `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
66 //! sort orders; the filtering, sorting and paging run in the database. Fixed single-segment routes
77 //! are registered statically, so they win over this parameter route.
88
@@ -48,7 +48,7 @@ use crate::views::{
4848 path_param!(username);
4949
5050 /// Repos per page on the repositories and stars tabs.
51-const PER_PAGE: u64 = 30;
51+const PER_PAGE: u64 = 10;
5252 /// What the pin menu needs: shown to whoever may edit the pins, on the overview.
5353 struct PinsMenu {
5454 action: String,
@@ -229,6 +229,18 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
229229 .map(|summary| list_row(lang, summary))
230230 .collect()
231231 };
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();
232244
233245 // The viewer's Organizations tab lists the organizations they belong to, and whether the
234246 // instance lets them create one.
@@ -367,7 +379,8 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
367379 pins_menu_data: pins_menu_data, pins_error: pins_error, edit_profile: own, listing: listing,
368380 packages_on: packages_on, package_rows: package_rows,
369381 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,
371384 own_profile: own))
372385 })
373386 }
@@ -612,11 +625,14 @@ async fn profile_card(
612625 org_can_create: bool,
613626 heat: Option<(Calendar, Option<DayDetail>)>,
614627 snippets: Vec<ListRow>,
628+ snippet_total: u64,
629+ snippet_paging: (u64, u64, (Vec<PageLink>, Option<String>, Option<String>)),
615630 own_profile: bool,
616631 orgs: Vec<OrgCard>,
617632 org_create_allowed: bool,
618633 ) -> Result<impl View> {
619634 let has_snippets = !snippets.is_empty();
635+ let (snippet_page, snippet_pages, (snippet_links, snippet_prev, snippet_next)) = snippet_paging;
620636 let snippets_on = tab == "snippets";
621637 let orgs_on = tab == "organizations";
622638 let has_orgs = !orgs.is_empty();
@@ -637,7 +653,7 @@ async fn profile_card(
637653 profile_items(lang, &user.username, is_org, own_profile, org_member);
638654 let tab_counts = vec![
639655 ("repositories", repo_total.to_string()),
640- ("snippets", snippets.len().to_string()),
656+ ("snippets", snippet_total.to_string()),
641657 ("stars", star_total.to_string()),
642658 ("packages", package_rows.len().to_string()),
643659 ];
@@ -695,14 +711,20 @@ async fn profile_card(
695711 Ok(view! {
696712 head(title: heading.as_str(), sub: sub,
697713 <img class=(avatar_class) src=(src) alt="" width=(avatar_px) height=(avatar_px)>
698- if edit_profile {
714+ if edit_profile && overview_on {
699715 <a class="button" href="/settings/profile">(edit_label)</a>
700716 }
701- if org_owner {
717+ if org_owner && overview_on {
702718 <a class="button" href=(settings_href.as_str())>(org_edit_label)</a>
703719 }
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>
706728 }
707729 )
708730 profile_tabs(username: user.username.clone(), items: tab_items, current: tab.clone(), counts: tab_counts)
@@ -784,11 +806,6 @@ async fn profile_card(
784806 } else {
785807 <p class="state">(empty)</p>
786808 }
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- }
792809 pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang)
793810 </section>
794811 }
@@ -821,26 +838,17 @@ async fn profile_card(
821838 if snippets_on {
822839 <section class="sec snippet-listing">
823840 <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- }
829841 if has_snippets {
830842 snippet_rows(lang: lang, rows: snippets)
831843 } else {
832844 <p class="state">(cm::t(lang, CK::NoSnippets))</p>
833845 }
846+ pager(page: snippet_page, pages: snippet_pages, links: snippet_links, prev: snippet_prev, next: snippet_next, lang: lang)
834847 </section>
835848 }
836849 if orgs_on {
837850 <section class="sec profile-orgs">
838851 <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- }
844852 if has_orgs {
845853 for org in orgs.into_iter() {
846854 <div class="line" data-kb-row="">
@@ -1269,10 +1277,12 @@ mod tests {
12691277 !anon.contains("Customize pins"),
12701278 "org pins: anonymous has no edit link"
12711279 );
1280+ let (_, owner_repos) =
1281+ get(&site.router, "/acme?tab=repositories", Some(&owner_cookie)).await;
12721282 assert!(
12731283 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"
12761286 );
12771287 assert!(
12781288 !anon.contains("/org/acme/members"),
@@ -1434,19 +1444,19 @@ mod tests {
14341444 async fn repositories_tab_paging_and_name_filter() {
14351445 let site = bulk_site().await;
14361446
1437- // Thirty repos per page, the rest on page two.
1447+ // Ten repos per page, the last five on page four.
14381448 let (status, first) = get(&site.router, "/tahinli?tab=repositories&sort=name", None).await;
14391449 assert_eq!(status, 200, "paging: first page");
14401450 assert_eq!(
14411451 count(&first, "class=\"name repo-name\""),
1442- 30,
1452+ 10,
14431453 "paging: first page size"
14441454 );
14451455 assert!(first.contains("page=2"), "paging: next link: {first}");
14461456
14471457 let (_, second) = get(
14481458 &site.router,
1449- "/tahinli?tab=repositories&sort=name&page=2",
1459+ "/tahinli?tab=repositories&sort=name&page=4",
14501460 None,
14511461 )
14521462 .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
7070 `a.button` for a link that acts like one. Every action beside a title is that soft pill (or the filled
7171 one), whatever it is made of: an `a.act`, a form's `button.act` or a reveal's `summary.act` in the head
7272 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.
7383 - **Tool**: `.act`, a quiet word (14px, dim, radius 12). `.act.danger` for destructive. This is what goes in
7484 tools rows, in rows and in `.acts`.
7585 - `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 {
34263426 border-radius: 16px;
34273427 font-size: 14px;
34283428 }
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+ }
34293438 }
34303439
34313440 // 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 {
35733582 width: auto;
35743583 }
35753584 }
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+}