forge
Explore
Log in

Don't you dare go Hollow

The sidebar and dashboard are gone: / opens your profile, which holds the contribution calendar and tabs for Repositories (with New repository), Snippets, Stars, Packages and Organizations (with New organization), and a sidebar stays only on section pages

Browse files at this commit

c812504a9bcc48c0950d1f69f878aeaff146e97fAhmet Kaan GümüşParent: 2596bea
Some checks failed
Show checks
  • feat
    • the sidebar and dashboard are gone: / opens your profile, which holds the contribution calendar and tabs for Repositories (with New repository), Snippets, Stars, Packages and Organizations (with New organization), and a sidebar stays only on section pages
    • the profile corner is a floating panel, bottom left by default, that can be dragged anywhere and reset with a double click
    • organizations get a real profile with New repository, Members, Teams and Settings, and their settings take a display name and an avatar
    • failed bulk imports can be retried from a checklist with a token
    • a signed-in user's tree width, panel position, diff view and banner dismissal are stored in the database (migration 0069)
  • fix
    • a form the server refuses keeps its address, so a live refresh no longer lands on a 405 page after a wrong repo transfer
    • the Recent imports card matches the import form's width and no longer touches it
    • deleting a repo returns to the owner's Repositories tab with its notice
Show full message
✨ feat: the sidebar and dashboard are gone: / opens your profile, which holds the contribution calendar and tabs for Repositories (with New repository), Snippets, Stars, Packages and Organizations (with New organization), and a sidebar stays only on section pages; the profile corner is a floating panel, bottom left by default, that can be dragged anywhere and reset with a double click; organizations get a real profile with New repository, Members, Teams and Settings, and their settings take a display name and an avatar; failed bulk imports can be retried from a checklist with a token; a signed-in user's tree width, panel position, diff view and banner dismissal are stored in the database (migration 0069); 🐛 fix: a form the server refuses keeps its address, so a live refresh no longer lands on a 405 page after a wrong repo transfer; the Recent imports card matches the import form's width and no longer touches it; deleting a repo returns to the owner's Repositories tab with its notice

50 changed files +1708 -1357

crates/forge-core/migrations/0069_user_prefs.sqladded+11 -0
@@ -0,0 +1,11 @@
1+-- Account preferences that do not fit a column of `users`: the tree width, the profile corner's
2+-- position and similar. One row per user and key; the web layer decides the keys and values, and
3+-- a value of "" never reaches here (it deletes the row). Applied by store/migrate.rs.
4+
5+CREATE TABLE user_prefs (
6+ user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
7+ key TEXT NOT NULL,
8+ value TEXT NOT NULL,
9+ updated_at TEXT NOT NULL,
10+ PRIMARY KEY (user_id, key)
11+);
crates/forge-core/src/store/migrate.rsmodified+1 -0
@@ -108,6 +108,7 @@ pub const MIGRATIONS: &[(u32, &str)] = &[
108108 (66, include_str!("../../migrations/0066_session_ip.sql")),
109109 (67, include_str!("../../migrations/0067_coauthored_commits.sql")),
110110 (68, include_str!("../../migrations/0068_ci_jobs_runner.sql")),
111+ (69, include_str!("../../migrations/0069_user_prefs.sql")),
111112 ];
112113
113114 /// The highest migration version this binary knows about.
crates/forge-core/src/store/mod.rsmodified+1 -0
@@ -48,6 +48,7 @@ pub mod suspension;
4848 pub mod transfers;
4949 pub mod ui_prefs;
5050 pub mod user_delete;
51+pub mod user_prefs;
5152 pub mod web_push;
5253 pub mod webhooks;
5354 pub mod wiki;
crates/forge-core/src/store/snippets.rsmodified+40 -13
@@ -202,6 +202,20 @@ fn map_snippet(row: &turso::Row) -> Result<Snippet> {
202202 })
203203 }
204204
205+/// One row of the summary queries: id, owner name, title, visibility, update stamp, file count.
206+fn summary_row(row: &turso::Row) -> Result<SnippetSummary> {
207+ let visibility = col_text(row, 3)?;
208+ Ok(SnippetSummary {
209+ id: col_text(row, 0)?,
210+ owner_name: col_text(row, 1)?,
211+ title: col_text(row, 2)?,
212+ visibility: SnippetVisibility::parse(&visibility)
213+ .ok_or_else(|| Error::Database(format!("unknown snippet visibility {visibility}")))?,
214+ updated_at: col_text(row, 4)?,
215+ file_count: u64::try_from(col_int(row, 5)?).unwrap_or(0),
216+ })
217+}
218+
205219 fn map_file(row: &turso::Row) -> Result<SnippetFile> {
206220 Ok(SnippetFile {
207221 name: col_text(row, 0)?,
@@ -411,19 +425,32 @@ impl Store {
411425 WHERE s.visibility = 'public' OR s.owner_id = ?1 \
412426 ORDER BY s.updated_at DESC, s.id DESC LIMIT ?2",
413427 (viewer_id.unwrap_or("").to_string(), LIST_LIMIT),
414- |row| {
415- let visibility = col_text(row, 3)?;
416- Ok(SnippetSummary {
417- id: col_text(row, 0)?,
418- owner_name: col_text(row, 1)?,
419- title: col_text(row, 2)?,
420- visibility: SnippetVisibility::parse(&visibility).ok_or_else(|| {
421- Error::Database(format!("unknown snippet visibility {visibility}"))
422- })?,
423- updated_at: col_text(row, 4)?,
424- file_count: u64::try_from(col_int(row, 5)?).unwrap_or(0),
425- })
426- },
428+ summary_row,
429+ )
430+ .await
431+ }
432+
433+ /// The snippets `owner_id` owns that the viewer can list: their public ones, and all of them
434+ /// when the viewer is the owner. Unlisted ones are left out, as on `list_snippets`. Newest first.
435+ pub async fn list_owner_snippets(
436+ &self,
437+ owner_id: &str,
438+ viewer_id: Option<&str>,
439+ ) -> Result<Vec<SnippetSummary>> {
440+ let conn = self.read_conn().await;
441+ fetch_all(
442+ &conn,
443+ "SELECT s.id, u.username, s.title, s.visibility, s.updated_at, \
444+ (SELECT COUNT(*) FROM snippet_files f WHERE f.snippet_id = s.id) \
445+ FROM snippets s JOIN users u ON u.id = s.owner_id \
446+ WHERE s.owner_id = ?1 AND (s.visibility = 'public' OR s.owner_id = ?2) \
447+ ORDER BY s.updated_at DESC, s.id DESC LIMIT ?3",
448+ (
449+ owner_id.to_string(),
450+ viewer_id.unwrap_or("").to_string(),
451+ LIST_LIMIT,
452+ ),
453+ summary_row,
427454 )
428455 .await
429456 }
crates/forge-core/src/store/user_delete.rsmodified+1 -0
@@ -138,6 +138,7 @@ const REMOVED: &[(&str, &str, &str)] = &[
138138 ),
139139 ("admin notifications", "admin_notifications", "user_id"),
140140 ("reactions", "reactions", "user_id"),
141+ ("preferences", "user_prefs", "user_id"),
141142 ("review requests", "review_requests", "reviewer_id"),
142143 ];
143144
crates/forge-core/src/store/user_prefs.rsadded+55 -0
@@ -0,0 +1,55 @@
1+//! Account preferences that are not columns of `users`: one text value per user and key, in
2+//! `user_prefs` (migration 0069). The web layer decides which keys exist and what each value may
3+//! be; this store only keeps the rows. Rows go with the user (ON DELETE CASCADE).
4+
5+use std::collections::HashMap;
6+
7+use super::{Store, col_text, db_err, fetch_all};
8+use crate::error::Result;
9+use crate::time::now_stamp;
10+
11+impl Store {
12+ /// All of a user's preferences as `key -> value`.
13+ pub async fn user_prefs(&self, user_id: &str) -> Result<HashMap<String, String>> {
14+ let conn = self.read_conn().await;
15+ let rows = fetch_all(
16+ &conn,
17+ "SELECT key, value FROM user_prefs WHERE user_id = ?1",
18+ (user_id.to_string(),),
19+ |row| Ok((col_text(row, 0)?, col_text(row, 1)?)),
20+ )
21+ .await?;
22+ Ok(rows.into_iter().collect())
23+ }
24+
25+ /// Stores `value` under `key` for the user, replacing an earlier value.
26+ pub async fn set_user_pref(&self, user_id: &str, key: &str, value: &str) -> Result<()> {
27+ let conn = self.inner.conn.lock().await;
28+ conn.execute(
29+ "INSERT INTO user_prefs (user_id, key, value, updated_at) VALUES (?1, ?2, ?3, ?4) \
30+ ON CONFLICT (user_id, key) DO UPDATE SET \
31+ value = excluded.value, updated_at = excluded.updated_at",
32+ (
33+ user_id.to_string(),
34+ key.to_string(),
35+ value.to_string(),
36+ now_stamp(),
37+ ),
38+ )
39+ .await
40+ .map_err(db_err)?;
41+ Ok(())
42+ }
43+
44+ /// Removes one preference. A key the user never set is not an error.
45+ pub async fn delete_user_pref(&self, user_id: &str, key: &str) -> Result<()> {
46+ let conn = self.inner.conn.lock().await;
47+ conn.execute(
48+ "DELETE FROM user_prefs WHERE user_id = ?1 AND key = ?2",
49+ (user_id.to_string(), key.to_string()),
50+ )
51+ .await
52+ .map_err(db_err)?;
53+ Ok(())
54+ }
55+}
crates/forge-web/assets/nav.jsmodified+179 -28
@@ -17,6 +17,7 @@
1717 var inFlight = 0; // requests on the wire, drives aria-busy
1818 var pending = new WeakSet(); // forms with a request on the wire: a second submit is ignored
1919 var queued = new WeakSet(); // forms that changed while pending: submitted again once it completes
20+ var heldForm = false; // a rejected form is on screen; see load()
2021 var shown = location.pathname + location.search;
2122 var GET_INIT = { headers: { accept: 'text/html' } };
2223
@@ -427,6 +428,12 @@
427428 }
428429 var dest = new URL(res.url.href);
429430 dest.hash = o.dest.hash;
431+ // A form the server refused comes back as a page under the POST's URL, which may have no GET.
432+ // The address stays on the page the form was sent from, and live refreshes wait, because one
433+ // would replace the error with a fresh page. The next navigation ends the wait.
434+ var refused = o.post && !res.redirected;
435+ if (refused) { dest = new URL(location.href); }
436+ if (o.how !== 'live') { heldForm = refused; }
430437 // A live refresh that lands on another path (a revoked session sent to the login page) is a
431438 // navigation: it gets a history entry, so the address bar shows where the page now is.
432439 var how = o.how === 'live' && res.url.pathname !== o.target.pathname ? 'nav' : o.how;
@@ -564,8 +571,8 @@
564571
565572 // Every page holds one stream to /-/shell/events (`/-/alive` for a page from before a deploy, and for
566573 // an anonymous visitor the same alive events). Its error means the server, or the proxy in front of
567- // it, is down; its open means it is back. Signed-in viewers also get `unread` (the inbox count),
568- // `activity` (the live strip and ring) and `side` (the sidebar's repo list) on the same connection.
574+ // it, is down; its open means it is back. Signed-in viewers also get `unread` (the inbox count) and
575+ // `activity` (the live strip and ring) on the same connection.
569576 // A `theme` event carries the signed-in user's appearance as `name=value` pairs joined by `;`
570577 // (the `<html>` attributes). An empty value removes the attribute. Only data-* names are applied.
571578 function applyAppearance(data) {
@@ -613,9 +620,7 @@
613620 // The inbox count changed (see `unreadChanged` above).
614621 unread: unreadChanged,
615622 // The viewer's activity changed: the strip, ring and chips are fetched again.
616- activity: function () { refreshActivity(); },
617- // The sidebar's repo list changed (the sidebar is re-rendered with the page).
618- side: sideChanged
623+ activity: function () { refreshActivity(); }
619624 });
620625 document.addEventListener('visibilitychange', function () { wake(false); });
621626 document.addEventListener('resume', function () { wake(true); });
@@ -643,11 +648,11 @@
643648 }
644649
645650 // Dropdown menus: the <details> that float over the page (avatar menu, branch selector, clone
646- // popover, phone menu, profile corner). Inline disclosures are not listed: a click outside leaves them open.
651+ // popover, section menu, profile corner). Inline disclosures are not listed: a click outside leaves them open.
647652 var DROPDOWN = 'details.menu, details.ref-select, details.clone, details.nav-toggle, details.corner, details.strip-runs';
648653
649- // Closes every open dropdown that does not contain `from` (pass null to close them all). The corner
650- // sits inside the phone menu, so a click in the corner keeps the phone menu open too.
654+ // Closes every open dropdown that does not contain `from` (pass null to close them all). A click
655+ // inside the floating corner keeps its own menu open.
651656 function closeDropdowns(from) {
652657 document.querySelectorAll(DROPDOWN).forEach(function (d) {
653658 if (d.open && !(from && d.contains(from))) { d.open = false; }
@@ -706,6 +711,138 @@
706711 closeDropdowns(e.target && e.target.nodeType === 1 ? e.target : null);
707712 }, false);
708713
714+ // The profile corner can be dragged anywhere on the window. A press records its start; it becomes a
715+ // drag after CORNER_SLOP px of movement, and then the panel follows the pointer, clamped to the
716+ // window. The released position is kept as fractions of the free space, so it holds at any size.
717+ var CORNER_SLOP = 5;
718+ var cornerPress = null; // { el, id, x, y, left, top, dragging } from a press to its release
719+ var cornerSwallow = false; // the click that ends a drag must not open the menu or the bell
720+
721+ function parseCorner(text) {
722+ var parts = String(text || '').split(',');
723+ if (parts.length !== 2) { return null; }
724+ var x = parseFloat(parts[0]), y = parseFloat(parts[1]);
725+ if (!isFinite(x) || !isFinite(y)) { return null; }
726+ return [Math.min(1, Math.max(0, x)), Math.min(1, Math.max(0, y))];
727+ }
728+ // [x, y] fractions of the stored position, or null for the default corner. Kept current by drags and resets.
729+ var cornerSaved = parseCorner(document.body.dataset.cornerPos);
730+
731+ // Registered before the bell's click listener below, so it runs first and stops the click that
732+ // follows a drag once.
733+ window.addEventListener('click', function (e) {
734+ if (!cornerSwallow) { return; }
735+ cornerSwallow = false;
736+ e.preventDefault();
737+ e.stopImmediatePropagation();
738+ }, true);
739+
740+ function cornerEl() { return document.querySelector('.corner-float'); }
741+
742+ // The menu opens down when the panel is in the top half of the window, and anchors to the right
743+ // edge when the panel is in the right half. The default corner (no attribute) opens up, as before.
744+ function cornerDirection(el, left, top, w, h) {
745+ if (top + h / 2 < window.innerHeight / 2) { el.setAttribute('data-open', 'down'); } else { el.removeAttribute('data-open'); }
746+ if (left + w / 2 > window.innerWidth / 2) { el.setAttribute('data-side', 'right'); } else { el.removeAttribute('data-side'); }
747+ }
748+
749+ // Places the panel at (left, top) in px, clamped so the whole panel stays in the window.
750+ function cornerPlace(el, left, top) {
751+ var w = el.offsetWidth, h = el.offsetHeight;
752+ left = Math.max(0, Math.min(left, window.innerWidth - w));
753+ top = Math.max(0, Math.min(top, window.innerHeight - h));
754+ el.style.left = left + 'px';
755+ el.style.top = top + 'px';
756+ el.style.right = 'auto';
757+ el.style.bottom = 'auto';
758+ cornerDirection(el, left, top, w, h);
759+ }
760+
761+ // Puts the panel where the stored position says, or in the default corner. It does nothing while a
762+ // drag runs, so a re-render or a resize does not pull the panel from under the pointer.
763+ function cornerApply() {
764+ var el = cornerEl();
765+ if (!el || (cornerPress && cornerPress.dragging)) { return; }
766+ if (cornerSaved) {
767+ cornerPlace(el, cornerSaved[0] * (window.innerWidth - el.offsetWidth), cornerSaved[1] * (window.innerHeight - el.offsetHeight));
768+ return;
769+ }
770+ el.style.left = '';
771+ el.style.top = '';
772+ el.style.right = '';
773+ el.style.bottom = '';
774+ var r = el.getBoundingClientRect();
775+ cornerDirection(el, r.left, r.top, el.offsetWidth, el.offsetHeight);
776+ }
777+
778+ // Saves one account preference through /-/prefs, signed in only (the CSRF token comes from the
779+ // panel). Saves go one after another, and `read` gives the value at the moment of sending, so the
780+ // last one sent holds the newest value. A failure is ignored: the next load shows what the server has.
781+ var prefsChain = Promise.resolve();
782+ function prefSave(key, read) {
783+ prefsChain = prefsChain.then(function () {
784+ var el = document.querySelector('.corner-float[data-prefs-csrf]');
785+ var body = new URLSearchParams({ csrf: el ? el.getAttribute('data-prefs-csrf') : '', key: key, value: read() });
786+ return fetch('/-/prefs', { method: 'POST', credentials: 'same-origin', body: body });
787+ }).catch(function () { });
788+ }
789+
790+ document.addEventListener('pointerdown', function (e) {
791+ cornerSwallow = false;
792+ var el = e.target && e.target.closest ? e.target.closest('.corner-float') : null;
793+ if (!el || e.button !== 0) { cornerPress = null; return; }
794+ var r = el.getBoundingClientRect();
795+ cornerPress = { el: el, id: e.pointerId, x: e.clientX, y: e.clientY, left: r.left, top: r.top, dragging: false };
796+ });
797+
798+ document.addEventListener('pointermove', function (e) {
799+ var p = cornerPress;
800+ if (!p || e.pointerId !== p.id) { return; }
801+ if (!p.dragging) {
802+ if (Math.hypot(e.clientX - p.x, e.clientY - p.y) < CORNER_SLOP) { return; }
803+ p.dragging = true;
804+ try { p.el.setPointerCapture(p.id); } catch (err) { }
805+ p.el.classList.add('dragging');
806+ }
807+ cornerPlace(p.el, p.left + e.clientX - p.x, p.top + e.clientY - p.y);
808+ });
809+
810+ function cornerEnd(e) {
811+ var p = cornerPress;
812+ if (!p || e.pointerId !== p.id) { return; }
813+ cornerPress = null;
814+ if (!p.dragging) { return; }
815+ p.el.classList.remove('dragging');
816+ if (e.type === 'pointercancel') { cornerApply(); return; }
817+ cornerSwallow = true;
818+ // A swap that replaced the panel during the drag leaves the new one to the stored position.
819+ if (!p.el.isConnected) { cornerApply(); return; }
820+ var room = { x: window.innerWidth - p.el.offsetWidth, y: window.innerHeight - p.el.offsetHeight };
821+ var x = room.x > 0 ? Math.round(10000 * (parseFloat(p.el.style.left) || 0) / room.x) / 10000 : 0;
822+ var y = room.y > 0 ? Math.round(10000 * (parseFloat(p.el.style.top) || 0) / room.y) / 10000 : 0;
823+ x = Math.min(1, Math.max(0, x));
824+ y = Math.min(1, Math.max(0, y));
825+ cornerSaved = [x, y];
826+ prefSave('corner_pos', function () { return x + ',' + y; });
827+ }
828+ document.addEventListener('pointerup', cornerEnd);
829+ document.addEventListener('pointercancel', cornerEnd);
830+
831+ // A double click on the panel, not on a link or a button, returns it to the default corner.
832+ document.addEventListener('dblclick', function (e) {
833+ var target = e.target;
834+ if (!target || !target.closest || target.closest('a, button, input, select, textarea, summary, label, [role="button"]')) { return; }
835+ var el = target.closest('.corner-float');
836+ if (!el) { return; }
837+ cornerSaved = null;
838+ prefSave('corner_pos', function () { return ''; });
839+ cornerApply();
840+ });
841+
842+ document.addEventListener('forge:swapped', cornerApply);
843+ window.addEventListener('resize', cornerApply);
844+ cornerApply();
845+
709846 // The bell beside the profile corner opens a popover of the newest notifications instead of going
710847 // to the inbox. A plain click toggles it; with a modifier or a middle click the link's own
711848 // behaviour stays. The Popover API light-dismisses it and Escape closes it. Its list is fetched
@@ -718,12 +855,20 @@
718855
719856 // Under the bell, opening upward: the popover's bottom sits 6px above the bell's top, and its left
720857 // edge follows the bell but stays inside the viewport.
858+ // When the panel sits in the top half (data-open="down" on it), the popover opens below the bell.
721859 function placePeek(bell, pop) {
722860 if (!bell) { return; }
723861 var r = bell.getBoundingClientRect();
724862 var left = Math.max(8, Math.min(r.left, window.innerWidth - pop.offsetWidth - 8));
725863 pop.style.left = left + 'px';
726- pop.style.bottom = (window.innerHeight - r.top + 6) + 'px';
864+ var corner = bell.closest('.corner-float');
865+ if (corner && corner.getAttribute('data-open') === 'down') {
866+ pop.style.top = (r.bottom + 6) + 'px';
867+ pop.style.bottom = 'auto';
868+ } else {
869+ pop.style.top = 'auto';
870+ pop.style.bottom = (window.innerHeight - r.top + 6) + 'px';
871+ }
727872 }
728873
729874 // Fills the popover's list with the server's fragment. A reader who closed it meanwhile, or a newer
@@ -793,7 +938,7 @@
793938 }
794939 }, true);
795940
796- // A page swap replaces the sidebar; an open popover goes with the page it was opened on.
941+ // A page swap re-renders the page and its corner; an open popover goes with the page it was opened on.
797942 document.addEventListener('forge:swapped', function () {
798943 document.querySelectorAll('.bell-pop').forEach(function (pop) {
799944 try { pop.hidePopover(); } catch (err) { }
@@ -803,17 +948,33 @@
803948 // Repo home resize: a drag on the separator between the file tree and the README sets the tree's
804949 // width, the --tree-w property of the .repo-home grid. The width is kept in localStorage and applied
805950 // to each repo home on load and after every swap. The README takes the rest of the row.
806- var TREE_KEY = 'forge-tree-w';
951+ var TREE_KEY = 'forge-tree-w'; // signed-out visitors keep the width in localStorage
952+ // Signed in, the width is the account's tree_width preference. The variable starts from the page's
953+ // data-tree-w and follows every change, so a swap never reads back an older value.
954+ var signedIn = document.body.dataset.signedIn === 'true';
955+ var treeAccount = parseFloat(document.body.dataset.treeW) || 0;
956+ var treeTimer = null;
807957 var TREE_MIN = 220; // px, the narrowest the tree goes
808958 var README_MIN = 360; // px, room the drag always leaves for the README
809959 var TREE_STEP = 16; // px per arrow key; Shift moves 64px
810960 var treeDrag = null; // { grid, id, x, w, moved } while a pointer drag runs
811961
812962 function treeLoad() {
963+ if (signedIn) { return treeAccount; }
813964 try { return parseFloat(localStorage.getItem(TREE_KEY)) || 0; } catch (err) { return 0; }
814965 }
815966
816967 function treeStore(px) {
968+ if (signedIn) {
969+ treeAccount = px ? Math.round(px) : 0;
970+ // One save once the changes settle, not one per step of a drag or a key repeat.
971+ clearTimeout(treeTimer);
972+ treeTimer = setTimeout(function () {
973+ treeTimer = null;
974+ prefSave('tree_width', function () { return treeAccount ? String(treeAccount) : ''; });
975+ }, 300);
976+ return;
977+ }
817978 try {
818979 if (px) { localStorage.setItem(TREE_KEY, String(Math.round(px))); } else { localStorage.removeItem(TREE_KEY); }
819980 } catch (err) { }
@@ -1812,8 +1973,8 @@
18121973 // Live unread count. The profile corner (data-unread-stream) is re-rendered by every swap, so it is
18131974 // looked up on each update. The count arrives as an `unread` event of the shell stream (see
18141975 // `/-/shell/events`, opened with the alive handlers above), which the server pushes on each change;
1815- // nothing polls. Each `unread` event also refreshes the activity (below). The count shows twice: as
1816- // a dot on the menu toggle (has-dot), and next to Notifications in the sidebar and the phone menu.
1976+ // nothing polls. Each `unread` event also refreshes the activity (below). The count shows on the
1977+ // bell of the floating profile corner.
18171978
18181979 // Shows the count in one link the way the server renders it: a span with the number, or no span at zero.
18191980 function setCount(el, cls, n) {
@@ -1831,12 +1992,9 @@
18311992 }
18321993
18331994 function setUnread(n) {
1834- // The menu toggle carries a dot while anything is unread.
1835- var toggles = document.querySelectorAll('details.nav-toggle > summary');
1836- for (var t = 0; t < toggles.length; t++) { toggles[t].classList.toggle('has-dot', n > 0); }
1837- // The sidebar's Notifications link (the sidebar and the phone menu hold one each), `.count` as the server renders it.
1838- var links = document.querySelectorAll('nav.side-links a[href="/notifications"]');
1839- for (var i = 0; i < links.length; i++) { setCount(links[i], 'count', n); }
1995+ // The bell of the profile corner, `.bell-count` as the server renders it.
1996+ var bells = document.querySelectorAll('.corner-bell');
1997+ for (var i = 0; i < bells.length; i++) { setCount(bells[i], 'bell-count', n); }
18401998 }
18411999
18422000 // An `unread` event: the count, then the activity is fetched again.
@@ -2574,15 +2732,6 @@
25742732 return es;
25752733 }
25762734
2577- // A `side` event of the shell stream: the sidebar's repo list changed. The page is re-rendered with
2578- // it, as a `changed` event of a data-live stream would, but at most once a second (a code view or a
2579- // live-now page re-renders at once).
2580- function sideChanged() {
2581- if (document.querySelector('[data-live-code], [data-live-now]')) { refreshLive(true); return; }
2582- if (liveTimer) { return; }
2583- liveTimer = setTimeout(function () { liveTimer = null; refreshLive(true); }, 1000);
2584- }
2585-
25862735 // Closes the streams the page no longer names and opens the ones it newly names.
25872736 function syncLive() {
25882737 var want = liveWanted();
@@ -2642,6 +2791,8 @@
26422791 // A one-time secret (a token, recovery codes) is on screen only in the response that made it: a
26432792 // re-render would take it away. The page is refreshed at the next navigation instead.
26442793 if (document.querySelector('[data-once]')) { return; }
2794+ // A rejected form is on screen: a re-render would replace its error. See load().
2795+ if (heldForm) { return; }
26452796 if (userBusy > 0 || liveBusy || selecting()) { liveDirty = true; if (force) { liveForced = true; } return; }
26462797 liveDirty = false;
26472798 liveForced = false;
crates/forge-web/src/boot.rsmodified+1 -0
@@ -172,6 +172,7 @@ pub async fn serve(
172172 .layer(crate::pages::settings_live::AccountWriteLayer)
173173 .cookies()
174174 .layer(crate::pages::settings_profile::avatar_body_limit())
175+ .layer(crate::pages::settings_profile::org_avatar_body_limit())
175176 .layer(crate::pages::repo_ctx::RepoMovedLayer)
176177 .layer(crate::pages::pull_live::PullWriteLayer)
177178 .layer(crate::pages::discussion_live::DiscussionWriteLayer)
crates/forge-web/src/i18n/migrate.rsmodified+15 -0
@@ -67,6 +67,10 @@ pub enum K {
6767 JobProgress,
6868 JobNoLog,
6969 JobStarted,
70+ RetryFailedTitle,
71+ RetrySelected,
72+ RetryNone,
73+ RetryTokenHelp,
7074 StageGit,
7175 StageLabels,
7276 StageMilestones,
@@ -155,6 +159,10 @@ const ALL: &[K] = &[
155159 K::JobProgress,
156160 K::JobNoLog,
157161 K::JobStarted,
162+ K::RetryFailedTitle,
163+ K::RetrySelected,
164+ K::RetryNone,
165+ K::RetryTokenHelp,
158166 K::StageGit,
159167 K::StageLabels,
160168 K::StageMilestones,
@@ -278,6 +286,13 @@ fn pair(key: K) -> (&'static str, &'static str) {
278286 K::JobProgress => ("Progress", "İlerleme"),
279287 K::JobNoLog => ("Nothing yet.", "Henüz bir şey yok."),
280288 K::JobStarted => ("Started", "Başladı"),
289+ K::RetryFailedTitle => ("Retry failed imports", "Başarısız içe aktarmaları yeniden dene"),
290+ K::RetrySelected => ("Retry selected", "Seçilenleri yeniden dene"),
291+ K::RetryNone => ("No failed imports", "Başarısız içe aktarma yok"),
292+ K::RetryTokenHelp => (
293+ "Used for every import you select, then discarded. Retry imports from another account or provider separately with their own token. What was already imported is skipped.",
294+ "Seçtiğiniz her içe aktarma için kullanılır, sonra silinir. Başka bir hesap veya sağlayıcıdan gelen içe aktarmaları kendi belirteçleriyle ayrı olarak yeniden deneyin. Daha önce içe aktarılanlar atlanır.",
295+ ),
281296 K::StageGit => ("Git data", "Git verisi"),
282297 K::StageLabels => ("Labels", "Etiketler"),
283298 K::StageMilestones => ("Milestones", "Kilometre taşları"),
crates/forge-web/src/i18n/misc.rsmodified+0 -40
@@ -158,12 +158,6 @@ pub enum K {
158158 WedLabel,
159159 FriLabel,
160160 NoContributionsDay,
161- // Dashboard greeting and "Needs your attention" column.
162- GoodMorning,
163- GoodAfternoon,
164- GoodEvening,
165- NeedsAttention,
166- NothingNeedsYou,
167161 ViewAllNotifications,
168162 // Shell chrome (`views::mod`): breadcrumb landmark, theme picker, ref selector.
169163 BreadcrumbNav,
@@ -323,11 +317,6 @@ const ALL: &[K] = &[
323317 K::WedLabel,
324318 K::FriLabel,
325319 K::NoContributionsDay,
326- K::GoodMorning,
327- K::GoodAfternoon,
328- K::GoodEvening,
329- K::NeedsAttention,
330- K::NothingNeedsYou,
331320 K::ViewAllNotifications,
332321 K::BreadcrumbNav,
333322 K::ApplyTheme,
@@ -644,16 +633,6 @@ pub fn t(lang: Lang, key: K) -> &'static str {
644633 (FriLabel, Tr) => "Cum",
645634 (NoContributionsDay, En) => "No contributions on this day.",
646635 (NoContributionsDay, Tr) => "Bu günde katkı yok.",
647- (GoodMorning, En) => "Good morning",
648- (GoodMorning, Tr) => "Günaydın",
649- (GoodAfternoon, En) => "Good afternoon",
650- (GoodAfternoon, Tr) => "İyi günler",
651- (GoodEvening, En) => "Good evening",
652- (GoodEvening, Tr) => "İyi akşamlar",
653- (NeedsAttention, En) => "Needs your attention",
654- (NeedsAttention, Tr) => "Dikkatinizi bekleyenler",
655- (NothingNeedsYou, En) => "Nothing needs you right now.",
656- (NothingNeedsYou, Tr) => "Şu an dikkatinizi bekleyen bir şey yok.",
657636 (ViewAllNotifications, En) => "View all notifications",
658637 (ViewAllNotifications, Tr) => "Tüm bildirimleri gör",
659638 (BreadcrumbNav, En) => "Path",
@@ -994,25 +973,6 @@ pub fn git_init_failed(lang: Lang, error: impl Display) -> String {
994973
995974 /// Upper-cases the first character. Turkish verbs here start with a plain letter, so the
996975 /// default mapping is right.
997-/// "Good morning, Ahmet" for an hour before noon, "Good afternoon" before 18:00 and "Good
998-/// evening" otherwise. `hour` is 0-23 in UTC.
999-pub fn greeting(lang: Lang, hour: u8, name: &str) -> String {
1000- let phrase = match hour {
1001- 0..12 => K::GoodMorning,
1002- 12..18 => K::GoodAfternoon,
1003- _ => K::GoodEvening,
1004- };
1005- format!("{}, {name}", t(lang, phrase))
1006-}
1007-
1008-/// `1 repository` / `3 repositories`, and `3 depo` in Turkish.
1009-pub fn repositories_count(lang: Lang, n: u64) -> String {
1010- match lang {
1011- Lang::En => format!("{n} repositor{}", if n == 1 { "y" } else { "ies" }),
1012- Lang::Tr => format!("{n} depo"),
1013- }
1014-}
1015-
1016976 fn capitalize(text: &str) -> String {
1017977 let mut chars = text.chars();
1018978 match chars.next() {
crates/forge-web/src/i18n/orgs.rsmodified+26 -18
@@ -1,5 +1,5 @@
11 //! Strings for the organization pages (`/org/...`), org creation, and the org-related parts of the
2-//! profile, explore and dashboard pages.
2+//! profile, explore and landing pages.
33
44 use super::Lang;
55
@@ -33,6 +33,8 @@ pub enum K {
3333 NoticeHasRepos,
3434 NoticeConfirmName,
3535 NoticeDescriptionLength,
36+ NoticeInvalidDisplayName,
37+ NoticeAvatarInvalid,
3638 // Shared labels.
3739 Save,
3840 Remove,
@@ -49,6 +51,7 @@ pub enum K {
4951 // Organization settings.
5052 Settings,
5153 Description,
54+ DisplayNameLabel,
5255 DefaultRoleLabel,
5356 DefaultRoleHelp,
5457 MembersCanCreate,
@@ -107,6 +110,7 @@ pub enum K {
107110 // Profile.
108111 LocalTime,
109112 NoMembers,
113+ NoOrganizations,
110114 NoVisibleRepos,
111115 NoVisibleStarred,
112116 Pinned,
@@ -117,19 +121,16 @@ pub enum K {
117121 PinsTooMany,
118122 NoPinnableRepos,
119123 TabOverview,
124+ Overview,
120125 TabStars,
121126 FilterRepos,
122127 NoReposMatch,
123128 ClearSearch,
124- // Dashboard and landing.
125- Dashboard,
129+ // Landing.
126130 Home,
127131 LandingTagline,
128132 LogIn,
129133 SetUpForge,
130- YourRepositories,
131- RecentRepositories,
132- NoReposYet,
133134 }
134135
135136 pub fn t(lang: Lang, key: K) -> &'static str {
@@ -190,6 +191,14 @@ pub fn t(lang: Lang, key: K) -> &'static str {
190191 (NoticeConfirmName, Tr) => "Kuruluşu silmek için adını tam olarak yazın.",
191192 (NoticeDescriptionLength, En) => "The description is longer than 2000 characters.",
192193 (NoticeDescriptionLength, Tr) => "Açıklama 2000 karakterden uzun.",
194+ (NoticeInvalidDisplayName, En) => "That display name can't be used.",
195+ (NoticeInvalidDisplayName, Tr) => "Bu görünen ad kullanılamıyor.",
196+ (NoticeAvatarInvalid, En) => {
197+ "That image can't be used. Try a PNG, JPEG, WebP or GIF up to 5 MiB."
198+ }
199+ (NoticeAvatarInvalid, Tr) => {
200+ "Bu görsel kullanılamıyor. PNG, JPEG, WebP ya da GIF, en fazla 5 MiB deneyin."
201+ }
193202 (Save, En) => "Save",
194203 (Save, Tr) => "Kaydet",
195204 (Remove, En) => "Remove",
@@ -220,6 +229,8 @@ pub fn t(lang: Lang, key: K) -> &'static str {
220229 (Settings, Tr) => "Ayarlar",
221230 (Description, En) => "Description",
222231 (Description, Tr) => "Açıklama",
232+ (DisplayNameLabel, En) => "Display name",
233+ (DisplayNameLabel, Tr) => "Görünen ad",
223234 (DefaultRoleLabel, En) => "Default role on the organization's repositories",
224235 (DefaultRoleLabel, Tr) => "Kuruluş depolarında varsayılan rol",
225236 (DefaultRoleHelp, En) => {
@@ -342,6 +353,8 @@ pub fn t(lang: Lang, key: K) -> &'static str {
342353 (LocalTime, Tr) => "Yerel saat: ",
343354 (NoMembers, En) => "No members.",
344355 (NoMembers, Tr) => "Üye yok.",
356+ (NoOrganizations, En) => "You are not in any organization yet.",
357+ (NoOrganizations, Tr) => "Henüz hiçbir kuruluşta değilsiniz.",
345358 (NoVisibleRepos, En) => "No visible repositories.",
346359 (NoVisibleRepos, Tr) => "Görünür depo yok.",
347360 (NoVisibleStarred, En) => "No visible starred repositories.",
@@ -362,6 +375,8 @@ pub fn t(lang: Lang, key: K) -> &'static str {
362375 (NoPinnableRepos, Tr) => "Henüz sabitlenecek depo yok.",
363376 (TabOverview, En) => "Overview",
364377 (TabOverview, Tr) => "Genel bakış",
378+ (Overview, En) => "Overview",
379+ (Overview, Tr) => "Genel bakış",
365380 (TabStars, En) => "Stars",
366381 (TabStars, Tr) => "Yıldızlar",
367382 (FilterRepos, En) => "Find a repository",
@@ -370,8 +385,6 @@ pub fn t(lang: Lang, key: K) -> &'static str {
370385 (NoReposMatch, Tr) => "Aramayla eşleşen depo yok.",
371386 (ClearSearch, En) => "Clear search",
372387 (ClearSearch, Tr) => "Aramayı temizle",
373- (Dashboard, En) => "Dashboard",
374- (Dashboard, Tr) => "Pano",
375388 (Home, En) => "Home",
376389 (Home, Tr) => "Ana sayfa",
377390 (LandingTagline, En) => "Self-hosted git repositories with a small, fast web interface.",
@@ -382,12 +395,6 @@ pub fn t(lang: Lang, key: K) -> &'static str {
382395 (LogIn, Tr) => "Giriş yap",
383396 (SetUpForge, En) => "Set up forge",
384397 (SetUpForge, Tr) => "forge'u kur",
385- (YourRepositories, En) => "Your repositories",
386- (YourRepositories, Tr) => "Depolarınız",
387- (RecentRepositories, En) => "Recent repositories",
388- (RecentRepositories, Tr) => "Son depolar",
389- (NoReposYet, En) => "You have no repositories yet.",
390- (NoReposYet, Tr) => "Henüz deponuz yok.",
391398 }
392399 }
393400
@@ -531,6 +538,8 @@ mod tests {
531538 K::NoticeHasRepos,
532539 K::NoticeConfirmName,
533540 K::NoticeDescriptionLength,
541+ K::NoticeInvalidDisplayName,
542+ K::NoticeAvatarInvalid,
534543 K::Save,
535544 K::Remove,
536545 K::Username,
@@ -544,6 +553,7 @@ mod tests {
544553 K::CreateOrg,
545554 K::Settings,
546555 K::Description,
556+ K::DisplayNameLabel,
547557 K::DefaultRoleLabel,
548558 K::DefaultRoleHelp,
549559 K::MembersCanCreate,
@@ -597,6 +607,7 @@ mod tests {
597607 K::NoPublicReposMatch,
598608 K::LocalTime,
599609 K::NoMembers,
610+ K::NoOrganizations,
600611 K::NoVisibleRepos,
601612 K::NoVisibleStarred,
602613 K::Pinned,
@@ -607,18 +618,15 @@ mod tests {
607618 K::PinsTooMany,
608619 K::NoPinnableRepos,
609620 K::TabOverview,
621+ K::Overview,
610622 K::TabStars,
611623 K::FilterRepos,
612624 K::NoReposMatch,
613625 K::ClearSearch,
614- K::Dashboard,
615626 K::Home,
616627 K::LandingTagline,
617628 K::LogIn,
618629 K::SetUpForge,
619- K::YourRepositories,
620- K::RecentRepositories,
621- K::NoReposYet,
622630 ];
623631
624632 #[test]
crates/forge-web/src/importer/mod.rsmodified+1 -0
@@ -359,6 +359,7 @@ async fn run_production(state: &AppState, job: &ImportJob, spec: &JobSpec) {
359359 }
360360
361361 async fn fail(state: &AppState, rep: &Reporter, message: &str) {
362+ tracing::warn!(job = %rep.job_id, %message, "import failed");
362363 rep.log("error", message).await;
363364 if let Err(e) = state
364365 .store
crates/forge-web/src/importer/tests.rsmodified+60 -1
@@ -8,6 +8,8 @@ use std::sync::Mutex;
88 use forge_core::issues::IssueFilter;
99 use forge_core::store::imports::{ImportJob, ImportState};
1010 use forge_core::{IssueState, Visibility};
11+use topcoat::router::request::Request;
12+use topcoat::router::{Body, to_bytes};
1113
1214 use super::api::{
1315 ApiError, ApiResult, AssetStream, ExtAsset, ExtComment, ExtIssue, ExtLabel, ExtMilestone,
@@ -16,8 +18,9 @@ use super::api::{
1618 use super::{
1719 ImportOptions, JobSpec, Source, Transport, asset_name, origin_note, run_job, with_note,
1820 };
21+use crate::auth::SESSION_COOKIE;
1922 use crate::state::AppState;
20-use crate::test_support::test_state;
23+use crate::test_support::{app_router, create_session, test_state};
2124
2225 const TOKEN: &str = "ghp_supersecret_token_value";
2326
@@ -495,6 +498,62 @@ async fn the_token_is_never_written_to_the_database() {
495498 );
496499 }
497500
501+#[tokio::test]
502+async fn retry_submit_leaves_another_users_failed_job_alone() {
503+ let fx = fixture().await;
504+ let other = fx
505+ .state
506+ .store
507+ .create_user("mallory", None, "unused", false)
508+ .await
509+ .unwrap();
510+ let job = new_job(&fx, Source::GitHub).await;
511+ fx.state
512+ .store
513+ .set_import_state(&job.id, ImportState::Failed, Some("rate limit"))
514+ .await
515+ .unwrap();
516+ create_session(&fx.state.store, &other.id, "retry-other-session", "retry-csrf").await;
517+
518+ let router = app_router(fx.state.clone());
519+ let cookie = format!("__Host-{SESSION_COOKIE}=retry-other-session");
520+
521+ // The static /import/retry is not taken for /import/{job_id}: mallory sees her own empty list.
522+ let page = router
523+ .handle(
524+ Request::builder()
525+ .method("GET")
526+ .uri("/import/retry")
527+ .header("cookie", cookie.as_str())
528+ .body(Body::empty())
529+ .unwrap(),
530+ )
531+ .await;
532+ assert_eq!(page.status().as_u16(), 200);
533+ let bytes = to_bytes(page.into_body(), usize::MAX).await.unwrap();
534+ assert!(String::from_utf8_lossy(&bytes).contains("No failed imports"));
535+
536+ // The form names the owner's job, and mallory is signed in: the page redirects, nothing starts.
537+ let form = format!("csrf=retry-csrf&token=&sel_0={}", job.id);
538+ let res = router
539+ .handle(
540+ Request::builder()
541+ .method("POST")
542+ .uri("/import/retry")
543+ .header("cookie", cookie.as_str())
544+ .header("content-type", "application/x-www-form-urlencoded")
545+ .body(Body::from(form))
546+ .unwrap(),
547+ )
548+ .await;
549+ assert_eq!(res.status().as_u16(), 303);
550+ let _ = to_bytes(res.into_body(), usize::MAX).await.unwrap();
551+
552+ let after = fx.state.store.import_job(&job.id).await.unwrap().unwrap();
553+ assert_eq!(after.state, ImportState::Failed);
554+ assert_eq!(after.error.as_deref(), Some("rate limit"));
555+}
556+
498557 #[test]
499558 fn the_origin_note_escapes_the_mention_and_cleans_the_name() {
500559 let note = origin_note(
crates/forge-web/src/live.rsmodified+1 -1
@@ -59,7 +59,7 @@ pub enum Topic {
5959 /// home page shows its newest version). The header's counts follow [`Topic::RepoIssues`] and
6060 /// [`Topic::PullList`] as well.
6161 Repo(String),
62- /// A user's repo listing, pins, contribution calendar and the signed-in sidebar's repo list.
62+ /// A user's repo listing, pins and contribution calendar.
6363 /// Keyed by user id (an organization is a user too).
6464 User(String),
6565 /// A user's inbox: a notification was added, read or marked read. Keyed by user id.
crates/forge-web/src/pages/banner.rsmodified+24 -9
@@ -1,26 +1,32 @@
11 //! The site announcement banner. The admin sets it in the server settings (`banner.*`, live), and
22 //! the shell shows it under the header on every page. A visitor dismisses it with
3-//! `POST /-/banner/dismiss`, which stores the hash of the message in the `forge_banner` cookie, so a
4-//! changed message shows again.
3+//! `POST /-/banner/dismiss`, which stores the hash of the message so a changed message shows again:
4+//! in the `forge_banner` cookie for a signed-out visitor, and as the `banner_dismissed` account
5+//! preference for a signed-in user.
56
7+use std::collections::HashMap;
68 use std::time::Duration;
79
810 use forge_core::config::BannerConfig;
911 use forge_core::token::hash_token;
1012 use serde::Deserialize;
1113 use topcoat::Result;
12-use topcoat::context::{Cx, try_app_context};
14+use topcoat::context::{Cx, app_context, try_app_context};
1315 use topcoat::cookie::{Cookie, Cookies, SameSite, cookies, time};
1416 use topcoat::router::content::Form;
1517 use topcoat::router::error::{SeeOther, see_other};
1618 use topcoat::router::route;
1719
20+use crate::auth::current_user;
1821 use crate::pages::theme_cookie::safe_back;
1922 use crate::state::AppState;
2023
2124 /// Name of the dismissal cookie.
2225 pub const BANNER_COOKIE: &str = "forge_banner";
2326
27+/// Account preference key holding the dismissed hash of a signed-in user.
28+pub const BANNER_PREF: &str = "banner_dismissed";
29+
2430 const BANNER_COOKIE_TTL: Duration = Duration::from_secs(365 * 24 * 60 * 60);
2531
2632 /// What the shell draws.
@@ -39,7 +45,7 @@ pub fn banner_hash(message: &str, level: &str) -> String {
3945 }
4046
4147 /// The banner to show at `now`, or `None` when it is off, expired or dismissed (`dismissed` is the
42-/// cookie value).
48+/// stored hash).
4349 pub fn view_for(config: &BannerConfig, now: i64, dismissed: Option<&str>) -> Option<BannerView> {
4450 if !config.active_at(now) {
4551 return None;
@@ -57,15 +63,19 @@ pub fn view_for(config: &BannerConfig, now: i64, dismissed: Option<&str>) -> Opt
5763 })
5864 }
5965
60-/// The banner for this request, read from the live settings and the cookie.
61-pub fn current(cx: &Cx) -> Option<BannerView> {
66+/// The banner for this request, read from the live settings. `prefs` is a signed-in viewer's
67+/// account preferences; without them the dismissal comes from the cookie.
68+pub fn current(cx: &Cx, prefs: Option<&HashMap<String, String>>) -> Option<BannerView> {
6269 let state = try_app_context::<AppState>(cx)?;
6370 let live = state.live();
6471 if live.banner.message.trim().is_empty() {
6572 return None;
6673 }
67- let cookie = cookies(cx).get(BANNER_COOKIE).map(|c| c.value().to_owned());
68- view_for(&live.banner, crate::views::now_unix(), cookie.as_deref())
74+ let dismissed = match prefs {
75+ Some(prefs) => prefs.get(BANNER_PREF).cloned(),
76+ None => cookies(cx).get(BANNER_COOKIE).map(|c| c.value().to_owned()),
77+ };
78+ view_for(&live.banner, crate::views::now_unix(), dismissed.as_deref())
6979 }
7080
7181 #[derive(Deserialize)]
@@ -79,7 +89,12 @@ struct DismissForm {
7989 #[route(POST "/-/banner/dismiss")]
8090 async fn dismiss(cx: &Cx, Form(form): Form<DismissForm>) -> Result<SeeOther> {
8191 let hash_ok = form.hash.len() == 16 && form.hash.bytes().all(|b| b.is_ascii_hexdigit());
82- if hash_ok {
92+ if hash_ok && let Some((user, _)) = current_user(cx).await? {
93+ app_context::<AppState>(cx)
94+ .store
95+ .set_user_pref(&user.id, BANNER_PREF, &form.hash)
96+ .await?;
97+ } else if hash_ok {
8398 let max_age =
8499 time::Duration::seconds(i64::try_from(BANNER_COOKIE_TTL.as_secs()).unwrap_or(i64::MAX));
85100 cookies(cx).add(
crates/forge-web/src/pages/commit.rsmodified+2 -1
@@ -134,7 +134,8 @@ async fn commit_page(cx: &Cx) -> Result<impl View> {
134134 ctx.repo.owner_name, ctx.repo.name, info.oid
135135 ),
136136 )),
137- );
137+ )
138+ .await?;
138139 let diff =
139140 history::commit_diff_ws(&state.git, &ctx.path, &info.oid, LIMITS, opts.ignore_ws).await?;
140141
crates/forge-web/src/pages/compare.rsmodified+2 -1
@@ -269,7 +269,8 @@ async fn compare_view(
269269 format!("{compare_path}.patch"),
270270 format!("{compare_path}.diff"),
271271 )),
272- );
272+ )
273+ .await?;
273274 // The page may be a failed POST re-shown; the toolbar still links to the comparison itself.
274275 opts.path = compare_path;
275276 let diff = if show_diff {
crates/forge-web/src/pages/dashboard.rsdeleted+0 -401
@@ -1,401 +0,0 @@
1-//! Page: home. Landing page for visitors; repo dashboard for signed-in users.
2-//!
3-//! The dashboard is a greeting, the contribution calendar, then two columns: the user's
4-//! repositories and the unread inbox rows that need them.
5-
6-use std::time::Duration;
7-
8-use forge_core::store::RepoSort;
9-use forge_core::store::repo_listing::RepoScope;
10-use forge_core::time::stamp_from_unix;
11-use forge_core::{Notification, Repo, Visibility};
12-use jiff::{Timestamp, civil};
13-use topcoat::Result;
14-use topcoat::context::{Cx, app_context};
15-use topcoat::router::content::sse::Event;
16-use topcoat::router::response::Response;
17-use topcoat::router::{Body, StatusCode, page, query_params, route};
18-use topcoat::view::{View, component, view};
19-
20-use crate::auth::{current_user, percent_encode};
21-use crate::i18n::misc::{self as m, K as MK};
22-use crate::i18n::orgs::{self as g, K};
23-use crate::i18n::{self, Lang};
24-use crate::live::{Topic, named_changes, stream_changes};
25-use crate::pages::issue_parts::stamp_unix;
26-use crate::pages::repo_settings::{notice_banner_for, take_notice};
27-use crate::state::AppState;
28-use crate::views::heatmap::{self, Calendar, DayDetail, contribution_calendar};
29-use crate::views::{SIDE_REPOS, display_name, empty_state, now_unix, relative_time, shell};
30-
31-/// How far back the calendar reads contributions: 53 weeks plus the days of the current week.
32-const CALENDAR_DAYS: u64 = 371;
33-
34-/// The `since` stamp for the calendar. One extra day covers the viewer's local day, which can
35-/// start before the UTC day that `CALENDAR_DAYS` reaches back to.
36-fn calendar_since() -> String {
37- forge_core::time::stamp_ago(Duration::from_secs((CALENDAR_DAYS + 1) * 86_400))
38-}
39-
40-/// The `day` query: a calendar day whose contributions to list under the calendar.
41-#[query_params(error = bad_request)]
42-struct DayQuery {
43- day: Option<String>,
44-}
45-
46-/// Unread inbox rows in the "Needs your attention" column.
47-const ATTENTION_ROWS: u32 = 5;
48-
49-/// What the signed-in dashboard shows, loaded once per page view.
50-struct Dashboard {
51- name: String,
52- hour: u8,
53- repos: Vec<Repo>,
54- calendar: Calendar,
55- selected: Option<DayDetail>,
56- attention: Vec<AttentionRow>,
57-}
58-
59-/// One unread inbox row, with its strings ready for the view.
60-struct AttentionRow {
61- href: String,
62- reference: String,
63- title: String,
64- kind: &'static str,
65- /// The item's update stamp, for the `<time>` that shows `relative`.
66- updated: String,
67- relative: String,
68-}
69-
70-#[page("/")]
71-async fn home(cx: &Cx) -> Result<impl View> {
72- let state = app_context::<AppState>(cx);
73- let viewer = current_user(cx).await?;
74- let lang = i18n::lang(cx, viewer.as_ref().map(|(u, _)| u));
75- let query = query_params::<DayQuery>(cx)?;
76- let dash = match &viewer {
77- Some((user, _)) => Some(load_dashboard(state, user, lang, query.day.as_deref()).await?),
78- None => None,
79- };
80- let has_users = viewer.is_none() && state.store.user_count().await? > 0;
81- let title = if viewer.is_some() {
82- g::t(lang, K::Dashboard)
83- } else {
84- g::t(lang, K::Home)
85- };
86- let notice = take_notice(cx);
87- Ok(view! {
88- shell(title: title, viewer: viewer.as_ref(),
89- notice_banner_for(lang: lang, title: notice)
90- if let Some(dash) = dash {
91- dashboard(dash: dash, lang: lang)
92- } else {
93- landing(has_users: has_users, lang: lang)
94- })
95- })
96-}
97-
98-/// The dashboard's change stream for the viewer. It follows the viewer's own user topic (repo
99-/// listing and contribution calendar, both moved by the viewer's pushes and repo changes) and
100-/// their inbox. The viewer comes from the session only.
101-#[route(GET "/dashboard/events")]
102-async fn dashboard_events(cx: &Cx) -> Result<Response> {
103- let Some((user, _)) = current_user(cx).await? else {
104- let mut res = Response::new(Body::empty());
105- *res.status_mut() = StatusCode::UNAUTHORIZED;
106- return Ok(res);
107- };
108- let state = app_context::<AppState>(cx).clone();
109- let topics = [Topic::User(user.id.clone()), Topic::Inbox(user.id.clone())];
110- stream_changes(cx, &state.live.clone(), &topics, move || {
111- let state = state.clone();
112- let user = user.clone();
113- async move { dashboard_fingerprint(&state, &user).await }
114- })
115- .await
116-}
117-
118-/// The signed-in sidebar's change stream: the viewer's freshest repos and their total. It follows
119-/// the viewer's user topic only, and the viewer comes from the session, never from the URL.
120-#[route(GET "/-/side/events")]
121-async fn side_events(cx: &Cx) -> Result<Response> {
122- let Some((user, _)) = current_user(cx).await? else {
123- let mut res = Response::new(Body::empty());
124- *res.status_mut() = StatusCode::UNAUTHORIZED;
125- return Ok(res);
126- };
127- let state = app_context::<AppState>(cx).clone();
128- let topics = [Topic::User(user.id.clone())];
129- stream_changes(cx, &state.live.clone(), &topics, move || {
130- let state = state.clone();
131- let user = user.clone();
132- async move { side_fingerprint(&state, &user).await }
133- })
134- .await
135-}
136-
137-/// The sidebar's change events for `user`, each named `name` (`changed` on `/-/side/events`).
138-pub(crate) async fn side_changes(
139- state: &AppState,
140- user: &forge_core::User,
141- name: &'static str,
142-) -> topcoat::Result<impl futures_util::Stream<Item = topcoat::Result<Event>> + Send + 'static> {
143- let topics = vec![Topic::User(user.id.clone())];
144- let (state_for_read, user) = (state.clone(), user.clone());
145- named_changes(&state.live, topics, Vec::new(), name, move || {
146- let state = state_for_read.clone();
147- let user = user.clone();
148- async move { side_fingerprint(&state, &user).await }
149- })
150- .await
151-}
152-
153-/// The sidebar's repo list as it shows: the names in order, and the total.
154-async fn side_fingerprint(state: &AppState, user: &forge_core::User) -> Result<String> {
155- let (listed, total) = state
156- .store
157- .list_visible_repos(
158- RepoScope::OwnedBy(&user.id),
159- Some(user),
160- None,
161- RepoSort::RecentlyUpdated,
162- 1,
163- SIDE_REPOS,
164- )
165- .await?;
166- let mut lines = vec![format!("total {total}")];
167- lines.extend(listed.iter().map(|(repo, _, _)| repo.name.clone()));
168- Ok(lines.join("\n"))
169-}
170-
171-/// The state the dashboard shows: the repo list, the calendar counts and the attention rows.
172-async fn dashboard_fingerprint(state: &AppState, user: &forge_core::User) -> Result<String> {
173- let mut lines = Vec::new();
174- for repo in state.store.list_repos_by_owner(&user.id).await? {
175- lines.push(format!(
176- "repo {} {:?} {}",
177- repo.name, repo.visibility, repo.description
178- ));
179- }
180- let since = calendar_since();
181- for (day, count) in state
182- .store
183- .contribution_counts(&user.id, &since, &user.timezone)
184- .await?
185- {
186- lines.push(format!("day {day} {count}"));
187- }
188- for note in state
189- .store
190- .list_notifications(&user.id, true, None, ATTENTION_ROWS)
191- .await?
192- {
193- lines.push(format!(
194- "note {} {} {} {}",
195- note.id, note.updated_at, note.title, note.issue_state
196- ));
197- }
198- Ok(lines.join("\n"))
199-}
200-
201-/// The day the `day` query asks for: a strict `YYYY-MM-DD` date from the calendar's first day to
202-/// today. Anything else (malformed, a future day, or before the calendar) is ignored.
203-fn selected_day(
204- day: Option<&str>,
205- first: (i64, i64, i64),
206- today: (i64, i64, i64),
207-) -> Option<civil::Date> {
208- let text = day?;
209- let date: civil::Date = text.parse().ok()?;
210- // The parser takes more forms than the calendar link uses, so the date must print back as sent.
211- if date.to_string() != text {
212- return None;
213- }
214- let ymd = (
215- i64::from(date.year()),
216- i64::from(date.month()),
217- i64::from(date.day()),
218- );
219- (first..=today).contains(&ymd).then_some(date)
220-}
221-
222-/// The contributions the user made on their local day `date`, newest first.
223-async fn day_detail(
224- state: &AppState,
225- user: &forge_core::User,
226- date: civil::Date,
227-) -> Result<Option<DayDetail>> {
228- let Some((start, end)) = forge_core::tz::day_span(date, &user.timezone) else {
229- return Ok(None);
230- };
231- let (Some(from), Some(to)) = (stamp_from_unix(start), stamp_from_unix(end)) else {
232- return Ok(None);
233- };
234- let items = state
235- .store
236- .contributions_between(&user.id, &from, &to)
237- .await?;
238- Ok(Some(DayDetail {
239- date: (
240- i64::from(date.year()),
241- i64::from(date.month()),
242- i64::from(date.day()),
243- ),
244- items,
245- }))
246-}
247-
248-/// Reads the dashboard data for a signed-in user. `day` is the raw `day` query value.
249-async fn load_dashboard(
250- state: &AppState,
251- user: &forge_core::User,
252- lang: Lang,
253- day: Option<&str>,
254-) -> Result<Dashboard> {
255- let repos = state.store.list_repos_by_owner(&user.id).await?;
256- let local_now = forge_core::tz::local_datetime(Timestamp::now(), &user.timezone);
257- let today = (
258- i64::from(local_now.year()),
259- i64::from(local_now.month()),
260- i64::from(local_now.day()),
261- );
262- let counts = state
263- .store
264- .contribution_counts(&user.id, &calendar_since(), &user.timezone)
265- .await?;
266- let calendar = heatmap::build(&counts, today);
267- let selected = match selected_day(day, calendar.first_day, today) {
268- Some(date) => day_detail(state, user, date).await?,
269- None => None,
270- };
271- let now_secs = now_unix();
272- let attention = state
273- .store
274- .list_notifications(&user.id, true, None, ATTENTION_ROWS)
275- .await?
276- .iter()
277- .map(|note| attention_row(lang, note, now_secs))
278- .collect();
279- Ok(Dashboard {
280- name: display_name(lang, &user.username),
281- hour: u8::try_from(local_now.hour()).unwrap_or_default(),
282- repos,
283- calendar,
284- selected,
285- attention,
286- })
287-}
288-
289-#[component]
290-async fn landing(has_users: bool, lang: Lang) -> Result<impl View> {
291- Ok(view! {
292- <section class="hero">
293- <h1>"forge"</h1>
294- <p class="muted">(g::t(lang, K::LandingTagline))</p>
295- <div class="actions">
296- <a class="button primary" href="/login">(g::t(lang, K::LogIn))</a>
297- if !has_users {
298- <a class="button" href="/setup">(g::t(lang, K::SetUpForge))</a>
299- }
300- </div>
301- </section>
302- })
303-}
304-
305-#[component]
306-async fn dashboard(dash: Dashboard, lang: Lang) -> Result<impl View> {
307- let empty = dash.repos.is_empty();
308- let count = m::repositories_count(lang, dash.repos.len() as u64);
309- let greeting = m::greeting(lang, dash.hour, &dash.name);
310- let attention_empty = dash.attention.is_empty();
311- Ok(view! {
312- <div data-live="/dashboard/events">
313- <h1 class="greet">(greeting)</h1>
314- contribution_calendar(calendar: dash.calendar, selected: dash.selected, lang: lang)
315- <div class="dash-cols">
316- <section class="dash-repos" aria-labelledby="repos-h">
317- <div class="sec-head">
318- <h2 id="repos-h">(g::t(lang, K::YourRepositories))</h2>
319- <span class="small">(count)</span>
320- <a class="button primary" href="/new">(g::t(lang, K::NewRepository))</a>
321- </div>
322- if empty {
323- empty_state(title: g::t(lang, K::NoReposYet),
324- <a class="button primary" href="/new">(g::t(lang, K::NewRepository))</a>
325- <a class="button" href="/new/import">(crate::i18n::migrate::t(lang, crate::i18n::migrate::K::ImportTitle))</a>)
326- } else {
327- <div class="table-wrap">
328- <table class="table">
329- <thead>
330- <tr>
331- <th scope="col">(g::t(lang, K::Name))</th>
332- <th scope="col" class="dash-desc">(g::t(lang, K::Description))</th>
333- </tr>
334- </thead>
335- <tbody>
336- for repo in dash.repos.into_iter() {
337- <tr>
338- <td>
339- <a class="repo-name" href=(format!("/{}/{}", repo.owner_name, repo.name))>
340- (format!("{}/{}", repo.owner_name, repo.name))
341- </a>
342- if repo.visibility == Visibility::Private {
343- <span class=(badge_class(repo.visibility))>(i18n::visibility_label(lang, repo.visibility))</span>
344- }
345- </td>
346- <td class="muted dash-desc">(repo.description)</td>
347- </tr>
348- }
349- </tbody>
350- </table>
351- </div>
352- }
353- </section>
354- <section class="dash-attention" aria-labelledby="attn-h">
355- <div class="sec-head">
356- <h2 id="attn-h">(m::t(lang, MK::NeedsAttention))</h2>
357- </div>
358- if attention_empty {
359- empty_state(title: m::t(lang, MK::NothingNeedsYou))
360- } else {
361- <ul class="attn">
362- for item in dash.attention.into_iter() {
363- <li>
364- <a href=(item.href.as_str())><span class="mono">(item.reference.as_str())</span>" "(item.title.as_str())</a>
365- <span class="sub">(item.kind) " · " <time data-rel="true" datetime=(item.updated.as_str())>(item.relative.as_str())</time></span>
366- </li>
367- }
368- </ul>
369- }
370- <p class="small"><a href="/notifications">(m::t(lang, MK::ViewAllNotifications))</a></p>
371- </section>
372- </div>
373- </div>
374- })
375-}
376-
377-/// The row for an unread inbox entry on the dashboard.
378-fn attention_row(lang: Lang, note: &Notification, now: i64) -> AttentionRow {
379- let kind = match (note.is_pull, note.issue_state.as_str()) {
380- (false, "open") => m::t(lang, MK::KindOpenIssue),
381- (false, _) => m::t(lang, MK::KindClosedIssue),
382- (true, "open") => m::t(lang, MK::KindOpenPull),
383- (true, _) => m::t(lang, MK::KindClosedPull),
384- };
385- AttentionRow {
386- href: format!("/notifications/{}/open", percent_encode(&note.id)),
387- reference: format!("{}/{} #{}", note.repo_owner, note.repo_name, note.number),
388- title: note.title.clone(),
389- kind,
390- updated: note.updated_at.clone(),
391- relative: relative_time(lang, stamp_unix(&note.updated_at), now),
392- }
393-}
394-
395-/// CSS class for a visibility badge.
396-pub fn badge_class(visibility: Visibility) -> &'static str {
397- match visibility {
398- Visibility::Public => "badge public",
399- Visibility::Private => "badge private",
400- }
401-}
crates/forge-web/src/pages/home.rsadded+47 -0
@@ -0,0 +1,47 @@
1+//! Page: home. The landing page for visitors. A signed-in viewer is sent to their own profile.
2+
3+use topcoat::Result;
4+use topcoat::context::{Cx, app_context};
5+use topcoat::router::error::see_other;
6+use topcoat::router::page;
7+use topcoat::view::{View, component, view};
8+
9+use crate::auth::current_user;
10+use crate::i18n::orgs::{self as g, K};
11+use crate::i18n::{self, Lang};
12+use crate::pages::repo_settings::{notice_banner_for, take_notice};
13+use crate::state::AppState;
14+use crate::views::{enc, shell};
15+
16+#[page("/")]
17+async fn home(cx: &Cx) -> Result<impl View> {
18+ let state = app_context::<AppState>(cx);
19+ if let Some((user, _)) = current_user(cx).await? {
20+ return Err(see_other(format!("/{}", enc(&user.username))).into());
21+ }
22+ let lang = i18n::lang(cx, None);
23+ let has_users = state.store.user_count().await? > 0;
24+ let notice = take_notice(cx);
25+ Ok(view! {
26+ shell(title: g::t(lang, K::Home), viewer: None,
27+ notice_banner_for(lang: lang, title: notice)
28+ landing(has_users: has_users, lang: lang)
29+ )
30+ })
31+}
32+
33+#[component]
34+async fn landing(has_users: bool, lang: Lang) -> Result<impl View> {
35+ Ok(view! {
36+ <section class="hero">
37+ <h1>"forge"</h1>
38+ <p class="muted">(g::t(lang, K::LandingTagline))</p>
39+ <div class="actions">
40+ <a class="button primary" href="/login">(g::t(lang, K::LogIn))</a>
41+ if !has_users {
42+ <a class="button" href="/setup">(g::t(lang, K::SetUpForge))</a>
43+ }
44+ </div>
45+ </section>
46+ })
47+}
crates/forge-web/src/pages/import.rsmodified+191 -13
@@ -949,6 +949,13 @@ async fn run_bulk(
949949 } else {
950950 Visibility::Private
951951 };
952+ let failed: Vec<ImportJob> = state
953+ .store
954+ .list_import_jobs(&viewer.id, 200)
955+ .await?
956+ .into_iter()
957+ .filter(|job| job.state == ImportState::Failed)
958+ .collect();
952959 let mut skipped: Vec<String> = Vec::new();
953960 for (_, full_name) in picked {
954961 let Some((remote, inst)) = parse_remote(source, full_name, instance) else {
@@ -963,6 +970,19 @@ async fn run_bulk(
963970 options,
964971 };
965972 let name = default_name(&remote);
973+ // The repository from a failed import of this source is there already: retry that import
974+ // instead of refusing the name as taken.
975+ if let Some(repo) = state
976+ .store
977+ .repo_by_owner_and_name(&target.username, &name)
978+ .await?
979+ && let Some(job) = failed.iter().find(|job| {
980+ job.repo_id.as_deref() == Some(repo.id.as_str()) && job.source == source.as_str()
981+ })
982+ {
983+ retry_job(state, job.clone(), &form.token).await?;
984+ continue;
985+ }
966986 // A name already taken, or any refusal, skips that one; the list page says which and why.
967987 if let Err(message) = begin(cx, viewer, &target, &name, "", visibility, spec).await? {
968988 tracing::info!(repo = %remote, %message, "bulk import: skipped a repository");
@@ -1061,13 +1081,24 @@ async fn recent_imports(
10611081 more: bool,
10621082 ) -> Result<impl View> {
10631083 let empty = jobs.is_empty();
1084+ let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed);
10641085 Ok(view! {
10651086 if !empty {
10661087 <section class="card import-recent">
10671088 <h2>(g::t(lang, K::RecentImports))</h2>
10681089 job_rows(lang: lang, jobs: jobs)
1069- if more {
1070- <p class="small"><a href="/import">(g::t(lang, K::ViewAll))</a></p>
1090+ if more || retry {
1091+ <p class="small">
1092+ if more {
1093+ <a href="/import">(g::t(lang, K::ViewAll))</a>
1094+ }
1095+ if more && retry {
1096+ " · "
1097+ }
1098+ if retry {
1099+ <a href="/import/retry">(g::t(lang, K::RetryFailedTitle))</a>
1100+ }
1101+ </p>
10711102 }
10721103 </section>
10731104 }
@@ -1081,10 +1112,14 @@ async fn jobs_list(
10811112 skipped: Option<String>,
10821113 ) -> Result<impl View> {
10831114 let empty = jobs.is_empty();
1115+ let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed);
10841116 Ok(view! {
10851117 newrepo_tabs(lang: lang, active: "import")
10861118 <section class="page-head" data-live="/import/events">
10871119 <h1>(g::t(lang, K::JobsTitle))</h1>
1120+ if retry {
1121+ <a class="button" href="/import/retry">(g::t(lang, K::RetryFailedTitle))</a>
1122+ }
10881123 </section>
10891124 if let Some(message) = skipped {
10901125 alert(message: message.as_str())
@@ -1308,25 +1343,23 @@ struct RetryForm {
13081343 token: String,
13091344 }
13101345
1311-#[route(POST "/import/{job_id}/retry")]
1312-async fn job_retry(cx: &Cx, Form(form): Form<RetryForm>) -> Result<SeeOther> {
1313- let viewer = require_csrf(cx, &form.csrf).await?;
1314- let state = app_context::<AppState>(cx);
1315- let job = owned_job(cx, &viewer.0).await?;
1316- let href = format!("/import/{}", job.id);
1346+/// Re-queues a failed import and starts it again; what was imported before is skipped. `Ok(false)`
1347+/// when nothing was started: the job is not failed, its source or remote does not parse, or its
1348+/// repository already has an import running.
1349+async fn retry_job(state: &AppState, job: ImportJob, token: &str) -> Result<bool> {
13171350 if job.state != ImportState::Failed {
1318- return Err(see_other(href).into());
1351+ return Ok(false);
13191352 }
13201353 let Some(source) = Source::parse(&job.source) else {
1321- return Err(see_other(href).into());
1354+ return Ok(false);
13221355 };
13231356 let Some((remote, instance)) = parse_remote(source, &job.source_ref, "") else {
1324- return Err(see_other(href).into());
1357+ return Ok(false);
13251358 };
13261359 if let Some(repo_id) = &job.repo_id
13271360 && state.store.active_import_for_repo(repo_id).await?.is_some()
13281361 {
1329- return Err(see_other(href).into());
1362+ return Ok(false);
13301363 }
13311364 let options: ImportOptions = serde_json::from_str(&job.options).unwrap_or_default();
13321365 state
@@ -1345,10 +1378,155 @@ async fn job_retry(cx: &Cx, Form(form): Form<RetryForm>) -> Result<SeeOther> {
13451378 source,
13461379 remote,
13471380 instance,
1348- token: token_of(&form.token),
1381+ token: token_of(token),
13491382 git_user: String::new(),
13501383 options,
13511384 };
13521385 importer::spawn_job(state.clone(), job, spec);
1386+ Ok(true)
1387+}
1388+
1389+#[route(POST "/import/{job_id}/retry")]
1390+async fn job_retry(cx: &Cx, Form(form): Form<RetryForm>) -> Result<SeeOther> {
1391+ let viewer = require_csrf(cx, &form.csrf).await?;
1392+ let state = app_context::<AppState>(cx);
1393+ let job = owned_job(cx, &viewer.0).await?;
1394+ let href = format!("/import/{}", job.id);
1395+ retry_job(state, job, &form.token).await?;
13531396 Err(see_other(href).into())
13541397 }
1398+
1399+// ---- retry several failed imports ----
1400+
1401+/// The viewer's failed imports whose repository still exists and is readable, with the repository,
1402+/// and no import running on it. Newest first.
1403+async fn retry_candidates(state: &AppState, viewer: &User) -> Result<Vec<(ImportJob, Repo)>> {
1404+ let mut rows = Vec::new();
1405+ for job in state.store.list_import_jobs(&viewer.id, 200).await? {
1406+ if job.state != ImportState::Failed {
1407+ continue;
1408+ }
1409+ let Some(repo) = job_repo(state, Some(viewer), &job).await? else {
1410+ continue;
1411+ };
1412+ if state.store.active_import_for_repo(&repo.id).await?.is_some() {
1413+ continue;
1414+ }
1415+ rows.push((job, repo));
1416+ }
1417+ Ok(rows)
1418+}
1419+
1420+/// The provider's name for a job's source, as the source tabs show it.
1421+fn source_label(raw: &str) -> &'static str {
1422+ Source::parse(raw).map_or("", Source::label)
1423+}
1424+
1425+#[component]
1426+async fn retry_list(lang: Lang, csrf: &str, rows: Vec<(ImportJob, Repo)>) -> Result<impl View> {
1427+ let count = rows.len();
1428+ let empty = rows.is_empty();
1429+ Ok(view! {
1430+ newrepo_tabs(lang: lang, active: "import")
1431+ <form method="post" action="/import/retry" class="newrepo-form">
1432+ csrf_field(token: csrf)
1433+ <header class="newrepo-head">
1434+ <h1>(g::t(lang, K::RetryFailedTitle))</h1>
1435+ <div class="newrepo-head-actions">
1436+ if !empty {
1437+ <button type="submit" class="primary">(g::t(lang, K::RetrySelected))</button>
1438+ }
1439+ </div>
1440+ </header>
1441+ if empty {
1442+ empty_state(title: g::t(lang, K::RetryNone))
1443+ } else {
1444+ <div class="newrepo-card">
1445+ <label>
1446+ <span>(g::t(lang, K::TokenOptional))</span>
1447+ <input type="password" name="token" autocomplete="new-password" maxlength="1024">
1448+ </label>
1449+ <p class="muted small">(g::t(lang, K::RetryTokenHelp))</p>
1450+ </div>
1451+ <div class="newrepo-card import-pick">
1452+ <label class="import-pick-row import-pick-all">
1453+ <input type="checkbox" data-select-all=".import-pick-list">
1454+ <span class="import-pick-main">
1455+ <span class="import-pick-title">(g::t(lang, K::BulkSelectAll))</span>
1456+ </span>
1457+ <span class="muted small">(count)</span>
1458+ </label>
1459+ <ul class="import-pick-list">
1460+ for (i, (job, repo)) in rows.iter().enumerate() {
1461+ <li>
1462+ <label class="import-pick-row">
1463+ <input type="checkbox" name=(format!("sel_{i}")) value=(job.id.as_str())>
1464+ <span class="import-pick-main">
1465+ <span class="import-pick-title">
1466+ <span class="import-pick-name">(format!("{}/{}", repo.owner_name, repo.name))</span>
1467+ <span class="badge">(source_label(&job.source))</span>
1468+ </span>
1469+ <span class="muted small import-pick-desc">(job.source_ref.as_str())</span>
1470+ if let Some(message) = job.error.as_ref() {
1471+ <span class="muted small import-pick-desc">(message.as_str())</span>
1472+ }
1473+ </span>
1474+ </label>
1475+ </li>
1476+ }
1477+ </ul>
1478+ </div>
1479+ }
1480+ </form>
1481+ })
1482+}
1483+
1484+#[page("/import/retry")]
1485+async fn retry_page(cx: &Cx) -> Result<impl View> {
1486+ let viewer = require_user(cx).await?;
1487+ let lang = i18n::lang(cx, Some(&viewer.0));
1488+ let state = app_context::<AppState>(cx);
1489+ let rows = retry_candidates(state, &viewer.0).await?;
1490+ let csrf = viewer.1.csrf_token.clone();
1491+ Ok(view! { cx =>
1492+ shell(title: g::t(lang, K::RetryFailedTitle), viewer: Some(&viewer),
1493+ retry_list(lang: lang, csrf: csrf.as_str(), rows: rows))
1494+ })
1495+}
1496+
1497+#[derive(Deserialize)]
1498+struct RetrySelectedForm {
1499+ #[serde(default)]
1500+ csrf: String,
1501+ #[serde(default)]
1502+ token: String,
1503+ /// The ticked jobs arrive as `sel_0`, `sel_1`, ... with the job id as the value.
1504+ #[serde(flatten)]
1505+ extra: HashMap<String, String>,
1506+}
1507+
1508+#[route(POST "/import/retry")]
1509+async fn retry_submit(cx: &Cx, Form(form): Form<RetrySelectedForm>) -> Result<SeeOther> {
1510+ let viewer = require_csrf(cx, &form.csrf).await?;
1511+ let state = app_context::<AppState>(cx);
1512+ let mut picked: Vec<(usize, &String)> = form
1513+ .extra
1514+ .iter()
1515+ .filter_map(|(k, v)| Some((k.strip_prefix("sel_")?.parse::<usize>().ok()?, v)))
1516+ .collect();
1517+ picked.sort_by_key(|(i, _)| *i);
1518+ if picked.is_empty() {
1519+ return Err(see_other("/import/retry").into());
1520+ }
1521+ for (_, id) in picked {
1522+ // Only the viewer's own jobs; anything else is skipped without a word.
1523+ let Some(job) = state.store.import_job(id).await? else {
1524+ continue;
1525+ };
1526+ if job.user_id != viewer.0.id {
1527+ continue;
1528+ }
1529+ retry_job(state, job, &form.token).await?;
1530+ }
1531+ Err(see_other("/import").into())
1532+}
crates/forge-web/src/pages/mod.rsmodified+3 -1
@@ -36,7 +36,6 @@ pub mod code_search;
3636 pub mod commit;
3737 pub mod commits;
3838 pub mod compare;
39-pub mod dashboard;
4039 pub mod discussion_actions;
4140 pub mod discussion_live;
4241 #[cfg(test)]
@@ -49,6 +48,7 @@ pub mod explore;
4948 pub mod finder;
5049 pub mod forgot;
5150 pub mod fork;
51+pub mod home;
5252 pub mod import;
5353 #[cfg(test)]
5454 mod import_tests;
@@ -85,6 +85,7 @@ pub mod passkeys;
8585 #[cfg(test)]
8686 mod passkeys_tests;
8787 pub mod profile;
88+pub mod profile_calendar;
8889 pub mod profile_pins;
8990 pub mod pull_branch;
9091 pub mod pull_files;
@@ -142,5 +143,6 @@ pub mod snippets_live;
142143 pub mod star;
143144 pub mod theme_cookie;
144145 pub mod tree;
146+pub mod user_prefs;
145147 pub mod wiki;
146148 pub mod wiki_live;
crates/forge-web/src/pages/new_repo.rsmodified+18 -2
@@ -10,7 +10,10 @@ use topcoat::Result;
1010 use topcoat::context::{Cx, app_context};
1111 use topcoat::router::content::Form;
1212 use topcoat::router::error::see_other;
13-use topcoat::router::page;
13+// Named by the `#[query_params]` attribute below, which the unused-import lint does not see.
14+#[allow(unused_imports)]
15+use topcoat::router::error::bad_request;
16+use topcoat::router::{page, query_params};
1417 use topcoat::view::{View, component, view};
1518
1619 use crate::audit::{self, Actor, Target};
@@ -301,14 +304,27 @@ pub(crate) async fn owner_choices(state: &AppState, viewer: &User) -> Result<Vec
301304 Ok(names)
302305 }
303306
307+/// `/new?owner=acme` preselects that owner. An owner the viewer cannot pick is ignored.
308+#[query_params(error = bad_request)]
309+struct NewRepoQuery {
310+ owner: Option<String>,
311+}
312+
304313 #[page("/new")]
305314 async fn new_repo_page(cx: &Cx) -> Result<impl View> {
306315 let viewer = require_user(cx).await?;
307316 let lang = i18n::lang(cx, Some(&viewer.0));
317+ let wanted = query_params::<NewRepoQuery>(cx)?.owner.clone();
308318 let owners = owner_choices(app_context::<AppState>(cx), &viewer.0).await?;
319+ let mut draft = Draft::fresh();
320+ if let Some(wanted) = wanted.as_deref()
321+ && let Some(owner) = owners.iter().find(|name| name.eq_ignore_ascii_case(wanted))
322+ {
323+ draft.owner = owner.clone();
324+ }
309325 let csrf = viewer.1.csrf_token.clone();
310326 Ok(view! { cx =>
311- shell(title: i18n::t(lang, Key::NewRepository), viewer: Some(&viewer), new_repo_form(lang: lang, csrf: csrf.as_str(), draft: Draft::fresh(), error: None, owners: owners))
327+ shell(title: i18n::t(lang, Key::NewRepository), viewer: Some(&viewer), new_repo_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners))
312328 })
313329 }
314330
crates/forge-web/src/pages/notifications.rsmodified+5 -5
@@ -1545,18 +1545,18 @@ mod tests {
15451545 }
15461546
15471547 #[tokio::test]
1548- async fn sidebar_shows_the_unread_count() {
1548+ async fn corner_bell_shows_the_unread_count() {
15491549 let site = site().await;
15501550 let w = world(&site, Visibility::Public).await;
15511551 let cookie = sign_in(&site.store, &w.bob.id, "bob-token").await;
15521552
1553- let none = get(&site, "/", Some(&cookie)).await;
1553+ let none = get(&site, "/explore", Some(&cookie)).await;
15541554 assert!(none.body.contains("href=\"/notifications\""));
1555- assert!(!none.body.contains("<span class=\"count\">"));
1555+ assert!(!none.body.contains("<span class=\"bell-count\">"));
15561556
15571557 notify(&site, &w, Reason::Mention).await;
1558- let one = get(&site, "/", Some(&cookie)).await;
1559- assert!(one.body.contains("<span class=\"count\">1</span>"));
1558+ let one = get(&site, "/explore", Some(&cookie)).await;
1559+ assert!(one.body.contains("<span class=\"bell-count\">1</span>"));
15601560 }
15611561
15621562 #[tokio::test]
crates/forge-web/src/pages/org_ctx.rsmodified+2 -0
@@ -56,6 +56,8 @@ pub const NOTICES: &[(&str, K, bool)] = &[
5656 ("has_repos", K::NoticeHasRepos, true),
5757 ("confirm_name", K::NoticeConfirmName, true),
5858 ("description_length", K::NoticeDescriptionLength, true),
59+ ("invalid_display_name", K::NoticeInvalidDisplayName, true),
60+ ("avatar_invalid", K::NoticeAvatarInvalid, true),
5961 ];
6062
6163 /// Roles a team can carry, in the order the selects show them.
crates/forge-web/src/pages/org_settings.rsmodified+189 -47
@@ -1,6 +1,10 @@
1-//! Page: organization settings (`/org/{org}/settings`): the public description, the default role
2-//! members get on the org's repos, whether members may create repos, and deletion. Owners only:
3-//! non-members get 404 and members who are not owners get 403.
1+//! Page: organization settings (`/org/{org}/settings`): the display name, the avatar, the public
2+//! description, the default role members get on the org's repos, whether members may create repos,
3+//! and deletion. Owners only: non-members get 404 and members who are not owners get 403.
4+//!
5+//! The avatar has its own routes under `/org/{org}/settings/avatar`, which take the same multipart
6+//! form as a person's upload. Every write bumps the org's user topic through `OrgWriteLayer`
7+//! (`org_live.rs`), so the profile page follows the change without a bump here.
48
59 use forge_core::AuditAction;
610 use forge_core::store::orgs::{DefaultRepoRole, OrgSettings};
@@ -8,20 +12,22 @@ use serde::Deserialize;
812 use topcoat::Result;
913 use topcoat::context::{Cx, app_context};
1014 use topcoat::router::content::Form;
15+use topcoat::router::content::multipart::Multipart;
1116 use topcoat::router::error::{SeeOther, see_other};
1217 use topcoat::router::{page, path_param, route};
1318 use topcoat::view::{View, component, view};
1419
1520 use crate::audit::{self, Actor, Target};
1621 use crate::i18n::orgs::{self as g, K};
17-use crate::i18n::{self, Lang};
22+use crate::i18n::{self, Key, Lang, t};
1823 use crate::live::Topic;
1924 use crate::pages::org_ctx::{
2025 DEFAULT_ROLES, load_org, notice_href, org_head, org_notice, require_form_csrf, require_owner,
2126 take_notice,
2227 };
28+use crate::pages::settings_profile::store_avatar;
2329 use crate::state::AppState;
24-use crate::views::shell;
30+use crate::views::{avatar_url, shell, user_facing_message};
2531
2632 path_param!(org);
2733
@@ -31,6 +37,9 @@ const MAX_DESCRIPTION_CHARS: usize = 2000;
3137 struct SettingsForm {
3238 #[serde(default)]
3339 csrf: String,
40+ /// The org's display name. Empty clears it.
41+ #[serde(default)]
42+ display_name: String,
3443 #[serde(default)]
3544 description: String,
3645 #[serde(default)]
@@ -40,6 +49,12 @@ struct SettingsForm {
4049 members_can_create: String,
4150 }
4251
52+#[derive(Deserialize)]
53+struct CsrfForm {
54+ #[serde(default)]
55+ csrf: String,
56+}
57+
4358 #[derive(Deserialize)]
4459 struct DeleteForm {
4560 #[serde(default)]
@@ -52,7 +67,10 @@ struct DeleteForm {
5267 #[component]
5368 async fn settings_body(
5469 name: String,
70+ display_name: String,
5571 description: String,
72+ has_avatar: bool,
73+ avatar_src: String,
5674 base: String,
5775 csrf: String,
5876 default_role: String,
@@ -62,52 +80,88 @@ async fn settings_body(
6280 live: String,
6381 ) -> Result<impl View> {
6482 let save_action = format!("{base}/settings");
83+ let avatar_action = format!("{base}/settings/avatar");
84+ let avatar_remove_action = format!("{base}/settings/avatar/delete");
6585 let delete_action = format!("{base}/settings/delete");
6686 let confirm_label = g::type_to_confirm(lang, &name);
6787 Ok(view! {
6888 <div data-live=(live.as_str())>
6989 org_head(name: name, description: description.clone())
7090 org_notice(notice: notice)
71- <section class="card">
72- <h2>(g::t(lang, K::Settings))</h2>
73- <form method="post" action=(save_action.as_str()) class="stack">
74- <input type="hidden" name="csrf" value=(csrf.as_str())>
75- <label>
76- <span>(g::t(lang, K::Description))</span>
77- <textarea name="description" rows="3" maxlength="2000">(description.as_str())</textarea>
78- </label>
79- <label>
80- <span>(g::t(lang, K::DefaultRoleLabel))</span>
81- <select name="default_repo_role">
82- for choice in DEFAULT_ROLES.iter() {
83- <option value=(*choice) selected=(*choice == default_role.as_str())>(g::role_name(lang, choice))</option>
84- }
85- </select>
86- </label>
87- <p class="muted small">(g::t(lang, K::DefaultRoleHelp))</p>
88- <label class="inline">
89- <input type="checkbox" name="members_can_create" value="on" checked=(members_can_create)>
90- <span>(g::t(lang, K::MembersCanCreate))</span>
91- </label>
92- <div>
93- <button type="submit" class="primary">(g::t(lang, K::SaveSettings))</button>
94- </div>
95- </form>
96- </section>
97- <section class="card">
98- <h2>(g::t(lang, K::DeleteOrg))</h2>
99- <p class="muted small">(g::t(lang, K::DeleteOrgIntro))</p>
100- <form method="post" action=(delete_action.as_str()) class="stack">
101- <input type="hidden" name="csrf" value=(csrf.as_str())>
102- <label>
103- <span>(confirm_label.as_str())</span>
104- <input type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)>
105- </label>
106- <div>
107- <button type="submit" class="danger">(g::t(lang, K::DeleteOrg))</button>
108- </div>
109- </form>
110- </section>
91+ <div class="org-settings-grid">
92+ <section class="card">
93+ <h2>(g::t(lang, K::Settings))</h2>
94+ <form method="post" action=(save_action.as_str()) class="stack">
95+ <input type="hidden" name="csrf" value=(csrf.as_str())>
96+ <label>
97+ <span>(g::t(lang, K::DisplayNameLabel))</span>
98+ <input type="text" name="display_name" maxlength="80" value=(display_name.as_str())>
99+ </label>
100+ <label>
101+ <span>(g::t(lang, K::Description))</span>
102+ <textarea name="description" rows="2" maxlength="2000">(description.as_str())</textarea>
103+ </label>
104+ <label>
105+ <span>(g::t(lang, K::DefaultRoleLabel))</span>
106+ <select name="default_repo_role">
107+ for choice in DEFAULT_ROLES.iter() {
108+ <option value=(*choice) selected=(*choice == default_role.as_str())>(g::role_name(lang, choice))</option>
109+ }
110+ </select>
111+ </label>
112+ <p class="muted small">(g::t(lang, K::DefaultRoleHelp))</p>
113+ <label class="inline">
114+ <input type="checkbox" name="members_can_create" value="on" checked=(members_can_create)>
115+ <span>(g::t(lang, K::MembersCanCreate))</span>
116+ </label>
117+ <div>
118+ <button type="submit" class="primary">(g::t(lang, K::SaveSettings))</button>
119+ </div>
120+ </form>
121+ </section>
122+ <div class="stack">
123+ <section class="card">
124+ <h2>(t(lang, Key::Avatar))</h2>
125+ <aside class="profile-settings-avatar" aria-label=(t(lang, Key::Avatar))>
126+ <div class="profile-settings-avatar-frame">
127+ <img class="avatar profile-settings-avatar-img" src=(avatar_src.as_str()) alt=(t(lang, Key::AvatarAlt)) width="180" height="180">
128+ <details class="menu profile-settings-avatar-menu">
129+ <summary>(t(lang, Key::Edit))</summary>
130+ <div class="menu-list profile-settings-avatar-list">
131+ <form method="post" action=(avatar_action.as_str()) enctype="multipart/form-data" class="profile-settings-avatar-upload">
132+ <input type="hidden" name="csrf" value=(csrf.as_str())>
133+ <input class="profile-settings-avatar-file" type="file" id="org-settings-avatar-file" name="avatar" aria-label=(t(lang, Key::Image)) accept="image/png,image/jpeg,image/webp,image/gif" required=(true)>
134+ <label class="profile-settings-avatar-item" for="org-settings-avatar-file">(t(lang, Key::UploadPhoto))</label>
135+ <button type="submit" class="primary">(t(lang, Key::Upload))</button>
136+ </form>
137+ if has_avatar {
138+ <form method="post" action=(avatar_remove_action.as_str()) class="profile-settings-avatar-remove">
139+ <input type="hidden" name="csrf" value=(csrf.as_str())>
140+ <button type="submit" class="link-button">(t(lang, Key::RemovePhoto))</button>
141+ </form>
142+ }
143+ </div>
144+ </details>
145+ </div>
146+ <small class="muted">(t(lang, Key::AvatarHint))</small>
147+ </aside>
148+ </section>
149+ <section class="card">
150+ <h2>(g::t(lang, K::DeleteOrg))</h2>
151+ <p class="muted small">(g::t(lang, K::DeleteOrgIntro))</p>
152+ <form method="post" action=(delete_action.as_str()) class="stack">
153+ <input type="hidden" name="csrf" value=(csrf.as_str())>
154+ <label>
155+ <span>(confirm_label.as_str())</span>
156+ <input type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)>
157+ </label>
158+ <div>
159+ <button type="submit" class="danger">(g::t(lang, K::DeleteOrg))</button>
160+ </div>
161+ </form>
162+ </section>
163+ </div>
164+ </div>
111165 </div>
112166 })
113167 }
@@ -122,21 +176,27 @@ async fn org_settings_page(cx: &Cx) -> Result<impl View> {
122176 let settings = state.store.org_settings(&ctx.org.id).await?;
123177 let default_role = settings.default_repo_role.as_str().to_owned();
124178 let members_can_create = settings.members_can_create_repos;
179+ let avatar = state.store.avatar_hash(&ctx.org.id).await?;
180+ let has_avatar = avatar.is_some();
181+ let avatar_src = avatar_url(&ctx.org.username, avatar.as_deref());
125182 let notice = take_notice(cx, lang);
126183 let title = g::page_title(lang, &ctx.org.username, K::Settings);
127184 let name = ctx.org.username.clone();
185+ let display_name = ctx.org.display_name.clone().unwrap_or_default();
128186 let description = ctx.org.about.clone();
129187 let base = ctx.href("");
130188 let csrf = ctx.viewer.1.csrf_token.clone();
131189 let live = ctx.href("/settings/events");
132190 Ok(view! { cx =>
133191 shell(title: title.as_str(), viewer: Some(&ctx.viewer),
134- settings_body(name: name, description: description, base: base, csrf: csrf,
192+ settings_body(name: name, display_name: display_name, description: description,
193+ has_avatar: has_avatar, avatar_src: avatar_src, base: base, csrf: csrf,
135194 default_role: default_role, members_can_create: members_can_create, notice: notice, lang: lang, live: live))
136195 })
137196 }
138197
139-/// Saves the description and the org settings. Owners only.
198+/// Saves the display name, the description and the org settings. Owners only. A display name the
199+/// store refuses redirects with a notice before anything is written.
140200 #[route(POST "/org/{org}/settings")]
141201 async fn org_settings_save(cx: &Cx, Form(form): Form<SettingsForm>) -> Result<SeeOther> {
142202 let ctx = load_org(cx, path_param::<Org>(cx)).await?;
@@ -154,6 +214,17 @@ async fn org_settings_save(cx: &Cx, Form(form): Form<SettingsForm>) -> Result<Se
154214 };
155215 let members_can_create_repos = !form.members_can_create.is_empty();
156216
217+ match state
218+ .store
219+ .set_display_name(&ctx.org.id, form.display_name.trim())
220+ .await
221+ {
222+ Ok(()) => {}
223+ Err(forge_core::Error::Invalid(_)) => {
224+ return Ok(see_other(notice_href(&back, "invalid_display_name")));
225+ }
226+ Err(e) => return Err(e.into()),
227+ }
157228 state
158229 .store
159230 .set_org_settings(
@@ -187,6 +258,77 @@ async fn org_settings_save(cx: &Cx, Form(form): Form<SettingsForm>) -> Result<Se
187258 Ok(see_other(notice_href(&back, "settings_saved")))
188259 }
189260
261+/// Uploads the org's avatar. Owners only. The multipart fields are read as the person's upload
262+/// reads them, then the CSRF token and the role are checked before the image is decoded.
263+#[route(POST "/org/{org}/settings/avatar")]
264+async fn org_avatar_upload(cx: &Cx, mut multipart: Multipart) -> Result<SeeOther> {
265+ let mut csrf = String::new();
266+ let mut image = None;
267+ while let Some(field) = multipart.next_field().await? {
268+ let name = field.name().map(str::to_owned);
269+ match name.as_deref() {
270+ Some("csrf") => csrf = field.text().await?,
271+ Some("avatar") => image = Some(field.bytes().await?.to_vec()),
272+ _ => {}
273+ }
274+ }
275+ let ctx = load_org(cx, path_param::<Org>(cx)).await?;
276+ require_form_csrf(&ctx, &csrf)?;
277+ require_owner(&ctx)?;
278+ let state = app_context::<AppState>(cx);
279+ let lang = i18n::lang(cx, Some(&ctx.viewer.0));
280+ let back = ctx.href("/settings");
281+
282+ match store_avatar(&state.store, &ctx.org.id, image, lang).await {
283+ Ok(()) => {
284+ audit::record(
285+ &state.store,
286+ Some(cx),
287+ Actor::User(&ctx.viewer.0),
288+ AuditAction::OrgSettingsUpdated,
289+ Target {
290+ kind: "org",
291+ id: &ctx.org.id,
292+ name: &ctx.org.username,
293+ },
294+ serde_json::json!({ "avatar": "updated" }),
295+ )
296+ .await;
297+ Ok(see_other(notice_href(&back, "settings_saved")))
298+ }
299+ Err(e) if user_facing_message(&e).is_some() => {
300+ Ok(see_other(notice_href(&back, "avatar_invalid")))
301+ }
302+ Err(e) => Err(e.into()),
303+ }
304+}
305+
306+/// Removes the org's avatar. Owners only.
307+#[route(POST "/org/{org}/settings/avatar/delete")]
308+async fn org_avatar_remove(cx: &Cx, Form(form): Form<CsrfForm>) -> Result<SeeOther> {
309+ let ctx = load_org(cx, path_param::<Org>(cx)).await?;
310+ require_form_csrf(&ctx, &form.csrf)?;
311+ require_owner(&ctx)?;
312+ let state = app_context::<AppState>(cx);
313+ let back = ctx.href("/settings");
314+
315+ state.store.delete_avatar(&ctx.org.id).await?;
316+ audit::record(
317+ &state.store,
318+ Some(cx),
319+ Actor::User(&ctx.viewer.0),
320+ AuditAction::OrgSettingsUpdated,
321+ Target {
322+ kind: "org",
323+ id: &ctx.org.id,
324+ name: &ctx.org.username,
325+ },
326+ serde_json::json!({ "avatar": "removed" }),
327+ )
328+ .await;
329+ Ok(see_other(notice_href(&back, "settings_saved")))
330+}
331+
190332 /// Deletes the org. Owners only, and the name must be typed again. Refused while the org owns
191333 /// repositories; then the settings page says so.
192334 #[route(POST "/org/{org}/settings/delete")]
crates/forge-web/src/pages/palette.rsmodified+2 -4
@@ -1,6 +1,6 @@
11 //! The command palette's destinations: `GET /-/palette` lists what the signed-in viewer can jump to,
2-//! their repos, the orgs they belong to and the fixed pages (the sidebar's links, the settings pages
3-//! and, for admins, the admin pages). The palette itself, its filtering and keys live in
2+//! their repos, the orgs they belong to and the fixed pages (Explore, notifications, snippets, new
3+//! repository and settings, and for admins the admin pages). The palette itself, its filtering and keys live in
44 //! `assets/nav.js`.
55
66 use http::header::{CACHE_CONTROL, CONTENT_TYPE, X_CONTENT_TYPE_OPTIONS};
@@ -12,7 +12,6 @@ use topcoat::router::{Body, HeaderValue, StatusCode, route};
1212
1313 use crate::auth::current_user;
1414 use crate::i18n::community::{self as cm, K as CK};
15-use crate::i18n::orgs::{self as o, K as OK};
1615 use crate::i18n::{self, Key, t};
1716 use crate::state::AppState;
1817 use crate::views::{admin_items, repo_href, settings_items, user_href};
@@ -47,7 +46,6 @@ async fn palette(cx: &Cx) -> Result<Response> {
4746 items.push(destination(&org.username, &user_href(&org.username), "org"));
4847 }
4948
50- items.push(destination(o::t(lang, OK::Dashboard), "/", "page"));
5149 items.push(destination(t(lang, Key::Explore), "/explore", "page"));
5250 items.push(destination(t(lang, Key::Notifications), "/notifications", "page"));
5351 items.push(destination(cm::t(lang, CK::Snippets), "/snippets", "page"));
crates/forge-web/src/pages/profile.rsmodified+228 -17
@@ -1,9 +1,10 @@
11 //! Page: public profile at `/{username}`. Avatar, about (rendered markdown) and local time, then
2-//! three tabs: `overview` (pinned repos, or the most recently active ones when nothing is pinned,
3-//! plus an organization's members and teams), `repositories` and `stars`. The repo tabs list what
4-//! the viewer is allowed to read, 30 per page, with a name filter and three sort orders; the
5-//! filtering, sorting and paging run in the database. Fixed single-segment routes are registered
6-//! statically, so they win over this parameter route.
2+//! the tabs: `overview` (pinned repos, or the most recently active ones when nothing is pinned,
3+//! plus an organization's members and teams, or a person's contribution calendar), `repositories`,
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
6+//! sort orders; the filtering, sorting and paging run in the database. Fixed single-segment routes
7+//! are registered statically, so they win over this parameter route.
78
89 use forge_core::authz::{Action, authorize};
910 use forge_core::store::RepoSort;
@@ -20,17 +21,22 @@ use topcoat::router::{page, path_param, query_params, route};
2021 use topcoat::view::{Unescaped, View, component, view};
2122
2223 use crate::auth::current_user;
24+use crate::i18n::community::{self as cm, K as CK};
2325 use crate::i18n::misc::{self as mi, K as MK};
2426 use crate::i18n::orgs::{self as g, K};
2527 use crate::i18n::packages::{self as pk, K as PK};
2628 use crate::i18n::{self, Lang};
2729 use crate::live::{Topic, stream_changes};
28-use crate::pages::dashboard::badge_class;
30+use crate::pages::org_new::may_create_org;
2931 use crate::pages::packages::{self as packages, PackageRow};
32+use crate::pages::repo_settings::{notice_banner_for, take_notice};
33+use crate::pages::profile_calendar::{calendar_since, load_calendar};
34+use crate::pages::snippets::{ListRow, list_row, snippet_rows};
3035 use crate::render::markdown::render_markdown;
3136 use crate::state::AppState;
37+use crate::views::heatmap::{Calendar, DayDetail, contribution_calendar};
3238 use crate::views::repo_list::{
33- PageLink, RepoRow, SortLink, pager, pager_links, repo_rows, sort_chips,
39+ PageLink, RepoRow, SortLink, badge_class, pager, pager_links, repo_rows, sort_chips,
3440 };
3541 use crate::views::{avatar_url, empty_state, enc, now_unix, repo_href, shell};
3642
@@ -49,6 +55,8 @@ struct ProfileQuery {
4955 q: Option<String>,
5056 sort: Option<String>,
5157 page: Option<String>,
58+ /// A calendar day whose contributions to list under the calendar on the overview.
59+ day: Option<String>,
5260 }
5361
5462 /// Sort keys of the repo tabs in the order their chips are shown, with the label of each. The
@@ -89,7 +97,18 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
8997
9098 let actor = viewer.as_ref().map(|(u, _)| u);
9199 let lang = i18n::lang(cx, actor);
100+ // Whether the viewer is this person. Only the person sees their Organizations tab and edit links.
101+ let own =!user.is_org() && actor.is_some_and(|u| u.id == user.id);
102+ // An organization cannot be starred or keep snippets, so those tabs show the overview instead.
103+ // The Organizations tab is the viewer's own, so anyone else gets the overview.
92104 let tab = tab_key(query.tab.as_deref());
105+ let tab = if (user.is_org() && matches!(tab, "stars" | "snippets"))
106+ || (tab == "organizations" && !own)
107+ {
108+ "overview"
109+ } else {
110+ tab
111+ };
93112 let q: String = query
94113 .q
95114 .as_deref()
@@ -135,11 +154,23 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
135154 }
136155 }
137156
157+ // The viewer's role in an organization, looked up once for the header, the tabs and the pins.
158+ let org_role = match actor {
159+ Some(u) if user.is_org() => state.store.org_member_role(&user.id, &u.id).await?,
160+ _ => None,
161+ };
162+ let org_owner = org_role == Some(OrgMemberRole::Owner);
163+ let org_member = org_role.is_some();
164+ let org_can_create = match actor {
165+ Some(u) if org_member => {
166+ crate::pages::org_ctx::may_create_repo_in(state, &user.id, &u.id).await?
167+ }
168+ _ => false,
169+ };
170+
138171 // An organization's pins are edited by its owners, a user's by the user.
139172 let can_edit_pins = match actor {
140- Some(u) if user.is_org() => {
141- state.store.org_member_role(&user.id, &u.id).await? == Some(OrgMemberRole::Owner)
142- }
173+ Some(_) if user.is_org() => org_owner,
143174 Some(u) => u.id == user.id,
144175 None => false,
145176 };
@@ -150,7 +181,54 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
150181 "/settings/pins".to_owned()
151182 }
152183 });
153- let edit_profile = !user.is_org() && actor.is_some_and(|u| u.id == user.id);
184+
185+ // The overview's contribution calendar, for a person only. Its counts and day links use public
186+ // repos alone, so anyone may see it.
187+ let heat = if tab == "overview" && !user.is_org() {
188+ Some(load_calendar(state, &user, query.day.as_deref()).await?)
189+ } else {
190+ None
191+ };
192+
193+ // The Snippets tab lists the person's snippets the viewer may read. An organization keeps none.
194+ let snippets: Vec<ListRow> = if user.is_org() {
195+ Vec::new()
196+ } else {
197+ state
198+ .store
199+ .list_owner_snippets(&user.id, actor.map(|u| u.id.as_str()))
200+ .await?
201+ .into_iter()
202+ .map(|summary| list_row(lang, summary))
203+ .collect()
204+ };
205+
206+ // The viewer's Organizations tab lists the organizations they belong to, and whether the
207+ // instance lets them create one.
208+ let (orgs, org_create_allowed) = match actor {
209+ Some(viewer_user) if tab == "organizations" => {
210+ let mut cards = Vec::new();
211+ for (org, role) in state.store.orgs_for_user(&user.id).await? {
212+ let hash = state.store.avatar_hash(&org.id).await?;
213+ cards.push(OrgCard {
214+ href: format!("/{}", enc(&org.username)),
215+ avatar: avatar_url(&org.username, hash.as_deref()),
216+ name: org.username,
217+ display_name: org.display_name.unwrap_or_default(),
218+ role: g::t(
219+ lang,
220+ if role == OrgMemberRole::Owner {
221+ K::RoleOwner
222+ } else {
223+ K::RoleMember
224+ },
225+ ),
226+ });
227+ }
228+ (cards, may_create_org(state, viewer_user))
229+ }
230+ _ => (Vec::new(), false),
231+ };
154232
155233 let listing = match tab {
156234 "repositories" | "stars" => {
@@ -223,14 +301,20 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
223301 let package_rows = packages::package_rows(state, actor, &user).await?;
224302 let packages_on = tab == "packages";
225303
304+ // A repo deleted just before this redirect here shows its one-line notice once.
305+ let notice = take_notice(cx);
226306 let title = user.username.clone();
227307 Ok(view! { cx =>
228308 shell(title: title.as_str(), viewer: viewer.as_ref(),
309+ notice_banner_for(lang: lang, title: notice)
229310 profile_card(user: user, avatar: avatar, about_html: about_html, local_time: local_time,
230311 org: org, lang: lang, tab: tab.to_owned(), q: q, sort: sort, repo_total: repo_total,
231312 star_total: star_total, cards: cards, from_pins: from_pins,
232- pins_edit_href: pins_edit_href, edit_profile: edit_profile, listing: listing,
233- packages_on: packages_on, package_rows: package_rows))
313+ pins_edit_href: pins_edit_href, edit_profile: own, listing: listing,
314+ packages_on: packages_on, package_rows: package_rows,
315+ org_member: org_member, org_owner: org_owner, org_can_create: org_can_create,
316+ heat: heat, snippets: snippets, orgs: orgs, org_create_allowed: org_create_allowed,
317+ own_profile: own))
234318 })
235319 }
236320
@@ -293,6 +377,16 @@ async fn profile_fingerprint(
293377 let members = state.store.org_members(&user.id).await?.len();
294378 let teams = state.store.teams_for_org(&user.id).await?.len();
295379 lines.push(format!("org {members} {teams}"));
380+ } else {
381+ // A person's overview shows the contribution calendar, so its total moves with each one.
382+ let total: u64 = state
383+ .store
384+ .contribution_counts(&user.id, &calendar_since(), &user.timezone)
385+ .await?
386+ .iter()
387+ .map(|(_, count)| u64::from(*count))
388+ .sum();
389+ lines.push(format!("calendar {total}"));
296390 }
297391 let pins = readable(
298392 state,
@@ -330,6 +424,16 @@ struct PinCard {
330424 stars: u64,
331425 }
332426
427+/// One organization on the viewer's own Organizations tab, with its strings ready for the view.
428+struct OrgCard {
429+ href: String,
430+ avatar: String,
431+ name: String,
432+ /// Empty when the organization has no display name.
433+ display_name: String,
434+ role: &'static str,
435+}
436+
333437 /// One page of a repo tab: the rows, the pager, the sort chips, the match count text and the
334438 /// empty-list text.
335439 #[derive(Default)]
@@ -347,8 +451,10 @@ struct Listing {
347451 fn tab_key(raw: Option<&str>) -> &'static str {
348452 match raw {
349453 Some("repositories") => "repositories",
454+ Some("snippets") => "snippets",
350455 Some("stars") => "stars",
351456 Some("packages") => "packages",
457+ Some("organizations") => "organizations",
352458 _ => "overview",
353459 }
354460 }
@@ -438,8 +544,23 @@ async fn profile_card(
438544 listing: Listing,
439545 packages_on: bool,
440546 package_rows: Vec<PackageRow>,
547+ org_member: bool,
548+ org_owner: bool,
549+ org_can_create: bool,
550+ heat: Option<(Calendar, Option<DayDetail>)>,
551+ snippets: Vec<ListRow>,
552+ own_profile: bool,
553+ orgs: Vec<OrgCard>,
554+ org_create_allowed: bool,
441555 ) -> Result<impl View> {
442556 let package_count_text = package_rows.len().to_string();
557+ let snippet_count_text = snippets.len().to_string();
558+ let has_snippets = !snippets.is_empty();
559+ let snippets_on = tab == "snippets";
560+ let snippets_href = profile_href(&user.username, "snippets", "", SORTS[0].0, 1);
561+ let orgs_on = tab == "organizations";
562+ let organizations_href = profile_href(&user.username, "organizations", "", SORTS[0].0, 1);
563+ let has_orgs = !orgs.is_empty();
443564 let packages_href = profile_href(&user.username, "packages", "", SORTS[0].0, 1);
444565 let packages_events = packages::events_href(&user.username);
445566 let has_packages = !package_rows.is_empty();
@@ -480,6 +601,10 @@ async fn profile_card(
480601 empty,
481602 } = listing;
482603 let has_rows = !rows.is_empty();
604+ let new_repo_href = format!("/new?owner={}", enc(&user.username));
605+ let settings_href = format!("/org/{}/settings", enc(&user.username));
606+ let members_href = format!("/org/{}/members", enc(&user.username));
607+ let teams_href = format!("/org/{}/teams", enc(&user.username));
483608 Ok(view! {
484609 <article class="profile-page" data-live=(format!("/users/{}/events", user.username))>
485610 <header class="profile-head">
@@ -492,10 +617,22 @@ async fn profile_card(
492617 if is_org {
493618 <p class="muted small">(g::t(lang, K::Organization))</p>
494619 }
495- <p class="muted">(g::t(lang, K::LocalTime)) (local_time.as_str())</p>
620+ if !is_org {
621+ <p class="muted">(g::t(lang, K::LocalTime)) (local_time.as_str())</p>
622+ }
496623 if edit_profile {
497624 <a class="button profile-edit" href="/settings/profile">(edit_label)</a>
498625 }
626+ if is_org && (org_can_create || org_owner) {
627+ <div class="profile-org-actions">
628+ if org_can_create {
629+ <a class="button primary" href=(new_repo_href.as_str())>(g::t(lang, K::NewRepository))</a>
630+ }
631+ if org_owner {
632+ <a class="button" href=(settings_href.as_str())>(g::t(lang, K::Settings))</a>
633+ }
634+ </div>
635+ }
499636 </div>
500637 </header>
501638 if has_about {
@@ -506,12 +643,29 @@ async fn profile_card(
506643 <a class=(tab_class(repos_on)) href=(repositories_href.as_str())>
507644 (g::t(lang, K::Repositories)) " " <span class="tab-count">(repo_count_text.as_str())</span>
508645 </a>
509- <a class=(tab_class(stars_on)) href=(stars_href.as_str())>
510- (g::t(lang, K::TabStars)) " " <span class="tab-count">(star_count_text.as_str())</span>
511- </a>
646+ if !is_org {
647+ <a class=(tab_class(snippets_on)) href=(snippets_href.as_str())>
648+ (cm::t(lang, CK::Snippets)) " " <span class="tab-count">(snippet_count_text.as_str())</span>
649+ </a>
650+ }
651+ if !is_org {
652+ <a class=(tab_class(stars_on)) href=(stars_href.as_str())>
653+ (g::t(lang, K::TabStars)) " " <span class="tab-count">(star_count_text.as_str())</span>
654+ </a>
655+ }
512656 <a class=(tab_class(packages_on)) href=(packages_href.as_str())>
513657 (pk::t(lang, PK::TabPackages)) " " <span class="tab-count">(package_count_text.as_str())</span>
514658 </a>
659+ if own_profile {
660+ <a class=(tab_class(orgs_on)) href=(organizations_href.as_str())>(g::t(lang, K::Organizations))</a>
661+ }
662+ if org_member {
663+ <a class=(tab_class(false)) href=(members_href.as_str())>(g::t(lang, K::Members))</a>
664+ <a class=(tab_class(false)) href=(teams_href.as_str())>(g::t(lang, K::Teams))</a>
665+ }
666+ if org_owner {
667+ <a class=(tab_class(false)) href=(settings_href.as_str())>(g::t(lang, K::Settings))</a>
668+ }
515669 </nav>
516670 if overview_on {
517671 <section class="profile-pinned">
@@ -542,6 +696,9 @@ async fn profile_card(
542696 empty_state(title: g::t(lang, K::NoVisibleRepos))
543697 }
544698 </section>
699+ if let Some((calendar, selected)) = heat {
700+ contribution_calendar(calendar: calendar, selected: selected, lang: lang, base: base.clone())
701+ }
545702 if let Some(summary) = org {
546703 <section class="profile-org">
547704 <h2>(g::t(lang, K::Members))</h2>
@@ -560,6 +717,11 @@ async fn profile_card(
560717 }
561718 if list_on {
562719 <section class="repo-listing">
720+ if own_profile && repos_on {
721+ <div class="profile-section-head">
722+ <a class="button primary" href="/new">(g::t(lang, K::NewRepository))</a>
723+ </div>
724+ }
563725 <form method="get" action=(base.as_str()) class="explore-search" role="search">
564726 <input type="hidden" name="tab" value=(tab.as_str())>
565727 <input type="hidden" name="sort" value=(sort)>
@@ -611,6 +773,47 @@ async fn profile_card(
611773 }
612774 </section>
613775 }
776+ if snippets_on {
777+ <section class="snippet-listing">
778+ <div class="profile-section-head">
779+ <h2>(cm::t(lang, CK::Snippets))</h2>
780+ if own_profile {
781+ <a class="button primary" href="/snippets/new">(cm::t(lang, CK::NewSnippet))</a>
782+ }
783+ </div>
784+ if has_snippets {
785+ snippet_rows(lang: lang, rows: snippets)
786+ } else {
787+ empty_state(title: cm::t(lang, CK::NoSnippets))
788+ }
789+ </section>
790+ }
791+ if orgs_on {
792+ <section class="profile-orgs">
793+ <div class="profile-section-head">
794+ <h2>(g::t(lang, K::Organizations))</h2>
795+ if org_create_allowed {
796+ <a class="button primary" href="/org/new">(g::t(lang, K::NewOrganization))</a>
797+ }
798+ </div>
799+ if has_orgs {
800+ <ul class="item-list">
801+ for org in orgs.into_iter() {
802+ <li>
803+ <img class="avatar avatar-sm" src=(org.avatar.as_str()) alt="" width="24" height="24">
804+ <a href=(org.href.as_str())>(org.name.as_str())</a>
805+ if !org.display_name.is_empty() {
806+ " " <span class="muted small">(org.display_name.as_str())</span>
807+ }
808+ " " <span class="muted small">(org.role)</span>
809+ </li>
810+ }
811+ </ul>
812+ } else {
813+ empty_state(title: g::t(lang, K::NoOrganizations))
814+ }
815+ </section>
816+ }
614817 </article>
615818 })
616819 }
@@ -903,6 +1106,14 @@ mod tests {
9031106 !anon.contains("Customize pins"),
9041107 "org pins: anonymous has no edit link"
9051108 );
1109+ assert!(
1110+ owner.contains("href=\"/org/acme/settings\"") && owner.contains("/new?owner=acme"),
1111+ "org profile: owner sees Settings and New repository"
1112+ );
1113+ assert!(
1114+ !anon.contains("/org/acme/members"),
1115+ "org profile: anonymous has no members link"
1116+ );
9061117 }
9071118
9081119 /// Pins, the popular-repos fallback and the display name, on one seeded site. The
crates/forge-web/src/pages/profile_calendar.rsadded+92 -0
@@ -0,0 +1,92 @@
1+//! The contribution calendar and its selected day, shown on a person's profile.
2+//! The counts and the day's contributions come from public repos only, so anyone may see them.
3+
4+use std::time::Duration;
5+
6+use forge_core::time::stamp_from_unix;
7+use forge_core::User;
8+use jiff::{Timestamp, civil};
9+use topcoat::Result;
10+
11+use crate::state::AppState;
12+use crate::views::heatmap::{self, Calendar, DayDetail};
13+
14+/// How far back the calendar reads contributions: 53 weeks plus the days of the current week.
15+const CALENDAR_DAYS: u64 = 371;
16+
17+/// The `since` stamp for the calendar. One extra day covers the viewer's local day, which can
18+/// start before the UTC day that `CALENDAR_DAYS` reaches back to.
19+pub(crate) fn calendar_since() -> String {
20+ forge_core::time::stamp_ago(Duration::from_secs((CALENDAR_DAYS + 1) * 86_400))
21+}
22+
23+/// The day the `day` query asks for: a strict `YYYY-MM-DD` date from the calendar's first day to
24+/// today. Anything else (malformed, a future day, or before the calendar) is ignored.
25+pub(crate) fn selected_day(
26+ day: Option<&str>,
27+ first: (i64, i64, i64),
28+ today: (i64, i64, i64),
29+) -> Option<civil::Date> {
30+ let text = day?;
31+ let date: civil::Date = text.parse().ok()?;
32+ // The parser takes more forms than the calendar link uses, so the date must print back as sent.
33+ if date.to_string() != text {
34+ return None;
35+ }
36+ let ymd = (
37+ i64::from(date.year()),
38+ i64::from(date.month()),
39+ i64::from(date.day()),
40+ );
41+ (first..=today).contains(&ymd).then_some(date)
42+}
43+
44+/// The contributions the user made on their local day `date`, newest first.
45+pub(crate) async fn day_detail(
46+ state: &AppState,
47+ user: &User,
48+ date: civil::Date,
49+) -> Result<Option<DayDetail>> {
50+ let Some((start, end)) = forge_core::tz::day_span(date, &user.timezone) else {
51+ return Ok(None);
52+ };
53+ let (Some(from), Some(to)) = (stamp_from_unix(start), stamp_from_unix(end)) else {
54+ return Ok(None);
55+ };
56+ let items = state
57+ .store
58+ .contributions_between(&user.id, &from, &to)
59+ .await?;
60+ Ok(Some(DayDetail {
61+ date: (
62+ i64::from(date.year()),
63+ i64::from(date.month()),
64+ i64::from(date.day()),
65+ ),
66+ items,
67+ }))
68+}
69+
70+/// Reads the calendar for `user` and the day the `day` query picks, if it picks one.
71+pub(crate) async fn load_calendar(
72+ state: &AppState,
73+ user: &User,
74+ day: Option<&str>,
75+) -> Result<(Calendar, Option<DayDetail>)> {
76+ let local_now = forge_core::tz::local_datetime(Timestamp::now(), &user.timezone);
77+ let today = (
78+ i64::from(local_now.year()),
79+ i64::from(local_now.month()),
80+ i64::from(local_now.day()),
81+ );
82+ let counts = state
83+ .store
84+ .contribution_counts(&user.id, &calendar_since(), &user.timezone)
85+ .await?;
86+ let calendar = heatmap::build(&counts, today);
87+ let selected = match selected_day(day, calendar.first_day, today) {
88+ Some(date) => day_detail(state, user, date).await?,
89+ None => None,
90+ };
91+ Ok((calendar, selected))
92+}
crates/forge-web/src/pages/pull_files.rsmodified+1 -1
@@ -130,7 +130,7 @@ async fn pull_files(cx: &Cx) -> Result<impl View> {
130130 let commit_count = commits_of(state, &ctx, &pr).await?.len();
131131 let full_diff = pull_diff(state, &ctx, &pr).await?;
132132 let frame = frame_in(lang, state, &ctx, &pr, commit_count, full_diff.files.len()).await?;
133- let opts = DiffOpts::from_cx(cx, None);
133+ let opts = DiffOpts::from_cx(cx, None).await?;
134134 // With whitespace ignored the file list can shrink, so file indexes differ from the comment
135135 // routes' view. Existing threads still show; new inline comments wait for the full diff.
136136 let diff = if opts.ignore_ws {
crates/forge-web/src/pages/repo.rsmodified+1 -1
@@ -22,7 +22,6 @@ use crate::i18n::code::{self as g, K};
2222 use crate::i18n::{self, Lang};
2323 use crate::pages::passkeys::s;
2424 use crate::pages::code_live::{follows_branch, home_live_url};
25-use crate::pages::dashboard::badge_class;
2625 use crate::pages::finder::file_finder;
2726 use crate::pages::repo_side::{repo_ci_line, repo_strip, run_rows, tree_facts};
2827 use crate::pages::issue_parts::stamp_unix;
@@ -34,6 +33,7 @@ use crate::pages::tree::{
3433 entry_rows, last_commits, latest_bar, load_readme, read_dir, readme_card, tree_table,
3534 };
3635 use crate::state::AppState;
36+use crate::views::repo_list::badge_class;
3737 use crate::views::{now_unix, ref_selector, rel_time, relative_time, repo_href, repo_tabs, shell, user_link};
3838
3939 path_param!(owner);
crates/forge-web/src/pages/repo_settings.rsmodified+7 -6
@@ -40,12 +40,12 @@ use crate::pages::repo::repo_head;
4040 use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
4141 use crate::pages::repo_settings_live::settings_head;
4242 use crate::state::AppState;
43-use crate::views::{alert, shell};
43+use crate::views::{alert, enc, shell};
4444
4545 path_param!(owner);
4646 path_param!(repo);
4747
48-/// Cookie that carries a one-shot notice (the deleted repo's `owner/name`) to the next home page.
48+/// Cookie that carries a one-shot notice (the deleted repo's `owner/name`) to the next profile page.
4949 pub const NOTICE_COOKIE: &str = "forge_notice";
5050
5151 /// Cookie that carries a one-shot settings notice to the next settings page. Its value is one of
@@ -145,7 +145,7 @@ struct BranchDeleteForm {
145145 rule_id: String,
146146 }
147147
148-/// Sets the notice shown on the next home page view.
148+/// Sets the notice shown on the next profile page view.
149149 pub fn set_notice(cx: &Cx, title: &str) {
150150 cookies(cx).add(
151151 Cookie::build((NOTICE_COOKIE, title.to_owned()))
@@ -227,7 +227,7 @@ async fn load_branch_names(ctx: &RepoCtx) -> Result<Vec<String>> {
227227 .collect())
228228 }
229229
230-/// The one-line notice on the home page after a delete.
230+/// The one-line notice on the profile page after a delete.
231231 #[component]
232232 pub async fn notice_banner_for(lang: Lang, title: Option<String>) -> Result<impl View> {
233233 Ok(view! {
@@ -1101,7 +1101,7 @@ async fn settings_archive_save(cx: &Cx, Form(form): Form<ArchiveForm>) -> Result
11011101
11021102 /// Deletes the repo when the viewer may delete it, the CSRF token is valid and the confirmation
11031103 /// is exactly `owner/name`. On success the repo is moved to trash, its rows are deleted, and the
1104-/// viewer is redirected home with a notice. If the database delete fails the directory goes back.
1104+/// viewer is redirected to the owner's repositories tab with a notice. If the database delete fails the directory goes back.
11051105 /// A wrong confirmation re-renders the page with an error and changes nothing.
11061106 #[page(POST "/{owner}/{repo}/settings/delete")]
11071107 async fn settings_delete(cx: &Cx, Form(form): Form<DeleteForm>) -> Result<impl View> {
@@ -1204,7 +1204,8 @@ async fn settings_delete(cx: &Cx, Form(form): Form<DeleteForm>) -> Result<impl V
12041204 )
12051205 .await;
12061206 set_notice(cx, &title);
1207- return Err(see_other("/").into());
1207+ // The owner's profile repository list shows the notice (the profile reads the cookie).
1208+ return Err(see_other(format!("/{}?tab=repositories", enc(&ctx.repo.owner_name))).into());
12081209 }
12091210
12101211 let rules = app_context::<AppState>(cx)
crates/forge-web/src/pages/settings_profile.rsmodified+10 -4
@@ -37,6 +37,12 @@ pub fn avatar_body_limit() -> BodyLimit {
3737 BodyLimit::max(MAX_UPLOAD_BYTES + MULTIPART_OVERHEAD).at("/settings/profile/avatar")
3838 }
3939
40+/// Body limit for the org avatar upload route. A `{org}` segment in a layer path matches any
41+/// org name, as it does in the route path itself.
42+pub fn org_avatar_body_limit() -> BodyLimit {
43+ BodyLimit::max(MAX_UPLOAD_BYTES + MULTIPART_OVERHEAD).at("/org/{org}/settings/avatar")
44+}
45+
4046 #[query_params(error = bad_request)]
4147 struct ProfileQuery {
4248 saved: Option<String>,
@@ -299,7 +305,7 @@ fn avatar_slots() -> &'static Arc<Semaphore> {
299305 }
300306
301307 /// Stores a processed avatar, or removes it if no image was sent.
302-async fn store_avatar(
308+pub(crate) async fn store_avatar(
303309 store: &Store,
304310 user_id: &str,
305311 image: Option<Vec<u8>>,
@@ -687,7 +693,7 @@ pub(crate) mod tests {
687693 "Tahinli",
688694 "capitalization: stored"
689695 );
690- let (status, _, body) = send(&fx.router, "GET", "/", true, None).await;
696+ let (status, _, body) = send(&fx.router, "GET", "/explore", true, None).await;
691697 assert_eq!(status, 200, "capitalization: nav");
692698 assert!(
693699 body.contains("<summary class=\"corner-btn\" aria-label=\"Tahinli\">"),
@@ -913,7 +919,7 @@ pub(crate) mod tests {
913919 assert!(body.contains("Remove photo"), "page: remove item {body}");
914920
915921 // The top-nav avatar uses the real hash too, not the default URL.
916- let (_, _, body) = send(&fx.router, "GET", "/", true, None).await;
922+ let (_, _, body) = send(&fx.router, "GET", "/explore", true, None).await;
917923 let nav_src = format!(r#"src="/avatars/tahinli?v={stored_hash}""#);
918924 assert!(body.contains(&nav_src), "nav: avatar url {body}");
919925
@@ -981,7 +987,7 @@ pub(crate) mod tests {
981987 fx.store.avatar_hash(&fx.user.id).await.unwrap().is_none(),
982988 "remove: cleared"
983989 );
984- let (_, _, body) = send(&fx.router, "GET", "/", true, None).await;
990+ let (_, _, body) = send(&fx.router, "GET", "/explore", true, None).await;
985991 assert!(
986992 body.contains(r#"src="/avatars/tahinli?v=default""#),
987993 "remove: nav default {body}"
crates/forge-web/src/pages/setup.rsmodified+4 -4
@@ -297,10 +297,10 @@ mod tests {
297297 .is_some_and(|p| p == format!("{PRECSRF_COOKIE}="))
298298 );
299299
300- // The session cookie authenticates the dashboard.
301- let (status, _, home) = send(&router, "GET", "/", Some(&cookie), None).await;
300+ // The session cookie authenticates the signed-in pages.
301+ let (status, _, home) = send(&router, "GET", "/explore", Some(&cookie), None).await;
302302 assert_eq!(status, 200);
303- assert!(home.contains("Your repositories"));
303+ assert!(home.contains("class=\"corner-float\""));
304304 let csrf = field_from(&home, "csrf");
305305
306306 // Wrong CSRF token is refused.
@@ -371,7 +371,7 @@ mod tests {
371371 .unwrap()
372372 .contains("__Host-forge_session=")
373373 );
374- let (status, _, _) = send(&router, "GET", "/", Some(&cookie), None).await;
374+ let (status, _, _) = send(&router, "GET", "/explore", Some(&cookie), None).await;
375375 assert_eq!(status, 200);
376376
377377 // Login is protected the same way: a mismatched pre-session token is refused.
crates/forge-web/src/pages/shell_events.rsmodified+8 -10
@@ -1,13 +1,13 @@
1-//! `GET /-/shell/events`: the one live stream a page holds. It merges the four streams every
2-//! signed-in page used to open (`/-/alive`, `/notifications/stream`, `/-/activity/stream` and
3-//! `/-/side/events`) into one response. Chromium allows six connections per host over HTTP/1.1, and
4-//! a page that held more than that could not load anything else.
1+//! `GET /-/shell/events`: the one live stream a page holds. It merges the streams every signed-in
2+//! page used to open (`/-/alive`, `/notifications/stream` and `/-/activity/stream`) into one
3+//! response. Chromium allows six connections per host over HTTP/1.1, and a page that held more
4+//! than that could not load anything else.
55 //!
66 //! The events are named: `settings`, `theme`, `language` and `account` (the alive part, see
7-//! `settings_live::alive_stream`), `unread` (the inbox count), `activity` (the viewer's live strip
8-//! and ring) and `side` (the sidebar's repo list). An anonymous visitor gets the alive part only.
9-//! Each part keeps its own fingerprint, so an event is sent only when that part changed. The old
10-//! routes stay registered for tabs opened before a deploy.
7+//! `settings_live::alive_stream`), `unread` (the inbox count) and `activity` (the viewer's live
8+//! strip and ring). An anonymous visitor gets the alive part only. Each part keeps its own
9+//! fingerprint, so an event is sent only when that part changed. The old routes stay registered
10+//! for tabs opened before a deploy.
1111
1212 use futures_util::StreamExt;
1313 use futures_util::stream::{self, BoxStream};
@@ -20,7 +20,6 @@ use topcoat::router::route;
2020 use crate::auth::current_user;
2121 use crate::pages::activity::activity_changes;
2222 use crate::pages::ci_runs::events_response;
23-use crate::pages::dashboard::side_changes;
2423 use crate::pages::notifications::unread_changes;
2524 use crate::pages::settings_live::alive_stream;
2625 use crate::state::AppState;
@@ -42,7 +41,6 @@ async fn shell_events(cx: &Cx) -> Result<Response> {
4241 if let Some((user, _)) = viewer {
4342 parts.push(unread_changes(&state, &user.id).await?.boxed());
4443 parts.push(activity_changes(state.clone(), user.clone(), "activity").boxed());
45- parts.push(side_changes(&state, &user, "side").await?.boxed());
4644 }
4745 events_response(cx, stream::select_all(parts))
4846 }
crates/forge-web/src/pages/snippets.rsmodified+35 -22
@@ -194,8 +194,8 @@ struct RevisionView {
194194 file_names: String,
195195 }
196196
197-/// One row of the list page.
198-struct ListRow {
197+/// One row of the list page and of a profile's Snippets tab.
198+pub(crate) struct ListRow {
199199 id: String,
200200 title: String,
201201 owner: String,
@@ -205,6 +205,18 @@ struct ListRow {
205205 updated_at: String,
206206 }
207207
208+/// The list row for a snippet summary, with its strings ready for the view.
209+pub(crate) fn list_row(lang: Lang, summary: SnippetSummary) -> ListRow {
210+ ListRow {
211+ id: summary.id,
212+ title: summary.title,
213+ owner: summary.owner_name,
214+ visibility: visibility_label(lang, summary.visibility),
215+ files: g::files_count(lang, summary.file_count),
216+ updated_at: summary.updated_at,
217+ }
218+}
219+
208220 fn visibility_label(lang: Lang, visibility: SnippetVisibility) -> &'static str {
209221 match visibility {
210222 SnippetVisibility::Public => g::t(lang, K::VisibilityPublic),
@@ -260,6 +272,25 @@ async fn owned(cx: &Cx, user: &User, snippet_id: &str) -> Result<Snippet> {
260272 }
261273 }
262274
275+/// The snippet rows, one linked line each: title, owner, visibility, file count and update time.
276+#[component]
277+pub(crate) async fn snippet_rows(lang: Lang, rows: Vec<ListRow>) -> Result<impl View> {
278+ Ok(view! {
279+ <ul class="item-list snippet-list">
280+ for row in rows.into_iter() {
281+ <li class="item">
282+ <div class="item-main">
283+ <a href=(format!("/snippets/{}", row.id))><strong>(row.title)</strong></a>
284+ <span class="muted small">
285+ (row.owner) " · " (row.visibility) " · " (row.files) " · " (g::updated_before(lang)) rel_time(lang: lang, stamp: row.updated_at.as_str()) (g::updated_after(lang))
286+ </span>
287+ </div>
288+ </li>
289+ }
290+ </ul>
291+ })
292+}
293+
263294 #[component]
264295 async fn snippet_list_body(
265296 lang: Lang,
@@ -282,18 +313,7 @@ async fn snippet_list_body(
282313 }
283314 )
284315 } else {
285- <ul class="item-list snippet-list">
286- for row in rows.into_iter() {
287- <li class="item">
288- <div class="item-main">
289- <a href=(format!("/snippets/{}", row.id))><strong>(row.title)</strong></a>
290- <span class="muted small">
291- (row.owner) " · " (row.visibility) " · " (row.files) " · " (g::updated_before(lang)) rel_time(lang: lang, stamp: row.updated_at.as_str()) (g::updated_after(lang))
292- </span>
293- </div>
294- </li>
295- }
296- </ul>
316+ snippet_rows(lang: lang, rows: rows)
297317 }
298318 </section>
299319 })
@@ -571,14 +591,7 @@ async fn snippets_list(cx: &Cx) -> Result<impl View> {
571591 .await?;
572592 let rows: Vec<ListRow> = summaries
573593 .into_iter()
574- .map(|s| ListRow {
575- id: s.id,
576- title: s.title,
577- owner: s.owner_name,
578- visibility: visibility_label(lang, s.visibility),
579- files: g::files_count(lang, s.file_count),
580- updated_at: s.updated_at,
581- })
594+ .map(|s| list_row(lang, s))
582595 .collect();
583596 let signed_in = viewer.is_some();
584597 let title = g::t(lang, K::Snippets);
crates/forge-web/src/pages/user_prefs.rsadded+158 -0
@@ -0,0 +1,158 @@
1+//! Route: `POST /-/prefs`, a signed-in user's account preferences: the tree width of a repo home,
2+//! the profile corner's position and the diff view. The values live in the `user_prefs` table
3+//! (store/user_prefs.rs). Only the keys below are accepted; each has its own check. An empty value
4+//! deletes the key. Signed-out callers get what `require_csrf` gives.
5+
6+use http::StatusCode;
7+use serde::Deserialize;
8+use topcoat::Result;
9+use topcoat::context::{Cx, app_context};
10+use topcoat::router::content::Form;
11+use topcoat::router::error::bad_request;
12+use topcoat::router::response::Response;
13+use topcoat::router::{Body, route};
14+
15+use crate::auth::require_csrf;
16+use crate::state::AppState;
17+
18+/// Key of the repo home's file tree width, in CSS pixels.
19+pub const TREE_WIDTH: &str = "tree_width";
20+/// Key of the profile corner's position: `x,y` as fractions of the free space, each 0 to 1.
21+pub const CORNER_POS: &str = "corner_pos";
22+/// Key of the diff view: `split` or `unified`.
23+pub const DIFF_VIEW: &str = "diff_view";
24+
25+const MIN_TREE_WIDTH: u32 = 120;
26+const MAX_TREE_WIDTH: u32 = 4000;
27+
28+#[derive(Deserialize)]
29+struct PrefForm {
30+ #[serde(default)]
31+ csrf: String,
32+ #[serde(default)]
33+ key: String,
34+ #[serde(default)]
35+ value: String,
36+}
37+
38+/// Checks one preference. `Ok(None)` means the empty value that deletes the key, `Ok(Some(v))` is
39+/// the value to store (normalised), and `Err` is the reason a 400 gives.
40+pub fn clean_pref(key: &str, value: &str) -> std::result::Result<Option<String>, &'static str> {
41+ match key {
42+ TREE_WIDTH => {
43+ if value.is_empty() {
44+ return Ok(None);
45+ }
46+ let width = value
47+ .bytes()
48+ .all(|b| b.is_ascii_digit())
49+ .then(|| value.parse::<u32>().ok())
50+ .flatten()
51+ .filter(|w| (MIN_TREE_WIDTH..=MAX_TREE_WIDTH).contains(w));
52+ width
53+ .map(|w| Some(w.to_string()))
54+ .ok_or("tree_width must be a whole number from 120 to 4000")
55+ }
56+ CORNER_POS => {
57+ if value.is_empty() {
58+ return Ok(None);
59+ }
60+ let fraction = |s: &str| {
61+ s.parse::<f64>()
62+ .ok()
63+ .filter(|v| v.is_finite() && (0.0..=1.0).contains(v))
64+ };
65+ match value.split_once(',') {
66+ Some((x, y)) => match (fraction(x), fraction(y)) {
67+ (Some(x), Some(y)) => Ok(Some(format!("{x},{y}"))),
68+ _ => Err("corner_pos must be two numbers from 0 to 1 written x,y"),
69+ },
70+ None => Err("corner_pos must be two numbers from 0 to 1 written x,y"),
71+ }
72+ }
73+ DIFF_VIEW => match value {
74+ "" => Ok(None),
75+ "split" | "unified" => Ok(Some(value.to_owned())),
76+ _ => Err("diff_view must be split or unified"),
77+ },
78+ _ => Err("unknown preference"),
79+ }
80+}
81+
82+#[route(POST "/-/prefs")]
83+async fn set_pref(cx: &Cx, Form(form): Form<PrefForm>) -> Result<Response> {
84+ let (user, _) = require_csrf(cx, &form.csrf).await?;
85+ let store = &app_context::<AppState>(cx).store;
86+ match clean_pref(&form.key, &form.value) {
87+ Err(message) => return Err(bad_request(message).into()),
88+ Ok(None) => store.delete_user_pref(&user.id, &form.key).await?,
89+ Ok(Some(value)) => store.set_user_pref(&user.id, &form.key, &value).await?,
90+ }
91+ let mut res = Response::new(Body::empty());
92+ *res.status_mut() = StatusCode::NO_CONTENT;
93+ Ok(res)
94+}
95+
96+#[cfg(test)]
97+mod tests {
98+ use super::*;
99+ use topcoat::router::request::Request;
100+ use topcoat::router::to_bytes;
101+
102+ use crate::auth::SESSION_COOKIE;
103+ use crate::test_support::{app_router, create_session, test_state};
104+
105+ #[tokio::test]
106+ async fn prefs_route_refuses_unknown_keys_and_stores_a_corner_position() {
107+ let dir = tempfile::tempdir().expect("tempdir");
108+ let state = test_state(dir.path()).await;
109+ let user = state
110+ .store
111+ .create_user("tahinli", None, "unused", false)
112+ .await
113+ .expect("user");
114+ create_session(&state.store, &user.id, "prefs-session", "prefs-csrf").await;
115+ let router = app_router(state.clone());
116+ let cookie = format!("__Host-{SESSION_COOKIE}=prefs-session");
117+ let post = |form: &'static str| {
118+ Request::builder()
119+ .method("POST")
120+ .uri("/-/prefs")
121+ .header("cookie", cookie.as_str())
122+ .header("content-type", "application/x-www-form-urlencoded")
123+ .body(Body::from(form))
124+ .unwrap()
125+ };
126+
127+ let unknown = router
128+ .handle(post("csrf=prefs-csrf&key=nope&value=1"))
129+ .await;
130+ assert_eq!(unknown.status().as_u16(), 400, "unknown key");
131+ let _ = to_bytes(unknown.into_body(), usize::MAX).await.unwrap();
132+
133+ let stored = router
134+ .handle(post("csrf=prefs-csrf&key=corner_pos&value=0.5%2C0.25"))
135+ .await;
136+ assert_eq!(stored.status().as_u16(), 204, "corner position saved");
137+ let _ = to_bytes(stored.into_body(), usize::MAX).await.unwrap();
138+ let prefs = state.store.user_prefs(&user.id).await.unwrap();
139+ assert_eq!(prefs.get(CORNER_POS).map(String::as_str), Some("0.5,0.25"));
140+
141+ let page = router
142+ .handle(
143+ Request::builder()
144+ .method("GET")
145+ .uri("/tahinli")
146+ .header("cookie", cookie.as_str())
147+ .body(Body::empty())
148+ .unwrap(),
149+ )
150+ .await;
151+ assert_eq!(page.status().as_u16(), 200);
152+ let bytes = to_bytes(page.into_body(), usize::MAX).await.unwrap();
153+ assert!(
154+ String::from_utf8_lossy(&bytes).contains("data-corner-pos=\"0.5,0.25\""),
155+ "the page carries the stored corner"
156+ );
157+ }
158+}
crates/forge-web/src/post_update.rsmodified+2 -2
@@ -50,13 +50,13 @@ pub async fn after_ref_update(
5050 state
5151 .live
5252 .bump(&crate::live::Topic::RepoRefs(repo.id.clone()));
53- // The pusher's contribution calendar (dashboard and profile) counts the push.
53+ // The pusher's contribution calendar on their profile counts the push.
5454 if !actor_id.is_empty() {
5555 state
5656 .live
5757 .bump(&crate::live::Topic::User(actor_id.to_owned()));
5858 }
59- // The owner's sidebar lists its repos by last update, so a push by someone else moves it too.
59+ // The owner's repo listing sorts by last update, so a push by someone else moves it too.
6060 if repo.owner_id != actor_id {
6161 state
6262 .live
crates/forge-web/src/test_support.rsmodified+2 -1
@@ -18,7 +18,7 @@ use topcoat::router::tower::TowerLayer;
1818 use topcoat::router::{Compression, Router, RouterBuilderDiscoverExt};
1919
2020 use crate::pages::repo_ctx::RepoMovedLayer;
21-use crate::pages::settings_profile::avatar_body_limit;
21+use crate::pages::settings_profile::{avatar_body_limit, org_avatar_body_limit};
2222 use crate::state::AppState;
2323 use crate::throttle::Throttle;
2424
@@ -109,6 +109,7 @@ pub fn app_router(state: AppState) -> Router {
109109 .layer(crate::pages::settings_live::AccountWriteLayer)
110110 .cookies()
111111 .layer(avatar_body_limit())
112+ .layer(org_avatar_body_limit())
112113 .layer(RepoMovedLayer)
113114 .layer(crate::pages::repo_settings_live::RepoSettingsWriteLayer)
114115 .layer(crate::pages::pull_live::PullWriteLayer)
crates/forge-web/src/views/diff.rsmodified+45 -21
@@ -13,16 +13,19 @@ use std::collections::HashMap;
1313 use forge_core::{Side, Thread};
1414 use forge_git::history::{CommitDiff, DiffLimits, DiffStatus, FileDiff, LineKind};
1515 use topcoat::Result;
16-use topcoat::context::Cx;
16+use topcoat::context::{Cx, app_context};
1717 use topcoat::cookie::{Cookie, Cookies, SameSite, cookies, time};
1818 use topcoat::router::request::uri;
1919 use topcoat::view::{View, component, view};
2020
21+use crate::auth::current_user;
2122 use crate::i18n::Lang;
2223 use crate::i18n::browse as b;
2324 use crate::i18n::code::{self as g, K};
2425 use crate::i18n::pulls_review::{self as pr_g, K as PrK};
2526 use crate::pages::commits::url_path;
27+use crate::pages::user_prefs::DIFF_VIEW;
28+use crate::state::AppState;
2629 use crate::views::review_thread::{ThreadCtx, review_thread_in};
2730
2831 /// Per-diff limits used by the commit and pull-request pages.
@@ -85,9 +88,11 @@ pub struct DiffOpts {
8588 }
8689
8790 impl DiffOpts {
88- /// Reads the request: `?view=split|unified` wins and is remembered in a cookie, else the
89- /// cookie decides; `?w=1` ignores whitespace. `downloads` are the patch and diff links.
90- pub fn from_cx(cx: &Cx, downloads: Option<(String, String)>) -> Self {
91+ /// Reads the request: `?w=1` ignores whitespace. The unified or split view comes from
92+ /// `?view=split|unified`, which wins and is remembered: in the account's `diff_view`
93+ /// preference when signed in, else in a cookie. Without `?view=` the remembered choice
94+ /// decides. `downloads` are the patch and diff links.
95+ pub async fn from_cx(cx: &Cx, downloads: Option<(String, String)>) -> Result<Self> {
9196 let request = uri(cx);
9297 let mut view_param = None;
9398 let mut ignore_ws = false;
@@ -102,31 +107,50 @@ impl DiffOpts {
102107 }
103108 }
104109 }
105- let split = match view_param.as_deref() {
106- Some(v @ ("split" | "unified")) => {
107- let max_age = time::Duration::seconds(365 * 24 * 60 * 60);
108- cookies(cx).add(
109- Cookie::build((DIFF_VIEW_COOKIE, v.to_owned()))
110- .path("/")
111- .secure(true)
112- .same_site(SameSite::Lax)
113- .max_age(max_age)
114- .build(),
115- );
116- v == "split"
110+ let split = match current_user(cx).await? {
111+ Some((user, _)) => {
112+ let state = app_context::<AppState>(cx);
113+ let stored = state
114+ .store
115+ .user_prefs(&user.id)
116+ .await?
117+ .remove(DIFF_VIEW);
118+ match view_param.as_deref() {
119+ Some(v @ ("split" | "unified")) => {
120+ if stored.as_deref() != Some(v) {
121+ state.store.set_user_pref(&user.id, DIFF_VIEW, v).await?;
122+ }
123+ v == "split"
124+ }
125+ _ => stored.as_deref() == Some("split"),
126+ }
117127 }
118- _ => cookies(cx)
119- .get(DIFF_VIEW_COOKIE)
120- .is_some_and(|c| c.value() == "split"),
128+ None => match view_param.as_deref() {
129+ Some(v @ ("split" | "unified")) => {
130+ let max_age = time::Duration::seconds(365 * 24 * 60 * 60);
131+ cookies(cx).add(
132+ Cookie::build((DIFF_VIEW_COOKIE, v.to_owned()))
133+ .path("/")
134+ .secure(true)
135+ .same_site(SameSite::Lax)
136+ .max_age(max_age)
137+ .build(),
138+ );
139+ v == "split"
140+ }
141+ _ => cookies(cx)
142+ .get(DIFF_VIEW_COOKIE)
143+ .is_some_and(|c| c.value() == "split"),
144+ },
121145 };
122- Self {
146+ Ok(Self {
123147 enabled: true,
124148 split,
125149 ignore_ws,
126150 path: request.path().to_owned(),
127151 query,
128152 downloads,
129- }
153+ })
130154 }
131155
132156 /// The page URL for the given view and whitespace setting.
crates/forge-web/src/views/heatmap.rsmodified+10 -8
@@ -1,4 +1,4 @@
1-//! Dashboard contribution calendar: the last 53 weeks of daily contribution counts, one column per
1+//! Contribution calendar: the last 53 weeks of daily contribution counts, one column per
22 //! week (Monday first), with the four summary stats, month labels and the motivating line.
33 //!
44 //! `build` is pure date and streak maths over the counts from the store. `contribution_calendar`
@@ -209,14 +209,15 @@ struct DayView {
209209 }
210210
211211 /// The link for a calendar day: the day's contributions below the calendar, or back to the
212-/// plain calendar when the day is the selected one. The anchor brings a full page load back to the
213-/// calendar; nav.js swaps in place and keeps the scroll (`data-keep-scroll`), so it is not used there.
214-fn day_href(date: (i64, i64, i64), selected: bool) -> String {
212+/// plain calendar when the day is the selected one. `base` is the page the calendar sits on. The
213+/// anchor brings a full page load back to the calendar; nav.js swaps in place and keeps the scroll
214+/// (`data-keep-scroll`), so it is not used there.
215+fn day_href(base: &str, date: (i64, i64, i64), selected: bool) -> String {
215216 if selected {
216- "/#contributions-h".to_owned()
217+ format!("{base}#contributions-h")
217218 } else {
218219 format!(
219- "/?day={:04}-{:02}-{:02}#contributions-h",
220+ "{base}?day={:04}-{:02}-{:02}#contributions-h",
220221 date.0, date.1, date.2
221222 )
222223 }
@@ -335,12 +336,13 @@ fn day_entries(lang: Lang, items: &[ContributionItem], now: i64) -> Vec<DayEntry
335336
336337 /// The contribution card: heading and date range, the four stats, the month labels and the
337338 /// 53-week grid, then the motivating line and the Less/More legend, then the selected day's
338-/// contributions when a day is picked.
339+/// contributions when a day is picked. `base` is the URL the day links point at.
339340 #[component]
340341 pub async fn contribution_calendar(
341342 calendar: Calendar,
342343 selected: Option<DayDetail>,
343344 lang: Lang,
345+ base: String,
344346 ) -> Result<impl View> {
345347 let range = {
346348 let from = g::date_text(
@@ -400,7 +402,7 @@ pub async fn contribution_calendar(
400402 } else {
401403 level.to_owned()
402404 },
403- href: Some(day_href(day.date, picked)),
405+ href: Some(day_href(&base, day.date, picked)),
404406 title: g::contributions_on(
405407 lang,
406408 day.count,
crates/forge-web/src/views/mod.rsmodified+74 -200
@@ -10,8 +10,6 @@ pub mod review_thread;
1010 use std::sync::OnceLock;
1111
1212 use forge_core::ci::RunState;
13-use forge_core::store::RepoSort;
14-use forge_core::store::repo_listing::RepoScope;
1513 use forge_core::store::shell_activity::{ActorRun, ActorRuns, InboxKinds};
1614 use forge_core::{Error as CoreError, Session, User};
1715 use hex::encode;
@@ -30,13 +28,13 @@ use topcoat::view::{Child, Unescaped, View, ViewExt, component, view};
3028 use crate::i18n::admin::{self as ad, K as AK};
3129 use crate::i18n::browse as br;
3230 use crate::i18n::code::{self as g, K};
33-use crate::i18n::community::{self as cm, K as CK};
3431 use crate::i18n::link::{self as lk, K as LinkKey};
3532 use crate::i18n::migrate::{self as mg, K as MGK};
3633 use crate::i18n::misc::{self as mi, K as MK};
3734 use crate::i18n::orgs::{self as o, K as OK};
3835 use crate::i18n::{self, Key, Lang, t};
3936 use crate::pages::assets::highlight_css_text;
37+use crate::pages::user_prefs::{CORNER_POS, TREE_WIDTH, clean_pref};
4038 use crate::state::AppState;
4139
4240 /// Stylesheet URL. The version is a hash of the compiled CSS (build.rs), so a changed stylesheet
@@ -95,38 +93,6 @@ fn csp_header(base_url: &str) -> HeaderValue {
9593 HeaderValue::from_str(&policy).unwrap_or_else(|_| HeaderValue::from_static(CSP))
9694 }
9795
98-/// How many repos the signed-in sidebar lists, freshest first. The sidebar's change stream reads it too.
99-pub(crate) const SIDE_REPOS: u64 = 5;
100-
101-/// A repo link in the signed-in sidebar.
102-#[derive(Clone)]
103-struct SideRepo {
104- name: String,
105- href: String,
106-}
107-
108-/// The global nav item for a request path: `dashboard` for `/`, `new-org` for `/org/new`, otherwise
109-/// the first segment when it is a global page. Empty for repo pages and everything else.
110-fn nav_key(path: &str) -> &'static str {
111- if path.trim_matches('/') == "org/new" {
112- return "new-org";
113- }
114- match path.trim_matches('/').split('/').next().unwrap_or("") {
115- "" => "dashboard",
116- "explore" => "explore",
117- "notifications" => "notifications",
118- "snippets" => "snippets",
119- "new" => "new",
120- "settings" => "settings",
121- _ => "",
122- }
123-}
124-
125-/// CSS class of a sidebar link.
126-fn side_class(on: bool) -> &'static str {
127- if on { "side-link on" } else { "side-link" }
128-}
129-
13096 /// First path segments that are pages of their own, not owners. A `-` prefix is the same.
13197 const TOP_LEVEL_PAGES: &[&str] = &[
13298 "explore",
@@ -304,8 +270,8 @@ fn no_runs() -> ActorRuns {
304270 }
305271 }
306272
307-/// What the profile corner shows: the viewer, their inbox counts with where each leads, and whether
308-/// any of their runs is going (the ring glows).
273+/// What the profile corner shows: the viewer, their unread notification count, their inbox counts
274+/// with where each leads, and whether any of their runs is going (the ring glows).
309275 #[derive(Clone)]
310276 struct ProfileCorner {
311277 username: String,
@@ -316,6 +282,8 @@ struct ProfileCorner {
316282 back: String,
317283 is_admin: bool,
318284 theme: String,
285+ /// Unread notifications, shown as a count on the bell.
286+ unread: u64,
319287 reviews: u64,
320288 mentions: u64,
321289 failing: u64,
@@ -325,9 +293,9 @@ struct ProfileCorner {
325293 failing_href: String,
326294 }
327295
328-/// The account corner at the foot of the signed-in sidebar and in the phone menu. It opens upward:
329-/// the avatar, the chips, what waits on the viewer, the notifications link, the theme choice,
330-/// and the profile, settings, admin and log out links.
296+/// The floating account panel fixed at the bottom left of the window (signed in only). It opens
297+/// upward: the avatar, the chips, the notifications bell with its unread count and popover, then
298+/// the Explore, profile, settings, admin and log out links and the theme choice.
331299 #[component]
332300 async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> {
333301 let review_chip = (corner.reviews > 0).then(|| {
@@ -383,6 +351,7 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View>
383351 </span>
384352 </summary>
385353 <div class="corner-menu">
354+ <a class="corner-link" href="/explore">(t(lang, Key::Explore))</a>
386355 <div class="corner-theme"><span>(theme_label)</span>
387356 <form method="post" action="/-/theme" class="corner-theme-set" data-no-tick="true">
388357 <input type="hidden" name="csrf" value=(corner.csrf.as_str())>
@@ -409,7 +378,11 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View>
409378 </form>
410379 </div>
411380 </details>
412- <a class="corner-bell" href="/notifications" title=(bell_label) aria-label=(bell_label) aria-expanded="false"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg></a>
381+ <a class="corner-bell" href="/notifications" title=(bell_label) aria-label=(bell_label) aria-expanded="false"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg>
382+ if corner.unread > 0 {
383+ <span class="bell-count">(corner.unread.to_string())</span>
384+ }
385+ </a>
413386 <div class="bell-pop" popover="auto" role="dialog" aria-label=(bell_title) data-loading=(loading_label) data-error=(error_label)>
414387 <div class="bell-box">
415388 <div class="bell-head">
@@ -427,11 +400,11 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View>
427400 })
428401 }
429402
430-/// Page shell: sticky top bar (logo, path bar and, signed in, the live strip), the signed-in
431-/// sidebar with its profile corner, and `child` as the page content. `viewer` drives the chrome:
432-/// the sidebar, the live strip and the profile corner when signed in; search, theme, Explore and
433-/// Log in otherwise. `extra_stylesheet` adds one more stylesheet link to the head (such as a
434-/// repo's generated label colors).
403+/// Page shell: sticky top bar (logo, path bar and, signed in, the live strip), the section sidebar
404+/// on section pages, `child` as the page content, and for signed-in viewers the floating profile
405+/// corner fixed at the bottom left. `viewer` drives the chrome: the live strip and the profile
406+/// corner when signed in; search, theme, Explore and Log in otherwise. `extra_stylesheet` adds one
407+/// more stylesheet link to the head (such as a repo's generated label colors).
435408 #[component]
436409 pub async fn shell(
437410 title: &str,
@@ -440,59 +413,20 @@ pub async fn shell(
440413 #[default] child: Child<'_>,
441414 ) -> Result<impl View> {
442415 let full_title = format!("{title} \u{b7} forge");
443- // The unread count, the viewer's freshest repos for the sidebar (with the total), the profile
444- // corner's inbox counts, their CI runs and the items waiting on them. Signed-in only.
445- let (unread, (listed, _), inbox, runs, waiting) = match viewer {
416+ // The unread count, the profile corner's inbox counts, their CI runs and the items waiting on
417+ // them. Signed-in only.
418+ let (unread, inbox, runs, waiting) = match viewer {
446419 Some((user, _)) => match try_app_context::<AppState>(__cx) {
447420 Some(state) => (
448421 state.store.unread_count(&user.id).await?,
449- state
450- .store
451- .list_visible_repos(
452- RepoScope::OwnedBy(&user.id),
453- Some(user),
454- None,
455- RepoSort::RecentlyUpdated,
456- 1,
457- SIDE_REPOS,
458- )
459- .await?,
460422 state.store.inbox_kind_counts(&user.id).await?,
461423 state.store.actor_runs(&user.id, 120).await?,
462424 state.store.waiting_on(&user.id, 5).await?,
463425 ),
464- None => (0, (Vec::new(), 0), InboxKinds::default(), no_runs(), Vec::new()),
426+ None => (0, InboxKinds::default(), no_runs(), Vec::new()),
465427 },
466- None => (0, (Vec::new(), 0), InboxKinds::default(), no_runs(), Vec::new()),
467- };
468- // The sidebar offers New organization only to those the instance's policy lets create one.
469- let can_create_org = match (viewer, try_app_context::<AppState>(__cx)) {
470- (Some((user, _)), Some(state)) => crate::pages::org_new::may_create_org(state, user),
471- _ => false,
428+ None => (0, InboxKinds::default(), no_runs(), Vec::new()),
472429 };
473- let unread_badge = (unread > 0).then(|| unread.to_string());
474- let side_repos: Vec<SideRepo> = listed
475- .iter()
476- .map(|(repo, _, _)| SideRepo {
477- name: repo.name.clone(),
478- href: repo_href(&repo.owner_name, &repo.name, "", ""),
479- })
480- .collect();
481- // The viewer's own profile Repositories tab has its own sidebar key, so the pinned link lights up there.
482- let own_repos_tab = viewer.is_some_and(|(user, _)| {
483- uri(__cx).path().trim_matches('/') == user.username
484- && uri(__cx)
485- .query()
486- .is_some_and(|q| q.split('&').any(|p| p == "tab=repositories"))
487- });
488- let current = if own_repos_tab {
489- "repositories"
490- } else {
491- nav_key(uri(__cx).path())
492- };
493- let profile_repos_href = viewer
494- .map(|(user, _)| format!("/{}?tab=repositories", enc(&user.username)))
495- .unwrap_or_default();
496430 let signed_in = viewer.is_some();
497431 // Both kinds of visitor post to `/-/theme`. Signed-in users send their CSRF token and get the
498432 // stored preference saved. Anonymous visitors get the cookie. Either way the browser comes
@@ -500,7 +434,21 @@ pub async fn shell(
500434 let theme_csrf = viewer.map(|(_, session)| session.csrf_token.clone());
501435 let back = uri(__cx).path_and_query().map(|p| p.as_str().to_owned());
502436 let lang = i18n::lang(__cx, viewer.map(|(user, _)| user));
503- let banner = crate::pages::banner::current(__cx);
437+ // A signed-in viewer's account preferences, read once for the banner, the tree width and the
438+ // profile corner. Signed-out visitors keep theirs in the browser.
439+ let prefs = match (viewer, try_app_context::<AppState>(__cx)) {
440+ (Some((user, _)), Some(state)) => Some(state.store.user_prefs(&user.id).await?),
441+ _ => None,
442+ };
443+ let banner = crate::pages::banner::current(__cx, prefs.as_ref());
444+ let tree_w = prefs
445+ .as_ref()
446+ .and_then(|p| p.get(TREE_WIDTH))
447+ .and_then(|v| clean_pref(TREE_WIDTH, v).ok().flatten());
448+ let corner_pos = prefs
449+ .as_ref()
450+ .and_then(|p| p.get(CORNER_POS))
451+ .and_then(|v| clean_pref(CORNER_POS, v).ok().flatten());
504452 let banner_back = back.clone().unwrap_or_else(|| "/".to_owned());
505453 let dismiss_label = crate::i18n::accounts::t(lang, crate::i18n::accounts::A::Dismiss);
506454 // The admin area and the user settings swap the global links for their own list. Signed-in only.
@@ -591,10 +539,6 @@ pub async fn shell(
591539 let search_label = o::t(lang, OK::SearchPublicRepos);
592540 let palette_label = br::t(lang, br::K::PaletteOpen).to_owned();
593541 let menu_label = t(lang, Key::SiteMenu);
594- let toggle_class = if unread > 0 { "icon-btn has-dot" } else { "icon-btn" };
595- let side_repos_menu = side_repos.clone();
596- let unread_menu = unread_badge.clone();
597- let unread_aside = unread_badge.clone();
598542 // The path bar: one segment per part of the request path, the last one unlinked.
599543 let segments = path_segments(uri(__cx).path(), title);
600544 let path_attr = segments
@@ -619,8 +563,7 @@ pub async fn shell(
619563 let cancelled_tpl = count_template(&mi::cancelled_count(lang, 2), 2);
620564 let runs_label = mi::t(lang, MK::YourCiRuns);
621565 let search_for_label = mi::t(lang, MK::SearchPublicReposFor);
622- // The profile corner, the signed-in sidebar's account menu. The sidebar and the phone menu
623- // each get their own copy.
566+ // The profile corner, the signed-in account panel.
624567 // Each chip leads to the newest thing it counts; a review or mention past the five newest
625568 // waiting items falls back to the inbox.
626569 let newest_waiting = |review: bool| {
@@ -643,6 +586,8 @@ pub async fn shell(
643586 || "/notifications".to_owned(),
644587 |(owner, repo, number)| repo_href(owner, repo, "ci", &format!("runs/{number}")),
645588 );
589+ // The corner's drag saves its position with this token, the same one the page's forms send.
590+ let prefs_csrf = viewer.map(|(_, session)| session.csrf_token.clone()).unwrap_or_default();
646591 let corner = viewer.map(|(user, session)| ProfileCorner {
647592 username: user.username.clone(),
648593 name: user
@@ -657,6 +602,7 @@ pub async fn shell(
657602 back: back.clone().unwrap_or_else(|| "/".to_owned()),
658603 is_admin: user.is_admin,
659604 theme: theme_pref.to_owned(),
605+ unread,
660606 reviews: inbox.reviews,
661607 mentions: inbox.mentions,
662608 failing: runs.failing,
@@ -664,8 +610,6 @@ pub async fn shell(
664610 mention_href,
665611 failing_href,
666612 });
667- let corner_panel = corner.clone();
668- let corner_aside = corner;
669613 Ok(view! {
670614 <!DOCTYPE html>
671615 <html lang=(lang.code()) data-theme=(theme_attr) data-accent-light=(accent_light_id) data-accent-dark=(accent_dark_id) data-base-light=(base_light_id) data-base-dark=(base_dark_id) data-sidebar=(sidebar_side) data-rel-words=(rel_words_attr.as_str()) data-rel-now=(rel_now_attr.as_str())>
@@ -689,22 +633,15 @@ pub async fn shell(
689633 }
690634 <script src=(NAV_SCRIPT_HREF) defer="defer"></script>
691635 </head>
692- <body data-link-restarting=(lk::t(lang, LinkKey::Restarting)) data-link-back=(lk::t(lang, LinkKey::BackSubmit)) data-done-saved=(lk::t(lang, LinkKey::Saved)) data-done-ok=(lk::t(lang, LinkKey::Done)) data-draft-restored=(lk::t(lang, LinkKey::DraftRestored)) data-draft-discard=(lk::t(lang, LinkKey::DraftDiscard)) data-select-filter=(lk::t(lang, LinkKey::SelectFilter)) data-select-none=(lk::t(lang, LinkKey::SelectNone))>
636+ <body data-link-restarting=(lk::t(lang, LinkKey::Restarting)) data-link-back=(lk::t(lang, LinkKey::BackSubmit)) data-done-saved=(lk::t(lang, LinkKey::Saved)) data-done-ok=(lk::t(lang, LinkKey::Done)) data-draft-restored=(lk::t(lang, LinkKey::DraftRestored)) data-draft-discard=(lk::t(lang, LinkKey::DraftDiscard)) data-select-filter=(lk::t(lang, LinkKey::SelectFilter)) data-select-none=(lk::t(lang, LinkKey::SelectNone)) data-signed-in=(signed_in.then(|| "true".to_owned())) data-tree-w=(tree_w) data-corner-pos=(corner_pos)>
693637 <header class="topbar">
694- if signed_in {
638+ if let Some(section) = section_menu {
695639 <details class="nav-toggle">
696- <summary class=(toggle_class) aria-label=(menu_label) title=(menu_label)>
640+ <summary class="icon-btn" aria-label=(menu_label) title=(menu_label)>
697641 <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16"/></svg>
698642 </summary>
699643 <div class="nav-panel">
700- if let Some(section) = section_menu {
701- section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live)
702- } else {
703- side_nav(lang: lang, current: current, profile_repos_href: profile_repos_href.as_str(), unread: unread_menu, repos: side_repos_menu, can_create_org: can_create_org)
704- }
705- if let Some(corner) = corner_panel {
706- profile_corner(lang: lang, corner: corner)
707- }
644+ section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live)
708645 </div>
709646 </details>
710647 }
@@ -801,16 +738,9 @@ pub async fn shell(
801738 </div>
802739 }
803740 <div class="shell">
804- if signed_in {
741+ if let Some(section) = section {
805742 <aside class="shell-sidebar">
806- if let Some(section) = section {
807- section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live)
808- } else {
809- side_nav(lang: lang, current: current, profile_repos_href: profile_repos_href.as_str(), unread: unread_aside, repos: side_repos, can_create_org: can_create_org)
810- }
811- if let Some(corner) = corner_aside {
812- profile_corner(lang: lang, corner: corner)
813- }
743+ section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live)
814744 </aside>
815745 }
816746 <div class="shell-body">
@@ -835,6 +765,11 @@ pub async fn shell(
835765 </footer>
836766 </div>
837767 </div>
768+ if let Some(corner) = corner {
769+ <div class="corner-float" data-prefs-csrf=(prefs_csrf.as_str())>
770+ profile_corner(lang: lang, corner: corner)
771+ </div>
772+ }
838773 </body>
839774 </html>
840775 }
@@ -842,82 +777,6 @@ pub async fn shell(
842777 .boxed())
843778 }
844779
845-/// The signed-in global links and the viewer's repos. The sidebar shows it, and so does the phone
846-/// menu. `current` is the key from `nav_key`; `profile_repos_href` is the viewer's own Repositories
847-/// tab; `unread` is the bell count shown next to Notifications.
848-#[component]
849-async fn side_nav(
850- lang: Lang,
851- current: &str,
852- profile_repos_href: &str,
853- unread: Option<String>,
854- repos: Vec<SideRepo>,
855- can_create_org: bool,
856-) -> Result<impl View> {
857- let dashboard = current == "dashboard";
858- let explore = current == "explore";
859- let repositories = current == "repositories";
860- let notifications = current == "notifications";
861- let snippets = current == "snippets";
862- let new_repo = current == "new";
863- let new_org = current == "new-org";
864- let settings = current == "settings";
865- let empty = repos.is_empty();
866- Ok(view! {
867- <nav class="side-links">
868- <a class=(side_class(dashboard)) href="/" aria-current=(dashboard.then_some("page"))>
869- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="3" width="7" height="9" rx="1.5"/><rect x="14" y="3" width="7" height="5" rx="1.5"/><rect x="14" y="12" width="7" height="9" rx="1.5"/><rect x="3" y="16" width="7" height="5" rx="1.5"/></svg>
870- (o::t(lang, OK::Dashboard))
871- </a>
872- <a class=(side_class(explore)) href="/explore" aria-current=(explore.then_some("page"))>
873- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5z"/></svg>
874- (t(lang, Key::Explore))
875- </a>
876- <a class=(side_class(repositories)) href=(profile_repos_href) aria-current=(repositories.then_some("page"))>
877- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 4.5A1.5 1.5 0 0 1 6.5 3H19v15H6.5A1.5 1.5 0 0 0 5 19.5z"/><path d="M5 19.5A1.5 1.5 0 0 0 6.5 21H19v-3"/></svg>
878- (o::t(lang, OK::Repositories))
879- </a>
880- <a class=(side_class(notifications)) href="/notifications" aria-current=(notifications.then_some("page"))>
881- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 7 3 9H3c0-2 3-2 3-9"/><path d="M10.3 21a1.9 1.9 0 0 0 3.4 0"/></svg>
882- (t(lang, Key::Notifications))
883- if let Some(count) = unread {
884- <span class="count">(count.as_str())</span>
885- }
886- </a>
887- <a class=(side_class(snippets)) href="/snippets" aria-current=(snippets.then_some("page"))>
888- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M7 3h7l5 5v13H7z"/><path d="M10 13h5M10 17h5"/></svg>
889- (cm::t(lang, CK::Snippets))
890- </a>
891- <a class=(side_class(new_repo)) href="/new" aria-current=(new_repo.then_some("page"))>
892- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 8v8M8 12h8"/></svg>
893- (t(lang, Key::NewRepository))
894- </a>
895- if can_create_org {
896- <a class=(side_class(new_org)) href="/org/new" aria-current=(new_org.then_some("page"))>
897- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 21V5l8-2v18"/><path d="M12 9l8 2v10"/><path d="M2 21h20"/><path d="M8 8v.01M8 12v.01M8 16v.01M16 14v.01M16 18v.01"/></svg>
898- (o::t(lang, OK::NewOrganization))
899- </a>
900- }
901- <a class=(side_class(settings)) href="/settings/profile" aria-current=(settings.then_some("page"))>
902- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3M5.3 5.3l2.1 2.1M16.6 16.6l2.1 2.1M5.3 18.7l2.1-2.1M16.6 7.4l2.1-2.1"/></svg>
903- (o::t(lang, OK::Settings))
904- </a>
905- </nav>
906- <div class="side-group" data-shell-live="side">
907- <h2 class="side-h">(o::t(lang, OK::RecentRepositories))</h2>
908- if empty {
909- <p class="side-empty">(o::t(lang, OK::NoReposYet))</p>
910- } else {
911- <nav class="side-repos">
912- for repo in repos.into_iter() {
913- <a href=(repo.href.as_str())>(repo.name.as_str())</a>
914- }
915- </nav>
916- }
917- </div>
918- })
919-}
920-
921780 /// One link of a section sidebar. `key` is the second path segment it answers to (`users` for
922781 /// `/admin/users`), so the current link follows from the URL alone.
923782 #[derive(Clone)]
@@ -996,7 +855,21 @@ fn org_items(lang: Lang, org: &str) -> Vec<NavItem> {
996855 label,
997856 icon,
998857 };
858+ // Overview and Repositories go to the organization's profile, not to a page under `/org`.
859+ let profile = user_href(org);
999860 vec![
861+ NavItem {
862+ key: "overview",
863+ href: profile.clone(),
864+ label: o::t(lang, OK::Overview),
865+ icon: "profile",
866+ },
867+ NavItem {
868+ key: "repositories",
869+ href: format!("{profile}?tab=repositories"),
870+ label: o::t(lang, OK::Repositories),
871+ icon: "teams",
872+ },
1000873 item("members", o::t(lang, OK::Members), "users"),
1001874 item("teams", o::t(lang, OK::Teams), "teams"),
1002875 item("settings", o::t(lang, OK::Settings), "appearance"),
@@ -1112,7 +985,7 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> {
1112985 })
1113986 }
1114987
1115-/// The section sidebar: a link back to the global navigation, then the section's own links with
988+/// The section sidebar: a link back to the site, then the section's own links with
1116989 /// `aria-current="page"` on the current one.
1117990 #[component]
1118991 async fn section_nav(
@@ -1123,11 +996,12 @@ async fn section_nav(
1123996 live: &str,
1124997 ) -> Result<impl View> {
1125998 let live = (!live.is_empty()).then_some(live);
1126- let links: Vec<(NavItem, bool)> = items
999+ let links: Vec<(NavItem, bool, &'static str)> = items
11271000 .into_iter()
11281001 .map(|item| {
11291002 let on = item.key == current;
1130- (item, on)
1003+ let class = if on { "side-link on" } else { "side-link" };
1004+ (item, on, class)
11311005 })
11321006 .collect();
11331007 Ok(view! {
@@ -1140,8 +1014,8 @@ async fn section_nav(
11401014 <div class="side-group">
11411015 <h2 class="side-h">(title)</h2>
11421016 <nav class="side-links" aria-label=(title) data-live=(live)>
1143- for (item, on) in links.into_iter() {
1144- <a class=(side_class(on)) href=(item.href) aria-current=(on.then_some("page"))>
1017+ for (item, on, class) in links.into_iter() {
1018+ <a class=(class) href=(item.href) aria-current=(on.then_some("page"))>
11451019 nav_icon(name: item.icon)
11461020 (item.label)
11471021 </a>
crates/forge-web/src/views/repo_list.rsmodified+8 -1
@@ -8,10 +8,17 @@ use topcoat::view::{View, component, view};
88
99 use crate::i18n::orgs::{self as g, K};
1010 use crate::i18n::{self, Lang};
11-use crate::pages::dashboard::badge_class;
1211 use crate::pages::issue_parts::When;
1312 use crate::views::repo_href;
1413
14+/// CSS class for a visibility badge.
15+pub fn badge_class(visibility: Visibility) -> &'static str {
16+ match visibility {
17+ Visibility::Public => "badge public",
18+ Visibility::Private => "badge private",
19+ }
20+}
21+
1522 /// One listed repo, formatted for display.
1623 pub struct RepoRow {
1724 href: String,
crates/forge-web/tests/e2e/browse_e2e.rsmodified+3 -11
@@ -943,13 +943,11 @@ async fn browsing_pages_stream_their_changes() {
943943 );
944944 let pushed = push_fixtures(&dir, &pub_url, &dir.join("pub-pages"));
945945
946- // The inbox, the dashboard and the header need a session. Without one they refuse, and no URL
947- // names another user's inbox: the viewer always comes from the session.
946+ // The inbox needs a session. Without one it refuses, and no URL names another user's inbox:
947+ // the viewer always comes from the session.
948948 for path in [
949949 "/notifications/events",
950950 "/notifications/events?all=1&user=tahinli",
951- "/dashboard/events",
952- "/-/side/events",
953951 ] {
954952 let anonymous = open_stream(&http, path, None).await;
955953 assert_eq!(anonymous.status().as_u16(), 401, "anonymous {path}");
@@ -974,19 +972,13 @@ async fn browsing_pages_stream_their_changes() {
974972 "the header shows the star"
975973 );
976974
977- // A push moves the pusher's calendar on the dashboard. The dashboard streams to its owner only.
978- let mut dashboard = open_stream(&http, "/dashboard/events", Some(tahinli.as_str())).await;
979- assert_eq!(dashboard.status().as_u16(), 200);
975+ // A second push moves main.
980976 let work = dir.join("pub-pages");
981977 // push_fixtures leaves the clone on feature/x, so the new commit must go on main.
982978 ok(&git(&work, &["checkout", "-q", "main"]), "checkout main");
983979 fs::write(work.join("PUSH.txt"), "pushed again\n").expect("write PUSH.txt");
984980 commit_all(&work, "a second push");
985981 ok(&git(&work, &["push", "-q", "origin", "main"]), "push main");
986- let pushed_event = next_chunk(&mut dashboard)
987- .await
988- .expect("event for the push");
989- assert!(pushed_event.contains("event: changed"), "{pushed_event}");
990982 assert_ne!(pushed, head_sha(&work), "the second push moved main");
991983
992984 // The explore listing streams to anyone, and a new public repo changes it.
crates/forge-web/tests/e2e/orgs_ui_e2e.rsmodified+5 -2
@@ -387,6 +387,7 @@ async fn org_settings_delete_and_audit_end_to_end() {
387387 settings,
388388 &[
389389 ("csrf", &csrf),
390+ ("display_name", "Acme Inc"),
390391 ("description", "Anvils and more"),
391392 ("default_repo_role", "write"),
392393 ("members_can_create", "on"),
@@ -398,6 +399,8 @@ async fn org_settings_delete_and_audit_end_to_end() {
398399 let shown = http.get(&notice_location(&res), Some(&tahinli)).await;
399400 assert!(shown.body.contains("Settings saved."), "saved notice");
400401 assert!(shown.body.contains("Anvils and more"), "description saved");
402+ let profile = http.get("/acme", Some(&tahinli)).await;
403+ assert!(profile.body.contains("Acme Inc"), "display name on the profile");
401404 assert_eq!(
402405 selected_value(&shown.body, "default_repo_role").as_deref(),
403406 Some("write"),
@@ -492,14 +495,14 @@ async fn org_creation_can_be_limited_to_admins() {
492495
493496 assert!(
494497 !http
495- .get("/", Some(&tahinli))
498+ .get("/tahinli?tab=organizations", Some(&tahinli))
496499 .await
497500 .body
498501 .contains("href=\"/org/new\""),
499502 "a person who may not create orgs sees no New organization link"
500503 );
501504 assert!(
502- http.get("/", Some(&root_session))
505+ http.get("/root?tab=organizations", Some(&root_session))
503506 .await
504507 .body
505508 .contains("href=\"/org/new\""),
crates/forge-web/tests/e2e/repo_settings_e2e.rsmodified+10 -10
@@ -217,8 +217,11 @@ async fn repo_settings_end_to_end() {
217217 )
218218 .await;
219219 assert_eq!(deleted.status, 303, "owner delete: {}", deleted.body);
220- assert_eq!(deleted.header(LOCATION).as_deref(), Some("/"));
221- let notice = cookie_named(&deleted, "forge_notice").expect("notice cookie");
220+ assert_eq!(deleted.header(LOCATION).as_deref(), Some("/bob?tab=repositories"));
221+ assert!(
222+ cookie_named(&deleted, "forge_notice").is_some(),
223+ "notice cookie"
224+ );
222225 assert_eq!(
223226 http.get("/bob/pub", Some(&bob)).await.status,
224227 404,
@@ -236,13 +239,10 @@ async fn repo_settings_end_to_end() {
236239 "trash entry is a bare repo"
237240 );
238241
239- // The next home page shows the notice once.
240- let home = http.get("/", Some(&format!("{bob}; {notice}"))).await;
241- assert!(home.body.contains("Repository"), "home page notice missing");
242- assert!(
243- home.body.contains("bob/pub"),
244- "home page notice names the repo"
245- );
242+ // The home page sends a signed-in viewer to their own profile.
243+ let home = http.get("/", Some(&bob)).await;
244+ assert_eq!(home.status, 303, "home page for a signed-in viewer");
245+ assert_eq!(home.header(LOCATION).as_deref(), Some("/bob"));
246246
247247 // An admin who does not own the repo can delete it.
248248 let admin_page = http.get("/bob/priv/settings", Some(&tahinli)).await;
@@ -338,7 +338,7 @@ async fn repo_settings_deletes_rows_when_repo_dir_is_missing() {
338338 "delete with missing dir: {}",
339339 deleted.body
340340 );
341- assert_eq!(deleted.header(LOCATION).as_deref(), Some("/"));
341+ assert_eq!(deleted.header(LOCATION).as_deref(), Some("/bob?tab=repositories"));
342342 assert_eq!(
343343 http.get("/bob/gone", Some(&bob)).await.status,
344344 404,
style/_dashboard.scssdeleted+0 -273
@@ -1,273 +0,0 @@
1-// dashboard: sage redesign of the signed-in home page (pages/dashboard.rs). Greeting, the
2-// contribution card (see _heatmap.scss), then two columns: repositories and the inbox rows that
3-// need the viewer. Stacks to one column below 1000px.
4-
5-.greet {
6- margin: 0;
7- font-size: 14px;
8- font-weight: 400;
9- color: var(--muted);
10-}
11-
12-.dash-cols {
13- display: grid;
14- grid-template-columns: minmax(0, 1fr);
15- gap: 36px;
16- margin-top: 44px;
17-
18- @media (min-width: 1000px) {
19- grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
20- gap: 40px;
21- }
22-}
23-
24-// Section heading with a bottom border, the count and an optional button on the right.
25-.sec-head {
26- display: flex;
27- flex-wrap: wrap;
28- align-items: center;
29- gap: 12px;
30- min-height: calc(var(--control-h) + 12px);
31- margin-bottom: 4px;
32- padding-bottom: 12px;
33- border-bottom: 1px solid var(--border);
34-
35- h2 {
36- margin: 0;
37- font-size: 15px;
38- font-weight: 600;
39- }
40-
41- .small {
42- margin-right: auto;
43- color: var(--muted);
44- }
45-}
46-
47-.dash-repos {
48- min-width: 0;
49-
50- .table {
51- min-width: 520px;
52- font-size: 14.5px;
53-
54- th {
55- padding: 12px 12px 10px 0;
56- border-bottom: 1px solid var(--border);
57- text-align: left;
58- font-size: 12.5px;
59- font-weight: 500;
60- color: var(--muted);
61- }
62-
63- td {
64- padding: 14px 12px 14px 0;
65- border-bottom: 1px solid var(--border);
66- vertical-align: middle;
67- }
68-
69- td .badge {
70- margin-left: 8px;
71- vertical-align: middle;
72- }
73- }
74-}
75-
76-// Phone width: the description column goes, so the name column fits without sideways scrolling.
77-@media (max-width: 639px) {
78- .dash-repos .table {
79- min-width: 0;
80- width: 100%;
81- }
82-
83- .dash-repos .dash-desc {
84- display: none;
85- }
86-}
87-
88-.dash-attention {
89- min-width: 0;
90-
91- .attn {
92- list-style: none;
93- margin: 14px 0 0;
94- padding: 0;
95- }
96-
97- .attn li {
98- display: flex;
99- flex-direction: column;
100- gap: 2px;
101- padding: 12px 0;
102- border-bottom: 1px solid var(--border);
103- font-size: 14.5px;
104-
105- &:last-child {
106- border-bottom: 0;
107- }
108- }
109-
110- .attn a {
111- color: var(--text);
112- text-decoration: none;
113-
114- &:hover {
115- text-decoration: underline;
116- }
117- }
118-
119- .attn .sub {
120- color: var(--muted);
121- font-size: 13px;
122- }
123-
124- > p.small {
125- margin: 14px 0 0;
126- }
127-}
128-
129-// Explore: one-row search (input, then its button) and a sort control of pill links.
130-.explore-search {
131- display: flex;
132- flex-wrap: wrap;
133- gap: 8px;
134- align-items: center;
135- margin: 18px 0 0;
136-
137- input[type="search"] {
138- flex: 1 1 240px;
139- width: auto;
140- min-width: 0;
141- }
142-
143- button {
144- flex: 0 0 auto;
145- }
146-
147- @media (max-width: 479px) {
148- input[type="search"] {
149- flex: 1 1 100%;
150- }
151- }
152-}
153-
154-.explore-sort {
155- display: flex;
156- flex-wrap: wrap;
157- gap: 6px 8px;
158- align-items: center;
159- margin: 14px 0 0;
160- font-size: 13px;
161-
162- a,
163- .current {
164- display: inline-flex;
165- align-items: center;
166- height: 28px;
167- padding: 0 12px;
168- border: 1px solid var(--border);
169- border-radius: var(--radius-full);
170- color: var(--text-2);
171- text-decoration: none;
172- }
173-
174- a:hover {
175- background: var(--surface-2);
176- text-decoration: none;
177- }
178-
179- .current {
180- border-color: transparent;
181- background: var(--accent-soft);
182- color: var(--accent-ink);
183- font-weight: 600;
184- }
185-}
186-
187-// A repo listing (profile tabs): search, sort chips, count, rows and pager as one tight block, so
188-// the profile's section gap does not open between the count line and the list.
189-.repo-listing {
190- display: flex;
191- flex-direction: column;
192- gap: 10px;
193-
194- > .explore-search,
195- > .explore-sort,
196- > p {
197- margin: 0;
198- }
199-}
200-
201-.repo-item-head {
202- display: flex;
203- align-items: center;
204- gap: 8px;
205- min-width: 0;
206-
207- .repo-name {
208- min-width: 0;
209- overflow: hidden;
210- text-overflow: ellipsis;
211- white-space: nowrap;
212- }
213-
214- .badge {
215- flex: 0 0 auto;
216- }
217-}
218-
219-.repo-item .repo-desc {
220- overflow: hidden;
221- text-overflow: ellipsis;
222- white-space: nowrap;
223-}
224-
225-.pager-numbered {
226- flex-wrap: wrap;
227- gap: 4px;
228- font-size: 13px;
229-
230- .pager-page,
231- .pager-step,
232- .pager-gap {
233- display: inline-flex;
234- align-items: center;
235- justify-content: center;
236- min-width: 30px;
237- height: 30px;
238- padding: 0 8px;
239- border-radius: var(--radius-full);
240- color: var(--text-2);
241- text-decoration: none;
242- }
243-
244- a:hover {
245- background: var(--surface-2);
246- text-decoration: none;
247- }
248-
249- .current {
250- background: var(--accent-soft);
251- color: var(--accent-ink);
252- font-weight: 600;
253- }
254-
255- .pager-gap {
256- min-width: 20px;
257- padding: 0;
258- }
259-}
260-
261-// Organization pages: the name and description stack; the section links are in the shell sidebar.
262-.org-head {
263- .org-head-text {
264- display: grid;
265- gap: 4px;
266- min-width: 0;
267- }
268-
269- h1,
270- p {
271- margin: 0;
272- }
273-}
style/_heatmap.scssmodified+1 -1
@@ -1,6 +1,6 @@
11 // heatmap: sage redesign. See docs in the scratchpad PORT.md brief.
22 //
3-// The contribution card on the dashboard (views/heatmap.rs). Cells are squares with a 3px gap;
3+// The contribution card on a profile (views/heatmap.rs). Cells are squares with a 3px gap;
44 // the grid lays out seven rows and fills columns, so a week is one column. Colours come from the
55 // --h0..--h4 tokens below, mixed from the base's surface and the accent, so every accent, base
66 // and theme gets the same scale.
style/_import.scssmodified+6 -0
@@ -201,6 +201,12 @@
201201 max-width: 100%;
202202 }
203203
204+// The recent imports card under the import form (pages/import.rs, recent_imports): as wide as the form.
205+.import-recent {
206+ max-width: 960px;
207+ margin-top: 16px;
208+}
209+
204210 .import-job {
205211 display: flex;
206212 flex-direction: column;
style/_shell.scssmodified+101 -176
@@ -465,19 +465,6 @@
465465 }
466466 }
467467
468-// A dot on the menu button when there are unread notifications (the bell's count moved here).
469-.nav-toggle summary.has-dot::after {
470- content: "";
471- position: absolute;
472- top: 5px;
473- right: 5px;
474- width: 8px;
475- height: 8px;
476- border-radius: 50%;
477- background: var(--heat-3);
478- box-shadow: 0 0 0 2px var(--bg);
479-}
480-
481468 // The shared button keeps its natural width in columns; in the top bar it sits on the centre line.
482469 .topbar .button {
483470 align-self: center;
@@ -526,7 +513,7 @@
526513 top: calc(100% + 8px);
527514 }
528515
529-// Phone menu: the sidebar in a panel under the top bar. Hidden from 900px.
516+// Phone menu: the section sidebar in a panel under the top bar. Hidden from 900px.
530517
531518 .nav-toggle {
532519 flex: none;
@@ -549,7 +536,7 @@
549536 box-shadow: var(--shadow);
550537 }
551538
552-// Sidebar
539+// Section sidebar (admin, settings and an org's pages). Other pages have none.
553540
554541 .shell {
555542 display: grid;
@@ -589,20 +576,12 @@
589576 color: var(--muted);
590577 }
591578
592- .count {
593- margin-left: auto;
594- font-size: 12.5px;
595- color: var(--muted);
596- font-variant-numeric: tabular-nums;
597- }
598-
599579 &.on {
600580 background: var(--accent-soft);
601581 color: var(--accent-ink);
602582 font-weight: 600;
603583
604- .ico,
605- .count {
584+ .ico {
606585 color: var(--accent-ink);
607586 }
608587 }
@@ -620,61 +599,22 @@
620599 color: var(--muted);
621600 }
622601
623-.side-empty {
624- margin: 0 12px;
625- font-size: 13px;
626- color: var(--muted);
627-}
628-
629-.side-repos {
630- display: flex;
631- flex-direction: column;
632- gap: 2px;
633-
634- a {
635- display: flex;
636- align-items: center;
637- min-height: 32px;
638- padding: 0 12px;
639- overflow: hidden;
640- border-radius: var(--radius-md);
641- font-family: var(--mono);
642- font-size: 13.5px;
643- color: var(--text-2);
644- white-space: nowrap;
645- text-decoration: none;
646-
647- &:hover {
648- background: var(--surface-2);
649- text-decoration: none;
650- }
651- }
652-}
653-
654-// Profile corner: the signed-in user at the bottom of the sidebar. Its menu opens upward.
655-
656-// The corner's outer box: the rule above it and its place at the sidebar's foot. The bell sits in it
657-// beside the details, so the box holds both.
602+// Profile corner: the signed-in user's floating panel at the bottom left of the window (see
603+// `.corner-float`). Its menu opens upward from the panel.
658604 .corner-wrap {
659605 position: relative;
660- margin-top: auto;
661- padding-top: 8px;
662- border-top: 1px solid var(--border);
663-}
664-
665-.nav-panel .corner-wrap {
666- margin-top: 12px;
606+ display: flex;
607+ align-items: center;
608+ gap: 4px;
667609 }
668610
669611 .corner {
670612 position: relative;
671613 }
672614
673-// The phone panel scrolls, so a menu opening upward would be cut at its top: it opens in place.
674-.nav-panel .corner-menu {
615+// The panel's menu anchors to the panel's width, not to the summary, so it reads as a menu of its own.
616+.corner-float .corner {
675617 position: static;
676- margin-top: 6px;
677- box-shadow: none;
678618 }
679619
680620 .corner-btn {
@@ -696,11 +636,6 @@
696636 }
697637 }
698638
699-// The bell overlays the summary's right end, so the chips and the name keep clear of it.
700-.corner-wrap .corner-btn {
701- padding-right: 48px;
702-}
703-
704639 // The name wraps onto at most two lines, breaking at spaces. A single word too long for the line
705640 // breaks inside it.
706641 .corner-name {
@@ -769,12 +704,10 @@ a.chip {
769704 }
770705 }
771706
772-// The bell at the corner's right end, over the summary row (its 50px: the 8px top padding and the
773-// 34px avatar with the summary's padding). It opens the popover of the newest notifications.
707+// The bell beside the summary, inside the floating panel. It opens the popover of the newest
708+// notifications, and its unread count sits on its top right corner.
774709 .corner-bell {
775- position: absolute;
776- top: 19px;
777- right: 14px;
710+ position: relative;
778711 display: grid;
779712 flex: none;
780713 place-items: center;
@@ -794,6 +727,19 @@ a.chip {
794727 }
795728 }
796729
730+// The unread count on the bell: a small badge over its top right corner.
731+.corner-bell .bell-count {
732+ position: absolute;
733+ top: -4px;
734+ right: -4px;
735+ min-width: 16px;
736+ height: 16px;
737+ padding: 0 4px;
738+ font-size: 10px;
739+ line-height: 16px;
740+ box-shadow: 0 0 0 2px var(--surface);
741+}
742+
797743 // The bell's popover: the newest notifications, opened upward from the bell (nav.js places it). The
798744 // UA's centring is reset so the fixed placement holds. It has no display of its own: the UA hides it
799745 // while closed.
@@ -940,8 +886,6 @@ a.chip {
940886
941887 .corner-menu {
942888 position: absolute;
943- left: 8px;
944- right: 8px;
945889 bottom: calc(100% + 6px);
946890 z-index: 40;
947891 display: grid;
@@ -954,6 +898,63 @@ a.chip {
954898 box-shadow: var(--shadow);
955899 }
956900
901+// The profile corner: a small panel fixed at the bottom left of the window, the avatar, the chips and
902+// the bell. The name is left out of the panel; its aria-label still names the viewer.
903+.corner-float {
904+ position: fixed;
905+ left: 16px;
906+ bottom: 16px;
907+ z-index: 40;
908+ max-width: min(280px, calc(100vw - 32px));
909+ background: var(--surface);
910+ border: 1px solid var(--border);
911+ border-radius: 999px;
912+ box-shadow: var(--shadow);
913+ padding: 4px 8px;
914+ // The panel can be dragged with a pointer (nav.js): touch must not scroll under it.
915+ touch-action: none;
916+ cursor: grab;
917+ user-select: none;
918+}
919+
920+.corner-float.dragging {
921+ cursor: grabbing;
922+}
923+
924+// Placed in the top half of the window: the menu opens below the panel. In the right half it anchors
925+// to the panel's right edge instead of the left one. The default corner keeps the upward menu.
926+.corner-float[data-open="down"] .corner-menu {
927+ top: calc(100% + 6px);
928+ bottom: auto;
929+}
930+
931+// The menu is as wide as its content, at least the panel's width, and never wider than the window.
932+.corner-float .corner-menu {
933+ left: 8px;
934+ right: auto;
935+ width: max-content;
936+ min-width: calc(100% - 16px);
937+ max-width: calc(100vw - 32px);
938+}
939+
940+.corner-float[data-side="right"] .corner-menu {
941+ left: auto;
942+ right: 8px;
943+}
944+
945+.corner-float .corner-name {
946+ display: none;
947+}
948+
949+.corner-float .corner-btn {
950+ padding: 2px 4px;
951+}
952+
953+.corner-float .corner-avatar .avatar {
954+ width: 28px;
955+ height: 28px;
956+}
957+
957958 // `button.corner-link` too (Log out): the extra element in the selector outweighs `button.link-button`.
958959 .corner-link,
959960 button.corner-link.link-button {
@@ -1060,7 +1061,21 @@ button.corner-link.link-button {
10601061 border-top: 1px solid var(--border);
10611062 }
10621063
1063-// Wide screens: the sidebar sits beside the page, and a repo's tabs replace its links.
1064+// Signed-in pages without a sidebar: the floating profile panel sits over the footer's left edge.
1065+body[data-signed-in] .shell:not(:has(> .shell-sidebar)) .site-footer {
1066+ padding-left: 132px;
1067+}
1068+
1069+// The page is one full-width column. A section page (admin, settings, an org) adds its sidebar beside
1070+// it from 900px, below.
1071+
1072+// The floating profile corner sits over the bottom left of the page below 900px: the page keeps
1073+// clear of it at its end.
1074+@media (max-width: 899px) {
1075+ .shell-body {
1076+ padding-bottom: 72px;
1077+ }
1078+}
10641079
10651080 @media (max-width: 699px) {
10661081 .topbar .crumbs {
@@ -1132,7 +1147,6 @@ button.corner-link.link-button {
11321147 position: sticky;
11331148 top: var(--topbar-h);
11341149 align-self: start;
1135- // A column, so the profile corner sits at its bottom (margin-top: auto).
11361150 display: flex;
11371151 flex-direction: column;
11381152 box-sizing: border-box;
@@ -1144,93 +1158,11 @@ button.corner-link.link-button {
11441158 background: var(--surface);
11451159 border-right: 1px solid var(--border);
11461160 }
1147-
1148- // The profile corner stays above a repo page's fixed tabs, which end where it starts: 50px of
1149- // corner, its rule and the sidebar's 24px bottom padding.
1150- .shell-sidebar .corner-wrap {
1151- position: relative;
1152- z-index: 6;
1153- }
1154-
1155- .shell:has(> .shell-sidebar .corner-wrap) .repo-tabs {
1156- bottom: 76px;
1157- }
1158-
1159- // The sticky sidebar is its own stacking layer, under the fixed tabs, so the open menu would sit
1160- // behind them: while it is open the sidebar rises above the tabs, see-through so they still show.
1161- .shell-sidebar:has(.corner[open]) {
1162- z-index: 6;
1163- }
1164-
1165- .shell:has(.repo-tabs) .shell-sidebar:has(.corner[open]) {
1166- background: transparent;
1167- }
1168-
1169- // A repo page: its tabs become the sidebar, fixed under the top bar, and the global links go.
1170- .shell:has(.repo-tabs) .shell-sidebar .side-links,
1171- .shell:has(.repo-tabs) .shell-sidebar .side-group {
1172- display: none;
1173- }
1174-
1175- .shell:has(> .shell-sidebar) .repo-tabs {
1176- position: fixed;
1177- // nav.js sets --shell-top to where the page body starts, below the site banner when there is one.
1178- top: max(var(--topbar-h), var(--shell-top, 0px));
1179- bottom: 0;
1180- left: 0;
1181- z-index: 5;
1182- box-sizing: border-box;
1183- width: var(--sidebar-w);
1184- flex-direction: column;
1185- align-items: stretch;
1186- gap: 2px;
1187- margin: 0;
1188- padding: 16px 12px 24px;
1189- overflow-x: hidden;
1190- overflow-y: auto;
1191- background: var(--surface);
1192- border-right: 1px solid var(--border);
1193- border-bottom: 0;
1194- }
1195-
1196- .shell:has(> .shell-sidebar) .repo-tabs .tab {
1197- display: flex;
1198- align-items: center;
1199- gap: 8px;
1200- min-height: 36px;
1201- padding: 0 12px;
1202- border-radius: var(--radius-md);
1203- box-shadow: none;
1204- color: var(--text-2);
1205- font-size: 14.5px;
1206- font-weight: 500;
1207-
1208- &:hover {
1209- background: var(--surface-2);
1210- color: var(--text);
1211- }
1212-
1213- &.active {
1214- background: var(--accent-soft);
1215- color: var(--accent-ink);
1216- font-weight: 600;
1217- box-shadow: none;
1218- }
1219- }
1220-
1221- .shell:has(> .shell-sidebar) .repo-tabs .tab-count {
1222- margin-left: auto;
1223- padding: 0;
1224- background: none;
1225- font-size: 12.5px;
1226- color: var(--muted);
1227- font-variant-numeric: tabular-nums;
1228- }
12291161 }
12301162
1231-// Sidebar on the right (the user's preference, set on <html> as data-sidebar). The sidebar takes the
1232-// second column and its border moves to its inner edge. A repo's tabs follow it. Below 900px the
1233-// sidebar is hidden either way, so the phone layout and the nav toggle are unchanged.
1163+// Sidebar on the right (the user's preference, set on <html> as data-sidebar). The section sidebar
1164+// takes the second column and its border moves to its inner edge. Below
1165+// 900px the sidebar is hidden either way, so the phone layout and the nav toggle are unchanged.
12341166 @media (min-width: 900px) {
12351167 html[data-sidebar="right"] .shell:has(> .shell-sidebar) {
12361168 grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
@@ -1241,13 +1173,6 @@ button.corner-link.link-button {
12411173 border-right: 0;
12421174 border-left: 1px solid var(--border);
12431175 }
1244-
1245- html[data-sidebar="right"] .shell:has(> .shell-sidebar) .repo-tabs {
1246- left: auto;
1247- right: 0;
1248- border-right: 0;
1249- border-left: 1px solid var(--border);
1250- }
12511176 }
12521177
12531178 // Soft navigation: a thin progress line along the top while a page is being fetched in place
style/main.scssmodified+20 -1
@@ -2230,6 +2230,26 @@ code {
22302230 margin-top: 12px;
22312231 }
22322232
2233+.profile-org-actions {
2234+ display: flex;
2235+ flex-wrap: wrap;
2236+ gap: 8px;
2237+ margin-top: 8px;
2238+}
2239+
2240+.org-settings-grid {
2241+ display: grid;
2242+ grid-template-columns: minmax(0, 1fr);
2243+ gap: 16px;
2244+ align-items: start;
2245+}
2246+
2247+@media (min-width: 900px) {
2248+ .org-settings-grid {
2249+ grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
2250+ }
2251+}
2252+
22332253 // Profile tabs: a horizontal underline strip under the header. Reuses the `.tab` and `.tab-count`
22342254 // looks; the sidebar rules for `.repo-tabs` do not apply here. Below the sidebar breakpoint the
22352255 // strip runs to the screen edges, as `.repo-tabs` does, and the tabs snap as they scroll.
@@ -7023,7 +7043,6 @@ button.ci-job-last {
70237043 @import "heatmap";
70247044 @import "repo";
70257045 @import "pull";
7026-@import "dashboard";
70277046 @import "wiki";
70287047 @import "browse";
70297048 @import "import";