The tab bar, sidebars and command palette are built from the same navigation lists, so the palette finds every profile tab, Organizations, New organization and each organization's Members, Teams and Settings
Browse files at this commit8d87bc9e2e282252b87b8f7b0ddbbf0b10987aa5Parent: 75d5a52- feat
- the tab bar, sidebars and command palette are built from the same navigation lists, so the palette finds every profile tab, Organizations, New organization and each organization's Members, Teams and Settings
- Explore moves from the profile corner to a link after the search bar, an icon on narrow windows
- style
- pages fit the window without a page scrollbar: long lists page and dense pages use panes and columns
- an organization's overview is redesigned with a larger avatar and a Members card, Members and Teams lose their sidebar and use the profile tabs, and Settings moves from a tab to an Edit organization button
- CI status badges follow the theme
- the bell's Clear action becomes Mark as read
- fix
- the bell popover opens once at its full height instead of jumping when its list arrives
49 changed files +1735 -447
- crates/forge-web/assets/nav.js +102 -18
- crates/forge-web/src/i18n/misc.rs +6 -2
- crates/forge-web/src/i18n/orgs.rs +11 -4
- crates/forge-web/src/pages/admin_health.rs +47 -6
- crates/forge-web/src/pages/admin_mail.rs +2 -2
- crates/forge-web/src/pages/admin_runners.rs +54 -5
- crates/forge-web/src/pages/admin_server.rs +2 -2
- crates/forge-web/src/pages/admin_user_detail.rs +1 -1
- crates/forge-web/src/pages/audit_log.rs +18 -12
- crates/forge-web/src/pages/blob.rs +1 -1
- crates/forge-web/src/pages/ci_badge.rs +1 -1
- crates/forge-web/src/pages/ci_job.rs +3 -1
- crates/forge-web/src/pages/commit.rs +3 -1
- crates/forge-web/src/pages/discussion_view.rs +1 -1
- crates/forge-web/src/pages/import.rs +26 -7
- crates/forge-web/src/pages/issue_view.rs +2 -2
- crates/forge-web/src/pages/issues_list.rs +1 -1
- crates/forge-web/src/pages/labels_page.rs +40 -5
- crates/forge-web/src/pages/milestones_page.rs +39 -5
- crates/forge-web/src/pages/notifications.rs +47 -41
- crates/forge-web/src/pages/org_ctx.rs +35 -0
- crates/forge-web/src/pages/org_members.rs +9 -4
- crates/forge-web/src/pages/org_teams.rs +17 -5
- crates/forge-web/src/pages/palette.rs +90 -16
- crates/forge-web/src/pages/profile.rs +148 -60
- crates/forge-web/src/pages/pull_files.rs +1 -1
- crates/forge-web/src/pages/pull_view.rs +2 -2
- crates/forge-web/src/pages/releases.rs +65 -17
- crates/forge-web/src/pages/repo_collaborators.rs +12 -8
- crates/forge-web/src/pages/repo_mirrors.rs +66 -64
- crates/forge-web/src/pages/repo_secrets.rs +62 -60
- crates/forge-web/src/pages/repo_settings.rs +26 -15
- crates/forge-web/src/pages/repo_webhooks.rs +10 -8
- crates/forge-web/src/pages/snippets.rs +1 -1
- crates/forge-web/src/pages/tree.rs +21 -9
- crates/forge-web/src/pages/wiki.rs +1 -1
- crates/forge-web/src/views/mod.rs +110 -53
- style/_dashboard.scss +76 -0
- style/_fit.scss +11 -0
- style/_fit_admin.scss +117 -0
- style/_fit_code.scss +91 -0
- style/_fit_forms.scss +111 -0
- style/_fit_lists.scss +27 -0
- style/_fit_settings.scss +55 -0
- style/_fit_tables.scss +65 -0
- style/_fit_threads.scss +17 -0
- style/_repo.scss +49 -3
- style/_shell.scss +21 -1
- style/main.scss +12 -1
crates/forge-web/assets/nav.jsmodified+102 -18
| @@ -330,8 +330,11 @@ | |||
| 330 | if (how !== 'live') { closeDropdowns(null); } | 330 | if (how !== 'live') { closeDropdowns(null); } |
| 331 | var oldList = document.querySelector('.ci-run-list'); | 331 | var oldList = document.querySelector('.ci-run-list'); |
| 332 | var listTop = how === 'live' && oldList ? oldList.scrollTop : null; | 332 | var listTop = how === 'live' && oldList ? oldList.scrollTop : null; |
| 333 | + // A fit pane keeps its scroll when the page stays put (a live change, a post, a filter), by its place in the page. | ||
| 334 | + var paneTops = how === 'live' || how === 'post' || how === 'query' ? paneScrolls() : null; | ||
| 333 | adopt(doc, keepFields, dd, how === 'live' ? captureJobs() : null); | 335 | adopt(doc, keepFields, dd, how === 'live' ? captureJobs() : null); |
| 334 | placeRun(listTop); | 336 | placeRun(listTop); |
| 337 | + if (paneTops) { setPaneScrolls(paneTops); } | ||
| 335 | if (tailAt) { | 338 | if (tailAt) { |
| 336 | var nextTail = document.querySelector('[data-live-log]'); | 339 | var nextTail = document.querySelector('[data-live-log]'); |
| 337 | if (nextTail) { nextTail.scrollTop = tailAt.end ? nextTail.scrollHeight : tailAt.top; } | 340 | if (nextTail) { nextTail.scrollTop = tailAt.end ? nextTail.scrollHeight : tailAt.top; } |
| @@ -365,13 +368,29 @@ | |||
| 365 | var els = document.querySelectorAll('[data-keep-anchor]'); | 368 | var els = document.querySelectorAll('[data-keep-anchor]'); |
| 366 | for (var i = 0; i < els.length; i++) { | 369 | for (var i = 0; i < els.length; i++) { |
| 367 | if (els[i].getAttribute('data-keep-anchor') === at.key) { | 370 | if (els[i].getAttribute('data-keep-anchor') === at.key) { |
| 368 | - window.scrollTo(window.scrollX, window.scrollY + els[i].getBoundingClientRect().top - at.dy); | 371 | + var delta = els[i].getBoundingClientRect().top - at.dy; |
| 372 | + // A diff inside a fit pane moves the pane; the page itself does not scroll there. | ||
| 373 | + var pane = els[i].closest('.fit-pane'); | ||
| 374 | + if (pane && pane.scrollHeight > pane.clientHeight) { pane.scrollTop += delta; } | ||
| 375 | + else { window.scrollTo(window.scrollX, window.scrollY + delta); } | ||
| 369 | return true; | 376 | return true; |
| 370 | } | 377 | } |
| 371 | } | 378 | } |
| 372 | return false; | 379 | return false; |
| 373 | } | 380 | } |
| 374 | 381 | ||
| 382 | + // The scroll of each fit pane on the page, in order. A pane is a new element after a swap, so its place is | ||
| 383 | + // set again by its index. | ||
| 384 | + function paneScrolls() { | ||
| 385 | + return Array.prototype.map.call(document.querySelectorAll('.fit-pane'), function (p) { return p.scrollTop; }); | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + function setPaneScrolls(tops) { | ||
| 389 | + Array.prototype.forEach.call(document.querySelectorAll('.fit-pane'), function (p, i) { | ||
| 390 | + if (i < tops.length) { p.scrollTop = tops[i]; } | ||
| 391 | + }); | ||
| 392 | + } | ||
| 393 | + | ||
| 375 | // The runs list scrolls inside its card: bring the selected row into view there. scrollIntoView | 394 | // The runs list scrolls inside its card: bring the selected row into view there. scrollIntoView |
| 376 | // would also scroll the page, so the list's own scrollTop is set instead. | 395 | // would also scroll the page, so the list's own scrollTop is set instead. |
| 377 | function placeRun(keepTop) { | 396 | function placeRun(keepTop) { |
| @@ -1088,16 +1107,21 @@ | |||
| 1088 | } | 1107 | } |
| 1089 | } | 1108 | } |
| 1090 | 1109 | ||
| 1091 | - // Fills the popover's list with the server's fragment. A reader who closed it meanwhile, or a newer | 1110 | + // Fills the popover's list with the server's fragment. The popover stays invisible until then, so it |
| 1092 | - // open, leaves the answer unused. | 1111 | + // opens at its final height; a slow answer shows the loading note first. A reader who closed it |
| 1112 | + // meanwhile, or a newer open, leaves the answer unused. | ||
| 1093 | function loadPeek(pop) { | 1113 | function loadPeek(pop) { |
| 1094 | var list = pop.querySelector('.bell-list'); | 1114 | var list = pop.querySelector('.bell-list'); |
| 1095 | if (!list) { return; } | 1115 | if (!list) { return; } |
| 1096 | var seq = ++peekSeq; | 1116 | var seq = ++peekSeq; |
| 1097 | - var note = document.createElement('p'); | 1117 | + var slow = setTimeout(function () { |
| 1098 | - note.className = 'bell-empty muted'; | 1118 | + if (seq !== peekSeq || !isPeekOpen(pop)) { return; } |
| 1099 | - note.textContent = pop.getAttribute('data-loading') || ''; | 1119 | + var note = document.createElement('p'); |
| 1100 | - list.replaceChildren(note); | 1120 | + note.className = 'bell-empty muted'; |
| 1121 | + note.textContent = pop.getAttribute('data-loading') || ''; | ||
| 1122 | + list.replaceChildren(note); | ||
| 1123 | + pop.classList.add('bell-ready'); | ||
| 1124 | + }, PEEK_SLOW); | ||
| 1101 | fetch('/notifications/peek', { headers: { accept: 'text/html' }, credentials: 'same-origin' }).then(function (r) { | 1125 | fetch('/notifications/peek', { headers: { accept: 'text/html' }, credentials: 'same-origin' }).then(function (r) { |
| 1102 | if (!r.ok) { throw new Error('status ' + r.status); } | 1126 | if (!r.ok) { throw new Error('status ' + r.status); } |
| 1103 | return r.text(); | 1127 | return r.text(); |
| @@ -1112,8 +1136,12 @@ | |||
| 1112 | err.className = 'bell-empty muted'; | 1136 | err.className = 'bell-empty muted'; |
| 1113 | err.textContent = pop.getAttribute('data-error') || ''; | 1137 | err.textContent = pop.getAttribute('data-error') || ''; |
| 1114 | list.replaceChildren(err); | 1138 | list.replaceChildren(err); |
| 1139 | + }).then(function () { | ||
| 1140 | + clearTimeout(slow); | ||
| 1141 | + if (seq === peekSeq && isPeekOpen(pop)) { pop.classList.add('bell-ready'); } | ||
| 1115 | }); | 1142 | }); |
| 1116 | } | 1143 | } |
| 1144 | + var PEEK_SLOW = 300; // ms before a slow list shows its loading note | ||
| 1117 | var peekSeq = 0; // a fetch's number: only the newest answer is drawn | 1145 | var peekSeq = 0; // a fetch's number: only the newest answer is drawn |
| 1118 | 1146 | ||
| 1119 | // Records whether the popover was open when the press began. Light dismiss closes it on the press, | 1147 | // Records whether the popover was open when the press began. Light dismiss closes it on the press, |
| @@ -1158,9 +1186,12 @@ | |||
| 1158 | if (open) { | 1186 | if (open) { |
| 1159 | placePeek(bell, pop); | 1187 | placePeek(bell, pop); |
| 1160 | loadPeek(pop); | 1188 | loadPeek(pop); |
| 1161 | - } else if (hoverOn === 'bell') { | 1189 | + } else { |
| 1162 | - // Closed by Escape or a light dismiss: the mouse no longer holds it open. | 1190 | + pop.classList.remove('bell-ready'); |
| 1163 | - hoverOn = null; | 1191 | + if (hoverOn === 'bell') { |
| 1192 | + // Closed by Escape or a light dismiss: the mouse no longer holds it open. | ||
| 1193 | + hoverOn = null; | ||
| 1194 | + } | ||
| 1164 | } | 1195 | } |
| 1165 | }, true); | 1196 | }, true); |
| 1166 | 1197 | ||
| @@ -3153,21 +3184,73 @@ | |||
| 3153 | shellFrame = 0; | 3184 | shellFrame = 0; |
| 3154 | var shell = document.querySelector('.shell'); | 3185 | var shell = document.querySelector('.shell'); |
| 3155 | if (!shell) { return; } | 3186 | if (!shell) { return; } |
| 3156 | - document.documentElement.style.setProperty('--shell-top', Math.round(shell.getBoundingClientRect().top) + 'px'); | 3187 | + var root = document.documentElement.style; |
| 3188 | + root.setProperty('--shell-top', Math.round(shell.getBoundingClientRect().top) + 'px'); | ||
| 3189 | + // A pane that fills the window sits between headers and a footer of any height: both are measured. | ||
| 3190 | + // The CI card sticks while the page scrolls, so its wrapper gives the top. | ||
| 3191 | + var pane = document.querySelector('.repo-home, .ci-split, .fit-pane'); | ||
| 3192 | + var main = document.querySelector('main'); | ||
| 3193 | + var foot = document.querySelector('.site-footer'); | ||
| 3194 | + if (!pane || !main || !foot) { return; } | ||
| 3195 | + root.setProperty('--pane-top', Math.ceil(pane.getBoundingClientRect().top + window.scrollY) + 'px'); | ||
| 3196 | + root.setProperty('--pane-foot', Math.ceil(foot.getBoundingClientRect().height + parseFloat(getComputedStyle(main).paddingBottom)) + 'px'); | ||
| 3197 | + } | ||
| 3198 | + | ||
| 3199 | + // A CI badge (`/{owner}/{repo}/badge.svg`, often in a README) is drawn here as HTML from the data in | ||
| 3200 | + // its SVG, so it takes the theme's colours: an image cannot read them, and other sites keep the SVG. | ||
| 3201 | + // It is fetched again after a swap, and a badge seen before is drawn at once so a live render does | ||
| 3202 | + // not blink. | ||
| 3203 | + var badgeSeen = {}; // badge URL -> { label, status } | ||
| 3204 | + | ||
| 3205 | + function readBadge(href) { | ||
| 3206 | + return fetch(href, { credentials: 'same-origin' }).then(function (res) { | ||
| 3207 | + if (!res.ok) { throw new Error('badge'); } | ||
| 3208 | + return res.text(); | ||
| 3209 | + }).then(function (text) { | ||
| 3210 | + var svg = new DOMParser().parseFromString(text, 'image/svg+xml').documentElement; | ||
| 3211 | + var label = svg.querySelector('text'); | ||
| 3212 | + var status = svg.getAttribute('data-status'); | ||
| 3213 | + if (!label || !status) { throw new Error('badge'); } | ||
| 3214 | + return { label: label.textContent, status: status }; | ||
| 3215 | + }); | ||
| 3216 | + } | ||
| 3217 | + | ||
| 3218 | + function drawBadge(el, data) { | ||
| 3219 | + var chip = document.createElement('span'); | ||
| 3220 | + chip.className = 'ci-chip'; | ||
| 3221 | + chip.setAttribute('role', 'img'); | ||
| 3222 | + chip.setAttribute('aria-label', data.label + ': ' + data.status); | ||
| 3223 | + chip.setAttribute('data-badge', el.getAttribute('data-badge')); | ||
| 3224 | + chip.setAttribute('data-status', data.status); | ||
| 3225 | + [data.label, data.status].forEach(function (text) { | ||
| 3226 | + var part = document.createElement('span'); | ||
| 3227 | + part.textContent = text; | ||
| 3228 | + chip.appendChild(part); | ||
| 3229 | + }); | ||
| 3230 | + el.replaceWith(chip); | ||
| 3157 | } | 3231 | } |
| 3158 | 3232 | ||
| 3159 | - // A CI badge (`/{owner}/{repo}/badge.svg`, often in a README) is fetched again after a swap. The | ||
| 3160 | - // document stays the same across a soft navigation, and the browser reuses an image it already | ||
| 3161 | - // has at the same URL whatever its Cache-Control says, so the badge would keep an old state until | ||
| 3162 | - // a reload. The badge ignores query keys it does not know, so `_r` only makes the URL new. | ||
| 3163 | function syncBadges() { | 3233 | function syncBadges() { |
| 3164 | - var stamp = String(Date.now()); | ||
| 3165 | document.querySelectorAll('img[src*="/badge.svg"]').forEach(function (img) { | 3234 | document.querySelectorAll('img[src*="/badge.svg"]').forEach(function (img) { |
| 3166 | var url; | 3235 | var url; |
| 3167 | try { url = new URL(img.getAttribute('src'), location.href); } catch (err) { return; } | 3236 | try { url = new URL(img.getAttribute('src'), location.href); } catch (err) { return; } |
| 3168 | if (url.origin !== location.origin || !/\/badge\.svg$/.test(url.pathname)) { return; } | 3237 | if (url.origin !== location.origin || !/\/badge\.svg$/.test(url.pathname)) { return; } |
| 3169 | - url.searchParams.set('_r', stamp); | 3238 | + var href = url.pathname + url.search; |
| 3170 | - img.src = url.pathname + url.search; | 3239 | + img.setAttribute('data-badge', href); |
| 3240 | + if (badgeSeen[href]) { drawBadge(img, badgeSeen[href]); } else { img.classList.add('badge-wait'); } | ||
| 3241 | + }); | ||
| 3242 | + var all = document.querySelectorAll('[data-badge]'); | ||
| 3243 | + var hrefs = {}; | ||
| 3244 | + all.forEach(function (el) { hrefs[el.getAttribute('data-badge')] = true; }); | ||
| 3245 | + Object.keys(hrefs).forEach(function (href) { | ||
| 3246 | + readBadge(href).then(function (data) { | ||
| 3247 | + badgeSeen[href] = data; | ||
| 3248 | + document.querySelectorAll('[data-badge]').forEach(function (el) { | ||
| 3249 | + if (el.getAttribute('data-badge') === href) { drawBadge(el, data); } | ||
| 3250 | + }); | ||
| 3251 | + }).catch(function () { | ||
| 3252 | + document.querySelectorAll('img.badge-wait').forEach(function (img) { img.classList.remove('badge-wait'); }); | ||
| 3253 | + }); | ||
| 3171 | }); | 3254 | }); |
| 3172 | } | 3255 | } |
| 3173 | 3256 | ||
| @@ -3260,6 +3343,7 @@ | |||
| 3260 | syncBannerExpiry(); | 3343 | syncBannerExpiry(); |
| 3261 | syncShellTop(); | 3344 | syncShellTop(); |
| 3262 | syncDrafts(); | 3345 | syncDrafts(); |
| 3346 | + syncBadges(); | ||
| 3263 | 3347 | ||
| 3264 | window.__forgeQuery = function (href) { | 3348 | window.__forgeQuery = function (href) { |
| 3265 | var url = pageUrl(href); | 3349 | var url = pageUrl(href); |
crates/forge-web/src/i18n/misc.rsmodified+6 -2
| @@ -166,6 +166,7 @@ pub enum K { | |||
| 166 | // Top-bar user menu: the viewer's public profile and the settings editor. | 166 | // Top-bar user menu: the viewer's public profile and the settings editor. |
| 167 | YourProfile, | 167 | YourProfile, |
| 168 | EditProfile, | 168 | EditProfile, |
| 169 | + EditOrganization, | ||
| 169 | // Profile corner, live strip and path bar search. | 170 | // Profile corner, live strip and path bar search. |
| 170 | AllNotifications, | 171 | AllNotifications, |
| 171 | Passed, | 172 | Passed, |
| @@ -323,6 +324,7 @@ const ALL: &[K] = &[ | |||
| 323 | K::RefLabel, | 324 | K::RefLabel, |
| 324 | K::YourProfile, | 325 | K::YourProfile, |
| 325 | K::EditProfile, | 326 | K::EditProfile, |
| 327 | + K::EditOrganization, | ||
| 326 | K::AllNotifications, | 328 | K::AllNotifications, |
| 327 | K::Passed, | 329 | K::Passed, |
| 328 | K::Failed, | 330 | K::Failed, |
| @@ -483,8 +485,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 483 | (MarkAllAsRead, Tr) => "Tümünü okundu olarak işaretle", | 485 | (MarkAllAsRead, Tr) => "Tümünü okundu olarak işaretle", |
| 484 | (MarkAllRead, En) => "Mark all read", | 486 | (MarkAllRead, En) => "Mark all read", |
| 485 | (MarkAllRead, Tr) => "Tümünü okundu işaretle", | 487 | (MarkAllRead, Tr) => "Tümünü okundu işaretle", |
| 486 | - (ClearNotifications, En) => "Clear", | 488 | + (ClearNotifications, En) => "Mark as read", |
| 487 | - (ClearNotifications, Tr) => "Temizle", | 489 | + (ClearNotifications, Tr) => "Okundu işaretle", |
| 488 | (MarkRead, En) => "Mark read", | 490 | (MarkRead, En) => "Mark read", |
| 489 | (MarkRead, Tr) => "Okundu işaretle", | 491 | (MarkRead, Tr) => "Okundu işaretle", |
| 490 | (NoNotificationsYet, En) => "No notifications yet.", | 492 | (NoNotificationsYet, En) => "No notifications yet.", |
| @@ -645,6 +647,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 645 | (YourProfile, Tr) => "Profilin", | 647 | (YourProfile, Tr) => "Profilin", |
| 646 | (EditProfile, En) => "Edit profile", | 648 | (EditProfile, En) => "Edit profile", |
| 647 | (EditProfile, Tr) => "Profili düzenle", | 649 | (EditProfile, Tr) => "Profili düzenle", |
| 650 | + (EditOrganization, En) => "Edit organization", | ||
| 651 | + (EditOrganization, Tr) => "Kuruluşu düzenle", | ||
| 648 | (AllNotifications, En) => "All notifications", | 652 | (AllNotifications, En) => "All notifications", |
| 649 | (AllNotifications, Tr) => "Tüm bildirimler", | 653 | (AllNotifications, Tr) => "Tüm bildirimler", |
| 650 | (Passed, En) => "passed", | 654 | (Passed, En) => "passed", |
crates/forge-web/src/i18n/orgs.rsmodified+11 -4
| @@ -50,6 +50,8 @@ pub enum K { | |||
| 50 | CreateOrg, | 50 | CreateOrg, |
| 51 | // Organization settings. | 51 | // Organization settings. |
| 52 | Settings, | 52 | Settings, |
| 53 | + General, | ||
| 54 | + BackToOrganization, | ||
| 53 | Description, | 55 | Description, |
| 54 | DisplayNameLabel, | 56 | DisplayNameLabel, |
| 55 | DefaultRoleLabel, | 57 | DefaultRoleLabel, |
| @@ -62,6 +64,7 @@ pub enum K { | |||
| 62 | Members, | 64 | Members, |
| 63 | Teams, | 65 | Teams, |
| 64 | Organization, | 66 | Organization, |
| 67 | + ViewAllMembers, | ||
| 65 | MemberHeader, | 68 | MemberHeader, |
| 66 | Role, | 69 | Role, |
| 67 | RoleOwner, | 70 | RoleOwner, |
| @@ -121,7 +124,6 @@ pub enum K { | |||
| 121 | PinsTooMany, | 124 | PinsTooMany, |
| 122 | NoPinnableRepos, | 125 | NoPinnableRepos, |
| 123 | TabOverview, | 126 | TabOverview, |
| 124 | - Overview, | ||
| 125 | TabStars, | 127 | TabStars, |
| 126 | FilterRepos, | 128 | FilterRepos, |
| 127 | NoReposMatch, | 129 | NoReposMatch, |
| @@ -213,6 +215,12 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 213 | (NewRepository, Tr) => "Yeni depo", | 215 | (NewRepository, Tr) => "Yeni depo", |
| 214 | (NewOrganization, En) => "New organization", | 216 | (NewOrganization, En) => "New organization", |
| 215 | (NewOrganization, Tr) => "Yeni kuruluş", | 217 | (NewOrganization, Tr) => "Yeni kuruluş", |
| 218 | + (General, En) => "General", | ||
| 219 | + (General, Tr) => "Genel", | ||
| 220 | + (BackToOrganization, En) => "Back to organization", | ||
| 221 | + (BackToOrganization, Tr) => "Kuruluşa dön", | ||
| 222 | + (ViewAllMembers, En) => "View all", | ||
| 223 | + (ViewAllMembers, Tr) => "Tümünü gör", | ||
| 216 | (NewOrgIntro, En) => { | 224 | (NewOrgIntro, En) => { |
| 217 | "An organization owns repositories and shares them with its members through teams. You become its first owner." | 225 | "An organization owns repositories and shares them with its members through teams. You become its first owner." |
| 218 | } | 226 | } |
| @@ -375,8 +383,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 375 | (NoPinnableRepos, Tr) => "Henüz sabitlenecek depo yok.", | 383 | (NoPinnableRepos, Tr) => "Henüz sabitlenecek depo yok.", |
| 376 | (TabOverview, En) => "Overview", | 384 | (TabOverview, En) => "Overview", |
| 377 | (TabOverview, Tr) => "Genel bakış", | 385 | (TabOverview, Tr) => "Genel bakış", |
| 378 | - (Overview, En) => "Overview", | ||
| 379 | - (Overview, Tr) => "Genel bakış", | ||
| 380 | (TabStars, En) => "Stars", | 386 | (TabStars, En) => "Stars", |
| 381 | (TabStars, Tr) => "Yıldızlar", | 387 | (TabStars, Tr) => "Yıldızlar", |
| 382 | (FilterRepos, En) => "Find a repository", | 388 | (FilterRepos, En) => "Find a repository", |
| @@ -618,7 +624,8 @@ mod tests { | |||
| 618 | K::PinsTooMany, | 624 | K::PinsTooMany, |
| 619 | K::NoPinnableRepos, | 625 | K::NoPinnableRepos, |
| 620 | K::TabOverview, | 626 | K::TabOverview, |
| 621 | - K::Overview, | 627 | + K::General, |
| 628 | + K::BackToOrganization, | ||
| 622 | K::TabStars, | 629 | K::TabStars, |
| 623 | K::FilterRepos, | 630 | K::FilterRepos, |
| 624 | K::NoReposMatch, | 631 | K::NoReposMatch, |
crates/forge-web/src/pages/admin_health.rsmodified+47 -6
| @@ -16,7 +16,7 @@ use tokio::process::Command; | |||
| 16 | use topcoat::Result; | 16 | use topcoat::Result; |
| 17 | use topcoat::context::{Cx, app_context}; | 17 | use topcoat::context::{Cx, app_context}; |
| 18 | use topcoat::router::response::Response; | 18 | use topcoat::router::response::Response; |
| 19 | -use topcoat::router::{page, route}; | 19 | +use topcoat::router::{page, query_params, route}; |
| 20 | use topcoat::view::{View, component, view}; | 20 | use topcoat::view::{View, component, view}; |
| 21 | 21 | ||
| 22 | use crate::i18n::accounts::{A, duration_short, meta_line, needs_attention, on_disk, t as at}; | 22 | use crate::i18n::accounts::{A, duration_short, meta_line, needs_attention, on_disk, t as at}; |
| @@ -25,8 +25,19 @@ use crate::i18n::{self, Lang}; | |||
| 25 | use crate::live::{Topic, stream_changes}; | 25 | use crate::live::{Topic, stream_changes}; |
| 26 | use crate::pages::admin_users::admin_only; | 26 | use crate::pages::admin_users::admin_only; |
| 27 | use crate::state::AppState; | 27 | use crate::state::AppState; |
| 28 | +use crate::views::repo_list::{PageLink, pager, pager_links}; | ||
| 28 | use crate::views::{human_size, now_unix, rel_time, shell}; | 29 | use crate::views::{human_size, now_unix, rel_time, shell}; |
| 29 | 30 | ||
| 31 | +/// Active alerts per page of the alerts card. Each row is about 56px tall, so three keep the card | ||
| 32 | +/// short enough to fit the window. | ||
| 33 | +const ALERTS_PER_PAGE: usize = 3; | ||
| 34 | + | ||
| 35 | +/// The health page's query: only the alerts' page. | ||
| 36 | +#[query_params(error = bad_request)] | ||
| 37 | +struct HealthQuery { | ||
| 38 | + page: Option<String>, | ||
| 39 | +} | ||
| 40 | + | ||
| 30 | /// How a dot or a value is drawn: a bad outcome, a good one, a plain count, or a feature that is | 41 | /// How a dot or a value is drawn: a bad outcome, a good one, a plain count, or a feature that is |
| 31 | /// not set up. | 42 | /// not set up. |
| 32 | #[derive(Clone, Copy, PartialEq, Eq)] | 43 | #[derive(Clone, Copy, PartialEq, Eq)] |
| @@ -458,8 +469,18 @@ async fn since_line(lang: Lang, stamp: &str) -> Result<impl View> { | |||
| 458 | } | 469 | } |
| 459 | 470 | ||
| 460 | #[component] | 471 | #[component] |
| 461 | -async fn health_view(lang: Lang, health: Health, alerts: Vec<AlertRow>) -> Result<impl View> { | 472 | +async fn health_view( |
| 462 | - let count = alerts.len(); | 473 | + lang: Lang, |
| 474 | + health: Health, | ||
| 475 | + alerts: Vec<AlertRow>, | ||
| 476 | + total: usize, | ||
| 477 | + page: u64, | ||
| 478 | + pages: u64, | ||
| 479 | + nav: (Vec<PageLink>, Option<String>, Option<String>), | ||
| 480 | +) -> Result<impl View> { | ||
| 481 | + // The heading counts every active alert; the card lists the current page of them. | ||
| 482 | + let count = total; | ||
| 483 | + let (links, prev, next) = nav; | ||
| 463 | let Health { | 484 | let Health { |
| 464 | usage, | 485 | usage, |
| 465 | facts, | 486 | facts, |
| @@ -474,7 +495,7 @@ async fn health_view(lang: Lang, health: Health, alerts: Vec<AlertRow>) -> Resul | |||
| 474 | at(lang, A::Fine).to_owned() | 495 | at(lang, A::Fine).to_owned() |
| 475 | }; | 496 | }; |
| 476 | Ok(view! { | 497 | Ok(view! { |
| 477 | - <div data-live="/admin/health/events"> | 498 | + <div data-live="/admin/health/events" class="health-page"> |
| 478 | <section class="page-head"> | 499 | <section class="page-head"> |
| 479 | <h1>(at(lang, A::Health))</h1> | 500 | <h1>(at(lang, A::Health))</h1> |
| 480 | <p class="health-summary"> | 501 | <p class="health-summary"> |
| @@ -497,6 +518,7 @@ async fn health_view(lang: Lang, health: Health, alerts: Vec<AlertRow>) -> Resul | |||
| 497 | </li> | 518 | </li> |
| 498 | } | 519 | } |
| 499 | </ul> | 520 | </ul> |
| 521 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | ||
| 500 | <a class="small" href="/admin/server?tab=alerts">(alert_text::settings_link(lang))</a> | 522 | <a class="small" href="/admin/server?tab=alerts">(alert_text::settings_link(lang))</a> |
| 501 | </section> | 523 | </section> |
| 502 | } | 524 | } |
| @@ -559,11 +581,30 @@ async fn health_page(cx: &Cx) -> Result<impl View> { | |||
| 559 | let viewer = admin_only(cx).await?; | 581 | let viewer = admin_only(cx).await?; |
| 560 | let lang = i18n::lang(cx, Some(&viewer.0)); | 582 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 561 | let state = app_context::<AppState>(cx); | 583 | let state = app_context::<AppState>(cx); |
| 584 | + let query = query_params::<HealthQuery>(cx)?; | ||
| 562 | let health = gather(state, lang).await?; | 585 | let health = gather(state, lang).await?; |
| 563 | - let alerts = alert_rows(state, lang).await?; | 586 | + let all = alert_rows(state, lang).await?; |
| 587 | + let total = all.len(); | ||
| 588 | + let pages = total.div_ceil(ALERTS_PER_PAGE).max(1); | ||
| 589 | + let page = query | ||
| 590 | + .page | ||
| 591 | + .as_deref() | ||
| 592 | + .and_then(|p| p.parse::<usize>().ok()) | ||
| 593 | + .unwrap_or(1) | ||
| 594 | + .clamp(1, pages); | ||
| 595 | + let alerts: Vec<AlertRow> = all | ||
| 596 | + .into_iter() | ||
| 597 | + .skip((page - 1) * ALERTS_PER_PAGE) | ||
| 598 | + .take(ALERTS_PER_PAGE) | ||
| 599 | + .collect(); | ||
| 600 | + let nav = pager_links(page as u64, pages as u64, |n| { | ||
| 601 | + format!("/admin/health?page={n}") | ||
| 602 | + }); | ||
| 564 | let title = at(lang, A::Health); | 603 | let title = at(lang, A::Health); |
| 565 | Ok(view! { | 604 | Ok(view! { |
| 566 | - shell(title: title, viewer: Some(&viewer), health_view(lang: lang, health: health, alerts: alerts)) | 605 | + shell(title: title, viewer: Some(&viewer), |
| 606 | + health_view(lang: lang, health: health, alerts: alerts, total: total, | ||
| 607 | + page: page as u64, pages: pages as u64, nav: nav)) | ||
| 567 | }) | 608 | }) |
| 568 | } | 609 | } |
| 569 | 610 | ||
crates/forge-web/src/pages/admin_mail.rsmodified+2 -2
| @@ -245,7 +245,7 @@ async fn mail_view( | |||
| 245 | // Saved by any admin session: the stream re-renders the settings with the same signal | 245 | // Saved by any admin session: the stream re-renders the settings with the same signal |
| 246 | // as the queue (the save bumps it too), and the form keeps what was typed. | 246 | // as the queue (the save bumps it too), and the form keeps what was typed. |
| 247 | <div data-live="/admin/mail/events"> | 247 | <div data-live="/admin/mail/events"> |
| 248 | - <section class="card"> | 248 | + <section class="card fit-pane"> |
| 249 | <h2>(g::t(lang, K::SmtpServer))</h2> | 249 | <h2>(g::t(lang, K::SmtpServer))</h2> |
| 250 | <p class="muted small">(g::t(lang, K::MailTransportNote))</p> | 250 | <p class="muted small">(g::t(lang, K::MailTransportNote))</p> |
| 251 | <p class="small">(g::t(lang, K::MailTransportInUse)) " " <code>(data.transport)</code></p> | 251 | <p class="small">(g::t(lang, K::MailTransportInUse)) " " <code>(data.transport)</code></p> |
| @@ -279,7 +279,7 @@ async fn mail_view( | |||
| 279 | </section> | 279 | </section> |
| 280 | </div> | 280 | </div> |
| 281 | } else if let Some(queue) = data.queue { | 281 | } else if let Some(queue) = data.queue { |
| 282 | - <section class="card"> | 282 | + <section class="card fit-pane"> |
| 283 | <p class="muted small">(g::t(lang, K::MailQueueIntro))</p> | 283 | <p class="muted small">(g::t(lang, K::MailQueueIntro))</p> |
| 284 | <div class="mail-filters"> | 284 | <div class="mail-filters"> |
| 285 | for chip in queue.chips.into_iter() { | 285 | for chip in queue.chips.into_iter() { |
crates/forge-web/src/pages/admin_runners.rsmodified+54 -5
| @@ -22,7 +22,7 @@ use topcoat::router::content::Form; | |||
| 22 | use topcoat::router::error::{SeeOther, forbidden, see_other}; | 22 | use topcoat::router::error::{SeeOther, forbidden, see_other}; |
| 23 | use topcoat::router::request::uri; | 23 | use topcoat::router::request::uri; |
| 24 | use topcoat::router::response::Response; | 24 | use topcoat::router::response::Response; |
| 25 | -use topcoat::router::{page, path_param, route}; | 25 | +use topcoat::router::{page, path_param, query_params, route}; |
| 26 | use topcoat::view::{View, component, view}; | 26 | use topcoat::view::{View, component, view}; |
| 27 | 27 | ||
| 28 | use crate::audit::{self, Actor, Target}; | 28 | use crate::audit::{self, Actor, Target}; |
| @@ -36,10 +36,21 @@ use crate::pages::admin_users::admin_only; | |||
| 36 | use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text}; | 36 | use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text}; |
| 37 | use crate::pages::repo_mirrors::stamp_in_tz; | 37 | use crate::pages::repo_mirrors::stamp_in_tz; |
| 38 | use crate::state::AppState; | 38 | use crate::state::AppState; |
| 39 | +use crate::views::repo_list::{PageLink, pager, pager_links}; | ||
| 39 | use crate::views::{empty_state, enc, now_unix, relative_time, shell}; | 40 | use crate::views::{empty_state, enc, now_unix, relative_time, shell}; |
| 40 | 41 | ||
| 41 | path_param!(runner_id); | 42 | path_param!(runner_id); |
| 42 | 43 | ||
| 44 | +/// Runners per page on the list. Six rows fit the window beside the "Add a runner" card. | ||
| 45 | +const PER_PAGE: usize = 6; | ||
| 46 | + | ||
| 47 | +/// The list's query: the page, and the notice word that a paging link keeps. | ||
| 48 | +#[query_params(error = bad_request)] | ||
| 49 | +struct RunnersQuery { | ||
| 50 | + page: Option<String>, | ||
| 51 | + notice: Option<String>, | ||
| 52 | +} | ||
| 53 | + | ||
| 43 | /// Picks the English or Turkish text. The runner page strings live here, not in `i18n::admin`. | 54 | /// Picks the English or Turkish text. The runner page strings live here, not in `i18n::admin`. |
| 44 | fn s(lang: Lang, en: &'static str, tr: &'static str) -> &'static str { | 55 | fn s(lang: Lang, en: &'static str, tr: &'static str) -> &'static str { |
| 45 | match lang { | 56 | match lang { |
| @@ -315,9 +326,13 @@ async fn runners_view( | |||
| 315 | lang: Lang, | 326 | lang: Lang, |
| 316 | csrf: String, | 327 | csrf: String, |
| 317 | rows: Vec<RunnerRow>, | 328 | rows: Vec<RunnerRow>, |
| 329 | + page: u64, | ||
| 330 | + pages: u64, | ||
| 331 | + nav: (Vec<PageLink>, Option<String>, Option<String>), | ||
| 318 | notice: Option<(&'static str, bool)>, | 332 | notice: Option<(&'static str, bool)>, |
| 319 | note: String, | 333 | note: String, |
| 320 | ) -> Result<impl View> { | 334 | ) -> Result<impl View> { |
| 335 | + let (links, prev, next) = nav; | ||
| 321 | Ok(view! { | 336 | Ok(view! { |
| 322 | <div data-live="/admin/runners/events"> | 337 | <div data-live="/admin/runners/events"> |
| 323 | <section class="page-head"> | 338 | <section class="page-head"> |
| @@ -330,13 +345,15 @@ async fn runners_view( | |||
| 330 | <section class="card notice" role="status">(text)</section> | 345 | <section class="card notice" role="status">(text)</section> |
| 331 | } | 346 | } |
| 332 | } | 347 | } |
| 333 | - <section class="card"> | 348 | + <div class="fit-split"> |
| 349 | + <section class="card fit-pane fit-card fit-main"> | ||
| 334 | <h2>(g::t(lang, K::Runners))</h2> | 350 | <h2>(g::t(lang, K::Runners))</h2> |
| 335 | if rows.is_empty() { | 351 | if rows.is_empty() { |
| 336 | empty_state(title: g::t(lang, K::NoRunnersYet), hint: Some(g::t(lang, K::RunnersEmptyHint))) { | 352 | empty_state(title: g::t(lang, K::NoRunnersYet), hint: Some(g::t(lang, K::RunnersEmptyHint))) { |
| 337 | <pre><code>"forge runner register --url <forge-url> --token <token> --name <name> --labels linux,x86_64"</code></pre> | 353 | <pre><code>"forge runner register --url <forge-url> --token <token> --name <name> --labels linux,x86_64"</code></pre> |
| 338 | } | 354 | } |
| 339 | } else { | 355 | } else { |
| 356 | + <div class="fit-scroll fit-bleed"> | ||
| 340 | <ul class="runner-list"> | 357 | <ul class="runner-list"> |
| 341 | for row in rows.iter() { | 358 | for row in rows.iter() { |
| 342 | <li class="runner-row is-linked"> | 359 | <li class="runner-row is-linked"> |
| @@ -390,9 +407,11 @@ async fn runners_view( | |||
| 390 | </li> | 407 | </li> |
| 391 | } | 408 | } |
| 392 | </ul> | 409 | </ul> |
| 410 | + </div> | ||
| 411 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | ||
| 393 | } | 412 | } |
| 394 | </section> | 413 | </section> |
| 395 | - <section class="card"> | 414 | + <section class="card fit-side"> |
| 396 | <h2>(g::t(lang, K::AddARunner))</h2> | 415 | <h2>(g::t(lang, K::AddARunner))</h2> |
| 397 | <p class="muted small">(note.as_str())</p> | 416 | <p class="muted small">(note.as_str())</p> |
| 398 | <form method="post" action="/admin/runners/tokens" class="inline-form"> | 417 | <form method="post" action="/admin/runners/tokens" class="inline-form"> |
| @@ -401,9 +420,20 @@ async fn runners_view( | |||
| 401 | </form> | 420 | </form> |
| 402 | </section> | 421 | </section> |
| 403 | </div> | 422 | </div> |
| 423 | + </div> | ||
| 404 | }) | 424 | }) |
| 405 | } | 425 | } |
| 406 | 426 | ||
| 427 | +/// The list page's link for `page`, keeping the notice word a refused or saved action left in the | ||
| 428 | +/// query, so paging does not lose it. | ||
| 429 | +fn list_href(page: u64, notice: &str) -> String { | ||
| 430 | + if notice.is_empty() { | ||
| 431 | + format!("/admin/runners?page={page}") | ||
| 432 | + } else { | ||
| 433 | + format!("/admin/runners?page={page}¬ice={}", enc(notice)) | ||
| 434 | + } | ||
| 435 | +} | ||
| 436 | + | ||
| 407 | /// A destructive button that opens the shared `confirm-inline` popover; the POST only fires from the | 437 | /// A destructive button that opens the shared `confirm-inline` popover; the POST only fires from the |
| 408 | /// confirm button inside it, and Cancel closes the popover. | 438 | /// confirm button inside it, and Cancel closes the popover. |
| 409 | #[component] | 439 | #[component] |
| @@ -600,25 +630,44 @@ async fn token_view( | |||
| 600 | async fn runners_page(cx: &Cx) -> Result<impl View> { | 630 | async fn runners_page(cx: &Cx) -> Result<impl View> { |
| 601 | let viewer = admin_only(cx).await?; | 631 | let viewer = admin_only(cx).await?; |
| 602 | let lang = i18n::lang(cx, Some(&viewer.0)); | 632 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 633 | + let query = query_params::<RunnersQuery>(cx)?; | ||
| 603 | let state = app_context::<AppState>(cx); | 634 | let state = app_context::<AppState>(cx); |
| 604 | let tz = viewer.0.timezone.clone(); | 635 | let tz = viewer.0.timezone.clone(); |
| 605 | let now = now_unix(); | 636 | let now = now_unix(); |
| 606 | - let rows: Vec<RunnerRow> = state | 637 | + let all: Vec<RunnerRow> = state |
| 607 | .store | 638 | .store |
| 608 | .list_runners() | 639 | .list_runners() |
| 609 | .await? | 640 | .await? |
| 610 | .iter() | 641 | .iter() |
| 611 | .map(|runner| runner_row(runner, &tz, lang, now)) | 642 | .map(|runner| runner_row(runner, &tz, lang, now)) |
| 612 | .collect(); | 643 | .collect(); |
| 644 | + let pages = all.len().div_ceil(PER_PAGE).max(1); | ||
| 645 | + let page = query | ||
| 646 | + .page | ||
| 647 | + .as_deref() | ||
| 648 | + .and_then(|p| p.parse::<usize>().ok()) | ||
| 649 | + .unwrap_or(1) | ||
| 650 | + .clamp(1, pages); | ||
| 651 | + let rows: Vec<RunnerRow> = all | ||
| 652 | + .into_iter() | ||
| 653 | + .skip((page - 1) * PER_PAGE) | ||
| 654 | + .take(PER_PAGE) | ||
| 655 | + .collect(); | ||
| 613 | let csrf = viewer.1.csrf_token.clone(); | 656 | let csrf = viewer.1.csrf_token.clone(); |
| 614 | let notice = notice_from_query(cx, lang); | 657 | let notice = notice_from_query(cx, lang); |
| 658 | + let kept = if notice.is_some() { | ||
| 659 | + query.notice.clone().unwrap_or_default() | ||
| 660 | + } else { | ||
| 661 | + String::new() | ||
| 662 | + }; | ||
| 663 | + let nav = pager_links(page as u64, pages as u64, |n| list_href(n, &kept)); | ||
| 615 | let note = g::token_ttl_note( | 664 | let note = g::token_ttl_note( |
| 616 | lang, | 665 | lang, |
| 617 | &g::hours_text(lang, state.live().ci.registration_token_hours), | 666 | &g::hours_text(lang, state.live().ci.registration_token_hours), |
| 618 | ); | 667 | ); |
| 619 | let title = g::t(lang, K::CiRunners); | 668 | let title = g::t(lang, K::CiRunners); |
| 620 | Ok(view! { | 669 | Ok(view! { |
| 621 | - shell(title: title, viewer: Some(&viewer), runners_view(lang: lang, csrf: csrf, rows: rows, notice: notice, note: note)) | 670 | + shell(title: title, viewer: Some(&viewer), runners_view(lang: lang, csrf: csrf, rows: rows, page: page as u64, pages: pages as u64, nav: nav, notice: notice, note: note)) |
| 622 | }) | 671 | }) |
| 623 | } | 672 | } |
| 624 | 673 | ||
crates/forge-web/src/pages/admin_server.rsmodified+2 -2
| @@ -232,7 +232,7 @@ async fn server_view( | |||
| 232 | _ => "/admin/server/events".to_owned(), | 232 | _ => "/admin/server/events".to_owned(), |
| 233 | }; | 233 | }; |
| 234 | Ok(view! { | 234 | Ok(view! { |
| 235 | - <div data-live=(live.as_str())> | 235 | + <div data-live=(live.as_str()) class="srv-page"> |
| 236 | <section class="page-head"> | 236 | <section class="page-head"> |
| 237 | <h1>(g::t(lang, K::ServerSettings))</h1> | 237 | <h1>(g::t(lang, K::ServerSettings))</h1> |
| 238 | <p class="muted">(g::t(lang, K::ServerSettingsIntro))</p> | 238 | <p class="muted">(g::t(lang, K::ServerSettingsIntro))</p> |
| @@ -257,7 +257,7 @@ async fn server_view( | |||
| 257 | <p>(message.as_str())</p> | 257 | <p>(message.as_str())</p> |
| 258 | </section> | 258 | </section> |
| 259 | } | 259 | } |
| 260 | - <section class="card"> | 260 | + <section class="card fit-pane"> |
| 261 | <form method="post" action="/admin/server" class="srv-form"> | 261 | <form method="post" action="/admin/server" class="srv-form"> |
| 262 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 262 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 263 | <input type="hidden" name="tab" value=(tab)> | 263 | <input type="hidden" name="tab" value=(tab)> |
crates/forge-web/src/pages/admin_user_detail.rsmodified+1 -1
| @@ -157,7 +157,7 @@ async fn detail_body( | |||
| 157 | let live = format!("{base}/events"); | 157 | let live = format!("{base}/events"); |
| 158 | let Notice { done, error, link } = notice; | 158 | let Notice { done, error, link } = notice; |
| 159 | Ok(view! { | 159 | Ok(view! { |
| 160 | - <div data-live=(live.as_str())> | 160 | + <div data-live=(live.as_str()) class="user-page"> |
| 161 | <section class="user-head"> | 161 | <section class="user-head"> |
| 162 | <a class="user-back small" href="/admin/users">"← "(g::t(lang, K::Users))</a> | 162 | <a class="user-back small" href="/admin/users">"← "(g::t(lang, K::Users))</a> |
| 163 | <div class="user-id"> | 163 | <div class="user-id"> |
crates/forge-web/src/pages/audit_log.rsmodified+18 -12
| @@ -1,6 +1,7 @@ | |||
| 1 | //! Pages: the admin audit log (`/admin/audit`, instance admins only, 404 otherwise) and a user's | 1 | //! Pages: the admin audit log (`/admin/audit`, instance admins only, 404 otherwise) and a user's |
| 2 | //! own security log (`/settings/security/log`: entries the viewer acted in, or that targeted | 2 | //! own security log (`/settings/security/log`: entries the viewer acted in, or that targeted |
| 3 | -//! them). Both list newest first, 50 per page, continued with a cursor. | 3 | +//! them). Both list newest first, a page of rows at a time, continued with a cursor: 8 rows on the |
| 4 | +//! admin page (its filter bar takes the room) and 10 in the own log, sized to fit the window. | ||
| 4 | 5 | ||
| 5 | use forge_core::{AuditAction, AuditCursor, AuditEntry, AuditFilter, Store}; | 6 | use forge_core::{AuditAction, AuditCursor, AuditEntry, AuditFilter, Store}; |
| 6 | use topcoat::Result; | 7 | use topcoat::Result; |
| @@ -18,8 +19,11 @@ use crate::pages::issues_list::list_href; | |||
| 18 | use crate::state::AppState; | 19 | use crate::state::AppState; |
| 19 | use crate::views::{empty_state, rel_time, shell}; | 20 | use crate::views::{empty_state, rel_time, shell}; |
| 20 | 21 | ||
| 21 | -/// Entries per page. | 22 | +/// Entries per page of the admin audit log, under its filter bar. |
| 22 | -const PAGE_SIZE: usize = 50; | 23 | +const ADMIN_PAGE_SIZE: usize = 8; |
| 24 | + | ||
| 25 | +/// Entries per page of the own security log. | ||
| 26 | +const OWN_PAGE_SIZE: usize = 10; | ||
| 23 | 27 | ||
| 24 | #[query_params(error = bad_request)] | 28 | #[query_params(error = bad_request)] |
| 25 | pub(crate) struct AuditQuery { | 29 | pub(crate) struct AuditQuery { |
| @@ -67,18 +71,19 @@ fn row_view(entry: &AuditEntry, lang: Lang) -> RowView { | |||
| 67 | } | 71 | } |
| 68 | } | 72 | } |
| 69 | 73 | ||
| 70 | -/// One page of entries, and the cursor for the page after it when there may be one. | 74 | +/// One page of `size` entries, and the cursor for the page after it when there may be one. |
| 71 | async fn fetch_page( | 75 | async fn fetch_page( |
| 72 | store: &Store, | 76 | store: &Store, |
| 73 | filter: &AuditFilter, | 77 | filter: &AuditFilter, |
| 74 | before: Option<&str>, | 78 | before: Option<&str>, |
| 79 | + size: usize, | ||
| 75 | ) -> forge_core::Result<(Vec<AuditEntry>, Option<String>)> { | 80 | ) -> forge_core::Result<(Vec<AuditEntry>, Option<String>)> { |
| 76 | let cursor = before.and_then(AuditCursor::decode); | 81 | let cursor = before.and_then(AuditCursor::decode); |
| 77 | let mut entries = store | 82 | let mut entries = store |
| 78 | - .list_audit(filter, cursor.as_ref(), (PAGE_SIZE + 1) as u32) | 83 | + .list_audit(filter, cursor.as_ref(), (size + 1) as u32) |
| 79 | .await?; | 84 | .await?; |
| 80 | - let more = entries.len() > PAGE_SIZE; | 85 | + let more = entries.len() > size; |
| 81 | - entries.truncate(PAGE_SIZE); | 86 | + entries.truncate(size); |
| 82 | let next = if more { | 87 | let next = if more { |
| 83 | entries | 88 | entries |
| 84 | .last() | 89 | .last() |
| @@ -168,7 +173,7 @@ async fn admin_audit_view( | |||
| 168 | <p>(message.as_str())</p> | 173 | <p>(message.as_str())</p> |
| 169 | </section> | 174 | </section> |
| 170 | } | 175 | } |
| 171 | - <section class="card"> | 176 | + <section class="card fit-pane fit-list"> |
| 172 | audit_table(lang: lang, rows: rows, show_actor: true) | 177 | audit_table(lang: lang, rows: rows, show_actor: true) |
| 173 | if let Some(href) = older_href { | 178 | if let Some(href) = older_href { |
| 174 | <nav class="pager"> | 179 | <nav class="pager"> |
| @@ -191,7 +196,7 @@ async fn own_log_view( | |||
| 191 | <h1>(g::t(lang, K::SecurityLogTitle))</h1> | 196 | <h1>(g::t(lang, K::SecurityLogTitle))</h1> |
| 192 | <p class="muted">(g::t(lang, K::OwnLogIntro))</p> | 197 | <p class="muted">(g::t(lang, K::OwnLogIntro))</p> |
| 193 | </section> | 198 | </section> |
| 194 | - <section class="card"> | 199 | + <section class="card fit-pane fit-list"> |
| 195 | audit_table(lang: lang, rows: rows, show_actor: false) | 200 | audit_table(lang: lang, rows: rows, show_actor: false) |
| 196 | if let Some(href) = older_href { | 201 | if let Some(href) = older_href { |
| 197 | <nav class="pager"> | 202 | <nav class="pager"> |
| @@ -229,7 +234,7 @@ async fn admin_audit_page(cx: &Cx) -> Result<impl View> { | |||
| 229 | let (entries, next) = if notice.is_some() { | 234 | let (entries, next) = if notice.is_some() { |
| 230 | (Vec::new(), None) | 235 | (Vec::new(), None) |
| 231 | } else { | 236 | } else { |
| 232 | - fetch_page(store, &filter, query.before.as_deref()).await? | 237 | + fetch_page(store, &filter, query.before.as_deref(), ADMIN_PAGE_SIZE).await? |
| 233 | }; | 238 | }; |
| 234 | 239 | ||
| 235 | let rows: Vec<RowView> = entries | 240 | let rows: Vec<RowView> = entries |
| @@ -272,7 +277,7 @@ async fn first_page_fingerprint(store: &Store, action: &str, actor: &str) -> Res | |||
| 272 | None => return Ok(String::new()), | 277 | None => return Ok(String::new()), |
| 273 | } | 278 | } |
| 274 | } | 279 | } |
| 275 | - let (entries, _) = fetch_page(store, &filter, None).await?; | 280 | + let (entries, _) = fetch_page(store, &filter, None, ADMIN_PAGE_SIZE).await?; |
| 276 | Ok(entries | 281 | Ok(entries |
| 277 | .iter() | 282 | .iter() |
| 278 | .map(|entry| entry.id.as_str()) | 283 | .map(|entry| entry.id.as_str()) |
| @@ -307,7 +312,8 @@ async fn own_log_page(cx: &Cx) -> Result<impl View> { | |||
| 307 | involving_user: Some(viewer.0.id.clone()), | 312 | involving_user: Some(viewer.0.id.clone()), |
| 308 | ..Default::default() | 313 | ..Default::default() |
| 309 | }; | 314 | }; |
| 310 | - let (entries, next) = fetch_page(store, &filter, query.before.as_deref()).await?; | 315 | + let (entries, next) = |
| 316 | + fetch_page(store, &filter, query.before.as_deref(), OWN_PAGE_SIZE).await?; | ||
| 311 | 317 | ||
| 312 | let rows: Vec<RowView> = entries | 318 | let rows: Vec<RowView> = entries |
| 313 | .iter() | 319 | .iter() |
crates/forge-web/src/pages/blob.rsmodified+1 -1
| @@ -280,7 +280,7 @@ async fn blob_page(cx: &Cx) -> Result<impl View> { | |||
| 280 | breadcrumb(lang: lang, crumbs: crumbs) | 280 | breadcrumb(lang: lang, crumbs: crumbs) |
| 281 | file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) | 281 | file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) |
| 282 | </div> | 282 | </div> |
| 283 | - <section class="file" data-lines="" data-permalink=(permalink.as_str())> | 283 | + <section class="file fit-pane" data-lines="" data-permalink=(permalink.as_str())> |
| 284 | <header class="file-head"> | 284 | <header class="file-head"> |
| 285 | <span class="muted small">(size)</span> | 285 | <span class="muted small">(size)</span> |
| 286 | <nav class="file-actions" aria-label=(g::t(lang, K::FileNav))> | 286 | <nav class="file-actions" aria-label=(g::t(lang, K::FileNav))> |
crates/forge-web/src/pages/ci_badge.rsmodified+1 -1
| @@ -138,7 +138,7 @@ pub fn render_badge(label: &str, status: BadgeStatus) -> String { | |||
| 138 | let status_color = status.color(); | 138 | let status_color = status.color(); |
| 139 | format!( | 139 | format!( |
| 140 | concat!( | 140 | concat!( |
| 141 | - r##"<svg xmlns="http://www.w3.org/2000/svg" width="{total}" height="{h}" role="img" aria-label="{aria}">"##, | 141 | + r##"<svg xmlns="http://www.w3.org/2000/svg" width="{total}" height="{h}" role="img" data-status="{status_text}" aria-label="{aria}">"##, |
| 142 | r##"<title>{aria}</title>"##, | 142 | r##"<title>{aria}</title>"##, |
| 143 | r##"<linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient>"##, | 143 | r##"<linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient>"##, |
| 144 | r##"<clipPath id="r"><rect width="{total}" height="{h}" rx="3" fill="#fff"/></clipPath>"##, | 144 | r##"<clipPath id="r"><rect width="{total}" height="{h}" rx="3" fill="#fff"/></clipPath>"##, |
crates/forge-web/src/pages/ci_job.rsmodified+3 -1
| @@ -346,6 +346,7 @@ async fn job_body( | |||
| 346 | repo_head(head: RepoHead { live: String::new(), ..head }) | 346 | repo_head(head: RepoHead { live: String::new(), ..head }) |
| 347 | <div data-live=(live.as_str()) data-live-state=(job.fingerprint.as_str())> | 347 | <div data-live=(live.as_str()) data-live-state=(job.fingerprint.as_str())> |
| 348 | <p class="muted small"><a href=(job.run_href.as_str())>(g::t(lang, K::RunNumber)) (job.run_number)</a></p> | 348 | <p class="muted small"><a href=(job.run_href.as_str())>(g::t(lang, K::RunNumber)) (job.run_number)</a></p> |
| 349 | + <div class="ci-job-grid fit-pane"> | ||
| 349 | <section class="card"> | 350 | <section class="card"> |
| 350 | <h2>(job.name.as_str())</h2> | 351 | <h2>(job.name.as_str())</h2> |
| 351 | <p class="muted small"> | 352 | <p class="muted small"> |
| @@ -381,7 +382,7 @@ async fn job_body( | |||
| 381 | </div> | 382 | </div> |
| 382 | } | 383 | } |
| 383 | </section> | 384 | </section> |
| 384 | - <section class="card"> | 385 | + <section class="card ci-logcard"> |
| 385 | <h2>(g::t(lang, K::Log))</h2> | 386 | <h2>(g::t(lang, K::Log))</h2> |
| 386 | <p class="muted small"><a href=(job.log_href.as_str())>(g::t(lang, K::FullLog))</a></p> | 387 | <p class="muted small"><a href=(job.log_href.as_str())>(g::t(lang, K::FullLog))</a></p> |
| 387 | if truncated { | 388 | if truncated { |
| @@ -411,6 +412,7 @@ async fn job_body( | |||
| 411 | </section> | 412 | </section> |
| 412 | } | 413 | } |
| 413 | </div> | 414 | </div> |
| 415 | + </div> | ||
| 414 | }) | 416 | }) |
| 415 | } | 417 | } |
| 416 | 418 | ||
crates/forge-web/src/pages/commit.rsmodified+3 -1
| @@ -314,7 +314,9 @@ async fn commit_page(cx: &Cx) -> Result<impl View> { | |||
| 314 | if has_body { | 314 | if has_body { |
| 315 | <pre class="code commit-message"><code>(message.as_str())</code></pre> | 315 | <pre class="code commit-message"><code>(message.as_str())</code></pre> |
| 316 | } | 316 | } |
| 317 | - diff_section(diff: &diff, owner: owner_name.as_str(), repo: repo_name.as_str(), oid: info.oid.as_str(), parent: parent.as_deref(), subject: g::t(lang, K::ThisCommit), lang: DiffLang(lang), opts: opts) | 317 | + <div class="commit-diff fit-pane"> |
| 318 | + diff_section(diff: &diff, owner: owner_name.as_str(), repo: repo_name.as_str(), oid: info.oid.as_str(), parent: parent.as_deref(), subject: g::t(lang, K::ThisCommit), lang: DiffLang(lang), opts: opts) | ||
| 319 | + </div> | ||
| 318 | ) | 320 | ) |
| 319 | }) | 321 | }) |
| 320 | } | 322 | } |
crates/forge-web/src/pages/discussion_view.rsmodified+1 -1
| @@ -421,7 +421,7 @@ async fn discussion_page( | |||
| 421 | </p> | 421 | </p> |
| 422 | </section> | 422 | </section> |
| 423 | <div class="issue-layout"> | 423 | <div class="issue-layout"> |
| 424 | - <div class="issue-column"> | 424 | + <div class="issue-column fit-pane"> |
| 425 | <article class="issue-item" id="discussion-body"> | 425 | <article class="issue-item" id="discussion-body"> |
| 426 | <header class="issue-item-head"> | 426 | <header class="issue-item-head"> |
| 427 | <a href=(author_profile.as_str())><img class="avatar avatar-sm" src=(author_avatar.as_str()) alt="" width="24" height="24"></a> | 427 | <a href=(author_profile.as_str())><img class="avatar avatar-sm" src=(author_avatar.as_str()) alt="" width="24" height="24"></a> |
crates/forge-web/src/pages/import.rsmodified+26 -7
| @@ -319,11 +319,10 @@ async fn import_form( | |||
| 319 | let private = draft.private; | 319 | let private = draft.private; |
| 320 | let opts = draft.opts; | 320 | let opts = draft.opts; |
| 321 | Ok(view! { | 321 | Ok(view! { |
| 322 | - newrepo_tabs(lang: lang, active: "import") | ||
| 323 | if let Some(message) = error { | 322 | if let Some(message) = error { |
| 324 | alert(message: message.as_str()) | 323 | alert(message: message.as_str()) |
| 325 | } | 324 | } |
| 326 | - <form method="post" action="/new/import" class="newrepo-form"> | 325 | + <form method="post" action="/new/import" class="newrepo-form fit-pane"> |
| 327 | csrf_field(token: csrf) | 326 | csrf_field(token: csrf) |
| 328 | <input type="hidden" name="source" value=(source_value)> | 327 | <input type="hidden" name="source" value=(source_value)> |
| 329 | <header class="newrepo-head"> | 328 | <header class="newrepo-head"> |
| @@ -401,7 +400,7 @@ async fn import_form( | |||
| 401 | /// How many imports the Import tab lists under the form. | 400 | /// How many imports the Import tab lists under the form. |
| 402 | const RECENT_IMPORTS: usize = 5; | 401 | const RECENT_IMPORTS: usize = 5; |
| 403 | 402 | ||
| 404 | -/// The GET import page: the form, then the recent imports. | 403 | +/// The GET import page: the tabs, then the form and the recent imports side by side on wide windows. |
| 405 | #[component] | 404 | #[component] |
| 406 | async fn import_home( | 405 | async fn import_home( |
| 407 | lang: Lang, | 406 | lang: Lang, |
| @@ -412,8 +411,28 @@ async fn import_home( | |||
| 412 | more: bool, | 411 | more: bool, |
| 413 | ) -> Result<impl View> { | 412 | ) -> Result<impl View> { |
| 414 | Ok(view! { | 413 | Ok(view! { |
| 415 | - import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners) | 414 | + newrepo_tabs(lang: lang, active: "import") |
| 416 | - recent_imports(lang: lang, jobs: jobs, more: more) | 415 | + <div class="import-home"> |
| 416 | + import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners) | ||
| 417 | + recent_imports(lang: lang, jobs: jobs, more: more) | ||
| 418 | + </div> | ||
| 419 | + }) | ||
| 420 | +} | ||
| 421 | + | ||
| 422 | +/// The import form again after a rejected submit: the tabs, then the form. | ||
| 423 | +#[component] | ||
| 424 | +async fn import_error_body( | ||
| 425 | + lang: Lang, | ||
| 426 | + csrf: String, | ||
| 427 | + draft: Draft, | ||
| 428 | + error: String, | ||
| 429 | + owners: Vec<String>, | ||
| 430 | +) -> Result<impl View> { | ||
| 431 | + Ok(view! { | ||
| 432 | + newrepo_tabs(lang: lang, active: "import") | ||
| 433 | + <div class="import-home"> | ||
| 434 | + import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: Some(error), owners: owners) | ||
| 435 | + </div> | ||
| 417 | }) | 436 | }) |
| 418 | } | 437 | } |
| 419 | 438 | ||
| @@ -449,7 +468,7 @@ async fn import_submit(cx: &Cx, Form(form): Form<ImportForm>) -> Result<impl Vie | |||
| 449 | let draft = Draft::from_form(&form, source); | 468 | let draft = Draft::from_form(&form, source); |
| 450 | Ok(view! { cx => | 469 | Ok(view! { cx => |
| 451 | shell(title: g::t(lang, K::ImportTitle), viewer: Some(&viewer), | 470 | shell(title: g::t(lang, K::ImportTitle), viewer: Some(&viewer), |
| 452 | - import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: Some(message), owners: owners)) | 471 | + import_error_body(lang: lang, csrf: csrf, draft: draft, error: message, owners: owners)) |
| 453 | }) | 472 | }) |
| 454 | } | 473 | } |
| 455 | } | 474 | } |
| @@ -1084,7 +1103,7 @@ async fn recent_imports( | |||
| 1084 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); | 1103 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); |
| 1085 | Ok(view! { | 1104 | Ok(view! { |
| 1086 | if !empty { | 1105 | if !empty { |
| 1087 | - <section class="card import-recent"> | 1106 | + <section class="card import-recent fit-pane"> |
| 1088 | <h2>(g::t(lang, K::RecentImports))</h2> | 1107 | <h2>(g::t(lang, K::RecentImports))</h2> |
| 1089 | job_rows(lang: lang, jobs: jobs) | 1108 | job_rows(lang: lang, jobs: jobs) |
| 1090 | if more || retry { | 1109 | if more || retry { |
crates/forge-web/src/pages/issue_view.rsmodified+2 -2
| @@ -106,7 +106,7 @@ async fn issue_page( | |||
| 106 | </p> | 106 | </p> |
| 107 | </section> | 107 | </section> |
| 108 | <div class="issue-layout"> | 108 | <div class="issue-layout"> |
| 109 | - <div class="issue-column"> | 109 | + <div class="issue-column fit-pane"> |
| 110 | discussion_timeline(lang: lang, discussion: discussion) | 110 | discussion_timeline(lang: lang, discussion: discussion) |
| 111 | if can_comment { | 111 | if can_comment { |
| 112 | comment_form(lang: lang, action: comment_action.clone(), state_action: comment_action.clone(), | 112 | comment_form(lang: lang, action: comment_action.clone(), state_action: comment_action.clone(), |
| @@ -121,7 +121,7 @@ async fn issue_page( | |||
| 121 | <p class="muted">(g::comment_login_lead(lang))<a href=(login_href.as_str())>(g::t(lang, K::LogInLink))</a>(g::t(lang, K::ToComment))</p> | 121 | <p class="muted">(g::comment_login_lead(lang))<a href=(login_href.as_str())>(g::t(lang, K::LogInLink))</a>(g::t(lang, K::ToComment))</p> |
| 122 | } | 122 | } |
| 123 | </div> | 123 | </div> |
| 124 | - <aside class="issue-sidebar"> | 124 | + <aside class="issue-sidebar fit-pane"> |
| 125 | pin_box(lang: lang, write: write_meta, pinned: pinned, action: pin_action.clone(), csrf: csrf.clone()) | 125 | pin_box(lang: lang, write: write_meta, pinned: pinned, action: pin_action.clone(), csrf: csrf.clone()) |
| 126 | item_sidebar(lang: lang, write: write_meta, base: issue_href.clone(), csrf: csrf.clone(), sidebar: sidebar, notify: notify) | 126 | item_sidebar(lang: lang, write: write_meta, base: issue_href.clone(), csrf: csrf.clone(), sidebar: sidebar, notify: notify) |
| 127 | </aside> | 127 | </aside> |
crates/forge-web/src/pages/issues_list.rsmodified+1 -1
| @@ -704,7 +704,7 @@ async fn new_issue_body( | |||
| 704 | let has_labels = !labels.is_empty(); | 704 | let has_labels = !labels.is_empty(); |
| 705 | Ok(view! { | 705 | Ok(view! { |
| 706 | repo_head(head: head) | 706 | repo_head(head: head) |
| 707 | - <section class="card issue-new"> | 707 | + <section class="card issue-new fit-pane"> |
| 708 | <h2>(g::t(lang, K::NewIssue))</h2> | 708 | <h2>(g::t(lang, K::NewIssue))</h2> |
| 709 | if chooser_mode { | 709 | if chooser_mode { |
| 710 | <p class="muted">(g::t(lang, K::ChooseTemplate))</p> | 710 | <p class="muted">(g::t(lang, K::ChooseTemplate))</p> |
crates/forge-web/src/pages/labels_page.rsmodified+40 -5
| @@ -9,7 +9,7 @@ use topcoat::Result; | |||
| 9 | use topcoat::context::{Cx, app_context}; | 9 | use topcoat::context::{Cx, app_context}; |
| 10 | use topcoat::router::content::Form; | 10 | use topcoat::router::content::Form; |
| 11 | use topcoat::router::error::see_other; | 11 | use topcoat::router::error::see_other; |
| 12 | -use topcoat::router::{page, path_param}; | 12 | +use topcoat::router::{page, path_param, query_params}; |
| 13 | use topcoat::view::{View, component, view}; | 13 | use topcoat::view::{View, component, view}; |
| 14 | 14 | ||
| 15 | use crate::i18n::issues::{self as g, K}; | 15 | use crate::i18n::issues::{self as g, K}; |
| @@ -21,12 +21,22 @@ use crate::pages::issues_live::list_live_url; | |||
| 21 | use crate::pages::repo::repo_head; | 21 | use crate::pages::repo::repo_head; |
| 22 | use crate::pages::repo_ctx::load_repo; | 22 | use crate::pages::repo_ctx::load_repo; |
| 23 | use crate::state::AppState; | 23 | use crate::state::AppState; |
| 24 | +use crate::views::repo_list::{PageLink, pager, pager_links}; | ||
| 24 | use crate::views::{empty_state, enc, shell}; | 25 | use crate::views::{empty_state, enc, shell}; |
| 25 | 26 | ||
| 26 | path_param!(owner); | 27 | path_param!(owner); |
| 27 | path_param!(repo); | 28 | path_param!(repo); |
| 28 | path_param!(label_id); | 29 | path_param!(label_id); |
| 29 | 30 | ||
| 31 | +/// Labels per page. Twelve fill three or four rows of the list beside the create form. | ||
| 32 | +const PER_PAGE: usize = 12; | ||
| 33 | + | ||
| 34 | +/// The list's query: only the page. | ||
| 35 | +#[query_params(error = bad_request)] | ||
| 36 | +struct LabelsQuery { | ||
| 37 | + page: Option<String>, | ||
| 38 | +} | ||
| 39 | + | ||
| 30 | /// The create and edit form. Only the fields the form sends are read. | 40 | /// The create and edit form. Only the fields the form sends are read. |
| 31 | #[derive(Deserialize)] | 41 | #[derive(Deserialize)] |
| 32 | struct LabelForm { | 42 | struct LabelForm { |
| @@ -71,7 +81,11 @@ async fn labels_body( | |||
| 71 | frame: RepoFrame, | 81 | frame: RepoFrame, |
| 72 | rows: Vec<LabelRow>, | 82 | rows: Vec<LabelRow>, |
| 73 | live: String, | 83 | live: String, |
| 84 | + page: u64, | ||
| 85 | + pages: u64, | ||
| 86 | + nav: (Vec<PageLink>, Option<String>, Option<String>), | ||
| 74 | ) -> Result<impl View> { | 87 | ) -> Result<impl View> { |
| 88 | + let (links, prev, next) = nav; | ||
| 75 | let labels_action = labels_href(&frame.title); | 89 | let labels_action = labels_href(&frame.title); |
| 76 | let defaults_action = format!("{labels_action}/defaults"); | 90 | let defaults_action = format!("{labels_action}/defaults"); |
| 77 | let empty = rows.is_empty(); | 91 | let empty = rows.is_empty(); |
| @@ -85,7 +99,8 @@ async fn labels_body( | |||
| 85 | if archived { | 99 | if archived { |
| 86 | <section class="card notice" role="status">(g::t(lang, K::LabelsArchived))</section> | 100 | <section class="card notice" role="status">(g::t(lang, K::LabelsArchived))</section> |
| 87 | } | 101 | } |
| 88 | - <section class="card" data-live=(live.as_str()) data-live-now=""> | 102 | + <div class="fit-split"> |
| 103 | + <section class="card fit-pane fit-card fit-main" data-live=(live.as_str()) data-live-now=""> | ||
| 89 | <h2>(g::t(lang, K::Labels))</h2> | 104 | <h2>(g::t(lang, K::Labels))</h2> |
| 90 | if empty { | 105 | if empty { |
| 91 | empty_state(title: g::t(lang, K::NoLabelsYet), | 106 | empty_state(title: g::t(lang, K::NoLabelsYet), |
| @@ -99,6 +114,7 @@ async fn labels_body( | |||
| 99 | } | 114 | } |
| 100 | ) | 115 | ) |
| 101 | } | 116 | } |
| 117 | + <div class="fit-scroll"> | ||
| 102 | <ul class="label-list"> | 118 | <ul class="label-list"> |
| 103 | for row in rows.iter() { | 119 | for row in rows.iter() { |
| 104 | <li class="label-row"> | 120 | <li class="label-row"> |
| @@ -141,9 +157,11 @@ async fn labels_body( | |||
| 141 | </li> | 157 | </li> |
| 142 | } | 158 | } |
| 143 | </ul> | 159 | </ul> |
| 160 | + </div> | ||
| 161 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | ||
| 144 | </section> | 162 | </section> |
| 145 | if can_triage { | 163 | if can_triage { |
| 146 | - <section class="card"> | 164 | + <section class="card fit-side"> |
| 147 | <h2>(g::t(lang, K::NewLabel))</h2> | 165 | <h2>(g::t(lang, K::NewLabel))</h2> |
| 148 | <form method="post" action=(labels_action.as_str()) class="stack"> | 166 | <form method="post" action=(labels_action.as_str()) class="stack"> |
| 149 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 167 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| @@ -165,6 +183,7 @@ async fn labels_body( | |||
| 165 | </form> | 183 | </form> |
| 166 | </section> | 184 | </section> |
| 167 | } | 185 | } |
| 186 | + </div> | ||
| 168 | }) | 187 | }) |
| 169 | } | 188 | } |
| 170 | 189 | ||
| @@ -173,6 +192,7 @@ async fn labels_body( | |||
| 173 | async fn labels_page(cx: &Cx) -> Result<impl View> { | 192 | async fn labels_page(cx: &Cx) -> Result<impl View> { |
| 174 | let owner = path_param::<Owner>(cx); | 193 | let owner = path_param::<Owner>(cx); |
| 175 | let name = path_param::<Repo>(cx); | 194 | let name = path_param::<Repo>(cx); |
| 195 | + let query = query_params::<LabelsQuery>(cx)?; | ||
| 176 | let ctx = load_repo(cx, owner, name).await?; | 196 | let ctx = load_repo(cx, owner, name).await?; |
| 177 | let lang = i18n::lang(cx, ctx.viewer.as_ref().map(|(u, _)| u)); | 197 | let lang = i18n::lang(cx, ctx.viewer.as_ref().map(|(u, _)| u)); |
| 178 | let store = &app_context::<AppState>(cx).store; | 198 | let store = &app_context::<AppState>(cx).store; |
| @@ -184,7 +204,7 @@ async fn labels_page(cx: &Cx) -> Result<impl View> { | |||
| 184 | .collect(); | 204 | .collect(); |
| 185 | let frame = RepoFrame::new(&ctx, app_context::<AppState>(cx), "issues").await?; | 205 | let frame = RepoFrame::new(&ctx, app_context::<AppState>(cx), "issues").await?; |
| 186 | let title = frame.title.clone(); | 206 | let title = frame.title.clone(); |
| 187 | - let rows: Vec<LabelRow> = labels | 207 | + let all: Vec<LabelRow> = labels |
| 188 | .into_iter() | 208 | .into_iter() |
| 189 | .map(|label| { | 209 | .map(|label| { |
| 190 | let open = counts.get(&label.id).copied().unwrap_or(0); | 210 | let open = counts.get(&label.id).copied().unwrap_or(0); |
| @@ -200,13 +220,28 @@ async fn labels_page(cx: &Cx) -> Result<impl View> { | |||
| 200 | } | 220 | } |
| 201 | }) | 221 | }) |
| 202 | .collect(); | 222 | .collect(); |
| 223 | + let pages = all.len().div_ceil(PER_PAGE).max(1); | ||
| 224 | + let page = query | ||
| 225 | + .page | ||
| 226 | + .as_deref() | ||
| 227 | + .and_then(|p| p.parse::<usize>().ok()) | ||
| 228 | + .unwrap_or(1) | ||
| 229 | + .clamp(1, pages); | ||
| 230 | + let rows: Vec<LabelRow> = all | ||
| 231 | + .into_iter() | ||
| 232 | + .skip((page - 1) * PER_PAGE) | ||
| 233 | + .take(PER_PAGE) | ||
| 234 | + .collect(); | ||
| 235 | + let nav = pager_links(page as u64, pages as u64, |n| { | ||
| 236 | + format!("{}?page={n}", labels_href(&title)) | ||
| 237 | + }); | ||
| 203 | let live = list_live_url(&ctx.repo.owner_name, &ctx.repo.name); | 238 | let live = list_live_url(&ctx.repo.owner_name, &ctx.repo.name); |
| 204 | let css_href = format!("/{}/labels.css", frame.title); | 239 | let css_href = format!("/{}/labels.css", frame.title); |
| 205 | let page_title = g::labels_title(lang, &frame.title); | 240 | let page_title = g::labels_title(lang, &frame.title); |
| 206 | Ok(view! { | 241 | Ok(view! { |
| 207 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 242 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 208 | extra_stylesheet: Some(css_href.as_str()), | 243 | extra_stylesheet: Some(css_href.as_str()), |
| 209 | - labels_body(lang: lang, frame: frame, rows: rows, live: live)) | 244 | + labels_body(lang: lang, frame: frame, rows: rows, live: live, page: page as u64, pages: pages as u64, nav: nav)) |
| 210 | }) | 245 | }) |
| 211 | } | 246 | } |
| 212 | 247 | ||
crates/forge-web/src/pages/milestones_page.rsmodified+39 -5
| @@ -25,15 +25,20 @@ use crate::pages::repo::repo_head; | |||
| 25 | use crate::pages::repo_ctx::load_repo; | 25 | use crate::pages::repo_ctx::load_repo; |
| 26 | use crate::render::markdown::render_markdown; | 26 | use crate::render::markdown::render_markdown; |
| 27 | use crate::state::AppState; | 27 | use crate::state::AppState; |
| 28 | +use crate::views::repo_list::{PageLink, pager, pager_links}; | ||
| 28 | use crate::views::{empty_state, enc, shell}; | 29 | use crate::views::{empty_state, enc, shell}; |
| 29 | 30 | ||
| 30 | path_param!(owner); | 31 | path_param!(owner); |
| 31 | path_param!(repo); | 32 | path_param!(repo); |
| 32 | path_param!(milestone_id); | 33 | path_param!(milestone_id); |
| 33 | 34 | ||
| 35 | +/// Milestones per page. A milestone card is tall, so four fit the window beside the create form. | ||
| 36 | +const PER_PAGE: usize = 4; | ||
| 37 | + | ||
| 34 | #[query_params(error = bad_request)] | 38 | #[query_params(error = bad_request)] |
| 35 | struct MilestoneQuery { | 39 | struct MilestoneQuery { |
| 36 | state: Option<String>, | 40 | state: Option<String>, |
| 41 | + page: Option<String>, | ||
| 37 | } | 42 | } |
| 38 | 43 | ||
| 39 | /// The create form, and the edit form (which also sends `state`). | 44 | /// The create form, and the edit form (which also sends `state`). |
| @@ -196,7 +201,8 @@ async fn milestones_page(cx: &Cx) -> Result<impl View> { | |||
| 196 | let name = path_param::<Repo>(cx); | 201 | let name = path_param::<Repo>(cx); |
| 197 | let ctx = load_repo(cx, owner, name).await?; | 202 | let ctx = load_repo(cx, owner, name).await?; |
| 198 | let lang = i18n::lang(cx, ctx.viewer.as_ref().map(|(u, _)| u)); | 203 | let lang = i18n::lang(cx, ctx.viewer.as_ref().map(|(u, _)| u)); |
| 199 | - let closed = query_params::<MilestoneQuery>(cx)?.state.as_deref() == Some("closed"); | 204 | + let query = query_params::<MilestoneQuery>(cx)?; |
| 205 | + let closed = query.state.as_deref() == Some("closed"); | ||
| 200 | let state = if closed { | 206 | let state = if closed { |
| 201 | IssueState::Closed | 207 | IssueState::Closed |
| 202 | } else { | 208 | } else { |
| @@ -209,7 +215,7 @@ async fn milestones_page(cx: &Cx) -> Result<impl View> { | |||
| 209 | let frame = RepoFrame::new(&ctx, app_context::<AppState>(cx), "issues").await?; | 215 | let frame = RepoFrame::new(&ctx, app_context::<AppState>(cx), "issues").await?; |
| 210 | let today = today_in(ctx.viewer_tz()); | 216 | let today = today_in(ctx.viewer_tz()); |
| 211 | let title = frame.title.clone(); | 217 | let title = frame.title.clone(); |
| 212 | - let rows: Vec<MilestoneRow> = milestones | 218 | + let all: Vec<MilestoneRow> = milestones |
| 213 | .into_iter() | 219 | .into_iter() |
| 214 | .map(|m| { | 220 | .map(|m| { |
| 215 | let overdue = m.state == IssueState::Open | 221 | let overdue = m.state == IssueState::Open |
| @@ -228,6 +234,22 @@ async fn milestones_page(cx: &Cx) -> Result<impl View> { | |||
| 228 | } | 234 | } |
| 229 | }) | 235 | }) |
| 230 | .collect(); | 236 | .collect(); |
| 237 | + let pages = all.len().div_ceil(PER_PAGE).max(1); | ||
| 238 | + let page = query | ||
| 239 | + .page | ||
| 240 | + .as_deref() | ||
| 241 | + .and_then(|p| p.parse::<usize>().ok()) | ||
| 242 | + .unwrap_or(1) | ||
| 243 | + .clamp(1, pages); | ||
| 244 | + let rows: Vec<MilestoneRow> = all | ||
| 245 | + .into_iter() | ||
| 246 | + .skip((page - 1) * PER_PAGE) | ||
| 247 | + .take(PER_PAGE) | ||
| 248 | + .collect(); | ||
| 249 | + let state_name = if closed { "closed" } else { "open" }; | ||
| 250 | + let nav = pager_links(page as u64, pages as u64, |n| { | ||
| 251 | + format!("{}?state={state_name}&page={n}", milestones_href(&title)) | ||
| 252 | + }); | ||
| 231 | let empty = rows.is_empty(); | 253 | let empty = rows.is_empty(); |
| 232 | let page_title = g::milestones_title(lang, &frame.title); | 254 | let page_title = g::milestones_title(lang, &frame.title); |
| 233 | let csrf = frame.csrf.clone(); | 255 | let csrf = frame.csrf.clone(); |
| @@ -237,7 +259,8 @@ async fn milestones_page(cx: &Cx) -> Result<impl View> { | |||
| 237 | Ok(view! { | 259 | Ok(view! { |
| 238 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 260 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 239 | milestones_body(lang: lang, frame: frame, rows: rows, empty: empty, closed: closed, | 261 | milestones_body(lang: lang, frame: frame, rows: rows, empty: empty, closed: closed, |
| 240 | - csrf: csrf, can_create: can_create, create_action: create_action, live: live)) | 262 | + csrf: csrf, can_create: can_create, create_action: create_action, live: live, |
| 263 | + page: page as u64, pages: pages as u64, nav: nav)) | ||
| 241 | }) | 264 | }) |
| 242 | } | 265 | } |
| 243 | 266 | ||
| @@ -253,7 +276,11 @@ async fn milestones_body( | |||
| 253 | can_create: bool, | 276 | can_create: bool, |
| 254 | create_action: String, | 277 | create_action: String, |
| 255 | live: String, | 278 | live: String, |
| 279 | + page: u64, | ||
| 280 | + pages: u64, | ||
| 281 | + nav: (Vec<PageLink>, Option<String>, Option<String>), | ||
| 256 | ) -> Result<impl View> { | 282 | ) -> Result<impl View> { |
| 283 | + let (links, prev, next) = nav; | ||
| 257 | let title = frame.title.clone(); | 284 | let title = frame.title.clone(); |
| 258 | let can_triage = frame.can_triage; | 285 | let can_triage = frame.can_triage; |
| 259 | let row_csrf = csrf.clone(); | 286 | let row_csrf = csrf.clone(); |
| @@ -270,19 +297,26 @@ async fn milestones_body( | |||
| 270 | <section class="card notice" role="status">(g::t(lang, K::MilestonesArchived))</section> | 297 | <section class="card notice" role="status">(g::t(lang, K::MilestonesArchived))</section> |
| 271 | } | 298 | } |
| 272 | state_tabs(lang: lang, title: title.clone(), closed: closed) | 299 | state_tabs(lang: lang, title: title.clone(), closed: closed) |
| 273 | - <section class="card" data-live=(live.as_str()) data-live-now=""> | 300 | + <div class="fit-split"> |
| 301 | + <section class="card fit-pane fit-card fit-main" data-live=(live.as_str()) data-live-now=""> | ||
| 274 | if empty { | 302 | if empty { |
| 275 | empty_state(title: empty_text) | 303 | empty_state(title: empty_text) |
| 276 | } | 304 | } |
| 305 | + <div class="fit-scroll"> | ||
| 277 | <ul class="milestone-list"> | 306 | <ul class="milestone-list"> |
| 278 | for row in rows.into_iter() { | 307 | for row in rows.into_iter() { |
| 279 | milestone_row(lang: lang, row: row, csrf: row_csrf.clone(), can_triage: can_triage) | 308 | milestone_row(lang: lang, row: row, csrf: row_csrf.clone(), can_triage: can_triage) |
| 280 | } | 309 | } |
| 281 | </ul> | 310 | </ul> |
| 311 | + </div> | ||
| 312 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | ||
| 282 | </section> | 313 | </section> |
| 283 | if can_create { | 314 | if can_create { |
| 284 | - milestone_create_form(lang: lang, csrf: csrf.clone(), action: create_action) | 315 | + <div class="fit-side"> |
| 316 | + milestone_create_form(lang: lang, csrf: csrf.clone(), action: create_action) | ||
| 317 | + </div> | ||
| 285 | } | 318 | } |
| 319 | + </div> | ||
| 286 | }) | 320 | }) |
| 287 | } | 321 | } |
| 288 | 322 | ||
crates/forge-web/src/pages/notifications.rsmodified+47 -41
| @@ -1,5 +1,5 @@ | |||
| 1 | //! Notifications. The inbox at `GET /notifications` (Unread by default, `?all=1` for everything, | 1 | //! Notifications. The inbox at `GET /notifications` (Unread by default, `?all=1` for everything, |
| 2 | -//! grouped by repo, 50 rows a page with a `?before=` cursor) and its routes: open a row, mark a | 2 | +//! grouped by repo, 8 rows a page with a `?before=` cursor) and its routes: open a row, mark a |
| 3 | //! row or a whole repo or inbox read, toggle the subscription on an issue or pull, and set the | 3 | //! row or a whole repo or inbox read, toggle the subscription on an issue or pull, and set the |
| 4 | //! repo watch level. Rows for repos the viewer can no longer read are hidden and marked read. | 4 | //! repo watch level. Rows for repos the viewer can no longer read are hidden and marked read. |
| 5 | //! The sidebar box and the watch form are shared with the issue, pull and repo header views. | 5 | //! The sidebar box and the watch form are shared with the issue, pull and repo header views. |
| @@ -37,8 +37,10 @@ use crate::pages::star::return_path; | |||
| 37 | use crate::state::AppState; | 37 | use crate::state::AppState; |
| 38 | use crate::views::{csrf_field, display_name, empty_state, iso_time, now_unix, relative_time, repo_href, shell}; | 38 | use crate::views::{csrf_field, display_name, empty_state, iso_time, now_unix, relative_time, repo_href, shell}; |
| 39 | 39 | ||
| 40 | -/// Rows per inbox page. | 40 | +/// Rows per inbox page: a group head and its rows, with the older link, fit the window's height |
| 41 | -const PAGE_SIZE: u32 = 50; | 41 | +/// (about 44px a row and 62px a group head at 1440×900). The list scrolls inside its pane when a page |
| 42 | +/// of many small groups is taller still. | ||
| 43 | +const PAGE_SIZE: u32 = 8; | ||
| 42 | 44 | ||
| 43 | path_param!(owner); | 45 | path_param!(owner); |
| 44 | path_param!(repo); | 46 | path_param!(repo); |
| @@ -1135,44 +1137,48 @@ async fn inbox_list( | |||
| 1135 | <a href="/notifications?all=1" class=(all_class)>(g::t(lang, K::AllTab))</a> | 1137 | <a href="/notifications?all=1" class=(all_class)>(g::t(lang, K::AllTab))</a> |
| 1136 | <a href="/review-requests">(crate::i18n::authoring::t(lang, crate::i18n::authoring::K::ReviewRequestsTab))</a> | 1138 | <a href="/review-requests">(crate::i18n::authoring::t(lang, crate::i18n::authoring::K::ReviewRequestsTab))</a> |
| 1137 | </nav> | 1139 | </nav> |
| 1138 | - if empty { | 1140 | + // The groups and the older link share one pane that fits the window, so the page itself does |
| 1139 | - empty_state(title: empty_text, | 1141 | + // not scroll; the older link ends the pane. |
| 1140 | - if !all { | 1142 | + <div class="notif-pane fit-pane"> |
| 1141 | - <a class="button" href="/notifications?all=1">(g::t(lang, K::ViewAllNotifications))</a> | 1143 | + if empty { |
| 1142 | - }) | 1144 | + empty_state(title: empty_text, |
| 1143 | - } | 1145 | + if !all { |
| 1144 | - for group in groups.into_iter() { | 1146 | + <a class="button" href="/notifications?all=1">(g::t(lang, K::ViewAllNotifications))</a> |
| 1145 | - <section class="card notif-group"> | 1147 | + }) |
| 1146 | - <header class="notif-group-head"> | 1148 | + } |
| 1147 | - <a class="notif-repo" href=(group.href.as_str())>(group.heading.as_str())</a> | 1149 | + for group in groups.into_iter() { |
| 1148 | - <form method="post" action=(group.mark_action.as_str()) class="notif-inline-form"> | 1150 | + <section class="card notif-group"> |
| 1149 | - csrf_field(token: csrf.as_str()) | 1151 | + <header class="notif-group-head"> |
| 1150 | - <button type="submit" class="link-button">(g::t(lang, K::MarkAllRead))</button> | 1152 | + <a class="notif-repo" href=(group.href.as_str())>(group.heading.as_str())</a> |
| 1151 | - </form> | 1153 | + <form method="post" action=(group.mark_action.as_str()) class="notif-inline-form"> |
| 1152 | - </header> | 1154 | + csrf_field(token: csrf.as_str()) |
| 1153 | - <ul class="notif-list"> | 1155 | + <button type="submit" class="link-button">(g::t(lang, K::MarkAllRead))</button> |
| 1154 | - for row in group.rows.into_iter() { | 1156 | + </form> |
| 1155 | - <li class=(row.item_class)> | 1157 | + </header> |
| 1156 | - <span class=(row.icon_class) aria-hidden="true"></span> | 1158 | + <ul class="notif-list"> |
| 1157 | - <span class="notif-sr">(row.kind_label)</span> | 1159 | + for row in group.rows.into_iter() { |
| 1158 | - <a class="notif-title" href=(row.open_href.as_str())>(row.title_line.as_str())</a> | 1160 | + <li class=(row.item_class)> |
| 1159 | - <span class="badge">(row.reason)</span> | 1161 | + <span class=(row.icon_class) aria-hidden="true"></span> |
| 1160 | - <span class="muted small">(row.activity.as_str())</span> | 1162 | + <span class="notif-sr">(row.kind_label)</span> |
| 1161 | - <time class="muted small" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | 1163 | + <a class="notif-title" href=(row.open_href.as_str())>(row.title_line.as_str())</a> |
| 1162 | - if row.unread { | 1164 | + <span class="badge">(row.reason)</span> |
| 1163 | - <form method="post" action=(row.read_action.as_str()) class="notif-inline-form"> | 1165 | + <span class="muted small">(row.activity.as_str())</span> |
| 1164 | - csrf_field(token: csrf.as_str()) | 1166 | + <time class="muted small" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 1165 | - <button type="submit" class="link-button">(g::t(lang, K::MarkRead))</button> | 1167 | + if row.unread { |
| 1166 | - </form> | 1168 | + <form method="post" action=(row.read_action.as_str()) class="notif-inline-form"> |
| 1167 | - } | 1169 | + csrf_field(token: csrf.as_str()) |
| 1168 | - </li> | 1170 | + <button type="submit" class="link-button">(g::t(lang, K::MarkRead))</button> |
| 1169 | - } | 1171 | + </form> |
| 1170 | - </ul> | 1172 | + } |
| 1171 | - </section> | 1173 | + </li> |
| 1172 | - } | 1174 | + } |
| 1173 | - if let Some(href) = more { | 1175 | + </ul> |
| 1174 | - <p class="notif-more"><a class="button" href=(href.as_str())>(g::t(lang, K::Older))</a></p> | 1176 | + </section> |
| 1175 | - } | 1177 | + } |
| 1178 | + if let Some(href) = more { | ||
| 1179 | + <p class="notif-more"><a class="button" href=(href.as_str())>(g::t(lang, K::Older))</a></p> | ||
| 1180 | + } | ||
| 1181 | + </div> | ||
| 1176 | }) | 1182 | }) |
| 1177 | } | 1183 | } |
| 1178 | 1184 | ||
crates/forge-web/src/pages/org_ctx.rsmodified+35 -0
| @@ -6,6 +6,7 @@ | |||
| 6 | //! membership is not revealed. A member who is not an owner gets 403 on the owner-only actions. | 6 | //! membership is not revealed. A member who is not an owner gets 403 on the owner-only actions. |
| 7 | 7 | ||
| 8 | use forge_core::store::orgs::OrgMemberRole; | 8 | use forge_core::store::orgs::OrgMemberRole; |
| 9 | +use forge_core::store::repo_listing::RepoScope; | ||
| 9 | use forge_core::{Role, Session, User}; | 10 | use forge_core::{Role, Session, User}; |
| 10 | use topcoat::Result; | 11 | use topcoat::Result; |
| 11 | use topcoat::context::{Cx, app_context}; | 12 | use topcoat::context::{Cx, app_context}; |
| @@ -16,7 +17,10 @@ use topcoat::view::{View, component, view}; | |||
| 16 | use crate::auth::{check_csrf, require_user}; | 17 | use crate::auth::{check_csrf, require_user}; |
| 17 | use crate::i18n::Lang; | 18 | use crate::i18n::Lang; |
| 18 | use crate::i18n::orgs::{self as g, K}; | 19 | use crate::i18n::orgs::{self as g, K}; |
| 20 | +use crate::pages::packages; | ||
| 21 | +use crate::pages::profile::profile_tabs; | ||
| 19 | use crate::state::AppState; | 22 | use crate::state::AppState; |
| 23 | +use crate::views::profile_items; | ||
| 20 | 24 | ||
| 21 | /// The query key that carries a notice on an org page. Its value is one of the fixed words in | 25 | /// The query key that carries a notice on an org page. Its value is one of the fixed words in |
| 22 | /// `NOTICES`, never user text. The notice lives in the URL, not in a cookie: a live refresh of the | 26 | /// `NOTICES`, never user text. The notice lives in the URL, not in a cookie: a live refresh of the |
| @@ -197,6 +201,37 @@ pub async fn org_head(name: String, description: String) -> Result<impl View> { | |||
| 197 | }) | 201 | }) |
| 198 | } | 202 | } |
| 199 | 203 | ||
| 204 | +/// The counts on an organization's tab labels: the repos the viewer may read and the packages the | ||
| 205 | +/// viewer may see, as the profile counts them. | ||
| 206 | +pub async fn org_tab_counts(state: &AppState, org: &User, viewer: &User) -> Result<(u64, usize)> { | ||
| 207 | + let repos = state | ||
| 208 | + .store | ||
| 209 | + .count_visible_repos(RepoScope::OwnedBy(&org.id), Some(viewer)) | ||
| 210 | + .await?; | ||
| 211 | + let packages = packages::package_rows(state, Some(viewer), org).await?.len(); | ||
| 212 | + Ok((repos, packages)) | ||
| 213 | +} | ||
| 214 | + | ||
| 215 | +/// The profile tab bar on an organization's member pages (members, teams). Only members reach | ||
| 216 | +/// them, so the Members and Teams tabs are always listed, and `current` marks the page's own. | ||
| 217 | +#[component] | ||
| 218 | +pub async fn org_tabs( | ||
| 219 | + lang: Lang, | ||
| 220 | + name: String, | ||
| 221 | + current: String, | ||
| 222 | + repo_count: u64, | ||
| 223 | + package_count: usize, | ||
| 224 | +) -> Result<impl View> { | ||
| 225 | + let items = profile_items(lang, &name, true, false, true); | ||
| 226 | + let counts = vec![ | ||
| 227 | + ("repositories", repo_count.to_string()), | ||
| 228 | + ("packages", package_count.to_string()), | ||
| 229 | + ]; | ||
| 230 | + Ok(view! { | ||
| 231 | + profile_tabs(username: name, items: items, current: current, counts: counts) | ||
| 232 | + }) | ||
| 233 | +} | ||
| 234 | + | ||
| 200 | /// The notice banner: an error alert, or a status line. | 235 | /// The notice banner: an error alert, or a status line. |
| 201 | #[component] | 236 | #[component] |
| 202 | pub async fn org_notice(notice: Option<(&'static str, bool)>) -> Result<impl View> { | 237 | pub async fn org_notice(notice: Option<(&'static str, bool)>) -> Result<impl View> { |
crates/forge-web/src/pages/org_members.rsmodified+9 -4
| @@ -19,8 +19,8 @@ use crate::audit::{self, Actor, Target}; | |||
| 19 | use crate::i18n::orgs::{self as g, K}; | 19 | use crate::i18n::orgs::{self as g, K}; |
| 20 | use crate::i18n::{self, Lang}; | 20 | use crate::i18n::{self, Lang}; |
| 21 | use crate::pages::org_ctx::{ | 21 | use crate::pages::org_ctx::{ |
| 22 | - load_org, member_role_word, notice_href, org_head, org_notice, parse_member_role, | 22 | + load_org, member_role_word, notice_href, org_head, org_notice, org_tab_counts, org_tabs, |
| 23 | - require_form_csrf, require_member, require_owner, take_notice, | 23 | + parse_member_role, require_form_csrf, require_member, require_owner, take_notice, |
| 24 | }; | 24 | }; |
| 25 | use crate::pages::passkeys; | 25 | use crate::pages::passkeys; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| @@ -79,13 +79,16 @@ async fn members_body( | |||
| 79 | notice: Option<(&'static str, bool)>, | 79 | notice: Option<(&'static str, bool)>, |
| 80 | lang: Lang, | 80 | lang: Lang, |
| 81 | live: String, | 81 | live: String, |
| 82 | + repo_count: u64, | ||
| 83 | + package_count: usize, | ||
| 82 | ) -> Result<impl View> { | 84 | ) -> Result<impl View> { |
| 83 | let role_action = format!("{base}/members/role"); | 85 | let role_action = format!("{base}/members/role"); |
| 84 | let remove_action = format!("{base}/members/remove"); | 86 | let remove_action = format!("{base}/members/remove"); |
| 85 | let add_action = format!("{base}/members/add"); | 87 | let add_action = format!("{base}/members/add"); |
| 86 | Ok(view! { | 88 | Ok(view! { |
| 87 | <div data-live=(live.as_str())> | 89 | <div data-live=(live.as_str())> |
| 88 | - org_head(name: name, description: description) | 90 | + org_head(name: name.clone(), description: description) |
| 91 | + org_tabs(lang: lang, name: name, current: "members".to_owned(), repo_count: repo_count, package_count: package_count) | ||
| 89 | org_notice(notice: notice) | 92 | org_notice(notice: notice) |
| 90 | <section class="card"> | 93 | <section class="card"> |
| 91 | <h2>(g::t(lang, K::Members))</h2> | 94 | <h2>(g::t(lang, K::Members))</h2> |
| @@ -196,10 +199,12 @@ async fn org_members_page(cx: &Cx) -> Result<impl View> { | |||
| 196 | let base = ctx.href(""); | 199 | let base = ctx.href(""); |
| 197 | let csrf = ctx.viewer.1.csrf_token.clone(); | 200 | let csrf = ctx.viewer.1.csrf_token.clone(); |
| 198 | let live = ctx.href("/members/events"); | 201 | let live = ctx.href("/members/events"); |
| 202 | + let (repo_count, package_count) = org_tab_counts(state, &ctx.org, &ctx.viewer.0).await?; | ||
| 199 | Ok(view! { cx => | 203 | Ok(view! { cx => |
| 200 | shell(title: title.as_str(), viewer: Some(&ctx.viewer), | 204 | shell(title: title.as_str(), viewer: Some(&ctx.viewer), |
| 201 | members_body(name: name, description: description, base: base, owner: owner, | 205 | members_body(name: name, description: description, base: base, owner: owner, |
| 202 | - rows: rows, csrf: csrf, notice: notice, lang: lang, live: live)) | 206 | + rows: rows, csrf: csrf, notice: notice, lang: lang, live: live, |
| 207 | + repo_count: repo_count, package_count: package_count)) | ||
| 203 | }) | 208 | }) |
| 204 | } | 209 | } |
| 205 | 210 | ||
crates/forge-web/src/pages/org_teams.rsmodified+17 -5
| @@ -19,8 +19,8 @@ use crate::audit::{self, Actor, Target}; | |||
| 19 | use crate::i18n::orgs::{self as g, K}; | 19 | use crate::i18n::orgs::{self as g, K}; |
| 20 | use crate::i18n::{self, Lang}; | 20 | use crate::i18n::{self, Lang}; |
| 21 | use crate::pages::org_ctx::{ | 21 | use crate::pages::org_ctx::{ |
| 22 | - OrgCtx, TEAM_ROLES, load_org, notice_href, org_head, org_notice, require_form_csrf, | 22 | + OrgCtx, TEAM_ROLES, load_org, notice_href, org_head, org_notice, org_tab_counts, org_tabs, |
| 23 | - require_member, require_owner, take_notice, | 23 | + require_form_csrf, require_member, require_owner, take_notice, |
| 24 | }; | 24 | }; |
| 25 | use crate::pages::passkeys; | 25 | use crate::pages::passkeys; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| @@ -122,6 +122,9 @@ struct TeamPage { | |||
| 122 | members: Vec<TeamMemberRow>, | 122 | members: Vec<TeamMemberRow>, |
| 123 | repos: Vec<TeamRepoRow>, | 123 | repos: Vec<TeamRepoRow>, |
| 124 | choices: Vec<RepoChoice>, | 124 | choices: Vec<RepoChoice>, |
| 125 | + /// The counts on the org's tab bar. | ||
| 126 | + repo_count: u64, | ||
| 127 | + package_count: usize, | ||
| 125 | } | 128 | } |
| 126 | 129 | ||
| 127 | /// The role a form sent, if it is one a team may carry. | 130 | /// The role a form sent, if it is one a team may carry. |
| @@ -189,11 +192,14 @@ async fn teams_body( | |||
| 189 | notice: Option<(&'static str, bool)>, | 192 | notice: Option<(&'static str, bool)>, |
| 190 | lang: Lang, | 193 | lang: Lang, |
| 191 | live: String, | 194 | live: String, |
| 195 | + repo_count: u64, | ||
| 196 | + package_count: usize, | ||
| 192 | ) -> Result<impl View> { | 197 | ) -> Result<impl View> { |
| 193 | let create_action = format!("{base}/teams/new"); | 198 | let create_action = format!("{base}/teams/new"); |
| 194 | Ok(view! { | 199 | Ok(view! { |
| 195 | - <div data-live=(live.as_str())> | 200 | + <div data-live=(live.as_str()) class="teams-page"> |
| 196 | - org_head(name: name, description: description) | 201 | + org_head(name: name.clone(), description: description) |
| 202 | + org_tabs(lang: lang, name: name, current: "teams".to_owned(), repo_count: repo_count, package_count: package_count) | ||
| 197 | org_notice(notice: notice) | 203 | org_notice(notice: notice) |
| 198 | <section class="card"> | 204 | <section class="card"> |
| 199 | <h2>(g::t(lang, K::Teams))</h2> | 205 | <h2>(g::t(lang, K::Teams))</h2> |
| @@ -280,10 +286,12 @@ async fn org_teams_page(cx: &Cx) -> Result<impl View> { | |||
| 280 | let base = ctx.href(""); | 286 | let base = ctx.href(""); |
| 281 | let csrf = ctx.viewer.1.csrf_token.clone(); | 287 | let csrf = ctx.viewer.1.csrf_token.clone(); |
| 282 | let live = ctx.href("/teams/events"); | 288 | let live = ctx.href("/teams/events"); |
| 289 | + let (repo_count, package_count) = org_tab_counts(state, &ctx.org, &ctx.viewer.0).await?; | ||
| 283 | Ok(view! { cx => | 290 | Ok(view! { cx => |
| 284 | shell(title: title.as_str(), viewer: Some(&ctx.viewer), | 291 | shell(title: title.as_str(), viewer: Some(&ctx.viewer), |
| 285 | teams_body(name: name, description: description, base: base, owner: owner, | 292 | teams_body(name: name, description: description, base: base, owner: owner, |
| 286 | - csrf: csrf, rows: rows, notice: notice, lang: lang, live: live)) | 293 | + csrf: csrf, rows: rows, notice: notice, lang: lang, live: live, |
| 294 | + repo_count: repo_count, package_count: package_count)) | ||
| 287 | }) | 295 | }) |
| 288 | } | 296 | } |
| 289 | 297 | ||
| @@ -307,6 +315,7 @@ async fn team_body( | |||
| 307 | Ok(view! { | 315 | Ok(view! { |
| 308 | <div data-live=(data.live.as_str())> | 316 | <div data-live=(data.live.as_str())> |
| 309 | org_head(name: data.org_name.clone(), description: data.org_description.clone()) | 317 | org_head(name: data.org_name.clone(), description: data.org_description.clone()) |
| 318 | + org_tabs(lang: lang, name: data.org_name.clone(), current: "teams".to_owned(), repo_count: data.repo_count, package_count: data.package_count) | ||
| 310 | org_notice(notice: notice) | 319 | org_notice(notice: notice) |
| 311 | <section class="card"> | 320 | <section class="card"> |
| 312 | <h2>(data.team_name.as_str())</h2> | 321 | <h2>(data.team_name.as_str())</h2> |
| @@ -468,7 +477,10 @@ async fn org_team_page(cx: &Cx) -> Result<impl View> { | |||
| 468 | }) | 477 | }) |
| 469 | .collect(); | 478 | .collect(); |
| 470 | let title = format!("{} \u{b7} {}", ctx.org.username, team.name); | 479 | let title = format!("{} \u{b7} {}", ctx.org.username, team.name); |
| 480 | + let (repo_count, package_count) = org_tab_counts(state, &ctx.org, &ctx.viewer.0).await?; | ||
| 471 | let data = TeamPage { | 481 | let data = TeamPage { |
| 482 | + repo_count, | ||
| 483 | + package_count, | ||
| 472 | org_name: ctx.org.username.clone(), | 484 | org_name: ctx.org.username.clone(), |
| 473 | org_description: ctx.org.about.clone(), | 485 | org_description: ctx.org.about.clone(), |
| 474 | base: ctx.href(&format!("/teams/{}", team.id)), | 486 | base: ctx.href(&format!("/teams/{}", team.id)), |
crates/forge-web/src/pages/palette.rsmodified+90 -16
| @@ -1,8 +1,14 @@ | |||
| 1 | -//! The command palette's destinations: `GET /-/palette` lists what the signed-in viewer can jump to, | 1 | +//! 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 (Explore, notifications, snippets, new | 2 | +//! Their repos, the orgs they belong to with that org's members, teams and (for owners) settings, |
| 3 | -//! repository and settings, and for admins the admin pages). The palette itself, its filtering and keys live in | 3 | +//! and the pages the navigation links to: their own profile's tabs, the fixed site pages and the |
| 4 | -//! `assets/nav.js`. | 4 | +//! settings and admin pages. Those pages come from the same lists the navigation is built from |
| 5 | +//! (`views::profile_items`, `views::global_items`, `views::settings_items`, `views::admin_items`), | ||
| 6 | +//! so a page the sidebar or a tab bar links to is found here too. Each href is listed once, the | ||
| 7 | +//! first time it appears. The palette itself, its filtering and keys live in `assets/nav.js`. | ||
| 5 | 8 | ||
| 9 | +use std::collections::HashSet; | ||
| 10 | + | ||
| 11 | +use forge_core::store::orgs::OrgMemberRole; | ||
| 6 | use http::header::{CACHE_CONTROL, CONTENT_TYPE, X_CONTENT_TYPE_OPTIONS}; | 12 | use http::header::{CACHE_CONTROL, CONTENT_TYPE, X_CONTENT_TYPE_OPTIONS}; |
| 7 | use serde_json::{Value, json}; | 13 | use serde_json::{Value, json}; |
| 8 | use topcoat::Result; | 14 | use topcoat::Result; |
| @@ -11,10 +17,13 @@ use topcoat::router::response::Response; | |||
| 11 | use topcoat::router::{Body, HeaderValue, StatusCode, route}; | 17 | use topcoat::router::{Body, HeaderValue, StatusCode, route}; |
| 12 | 18 | ||
| 13 | use crate::auth::current_user; | 19 | use crate::auth::current_user; |
| 14 | -use crate::i18n::community::{self as cm, K as CK}; | 20 | +use crate::i18n::orgs::{self as g, K}; |
| 15 | -use crate::i18n::{self, Key, t}; | 21 | +use crate::i18n; |
| 22 | +use crate::pages::org_new::may_create_org; | ||
| 16 | use crate::state::AppState; | 23 | use crate::state::AppState; |
| 17 | -use crate::views::{admin_items, repo_href, settings_items, user_href}; | 24 | +use crate::views::{ |
| 25 | + admin_items, enc, global_items, profile_items, repo_href, settings_items, user_href, | ||
| 26 | +}; | ||
| 18 | 27 | ||
| 19 | /// Repos listed at most. The palette filters in the browser, so a longer list would only cost time. | 28 | /// Repos listed at most. The palette filters in the browser, so a longer list would only cost time. |
| 20 | pub const MAX_REPOS: u64 = 500; | 29 | pub const MAX_REPOS: u64 = 500; |
| @@ -24,6 +33,13 @@ fn destination(label: &str, href: &str, kind: &str) -> Value { | |||
| 24 | json!({ "label": label, "href": href, "kind": kind }) | 33 | json!({ "label": label, "href": href, "kind": kind }) |
| 25 | } | 34 | } |
| 26 | 35 | ||
| 36 | +/// Adds a destination unless its href is already listed. | ||
| 37 | +fn push(items: &mut Vec<Value>, seen: &mut HashSet<String>, label: &str, href: &str, kind: &str) { | ||
| 38 | + if seen.insert(href.to_owned()) { | ||
| 39 | + items.push(destination(label, href, kind)); | ||
| 40 | + } | ||
| 41 | +} | ||
| 42 | + | ||
| 27 | /// `{"items": [{"label", "href", "kind"}, ...]}` for the signed-in viewer. Anonymous visitors get | 43 | /// `{"items": [{"label", "href", "kind"}, ...]}` for the signed-in viewer. Anonymous visitors get |
| 28 | /// 401, as the other signed-in-only JSON routes do. | 44 | /// 401, as the other signed-in-only JSON routes do. |
| 29 | #[route(GET "/-/palette")] | 45 | #[route(GET "/-/palette")] |
| @@ -37,25 +53,38 @@ async fn palette(cx: &Cx) -> Result<Response> { | |||
| 37 | let lang = i18n::lang(cx, Some(&user)); | 53 | let lang = i18n::lang(cx, Some(&user)); |
| 38 | 54 | ||
| 39 | let mut items = Vec::new(); | 55 | let mut items = Vec::new(); |
| 56 | + let mut seen = HashSet::new(); | ||
| 40 | for repo in state.store.list_viewer_repos(&user, MAX_REPOS).await? { | 57 | for repo in state.store.list_viewer_repos(&user, MAX_REPOS).await? { |
| 41 | let label = format!("{}/{}", repo.owner_name, repo.name); | 58 | let label = format!("{}/{}", repo.owner_name, repo.name); |
| 42 | let href = repo_href(&repo.owner_name, &repo.name, "", ""); | 59 | let href = repo_href(&repo.owner_name, &repo.name, "", ""); |
| 43 | - items.push(destination(&label, &href, "repo")); | 60 | + push(&mut items, &mut seen, &label, &href, "repo"); |
| 44 | } | 61 | } |
| 45 | - for (org, _) in state.store.orgs_for_user(&user.id).await? { | 62 | + for (org, role) in state.store.orgs_for_user(&user.id).await? { |
| 46 | - items.push(destination(&org.username, &user_href(&org.username), "org")); | 63 | + let name = &org.username; |
| 64 | + let base = format!("/org/{}", enc(name)); | ||
| 65 | + push(&mut items, &mut seen, name, &user_href(name), "org"); | ||
| 66 | + let members = format!("{name} \u{b7} {}", g::t(lang, K::Members)); | ||
| 67 | + push(&mut items, &mut seen, &members, &format!("{base}/members"), "page"); | ||
| 68 | + let teams = format!("{name} \u{b7} {}", g::t(lang, K::Teams)); | ||
| 69 | + push(&mut items, &mut seen, &teams, &format!("{base}/teams"), "page"); | ||
| 70 | + if role == OrgMemberRole::Owner { | ||
| 71 | + let settings = format!("{name} \u{b7} {}", g::t(lang, K::Settings)); | ||
| 72 | + push(&mut items, &mut seen, &settings, &format!("{base}/settings"), "page"); | ||
| 73 | + } | ||
| 47 | } | 74 | } |
| 48 | 75 | ||
| 49 | - items.push(destination(t(lang, Key::Explore), "/explore", "page")); | 76 | + for item in profile_items(lang, &user.username, false, true, false) { |
| 50 | - items.push(destination(t(lang, Key::Notifications), "/notifications", "page")); | 77 | + push(&mut items, &mut seen, item.label, &item.href, "page"); |
| 51 | - items.push(destination(cm::t(lang, CK::Snippets), "/snippets", "page")); | 78 | + } |
| 52 | - items.push(destination(t(lang, Key::NewRepository), "/new", "page")); | 79 | + for item in global_items(lang, may_create_org(state, &user)) { |
| 80 | + push(&mut items, &mut seen, item.label, &item.href, "page"); | ||
| 81 | + } | ||
| 53 | for item in settings_items(lang) { | 82 | for item in settings_items(lang) { |
| 54 | - items.push(destination(item.label, &item.href, "page")); | 83 | + push(&mut items, &mut seen, item.label, &item.href, "page"); |
| 55 | } | 84 | } |
| 56 | if user.is_admin { | 85 | if user.is_admin { |
| 57 | for item in admin_items(lang) { | 86 | for item in admin_items(lang) { |
| 58 | - items.push(destination(item.label, &item.href, "page")); | 87 | + push(&mut items, &mut seen, item.label, &item.href, "page"); |
| 59 | } | 88 | } |
| 60 | } | 89 | } |
| 61 | 90 | ||
| @@ -70,3 +99,48 @@ async fn palette(cx: &Cx) -> Result<Response> { | |||
| 70 | headers.insert(X_CONTENT_TYPE_OPTIONS, HeaderValue::from_static("nosniff")); | 99 | headers.insert(X_CONTENT_TYPE_OPTIONS, HeaderValue::from_static("nosniff")); |
| 71 | Ok(response) | 100 | Ok(response) |
| 72 | } | 101 | } |
| 102 | + | ||
| 103 | +#[cfg(test)] | ||
| 104 | +mod tests { | ||
| 105 | + use topcoat::router::request::Request; | ||
| 106 | + use topcoat::router::{Body, to_bytes}; | ||
| 107 | + | ||
| 108 | + use crate::auth::SESSION_COOKIE; | ||
| 109 | + use crate::i18n::Lang; | ||
| 110 | + use crate::views::profile_items; | ||
| 111 | + | ||
| 112 | + /// Every tab of the viewer's own profile is in the palette, so a tab is found by its name. | ||
| 113 | + #[tokio::test] | ||
| 114 | + async fn palette_lists_every_profile_tab() { | ||
| 115 | + let dir = tempfile::tempdir().expect("tempdir"); | ||
| 116 | + let state = crate::test_support::test_state(dir.path()).await; | ||
| 117 | + let store = state.store.clone(); | ||
| 118 | + let router = crate::test_support::app_router(state); | ||
| 119 | + let tahinli = store | ||
| 120 | + .create_user("tahinli", None, "not-a-real-hash", false) | ||
| 121 | + .await | ||
| 122 | + .unwrap(); | ||
| 123 | + crate::test_support::create_session(&store, &tahinli.id, "palette-token", "palette-csrf") | ||
| 124 | + .await; | ||
| 125 | + let request = Request::builder() | ||
| 126 | + .method("GET") | ||
| 127 | + .uri("/-/palette") | ||
| 128 | + .header("cookie", format!("__Host-{SESSION_COOKIE}=palette-token")) | ||
| 129 | + .body(Body::empty()) | ||
| 130 | + .unwrap(); | ||
| 131 | + let res = router.handle(request).await; | ||
| 132 | + let bytes = to_bytes(res.into_body(), usize::MAX).await.unwrap(); | ||
| 133 | + let body: serde_json::Value = serde_json::from_slice(&bytes).unwrap(); | ||
| 134 | + let hrefs: Vec<&str> = body["items"] | ||
| 135 | + .as_array() | ||
| 136 | + .unwrap() | ||
| 137 | + .iter() | ||
| 138 | + .map(|item| item["href"].as_str().unwrap()) | ||
| 139 | + .collect(); | ||
| 140 | + let tabs = profile_items(Lang::En, "tahinli", false, true, false); | ||
| 141 | + assert!(!tabs.is_empty()); | ||
| 142 | + for tab in tabs { | ||
| 143 | + assert!(hrefs.contains(&tab.href.as_str()), "palette lacks {}", tab.href); | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | +} | ||
crates/forge-web/src/pages/profile.rsmodified+148 -60
| @@ -38,7 +38,9 @@ use crate::views::heatmap::{Calendar, DayDetail, contribution_calendar}; | |||
| 38 | use crate::views::repo_list::{ | 38 | use crate::views::repo_list::{ |
| 39 | PageLink, RepoRow, SortLink, badge_class, pager, pager_links, repo_rows, sort_chips, | 39 | PageLink, RepoRow, SortLink, badge_class, pager, pager_links, repo_rows, sort_chips, |
| 40 | }; | 40 | }; |
| 41 | -use crate::views::{avatar_url, empty_state, enc, now_unix, repo_href, shell}; | 41 | +use crate::views::{ |
| 42 | + NavItem, avatar_url, empty_state, enc, now_unix, profile_items, repo_href, shell, user_href, | ||
| 43 | +}; | ||
| 42 | 44 | ||
| 43 | path_param!(username); | 45 | path_param!(username); |
| 44 | 46 | ||
| @@ -46,6 +48,8 @@ path_param!(username); | |||
| 46 | const PER_PAGE: u64 = 30; | 48 | const PER_PAGE: u64 = 30; |
| 47 | /// Repos the overview shows when the owner has no visible pins. | 49 | /// Repos the overview shows when the owner has no visible pins. |
| 48 | const POPULAR_COUNT: usize = 6; | 50 | const POPULAR_COUNT: usize = 6; |
| 51 | +/// Members an organization's overview lists; a longer list links to the members page. | ||
| 52 | +const ORG_MEMBERS_SHOWN: usize = 12; | ||
| 49 | /// Longest name filter kept, in characters. | 53 | /// Longest name filter kept, in characters. |
| 50 | const MAX_QUERY_CHARS: usize = 100; | 54 | const MAX_QUERY_CHARS: usize = 100; |
| 51 | 55 | ||
| @@ -282,14 +286,20 @@ async fn profile_page(cx: &Cx) -> Result<impl View> { | |||
| 282 | _ => Listing::default(), | 286 | _ => Listing::default(), |
| 283 | }; | 287 | }; |
| 284 | 288 | ||
| 285 | - // An organization shows its members and how many teams it has. Its `about` is its description. | 289 | + // An organization shows its members (the first few, with their avatars) and how many teams it |
| 290 | + // has. Its `about` is its description. | ||
| 286 | let org = if user.is_org() { | 291 | let org = if user.is_org() { |
| 287 | let members = state.store.org_members(&user.id).await?; | 292 | let members = state.store.org_members(&user.id).await?; |
| 288 | let teams = state.store.teams_for_org(&user.id).await?.len(); | 293 | let teams = state.store.teams_for_org(&user.id).await?.len(); |
| 289 | Some(OrgSummary { | 294 | Some(OrgSummary { |
| 295 | + total: members.len(), | ||
| 290 | members: members | 296 | members: members |
| 291 | .into_iter() | 297 | .into_iter() |
| 292 | - .map(|(member, _)| member.username) | 298 | + .take(ORG_MEMBERS_SHOWN) |
| 299 | + .map(|(member, _)| OrgMember { | ||
| 300 | + avatar: avatar_url(&member.username, member.avatar_hash.as_deref()), | ||
| 301 | + username: member.username, | ||
| 302 | + }) | ||
| 293 | .collect(), | 303 | .collect(), |
| 294 | teams, | 304 | teams, |
| 295 | }) | 305 | }) |
| @@ -412,12 +422,20 @@ async fn profile_fingerprint( | |||
| 412 | Ok(lines.join("\n")) | 422 | Ok(lines.join("\n")) |
| 413 | } | 423 | } |
| 414 | 424 | ||
| 415 | -/// What an organization's profile adds: its member names and its team count. | 425 | +/// What an organization's profile adds: its member count, the first members to list, and its team |
| 426 | +/// count. | ||
| 416 | struct OrgSummary { | 427 | struct OrgSummary { |
| 417 | - members: Vec<String>, | 428 | + total: usize, |
| 429 | + members: Vec<OrgMember>, | ||
| 418 | teams: usize, | 430 | teams: usize, |
| 419 | } | 431 | } |
| 420 | 432 | ||
| 433 | +/// A member on an organization's overview: the login name and the avatar URL. | ||
| 434 | +struct OrgMember { | ||
| 435 | + username: String, | ||
| 436 | + avatar: String, | ||
| 437 | +} | ||
| 438 | + | ||
| 421 | /// A repo card on the overview: the repo and its star count. | 439 | /// A repo card on the overview: the repo and its star count. |
| 422 | struct PinCard { | 440 | struct PinCard { |
| 423 | repo: Repo, | 441 | repo: Repo, |
| @@ -553,30 +571,41 @@ async fn profile_card( | |||
| 553 | orgs: Vec<OrgCard>, | 571 | orgs: Vec<OrgCard>, |
| 554 | org_create_allowed: bool, | 572 | org_create_allowed: bool, |
| 555 | ) -> Result<impl View> { | 573 | ) -> Result<impl View> { |
| 556 | - 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(); | 574 | let has_snippets = !snippets.is_empty(); |
| 559 | let snippets_on = tab == "snippets"; | 575 | let snippets_on = tab == "snippets"; |
| 560 | - let snippets_href = profile_href(&user.username, "snippets", "", SORTS[0].0, 1); | ||
| 561 | let orgs_on = tab == "organizations"; | 576 | 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(); | 577 | let has_orgs = !orgs.is_empty(); |
| 564 | - let packages_href = profile_href(&user.username, "packages", "", SORTS[0].0, 1); | ||
| 565 | let packages_events = packages::events_href(&user.username); | 578 | let packages_events = packages::events_href(&user.username); |
| 566 | let has_packages = !package_rows.is_empty(); | 579 | let has_packages = !package_rows.is_empty(); |
| 567 | let src = avatar_url(&user.username, avatar.as_deref()); | 580 | let src = avatar_url(&user.username, avatar.as_deref()); |
| 568 | let has_about = !about_html.is_empty(); | 581 | let has_about = !about_html.is_empty(); |
| 569 | let is_org = user.is_org(); | 582 | let is_org = user.is_org(); |
| 583 | + // An organization's header avatar is smaller. The tab bar comes from the shared list, with the | ||
| 584 | + // counts that go on its labels. | ||
| 585 | + let avatar_px = if is_org { "96" } else { "256" }; | ||
| 586 | + let avatar_class = if is_org { | ||
| 587 | + "profile-avatar org-avatar" | ||
| 588 | + } else { | ||
| 589 | + "profile-avatar" | ||
| 590 | + }; | ||
| 591 | + let tab_items: Vec<NavItem> = | ||
| 592 | + profile_items(lang, &user.username, is_org, own_profile, org_member); | ||
| 593 | + let tab_counts = vec![ | ||
| 594 | + ("repositories", repo_total.to_string()), | ||
| 595 | + ("snippets", snippets.len().to_string()), | ||
| 596 | + ("stars", star_total.to_string()), | ||
| 597 | + ("packages", package_rows.len().to_string()), | ||
| 598 | + ]; | ||
| 570 | let base = format!("/{}", enc(&user.username)); | 599 | let base = format!("/{}", enc(&user.username)); |
| 571 | let overview_on = tab == "overview"; | 600 | let overview_on = tab == "overview"; |
| 601 | + let overview_class = if is_org { | ||
| 602 | + "org-overview" | ||
| 603 | + } else { | ||
| 604 | + "profile-overview" | ||
| 605 | + }; | ||
| 572 | let repos_on = tab == "repositories"; | 606 | let repos_on = tab == "repositories"; |
| 573 | let stars_on = tab == "stars"; | 607 | let stars_on = tab == "stars"; |
| 574 | let list_on = repos_on || stars_on; | 608 | let list_on = repos_on || stars_on; |
| 575 | - let overview_href = profile_href(&user.username, "overview", "", SORTS[0].0, 1); | ||
| 576 | - let repositories_href = profile_href(&user.username, "repositories", "", SORTS[0].0, 1); | ||
| 577 | - let stars_href = profile_href(&user.username, "stars", "", SORTS[0].0, 1); | ||
| 578 | - let repo_count_text = repo_total.to_string(); | ||
| 579 | - let star_count_text = star_total.to_string(); | ||
| 580 | let pinned_heading = if from_pins { | 609 | let pinned_heading = if from_pins { |
| 581 | g::t(lang, K::Pinned) | 610 | g::t(lang, K::Pinned) |
| 582 | } else { | 611 | } else { |
| @@ -584,6 +613,7 @@ async fn profile_card( | |||
| 584 | }; | 613 | }; |
| 585 | let has_cards = !cards.is_empty(); | 614 | let has_cards = !cards.is_empty(); |
| 586 | let edit_label = mi::t(lang, MK::EditProfile); | 615 | let edit_label = mi::t(lang, MK::EditProfile); |
| 616 | + let org_edit_label = mi::t(lang, MK::EditOrganization); | ||
| 587 | // The display name is the heading when set; the username then moves under it. | 617 | // The display name is the heading when set; the username then moves under it. |
| 588 | let has_name = user.display_name.is_some(); | 618 | let has_name = user.display_name.is_some(); |
| 589 | let heading = user | 619 | let heading = user |
| @@ -604,11 +634,10 @@ async fn profile_card( | |||
| 604 | let new_repo_href = format!("/new?owner={}", enc(&user.username)); | 634 | let new_repo_href = format!("/new?owner={}", enc(&user.username)); |
| 605 | let settings_href = format!("/org/{}/settings", enc(&user.username)); | 635 | let settings_href = format!("/org/{}/settings", enc(&user.username)); |
| 606 | let members_href = format!("/org/{}/members", enc(&user.username)); | 636 | let members_href = format!("/org/{}/members", enc(&user.username)); |
| 607 | - let teams_href = format!("/org/{}/teams", enc(&user.username)); | ||
| 608 | Ok(view! { | 637 | Ok(view! { |
| 609 | <article class="profile-page" data-live=(format!("/users/{}/events", user.username))> | 638 | <article class="profile-page" data-live=(format!("/users/{}/events", user.username))> |
| 610 | <header class="profile-head"> | 639 | <header class="profile-head"> |
| 611 | - <img class="profile-avatar" src=(src) alt="" width="256" height="256"> | 640 | + <img class=(avatar_class) src=(src) alt="" width=(avatar_px) height=(avatar_px)> |
| 612 | <div class="profile-id"> | 641 | <div class="profile-id"> |
| 613 | <h1>(heading)</h1> | 642 | <h1>(heading)</h1> |
| 614 | if has_name { | 643 | if has_name { |
| @@ -623,9 +652,14 @@ async fn profile_card( | |||
| 623 | if edit_profile { | 652 | if edit_profile { |
| 624 | <a class="button profile-edit" href="/settings/profile">(edit_label)</a> | 653 | <a class="button profile-edit" href="/settings/profile">(edit_label)</a> |
| 625 | } | 654 | } |
| 626 | - if is_org && org_can_create { | 655 | + if is_org && (org_owner || org_can_create) { |
| 627 | <div class="profile-org-actions"> | 656 | <div class="profile-org-actions"> |
| 628 | - <a class="button primary" href=(new_repo_href.as_str())>(g::t(lang, K::NewRepository))</a> | 657 | + if org_owner { |
| 658 | + <a class="button profile-edit" href=(settings_href.as_str())>(org_edit_label)</a> | ||
| 659 | + } | ||
| 660 | + if org_can_create { | ||
| 661 | + <a class="button primary" href=(new_repo_href.as_str())>(g::t(lang, K::NewRepository))</a> | ||
| 662 | + } | ||
| 629 | </div> | 663 | </div> |
| 630 | } | 664 | } |
| 631 | </div> | 665 | </div> |
| @@ -633,39 +667,12 @@ async fn profile_card( | |||
| 633 | if has_about { | 667 | if has_about { |
| 634 | <section class="profile-about markdown-body">(Unescaped::new_unchecked(about_html))</section> | 668 | <section class="profile-about markdown-body">(Unescaped::new_unchecked(about_html))</section> |
| 635 | } | 669 | } |
| 636 | - <nav class="profile-tabs" aria-label=(user.username.as_str())> | 670 | + profile_tabs(username: user.username.clone(), items: tab_items, current: tab.clone(), counts: tab_counts) |
| 637 | - <a class=(tab_class(overview_on)) href=(overview_href.as_str())>(g::t(lang, K::TabOverview))</a> | ||
| 638 | - <a class=(tab_class(repos_on)) href=(repositories_href.as_str())> | ||
| 639 | - (g::t(lang, K::Repositories)) " " <span class="tab-count">(repo_count_text.as_str())</span> | ||
| 640 | - </a> | ||
| 641 | - if !is_org { | ||
| 642 | - <a class=(tab_class(snippets_on)) href=(snippets_href.as_str())> | ||
| 643 | - (cm::t(lang, CK::Snippets)) " " <span class="tab-count">(snippet_count_text.as_str())</span> | ||
| 644 | - </a> | ||
| 645 | - } | ||
| 646 | - if !is_org { | ||
| 647 | - <a class=(tab_class(stars_on)) href=(stars_href.as_str())> | ||
| 648 | - (g::t(lang, K::TabStars)) " " <span class="tab-count">(star_count_text.as_str())</span> | ||
| 649 | - </a> | ||
| 650 | - } | ||
| 651 | - <a class=(tab_class(packages_on)) href=(packages_href.as_str())> | ||
| 652 | - (pk::t(lang, PK::TabPackages)) " " <span class="tab-count">(package_count_text.as_str())</span> | ||
| 653 | - </a> | ||
| 654 | - if own_profile { | ||
| 655 | - <a class=(tab_class(orgs_on)) href=(organizations_href.as_str())>(g::t(lang, K::Organizations))</a> | ||
| 656 | - } | ||
| 657 | - if org_member { | ||
| 658 | - <a class=(tab_class(false)) href=(members_href.as_str())>(g::t(lang, K::Members))</a> | ||
| 659 | - <a class=(tab_class(false)) href=(teams_href.as_str())>(g::t(lang, K::Teams))</a> | ||
| 660 | - } | ||
| 661 | - if org_owner { | ||
| 662 | - <a class=(tab_class(false)) href=(settings_href.as_str())>(g::t(lang, K::Settings))</a> | ||
| 663 | - } | ||
| 664 | - </nav> | ||
| 665 | if overview_on { | 671 | if overview_on { |
| 666 | if let Some((calendar, selected)) = heat { | 672 | if let Some((calendar, selected)) = heat { |
| 667 | contribution_calendar(calendar: calendar, selected: selected, lang: lang, base: base.clone()) | 673 | contribution_calendar(calendar: calendar, selected: selected, lang: lang, base: base.clone()) |
| 668 | } | 674 | } |
| 675 | + <div class=(overview_class)> | ||
| 669 | <section class="profile-pinned"> | 676 | <section class="profile-pinned"> |
| 670 | <div class="profile-section-head"> | 677 | <div class="profile-section-head"> |
| 671 | <h2>(pinned_heading)</h2> | 678 | <h2>(pinned_heading)</h2> |
| @@ -695,20 +702,31 @@ async fn profile_card( | |||
| 695 | } | 702 | } |
| 696 | </section> | 703 | </section> |
| 697 | if let Some(summary) = org { | 704 | if let Some(summary) = org { |
| 698 | - <section class="profile-org"> | 705 | + <section class="card profile-org"> |
| 699 | - <h2>(g::t(lang, K::Members))</h2> | 706 | + <div class="profile-section-head"> |
| 700 | - <p class="muted small">(g::members_and_teams(lang, summary.members.len(), summary.teams))</p> | 707 | + <h2>(g::t(lang, K::Members))</h2> |
| 708 | + if org_member && summary.total > summary.members.len() { | ||
| 709 | + <a class="small" href=(members_href.as_str())>(g::t(lang, K::ViewAllMembers))</a> | ||
| 710 | + } | ||
| 711 | + </div> | ||
| 712 | + <p class="muted small">(g::members_and_teams(lang, summary.total, summary.teams))</p> | ||
| 701 | if summary.members.is_empty() { | 713 | if summary.members.is_empty() { |
| 702 | empty_state(title: g::t(lang, K::NoMembers)) | 714 | empty_state(title: g::t(lang, K::NoMembers)) |
| 703 | } else { | 715 | } else { |
| 704 | - <ul class="item-list"> | 716 | + <ul class="org-members"> |
| 705 | - for name in summary.members.iter() { | 717 | + for member in summary.members.into_iter() { |
| 706 | - <li><a href=(format!("/{}", name.as_str()))>(name.as_str())</a></li> | 718 | + <li> |
| 719 | + <a href=(user_href(member.username.as_str()))> | ||
| 720 | + <img class="avatar org-member-avatar" src=(member.avatar.as_str()) alt="" width="32" height="32"> | ||
| 721 | + <span>(member.username.as_str())</span> | ||
| 722 | + </a> | ||
| 723 | + </li> | ||
| 707 | } | 724 | } |
| 708 | </ul> | 725 | </ul> |
| 709 | } | 726 | } |
| 710 | </section> | 727 | </section> |
| 711 | } | 728 | } |
| 729 | + </div> | ||
| 712 | } | 730 | } |
| 713 | if list_on { | 731 | if list_on { |
| 714 | <section class="repo-listing"> | 732 | <section class="repo-listing"> |
| @@ -815,6 +833,48 @@ async fn profile_card( | |||
| 815 | }) | 833 | }) |
| 816 | } | 834 | } |
| 817 | 835 | ||
| 836 | +/// The profile tab bar: one link per item, the current tab marked, and a count after the label of | ||
| 837 | +/// each tab that has one in `counts`, by the item's key. A person's, an organization's and an | ||
| 838 | +/// organization's member pages all render it. | ||
| 839 | +#[component] | ||
| 840 | +pub async fn profile_tabs( | ||
| 841 | + username: String, | ||
| 842 | + items: Vec<NavItem>, | ||
| 843 | + current: String, | ||
| 844 | + counts: Vec<(&'static str, String)>, | ||
| 845 | +) -> Result<impl View> { | ||
| 846 | + let rows: Vec<(String, String, &'static str, String, bool)> = items | ||
| 847 | + .into_iter() | ||
| 848 | + .map(|item| { | ||
| 849 | + let on = item.key == current; | ||
| 850 | + let count = counts | ||
| 851 | + .iter() | ||
| 852 | + .find(|(key, _)| *key == item.key) | ||
| 853 | + .map(|(_, count)| count.clone()); | ||
| 854 | + let has_count = count.is_some(); | ||
| 855 | + ( | ||
| 856 | + item.href, | ||
| 857 | + item.label.to_owned(), | ||
| 858 | + tab_class(on), | ||
| 859 | + count.unwrap_or_default(), | ||
| 860 | + has_count, | ||
| 861 | + ) | ||
| 862 | + }) | ||
| 863 | + .collect(); | ||
| 864 | + Ok(view! { | ||
| 865 | + <nav class="profile-tabs" aria-label=(username.as_str())> | ||
| 866 | + for (href, label, class, count, has_count) in rows.into_iter() { | ||
| 867 | + <a class=(class) href=(href.as_str())> | ||
| 868 | + (label.as_str()) | ||
| 869 | + if has_count { | ||
| 870 | + " " <span class="tab-count">(count.as_str())</span> | ||
| 871 | + } | ||
| 872 | + </a> | ||
| 873 | + } | ||
| 874 | + </nav> | ||
| 875 | + }) | ||
| 876 | +} | ||
| 877 | + | ||
| 818 | #[cfg(test)] | 878 | #[cfg(test)] |
| 819 | mod tests { | 879 | mod tests { |
| 820 | 880 | ||
| @@ -1049,7 +1109,8 @@ mod tests { | |||
| 1049 | "stars: private starred repo" | 1109 | "stars: private starred repo" |
| 1050 | ); | 1110 | ); |
| 1051 | 1111 | ||
| 1052 | - // The org sidebar shows Settings to owners only. | 1112 | + // Members and teams pages have no sidebar; their tab bar leads to both, and a member gets no |
| 1113 | + // settings link. Owners edit the organization from its profile. | ||
| 1053 | let kaan = site | 1114 | let kaan = site |
| 1054 | .store | 1115 | .store |
| 1055 | .create_user("kaan", None, "not-a-real-hash", false) | 1116 | .create_user("kaan", None, "not-a-real-hash", false) |
| @@ -1068,16 +1129,42 @@ mod tests { | |||
| 1068 | let member_cookie = sign_in(&site.store, &kaan.id, "org-member-token").await; | 1129 | let member_cookie = sign_in(&site.store, &kaan.id, "org-member-token").await; |
| 1069 | let href = "href=\"/org/forge-org/settings\""; | 1130 | let href = "href=\"/org/forge-org/settings\""; |
| 1070 | let (_, as_owner) = get(&site.router, "/org/forge-org/members", Some(&owner_cookie)).await; | 1131 | let (_, as_owner) = get(&site.router, "/org/forge-org/members", Some(&owner_cookie)).await; |
| 1071 | - assert!(as_owner.contains(href), "org sidebar: owner sees Settings"); | 1132 | + assert!( |
| 1133 | + !as_owner.contains("class=\"side-group\""), | ||
| 1134 | + "org members: no sidebar" | ||
| 1135 | + ); | ||
| 1136 | + assert!( | ||
| 1137 | + as_owner.contains("href=\"/org/forge-org/teams\""), | ||
| 1138 | + "org members: owner sees Teams in the tab bar" | ||
| 1139 | + ); | ||
| 1072 | let (_, as_member) = | 1140 | let (_, as_member) = |
| 1073 | get(&site.router, "/org/forge-org/members", Some(&member_cookie)).await; | 1141 | get(&site.router, "/org/forge-org/members", Some(&member_cookie)).await; |
| 1074 | assert!( | 1142 | assert!( |
| 1075 | as_member.contains("href=\"/org/forge-org/teams\""), | 1143 | as_member.contains("href=\"/org/forge-org/teams\""), |
| 1076 | - "org sidebar: member sees Teams" | 1144 | + "org tabs: member sees Teams" |
| 1077 | ); | 1145 | ); |
| 1078 | assert!( | 1146 | assert!( |
| 1079 | !as_member.contains(href), | 1147 | !as_member.contains(href), |
| 1080 | - "org sidebar: member does not see Settings" | 1148 | + "org tabs: member does not see Settings" |
| 1149 | + ); | ||
| 1150 | + let (_, member_profile) = get(&site.router, "/forge-org", Some(&member_cookie)).await; | ||
| 1151 | + assert!( | ||
| 1152 | + !member_profile.contains("profile-edit"), | ||
| 1153 | + "org profile: member has no edit button" | ||
| 1154 | + ); | ||
| 1155 | + // Settings keeps a sidebar of its own pages, and its back link goes to the profile. | ||
| 1156 | + let (_, settings) = get(&site.router, "/org/forge-org/settings", Some(&owner_cookie)).await; | ||
| 1157 | + assert!( | ||
| 1158 | + settings.contains("href=\"/org/forge-org/settings/pins\""), | ||
| 1159 | + "org settings: sidebar lists Customize pins" | ||
| 1160 | + ); | ||
| 1161 | + assert!( | ||
| 1162 | + !settings.contains("href=\"/org/forge-org/members\""), | ||
| 1163 | + "org settings: sidebar has no members link" | ||
| 1164 | + ); | ||
| 1165 | + assert!( | ||
| 1166 | + settings.contains("class=\"side-link\" href=\"/forge-org\""), | ||
| 1167 | + "org settings: back link goes to the profile" | ||
| 1081 | ); | 1168 | ); |
| 1082 | 1169 | ||
| 1083 | // Org pins show on the org profile, with an edit link for owners only. | 1170 | // Org pins show on the org profile, with an edit link for owners only. |
| @@ -1104,8 +1191,9 @@ mod tests { | |||
| 1104 | "org pins: anonymous has no edit link" | 1191 | "org pins: anonymous has no edit link" |
| 1105 | ); | 1192 | ); |
| 1106 | assert!( | 1193 | assert!( |
| 1107 | - owner.contains("href=\"/org/acme/settings\"") && owner.contains("/new?owner=acme"), | 1194 | + owner.contains("class=\"button profile-edit\" href=\"/org/acme/settings\"") |
| 1108 | - "org profile: owner sees Settings and New repository" | 1195 | + && owner.contains("/new?owner=acme"), |
| 1196 | + "org profile: owner sees Edit organization and New repository" | ||
| 1109 | ); | 1197 | ); |
| 1110 | assert!( | 1198 | assert!( |
| 1111 | !anon.contains("/org/acme/members"), | 1199 | !anon.contains("/org/acme/members"), |
crates/forge-web/src/pages/pull_files.rsmodified+1 -1
| @@ -227,7 +227,7 @@ async fn pull_files(cx: &Cx) -> Result<impl View> { | |||
| 227 | if let Some(message) = error { | 227 | if let Some(message) = error { |
| 228 | alert(message: message.as_str()) | 228 | alert(message: message.as_str()) |
| 229 | } | 229 | } |
| 230 | - <div data-live=(live.as_str())> | 230 | + <div class="fit-pane" data-live=(live.as_str())> |
| 231 | if can_review { | 231 | if can_review { |
| 232 | review_bar(lang: lang, pr_href: href.clone(), csrf: csrf.clone(), pending: pending, is_author: is_author) | 232 | review_bar(lang: lang, pr_href: href.clone(), csrf: csrf.clone(), pending: pending, is_author: is_author) |
| 233 | } | 233 | } |
crates/forge-web/src/pages/pull_view.rsmodified+2 -2
| @@ -900,7 +900,7 @@ async fn pull_conversation( | |||
| 900 | alert(message: message) | 900 | alert(message: message) |
| 901 | } | 901 | } |
| 902 | <div class="issue-layout" data-live=(live.as_str())> | 902 | <div class="issue-layout" data-live=(live.as_str())> |
| 903 | - <div class="issue-column"> | 903 | + <div class="issue-column fit-pane"> |
| 904 | discussion_timeline(lang: lang, discussion: discussion) | 904 | discussion_timeline(lang: lang, discussion: discussion) |
| 905 | if review_box_shown { | 905 | if review_box_shown { |
| 906 | review_box(approved: approved, approved_before: approved_before, changes: changes, dismiss: dismiss, | 906 | review_box(approved: approved, approved_before: approved_before, changes: changes, dismiss: dismiss, |
| @@ -932,7 +932,7 @@ async fn pull_conversation( | |||
| 932 | <p class="muted">(login_before)<a href=(login_href.as_str())>(login_link)</a>(login_after)</p> | 932 | <p class="muted">(login_before)<a href=(login_href.as_str())>(login_link)</a>(login_after)</p> |
| 933 | } | 933 | } |
| 934 | </div> | 934 | </div> |
| 935 | - <aside class="issue-sidebar"> | 935 | + <aside class="issue-sidebar fit-pane"> |
| 936 | item_sidebar(lang: lang, write: write_meta, base: href.clone(), csrf: csrf.clone(), sidebar: sidebar, notify: notify) | 936 | item_sidebar(lang: lang, write: write_meta, base: href.clone(), csrf: csrf.clone(), sidebar: sidebar, notify: notify) |
| 937 | reviewers_box(lang: lang, reviewers: reviewers) | 937 | reviewers_box(lang: lang, reviewers: reviewers) |
| 938 | </aside> | 938 | </aside> |
crates/forge-web/src/pages/releases.rsmodified+65 -17
| @@ -25,7 +25,7 @@ use topcoat::router::content::Form; | |||
| 25 | use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; | 25 | use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; |
| 26 | use topcoat::router::request::headers; | 26 | use topcoat::router::request::headers; |
| 27 | use topcoat::router::response::Response; | 27 | use topcoat::router::response::Response; |
| 28 | -use topcoat::router::{Body, HeaderName, HeaderValue, StatusCode, page, path_param, route}; | 28 | +use topcoat::router::{Body, HeaderName, HeaderValue, StatusCode, page, path_param, query_params, route}; |
| 29 | use topcoat::view::{Unescaped, View, component, view}; | 29 | use topcoat::view::{Unescaped, View, component, view}; |
| 30 | 30 | ||
| 31 | use crate::auth::require_csrf; | 31 | use crate::auth::require_csrf; |
| @@ -42,6 +42,7 @@ use crate::pages::issue_parts::When; | |||
| 42 | use crate::release_ops::{self, CreateRelease, EditRelease, ReleaseError}; | 42 | use crate::release_ops::{self, CreateRelease, EditRelease, ReleaseError}; |
| 43 | use crate::render::markdown::render_markdown; | 43 | use crate::render::markdown::render_markdown; |
| 44 | use crate::state::AppState; | 44 | use crate::state::AppState; |
| 45 | +use crate::views::repo_list::{PageLink, pager, pager_links}; | ||
| 45 | use crate::views::{alert, empty_state, enc, now_unix, shell, user_link}; | 46 | use crate::views::{alert, empty_state, enc, now_unix, shell, user_link}; |
| 46 | 47 | ||
| 47 | path_param!(owner); | 48 | path_param!(owner); |
| @@ -54,6 +55,16 @@ path_param!(name); | |||
| 54 | /// Multipart framing allowed on top of the file itself when checking `Content-Length`. | 55 | /// Multipart framing allowed on top of the file itself when checking `Content-Length`. |
| 55 | const MULTIPART_OVERHEAD: u64 = 64 * 1024; | 56 | const MULTIPART_OVERHEAD: u64 = 64 * 1024; |
| 56 | 57 | ||
| 58 | +/// Releases per page. A release card is tall (its notes and assets), so three fit the window. | ||
| 59 | +const PER_PAGE: usize = 3; | ||
| 60 | + | ||
| 61 | +/// The list's query: the page, and the notice word that a paging link keeps. | ||
| 62 | +#[query_params(error = bad_request)] | ||
| 63 | +struct ReleasesQuery { | ||
| 64 | + page: Option<String>, | ||
| 65 | + notice: Option<String>, | ||
| 66 | +} | ||
| 67 | + | ||
| 57 | /// Notice words (the only text a `?notice=` query can show), their text and whether they are errors. | 68 | /// Notice words (the only text a `?notice=` query can show), their text and whether they are errors. |
| 58 | const NOTICES: [(&str, K, bool); 12] = [ | 69 | const NOTICES: [(&str, K, bool); 12] = [ |
| 59 | ("saved", K::RelSaved, false), | 70 | ("saved", K::RelSaved, false), |
| @@ -356,19 +367,22 @@ async fn release_form( | |||
| 356 | } | 367 | } |
| 357 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 368 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 358 | if is_new { | 369 | if is_new { |
| 359 | - <label> | 370 | + // The tag and the target branch are short, so they share a row. |
| 360 | - <span>(g::t(lang, K::Tag))</span> | 371 | + <div class="release-pair"> |
| 361 | - <input type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> | 372 | + <label> |
| 362 | - </label> | 373 | + <span>(g::t(lang, K::Tag))</span> |
| 363 | - <p class="muted small">(tag_hint)</p> | 374 | + <input type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> |
| 364 | - <label> | 375 | + </label> |
| 365 | - <span>(g::t(lang, K::TargetBranch))</span> | 376 | + <label> |
| 366 | - <select name="target"> | 377 | + <span>(g::t(lang, K::TargetBranch))</span> |
| 367 | - for branch in branches.iter() { | 378 | + <select name="target"> |
| 368 | - <option value=(branch.as_str()) selected=(branch.as_str() == draft.target.as_str())>(branch.as_str())</option> | 379 | + for branch in branches.iter() { |
| 369 | - } | 380 | + <option value=(branch.as_str()) selected=(branch.as_str() == draft.target.as_str())>(branch.as_str())</option> |
| 370 | - </select> | 381 | + } |
| 371 | - </label> | 382 | + </select> |
| 383 | + </label> | ||
| 384 | + <p class="muted small">(tag_hint)</p> | ||
| 385 | + </div> | ||
| 372 | } else { | 386 | } else { |
| 373 | <label> | 387 | <label> |
| 374 | <span>(g::t(lang, K::Tag))</span> | 388 | <span>(g::t(lang, K::Tag))</span> |
| @@ -474,7 +488,11 @@ async fn list_body( | |||
| 474 | new_href: Option<String>, | 488 | new_href: Option<String>, |
| 475 | cards: Vec<ReleaseCard>, | 489 | cards: Vec<ReleaseCard>, |
| 476 | live: String, | 490 | live: String, |
| 491 | + page: u64, | ||
| 492 | + pages: u64, | ||
| 493 | + nav: (Vec<PageLink>, Option<String>, Option<String>), | ||
| 477 | ) -> Result<impl View> { | 494 | ) -> Result<impl View> { |
| 495 | + let (links, prev, next) = nav; | ||
| 478 | Ok(view! { | 496 | Ok(view! { |
| 479 | repo_head(head: head) | 497 | repo_head(head: head) |
| 480 | if let Some((text, is_error)) = notice { | 498 | if let Some((text, is_error)) = notice { |
| @@ -484,7 +502,7 @@ async fn list_body( | |||
| 484 | <section class="card notice" role="status">(text)</section> | 502 | <section class="card notice" role="status">(text)</section> |
| 485 | } | 503 | } |
| 486 | } | 504 | } |
| 487 | - <section class="card" data-live=(live.as_str())> | 505 | + <section class="card fit-pane fit-card" data-live=(live.as_str())> |
| 488 | <div class="release-list-head"> | 506 | <div class="release-list-head"> |
| 489 | <h2>(g::t(lang, K::Releases))</h2> | 507 | <h2>(g::t(lang, K::Releases))</h2> |
| 490 | if let Some(href) = &new_href { | 508 | if let Some(href) = &new_href { |
| @@ -498,6 +516,7 @@ async fn list_body( | |||
| 498 | } | 516 | } |
| 499 | ) | 517 | ) |
| 500 | } | 518 | } |
| 519 | + <div class="fit-scroll"> | ||
| 501 | for card in cards.iter() { | 520 | for card in cards.iter() { |
| 502 | <article class="release-card"> | 521 | <article class="release-card"> |
| 503 | <h3> | 522 | <h3> |
| @@ -532,6 +551,8 @@ async fn list_body( | |||
| 532 | <p><a href=(card.edit_href.as_str())>(g::t(lang, K::Edit))</a></p> | 551 | <p><a href=(card.edit_href.as_str())>(g::t(lang, K::Edit))</a></p> |
| 533 | </article> | 552 | </article> |
| 534 | } | 553 | } |
| 554 | + </div> | ||
| 555 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | ||
| 535 | </section> | 556 | </section> |
| 536 | }) | 557 | }) |
| 537 | } | 558 | } |
| @@ -541,6 +562,7 @@ async fn list_body( | |||
| 541 | async fn releases_list_page(cx: &Cx) -> Result<impl View> { | 562 | async fn releases_list_page(cx: &Cx) -> Result<impl View> { |
| 542 | let owner = path_param::<Owner>(cx); | 563 | let owner = path_param::<Owner>(cx); |
| 543 | let name = path_param::<Repo>(cx); | 564 | let name = path_param::<Repo>(cx); |
| 565 | + let query = query_params::<ReleasesQuery>(cx)?; | ||
| 544 | let ctx = load_repo(cx, owner, name).await?; | 566 | let ctx = load_repo(cx, owner, name).await?; |
| 545 | let lang = i18n::lang(cx, viewer_user(&ctx)); | 567 | let lang = i18n::lang(cx, viewer_user(&ctx)); |
| 546 | let state = app_context::<AppState>(cx); | 568 | let state = app_context::<AppState>(cx); |
| @@ -561,11 +583,37 @@ async fn releases_list_page(cx: &Cx) -> Result<impl View> { | |||
| 561 | let title = format!("{} \u{b7} {}", title_of(&ctx), g::t(lang, K::Releases)); | 583 | let title = format!("{} \u{b7} {}", title_of(&ctx), g::t(lang, K::Releases)); |
| 562 | let new_href = writer.then(|| format!("{}/new", releases_href(&title_of(&ctx)))); | 584 | let new_href = writer.then(|| format!("{}/new", releases_href(&title_of(&ctx)))); |
| 563 | let notice = notice_from_query(cx, lang); | 585 | let notice = notice_from_query(cx, lang); |
| 586 | + let pages = cards.len().div_ceil(PER_PAGE).max(1); | ||
| 587 | + let page = query | ||
| 588 | + .page | ||
| 589 | + .as_deref() | ||
| 590 | + .and_then(|p| p.parse::<usize>().ok()) | ||
| 591 | + .unwrap_or(1) | ||
| 592 | + .clamp(1, pages); | ||
| 593 | + let kept = if notice.is_some() { | ||
| 594 | + query.notice.clone().unwrap_or_default() | ||
| 595 | + } else { | ||
| 596 | + String::new() | ||
| 597 | + }; | ||
| 598 | + let list_href = releases_href(&title_of(&ctx)); | ||
| 599 | + let nav = pager_links(page as u64, pages as u64, |n| { | ||
| 600 | + if kept.is_empty() { | ||
| 601 | + format!("{list_href}?page={n}") | ||
| 602 | + } else { | ||
| 603 | + format!("{list_href}?page={n}¬ice={}", enc(&kept)) | ||
| 604 | + } | ||
| 605 | + }); | ||
| 606 | + let cards: Vec<ReleaseCard> = cards | ||
| 607 | + .into_iter() | ||
| 608 | + .skip((page - 1) * PER_PAGE) | ||
| 609 | + .take(PER_PAGE) | ||
| 610 | + .collect(); | ||
| 564 | let head = ctx.head(state, "releases").await?; | 611 | let head = ctx.head(state, "releases").await?; |
| 565 | let live = releases_live::list_live_url(&title_of(&ctx)); | 612 | let live = releases_live::list_live_url(&title_of(&ctx)); |
| 566 | Ok(view! { | 613 | Ok(view! { |
| 567 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 614 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 568 | - list_body(head: head, lang: lang, notice: notice, new_href: new_href, cards: cards, live: live)) | 615 | + list_body(head: head, lang: lang, notice: notice, new_href: new_href, cards: cards, live: live, |
| 616 | + page: page as u64, pages: pages as u64, nav: nav)) | ||
| 569 | }) | 617 | }) |
| 570 | } | 618 | } |
| 571 | 619 | ||
| @@ -589,7 +637,7 @@ async fn new_form_body( | |||
| 589 | ) -> Result<impl View> { | 637 | ) -> Result<impl View> { |
| 590 | Ok(view! { | 638 | Ok(view! { |
| 591 | repo_head(head: head) | 639 | repo_head(head: head) |
| 592 | - <section class="card"> | 640 | + <section class="card fit-pane"> |
| 593 | <h2>(g::t(lang, K::NewRelease))</h2> | 641 | <h2>(g::t(lang, K::NewRelease))</h2> |
| 594 | release_form(action: action, csrf: csrf, lang: lang, is_new: true, move_target: true, draft: draft, branches: branches, submit: g::t(lang, K::SaveRelease)) | 642 | release_form(action: action, csrf: csrf, lang: lang, is_new: true, move_target: true, draft: draft, branches: branches, submit: g::t(lang, K::SaveRelease)) |
| 595 | </section> | 643 | </section> |
crates/forge-web/src/pages/repo_collaborators.rsmodified+12 -8
| @@ -314,14 +314,18 @@ async fn collaborators_body( | |||
| 314 | <section class="card notice" role="status">(text)</section> | 314 | <section class="card notice" role="status">(text)</section> |
| 315 | } | 315 | } |
| 316 | } | 316 | } |
| 317 | - <section class="card"> | 317 | + <div class="fit-pane settings-split"> |
| 318 | - <h2>(g::t(lang, K::Collaborators))</h2> | 318 | + <section class="card"> |
| 319 | - <p class="muted small">(g::t(lang, K::CollaboratorsHelp))</p> | 319 | + <h2>(g::t(lang, K::Collaborators))</h2> |
| 320 | - collaborators_table(lang: lang, rows: rows, role_action: role_action, | 320 | + <p class="muted small">(g::t(lang, K::CollaboratorsHelp))</p> |
| 321 | - remove_action: remove_action, csrf: csrf.clone()) | 321 | + collaborators_table(lang: lang, rows: rows, role_action: role_action, |
| 322 | - add_form(lang: lang, add_action: add_action, csrf: csrf) | 322 | + remove_action: remove_action, csrf: csrf.clone()) |
| 323 | - </section> | 323 | + </section> |
| 324 | - role_legend(lang: lang) | 324 | + <section class="card"> |
| 325 | + add_form(lang: lang, add_action: add_action, csrf: csrf) | ||
| 326 | + </section> | ||
| 327 | + role_legend(lang: lang) | ||
| 328 | + </div> | ||
| 325 | }) | 329 | }) |
| 326 | } | 330 | } |
| 327 | 331 | ||
crates/forge-web/src/pages/repo_mirrors.rsmodified+66 -64
| @@ -507,74 +507,76 @@ async fn mirrors_list_body( | |||
| 507 | let can_pull = pull_form.is_some(); | 507 | let can_pull = pull_form.is_some(); |
| 508 | Ok(view! { | 508 | Ok(view! { |
| 509 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang) | 509 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang) |
| 510 | - <section class="card"> | 510 | + <div class="fit-pane settings-split"> |
| 511 | - <h2>(g::t(lang, K::Mirrors))</h2> | 511 | + <section class="card"> |
| 512 | - <p class="muted small">(g::t(lang, K::MirrorsIntro))</p> | 512 | + <h2>(g::t(lang, K::Mirrors))</h2> |
| 513 | - if rows.is_empty() { | 513 | + <p class="muted small">(g::t(lang, K::MirrorsIntro))</p> |
| 514 | - empty_state(title: g::t(lang, K::NoMirrors), | 514 | + if rows.is_empty() { |
| 515 | - if !archived { | 515 | + empty_state(title: g::t(lang, K::NoMirrors), |
| 516 | - if can_pull { | 516 | + if !archived { |
| 517 | - <a class="button" href="#add-pull-mirror">(g::t(lang, K::AddPullMirror))</a> | 517 | + if can_pull { |
| 518 | - } | 518 | + <a class="button" href="#add-pull-mirror">(g::t(lang, K::AddPullMirror))</a> |
| 519 | - <a class="button" href="#add-push-mirror">(g::t(lang, K::AddPushMirror))</a> | 519 | + } |
| 520 | - }) | 520 | + <a class="button" href="#add-push-mirror">(g::t(lang, K::AddPushMirror))</a> |
| 521 | - } else { | 521 | + }) |
| 522 | - <ul class="runner-list mirror-list"> | 522 | + } else { |
| 523 | - for row in rows.iter() { | 523 | + <ul class="runner-list mirror-list"> |
| 524 | - <li class="runner-row"> | 524 | + for row in rows.iter() { |
| 525 | - <div class="runner-id"> | 525 | + <li class="runner-row"> |
| 526 | - <div class="runner-title"> | 526 | + <div class="runner-id"> |
| 527 | - <span class=(row.dot_class) role="img" aria-label=(row.status_text) title=(row.status_text)></span> | 527 | + <div class="runner-title"> |
| 528 | - <a class="runner-name mirror-url" href=(row.href.as_str())>(row.url.as_str())</a> | 528 | + <span class=(row.dot_class) role="img" aria-label=(row.status_text) title=(row.status_text)></span> |
| 529 | - </div> | 529 | + <a class="runner-name mirror-url" href=(row.href.as_str())>(row.url.as_str())</a> |
| 530 | - <p class="runner-meta muted"> | 530 | + </div> |
| 531 | - (row.direction)" · "(row.interval.as_str()) | 531 | + <p class="runner-meta muted"> |
| 532 | - if !row.enabled { | 532 | + (row.direction)" · "(row.interval.as_str()) |
| 533 | - " · "(adm::t(lang, adm::K::Disabled)) | 533 | + if !row.enabled { |
| 534 | - } | 534 | + " · "(adm::t(lang, adm::K::Disabled)) |
| 535 | - " · " | 535 | + } |
| 536 | - if row.last_sync_at.is_empty() { | 536 | + " · " |
| 537 | - (g::t(lang, K::StatusNotRun)) | 537 | + if row.last_sync_at.is_empty() { |
| 538 | - } else { | 538 | + (g::t(lang, K::StatusNotRun)) |
| 539 | - (row.sync_prefix)<time data-rel="true" datetime=(row.last_sync_at.as_str()) title=(row.last_sync.as_str())>(row.last_sync_rel.as_str())</time>(row.sync_suffix) | 539 | + } else { |
| 540 | + (row.sync_prefix)<time data-rel="true" datetime=(row.last_sync_at.as_str()) title=(row.last_sync.as_str())>(row.last_sync_rel.as_str())</time>(row.sync_suffix) | ||
| 541 | + } | ||
| 542 | + </p> | ||
| 543 | + if !row.error.is_empty() { | ||
| 544 | + <details class="mirror-failure"> | ||
| 545 | + <summary>(g::t(lang, K::ErrorLabel))</summary> | ||
| 546 | + <pre class="mirror-error">(row.error.as_str())</pre> | ||
| 547 | + </details> | ||
| 540 | } | 548 | } |
| 541 | - </p> | 549 | + </div> |
| 542 | - if !row.error.is_empty() { | 550 | + if !archived { |
| 543 | - <details class="mirror-failure"> | 551 | + <form method="post" action=(row.sync_action.as_str()) class="inline-form"> |
| 544 | - <summary>(g::t(lang, K::ErrorLabel))</summary> | 552 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 545 | - <pre class="mirror-error">(row.error.as_str())</pre> | 553 | + <button type="submit" class="hook-sync">(g::t(lang, K::SyncNow))</button> |
| 546 | - </details> | 554 | + </form> |
| 547 | } | 555 | } |
| 548 | - </div> | 556 | + </li> |
| 549 | - if !archived { | 557 | + } |
| 550 | - <form method="post" action=(row.sync_action.as_str()) class="inline-form"> | 558 | + </ul> |
| 551 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 559 | + } |
| 552 | - <button type="submit" class="hook-sync">(g::t(lang, K::SyncNow))</button> | 560 | + </section> |
| 553 | - </form> | 561 | + if !archived { |
| 554 | - } | 562 | + if let Some(pull) = pull_form { |
| 555 | - </li> | 563 | + <section class="card" id="add-pull-mirror"> |
| 556 | - } | 564 | + <h2>(g::t(lang, K::AddPullMirror))</h2> |
| 557 | - </ul> | 565 | + <p class="muted small">(g::t(lang, K::AddPullIntro))</p> |
| 558 | - } | 566 | + mirror_form(action: add_action.clone(), csrf: csrf.clone(), pull: true, current_url: String::new(), |
| 559 | - </section> | 567 | + url: pull.url, username: pull.username, has_secret: false, interval: pull.interval, |
| 560 | - if !archived { | 568 | + enabled: None, error: pull.error, submit: g::t(lang, K::AddPullMirror), direction: "pull", lang: lang) |
| 561 | - if let Some(pull) = pull_form { | 569 | + </section> |
| 562 | - <section class="card" id="add-pull-mirror"> | 570 | + } |
| 563 | - <h2>(g::t(lang, K::AddPullMirror))</h2> | 571 | + <section class="card" id="add-push-mirror"> |
| 564 | - <p class="muted small">(g::t(lang, K::AddPullIntro))</p> | 572 | + <h2>(g::t(lang, K::AddPushMirror))</h2> |
| 565 | - mirror_form(action: add_action.clone(), csrf: csrf.clone(), pull: true, current_url: String::new(), | 573 | + <p class="muted small">(g::t(lang, K::AddPushIntro))</p> |
| 566 | - url: pull.url, username: pull.username, has_secret: false, interval: pull.interval, | 574 | + mirror_form(action: add_action.clone(), csrf: csrf.clone(), pull: false, current_url: String::new(), |
| 567 | - enabled: None, error: pull.error, submit: g::t(lang, K::AddPullMirror), direction: "pull", lang: lang) | 575 | + url: draft.url, username: draft.username, has_secret: false, interval: draft.interval, |
| 576 | + enabled: None, error: draft.error, submit: g::t(lang, K::AddPushMirror), direction: "", lang: lang) | ||
| 568 | </section> | 577 | </section> |
| 569 | } | 578 | } |
| 570 | - <section class="card" id="add-push-mirror"> | 579 | + </div> |
| 571 | - <h2>(g::t(lang, K::AddPushMirror))</h2> | ||
| 572 | - <p class="muted small">(g::t(lang, K::AddPushIntro))</p> | ||
| 573 | - mirror_form(action: add_action.clone(), csrf: csrf.clone(), pull: false, current_url: String::new(), | ||
| 574 | - url: draft.url, username: draft.username, has_secret: false, interval: draft.interval, | ||
| 575 | - enabled: None, error: draft.error, submit: g::t(lang, K::AddPushMirror), direction: "", lang: lang) | ||
| 576 | - </section> | ||
| 577 | - } | ||
| 578 | }) | 580 | }) |
| 579 | } | 581 | } |
| 580 | 582 | ||
crates/forge-web/src/pages/repo_secrets.rsmodified+62 -60
| @@ -191,70 +191,72 @@ async fn secrets_body( | |||
| 191 | let delete_action = format!("{set_action}/delete"); | 191 | let delete_action = format!("{set_action}/delete"); |
| 192 | Ok(view! { | 192 | Ok(view! { |
| 193 | frame_top(lang: lang, head: head, title: title.clone(), notice: notice, archived: archived) | 193 | frame_top(lang: lang, head: head, title: title.clone(), notice: notice, archived: archived) |
| 194 | - <section class="card"> | 194 | + <div class="fit-pane settings-split"> |
| 195 | - <h2>(g::t(lang, K::Secrets))</h2> | 195 | + <section class="card"> |
| 196 | - <p class="muted small">(g::t(lang, K::SecretsHelp))</p> | 196 | + <h2>(g::t(lang, K::Secrets))</h2> |
| 197 | - if rows.is_empty() { | 197 | + <p class="muted small">(g::t(lang, K::SecretsHelp))</p> |
| 198 | - empty_state(title: g::t(lang, K::NoSecrets), | 198 | + if rows.is_empty() { |
| 199 | - if !archived { | 199 | + empty_state(title: g::t(lang, K::NoSecrets), |
| 200 | - <a class="button" href="#add-secret">(g::t(lang, K::AddOrUpdate))</a> | 200 | + if !archived { |
| 201 | - }) | 201 | + <a class="button" href="#add-secret">(g::t(lang, K::AddOrUpdate))</a> |
| 202 | - } else { | 202 | + }) |
| 203 | - <div class="table-wrap"> | 203 | + } else { |
| 204 | - <table class="table secrets"> | 204 | + <div class="table-wrap"> |
| 205 | - <thead> | 205 | + <table class="table secrets"> |
| 206 | - <tr> | 206 | + <thead> |
| 207 | - <th>(g::t(lang, K::Name))</th> | ||
| 208 | - <th>(g::t(lang, K::LastUpdated))</th> | ||
| 209 | - <th></th> | ||
| 210 | - </tr> | ||
| 211 | - </thead> | ||
| 212 | - <tbody> | ||
| 213 | - for row in rows.iter() { | ||
| 214 | <tr> | 207 | <tr> |
| 215 | - <td><code>(row.name.as_str())</code></td> | 208 | + <th>(g::t(lang, K::Name))</th> |
| 216 | - <td class="small">rel_time(lang: lang, stamp: row.updated_at.as_str())</td> | 209 | + <th>(g::t(lang, K::LastUpdated))</th> |
| 217 | - <td> | 210 | + <th></th> |
| 218 | - if !archived { | ||
| 219 | - <form method="post" action=(delete_action.as_str()) class="inline-form"> | ||
| 220 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 221 | - <input type="hidden" name="name" value=(row.name.as_str())> | ||
| 222 | - <button type="submit" class="danger">(g::t(lang, K::Delete))</button> | ||
| 223 | - </form> | ||
| 224 | - } | ||
| 225 | - </td> | ||
| 226 | </tr> | 211 | </tr> |
| 227 | - } | 212 | + </thead> |
| 228 | - </tbody> | 213 | + <tbody> |
| 229 | - </table> | 214 | + for row in rows.iter() { |
| 230 | - </div> | 215 | + <tr> |
| 231 | - } | 216 | + <td><code>(row.name.as_str())</code></td> |
| 232 | - </section> | 217 | + <td class="small">rel_time(lang: lang, stamp: row.updated_at.as_str())</td> |
| 233 | - if !archived { | 218 | + <td> |
| 234 | - <section class="card" id="add-secret"> | 219 | + if !archived { |
| 235 | - <h2>(g::t(lang, K::AddOrUpdate))</h2> | 220 | + <form method="post" action=(delete_action.as_str()) class="inline-form"> |
| 236 | - if let Some(message) = error { | 221 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 237 | - <p class="alert" role="alert">(message.as_str())</p> | 222 | + <input type="hidden" name="name" value=(row.name.as_str())> |
| 238 | - } | 223 | + <button type="submit" class="danger">(g::t(lang, K::Delete))</button> |
| 239 | - <form method="post" action=(set_action.as_str()) class="stack"> | 224 | + </form> |
| 240 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 225 | + } |
| 241 | - <label> | 226 | + </td> |
| 242 | - (g::t(lang, K::Name)) | 227 | + </tr> |
| 243 | - <input type="text" name="name" value=(draft_name.as_str()) required=(true) maxlength="64" | 228 | + } |
| 244 | - pattern="[A-Z_][A-Z0-9_]{0,63}" autocomplete="off" spellcheck="false" | 229 | + </tbody> |
| 245 | - placeholder="DEPLOY_TOKEN"> | 230 | + </table> |
| 246 | - </label> | ||
| 247 | - <label> | ||
| 248 | - (g::t(lang, K::Value)) | ||
| 249 | - <textarea name="value" required=(true) rows="6" autocomplete="off" spellcheck="false"></textarea> | ||
| 250 | - </label> | ||
| 251 | - <p class="muted small">(g::t(lang, K::SecretLimits))</p> | ||
| 252 | - <div class="actions"> | ||
| 253 | - <button type="submit" class="primary">(g::t(lang, K::SaveSecret))</button> | ||
| 254 | </div> | 231 | </div> |
| 255 | - </form> | 232 | + } |
| 256 | </section> | 233 | </section> |
| 257 | - } | 234 | + if !archived { |
| 235 | + <section class="card" id="add-secret"> | ||
| 236 | + <h2>(g::t(lang, K::AddOrUpdate))</h2> | ||
| 237 | + if let Some(message) = error { | ||
| 238 | + <p class="alert" role="alert">(message.as_str())</p> | ||
| 239 | + } | ||
| 240 | + <form method="post" action=(set_action.as_str()) class="stack"> | ||
| 241 | + <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 242 | + <label> | ||
| 243 | + (g::t(lang, K::Name)) | ||
| 244 | + <input type="text" name="name" value=(draft_name.as_str()) required=(true) maxlength="64" | ||
| 245 | + pattern="[A-Z_][A-Z0-9_]{0,63}" autocomplete="off" spellcheck="false" | ||
| 246 | + placeholder="DEPLOY_TOKEN"> | ||
| 247 | + </label> | ||
| 248 | + <label> | ||
| 249 | + (g::t(lang, K::Value)) | ||
| 250 | + <textarea name="value" required=(true) rows="6" autocomplete="off" spellcheck="false"></textarea> | ||
| 251 | + </label> | ||
| 252 | + <p class="muted small">(g::t(lang, K::SecretLimits))</p> | ||
| 253 | + <div class="actions"> | ||
| 254 | + <button type="submit" class="primary">(g::t(lang, K::SaveSecret))</button> | ||
| 255 | + </div> | ||
| 256 | + </form> | ||
| 257 | + </section> | ||
| 258 | + } | ||
| 259 | + </div> | ||
| 258 | }) | 260 | }) |
| 259 | } | 261 | } |
| 260 | 262 | ||
crates/forge-web/src/pages/repo_settings.rsmodified+26 -15
| @@ -830,10 +830,13 @@ async fn settings_body( | |||
| 830 | }); | 830 | }); |
| 831 | } | 831 | } |
| 832 | let new_draft = draft.unwrap_or_else(|| RuleDraft::for_default_branch(&default_branch)); | 832 | let new_draft = draft.unwrap_or_else(|| RuleDraft::for_default_branch(&default_branch)); |
| 833 | - let new_open = cards.is_empty() || new_draft.error.is_some(); | 833 | + // The New rule form stays collapsed unless its draft was rejected with an error. |
| 834 | + let new_open = new_draft.error.is_some(); | ||
| 834 | let (description, visibility) = (head.description.clone(), head.visibility); | 835 | let (description, visibility) = (head.description.clone(), head.visibility); |
| 835 | let discussions_on = head.discussions; | 836 | let discussions_on = head.discussions; |
| 836 | let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error)); | 837 | let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error)); |
| 838 | + // Three columns on a wide window: the General section, the branch rules, then discussions and the | ||
| 839 | + // danger zone. The pane holds them to one screen (see _fit_settings.scss). | ||
| 837 | Ok(view! { | 840 | Ok(view! { |
| 838 | repo_head(head: head) | 841 | repo_head(head: head) |
| 839 | settings_nav_for(lang: lang, title: title.clone(), current: "general") | 842 | settings_nav_for(lang: lang, title: title.clone(), current: "general") |
| @@ -844,20 +847,28 @@ async fn settings_body( | |||
| 844 | <section class="card notice" role="status">(text)</section> | 847 | <section class="card notice" role="status">(text)</section> |
| 845 | } | 848 | } |
| 846 | } | 849 | } |
| 847 | - general_section(lang: lang, title: title.clone(), csrf: csrf.clone(), description: description, | 850 | + <div class="fit-pane settings-split"> |
| 848 | - default_branch: default_branch.clone(), branches: branches, | 851 | + <div class="settings-col"> |
| 849 | - visibility: visibility, archived: archived) | 852 | + general_section(lang: lang, title: title.clone(), csrf: csrf.clone(), description: description, |
| 850 | - <section class="card"> | 853 | + default_branch: default_branch.clone(), branches: branches, |
| 851 | - <h2>(g::t(lang, K::BranchProtection))</h2> | 854 | + visibility: visibility, archived: archived) |
| 852 | - <p class="muted small">(g::t(lang, K::BranchProtectionHelp))</p> | 855 | + </div> |
| 853 | - branch_rule_cards(lang: lang, cards: cards, builtin_row: builtin_row, default_branch: default_branch.clone(), | 856 | + <div class="settings-col"> |
| 854 | - new_draft: new_draft, new_open: new_open, csrf: csrf.clone(), save_action: rules_action, | 857 | + <section class="card"> |
| 855 | - delete_action: delete_action, contexts: contexts) | 858 | + <h2>(g::t(lang, K::BranchProtection))</h2> |
| 856 | - </section> | 859 | + <p class="muted small">(g::t(lang, K::BranchProtectionHelp))</p> |
| 857 | - discussions_card(lang: lang, action: format!("/{title}/settings/discussions"), csrf: csrf.clone(), enabled: discussions_on) | 860 | + branch_rule_cards(lang: lang, cards: cards, builtin_row: builtin_row, default_branch: default_branch.clone(), |
| 858 | - if can_delete { | 861 | + new_draft: new_draft, new_open: new_open, csrf: csrf.clone(), save_action: rules_action, |
| 859 | - danger_zone(lang: lang, csrf: csrf, title: title, error: delete_error) | 862 | + delete_action: delete_action, contexts: contexts) |
| 860 | - } | 863 | + </section> |
| 864 | + </div> | ||
| 865 | + <div class="settings-col"> | ||
| 866 | + discussions_card(lang: lang, action: format!("/{title}/settings/discussions"), csrf: csrf.clone(), enabled: discussions_on) | ||
| 867 | + if can_delete { | ||
| 868 | + danger_zone(lang: lang, csrf: csrf, title: title, error: delete_error) | ||
| 869 | + } | ||
| 870 | + </div> | ||
| 871 | + </div> | ||
| 861 | }) | 872 | }) |
| 862 | } | 873 | } |
| 863 | 874 | ||
crates/forge-web/src/pages/repo_webhooks.rsmodified+10 -8
| @@ -812,14 +812,16 @@ async fn hook_new_body( | |||
| 812 | let back = hooks_href(&title); | 812 | let back = hooks_href(&title); |
| 813 | Ok(view! { | 813 | Ok(view! { |
| 814 | frame_top(head: head, title: title.clone(), notice: None, archived: archived, lang: lang) | 814 | frame_top(head: head, title: title.clone(), notice: None, archived: archived, lang: lang) |
| 815 | - <section class="card"> | 815 | + <div class="fit-pane settings-split"> |
| 816 | - <h2>(g::t(lang, K::AddWebhook))</h2> | 816 | + <section class="card"> |
| 817 | - <p class="muted small">(g::t(lang, K::AddWebhookIntro))</p> | 817 | + <h2>(g::t(lang, K::AddWebhook))</h2> |
| 818 | - hook_form(action: action, csrf: csrf, url: draft.url, events: events, | 818 | + <p class="muted small">(g::t(lang, K::AddWebhookIntro))</p> |
| 819 | - active: draft.active, secret_hint: g::t(lang, K::SecretHintNew).to_owned(), | 819 | + hook_form(action: action, csrf: csrf, url: draft.url, events: events, |
| 820 | - error: draft.error, submit: g::t(lang, K::CreateWebhook), lang: lang) | 820 | + active: draft.active, secret_hint: g::t(lang, K::SecretHintNew).to_owned(), |
| 821 | - <p><a href=(back.as_str())>(g::t(lang, K::BackToWebhooks))</a></p> | 821 | + error: draft.error, submit: g::t(lang, K::CreateWebhook), lang: lang) |
| 822 | - </section> | 822 | + <p><a href=(back.as_str())>(g::t(lang, K::BackToWebhooks))</a></p> |
| 823 | + </section> | ||
| 824 | + </div> | ||
| 823 | }) | 825 | }) |
| 824 | } | 826 | } |
| 825 | 827 | ||
crates/forge-web/src/pages/snippets.rsmodified+1 -1
| @@ -420,7 +420,7 @@ async fn snippet_form( | |||
| 420 | if let Some(message) = error { | 420 | if let Some(message) = error { |
| 421 | alert(message: message.as_str()) | 421 | alert(message: message.as_str()) |
| 422 | } | 422 | } |
| 423 | - <form method="post" action=(action) class="snippet-form"> | 423 | + <form method="post" action=(action) class="snippet-form fit-pane"> |
| 424 | <input type="hidden" name="csrf" value=(csrf)> | 424 | <input type="hidden" name="csrf" value=(csrf)> |
| 425 | <header class="snippet-head"> | 425 | <header class="snippet-head"> |
| 426 | <h1>(heading)</h1> | 426 | <h1>(heading)</h1> |
crates/forge-web/src/pages/tree.rsmodified+21 -9
| @@ -20,6 +20,7 @@ use crate::i18n::misc::{self as mi, K as MK}; | |||
| 20 | use crate::i18n::{self, Lang}; | 20 | use crate::i18n::{self, Lang}; |
| 21 | use crate::pages::code_live::{follows_branch, live_url}; | 21 | use crate::pages::code_live::{follows_branch, live_url}; |
| 22 | use crate::pages::finder::file_finder; | 22 | use crate::pages::finder::file_finder; |
| 23 | +use crate::pages::passkeys::s; | ||
| 23 | use crate::pages::refs::{load_refs, ref_links}; | 24 | use crate::pages::refs::{load_refs, ref_links}; |
| 24 | use crate::pages::repo::repo_head; | 25 | use crate::pages::repo::repo_head; |
| 25 | use crate::pages::repo_ctx::load_repo; | 26 | use crate::pages::repo_ctx::load_repo; |
| @@ -565,19 +566,30 @@ async fn tree_page(cx: &Cx) -> Result<impl View> { | |||
| 565 | if let Some(url) = &live { | 566 | if let Some(url) = &live { |
| 566 | header.live = url.clone(); | 567 | header.live = url.clone(); |
| 567 | } | 568 | } |
| 569 | + // The listing and the README sit side by side from 900px, as on the repo home, so the page fits | ||
| 570 | + // the window: each column scrolls on its own (the grid is the repo home's, see _repo.scss). | ||
| 568 | Ok(view! { | 571 | Ok(view! { |
| 569 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 572 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 570 | repo_head(head: header) | 573 | repo_head(head: header) |
| 571 | - <div class="browse-bar" data-live=(live.as_deref()) data-live-code=(live.is_some().then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> | 574 | + <div class="repo-grid repo-home"> |
| 572 | - ref_selector(lang: lang, label: mi::t(lang, MK::RefLabel), current: ref_name.clone(), branches: branches, tags: tags, | 575 | + <div class="repo-main"> |
| 573 | - branches_href: branches_href, tags_href: tags_href) | 576 | + <div class="browse-bar" data-live=(live.as_deref()) data-live-code=(live.is_some().then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> |
| 574 | - breadcrumb(lang: lang, crumbs: crumbs) | 577 | + ref_selector(lang: lang, label: mi::t(lang, MK::RefLabel), current: ref_name.clone(), branches: branches, tags: tags, |
| 575 | - file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) | 578 | + branches_href: branches_href, tags_href: tags_href) |
| 579 | + breadcrumb(lang: lang, crumbs: crumbs) | ||
| 580 | + file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) | ||
| 581 | + </div> | ||
| 582 | + tree_table(rows: rows, latest: bar, lang: lang) | ||
| 583 | + </div> | ||
| 584 | + <div class="repo-split" role="separator" aria-orientation="vertical" | ||
| 585 | + aria-label=(s(lang, "Resize file tree", "Dosya ağacını boyutlandır")) tabindex="0" | ||
| 586 | + data-repo-split=""></div> | ||
| 587 | + <div class="repo-readme"> | ||
| 588 | + if let Some(readme) = readme { | ||
| 589 | + readme_card(name: readme.name, markdown: readme.markdown, body: readme.body) | ||
| 590 | + } | ||
| 591 | + </div> | ||
| 576 | </div> | 592 | </div> |
| 577 | - tree_table(rows: rows, latest: bar, lang: lang) | ||
| 578 | - if let Some(readme) = readme { | ||
| 579 | - readme_card(name: readme.name, markdown: readme.markdown, body: readme.body) | ||
| 580 | - } | ||
| 581 | ) | 593 | ) |
| 582 | }) | 594 | }) |
| 583 | } | 595 | } |
crates/forge-web/src/pages/wiki.rsmodified+1 -1
| @@ -296,7 +296,7 @@ async fn wiki_edit_body( | |||
| 296 | error: Option<String>, | 296 | error: Option<String>, |
| 297 | ) -> Result<impl View> { | 297 | ) -> Result<impl View> { |
| 298 | Ok(view! { | 298 | Ok(view! { |
| 299 | - <section class="card wiki-page"> | 299 | + <section class="card wiki-page fit-pane"> |
| 300 | <form method="post" action=(action.as_str()) class="stack wiki-form"> | 300 | <form method="post" action=(action.as_str()) class="stack wiki-form"> |
| 301 | if let Some(message) = error { | 301 | if let Some(message) = error { |
| 302 | alert(message: message.as_str()) | 302 | alert(message: message.as_str()) |
crates/forge-web/src/views/mod.rsmodified+110 -53
| @@ -26,8 +26,11 @@ use topcoat::router::{Body, Next, layer}; | |||
| 26 | use topcoat::view::{Child, Unescaped, View, ViewExt, component, view}; | 26 | use topcoat::view::{Child, Unescaped, View, ViewExt, component, view}; |
| 27 | 27 | ||
| 28 | use crate::i18n::admin::{self as ad, K as AK}; | 28 | use crate::i18n::admin::{self as ad, K as AK}; |
| 29 | +use crate::i18n::authoring::{self as au, K as AuK}; | ||
| 29 | use crate::i18n::browse as br; | 30 | use crate::i18n::browse as br; |
| 30 | use crate::i18n::code::{self as g, K}; | 31 | use crate::i18n::code::{self as g, K}; |
| 32 | +use crate::i18n::community::{self as cm, K as CK}; | ||
| 33 | +use crate::i18n::packages::{self as pk, K as PK}; | ||
| 31 | use crate::i18n::link::{self as lk, K as LinkKey}; | 34 | use crate::i18n::link::{self as lk, K as LinkKey}; |
| 32 | use crate::i18n::migrate::{self as mg, K as MGK}; | 35 | use crate::i18n::migrate::{self as mg, K as MGK}; |
| 33 | use crate::i18n::misc::{self as mi, K as MK}; | 36 | use crate::i18n::misc::{self as mi, K as MK}; |
| @@ -295,7 +298,7 @@ struct ProfileCorner { | |||
| 295 | 298 | ||
| 296 | /// The floating account panel fixed at the bottom left of the window (signed in only). It opens | 299 | /// The floating account panel fixed at the bottom left of the window (signed in only). It opens |
| 297 | /// upward: the avatar, the viewer's full name, the chips, the notifications bell with its unread count and popover, then | 300 | /// upward: the avatar, the viewer's full name, 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. | 301 | +/// the profile, settings, admin and log out links and the theme choice. |
| 299 | #[component] | 302 | #[component] |
| 300 | async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> { | 303 | async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> { |
| 301 | let review_chip = (corner.reviews > 0).then(|| { | 304 | let review_chip = (corner.reviews > 0).then(|| { |
| @@ -351,7 +354,6 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> | |||
| 351 | </span> | 354 | </span> |
| 352 | </summary> | 355 | </summary> |
| 353 | <div class="corner-menu"> | 356 | <div class="corner-menu"> |
| 354 | - <a class="corner-link" href="/explore">(t(lang, Key::Explore))</a> | ||
| 355 | <div class="corner-theme"><span>(theme_label)</span> | 357 | <div class="corner-theme"><span>(theme_label)</span> |
| 356 | <form method="post" action="/-/theme" class="corner-theme-set" data-no-tick="true"> | 358 | <form method="post" action="/-/theme" class="corner-theme-set" data-no-tick="true"> |
| 357 | <input type="hidden" name="csrf" value=(corner.csrf.as_str())> | 359 | <input type="hidden" name="csrf" value=(corner.csrf.as_str())> |
| @@ -452,29 +454,11 @@ pub async fn shell( | |||
| 452 | let banner_back = back.clone().unwrap_or_else(|| "/".to_owned()); | 454 | let banner_back = back.clone().unwrap_or_else(|| "/".to_owned()); |
| 453 | let dismiss_label = crate::i18n::accounts::t(lang, crate::i18n::accounts::A::Dismiss); | 455 | let dismiss_label = crate::i18n::accounts::t(lang, crate::i18n::accounts::A::Dismiss); |
| 454 | // The admin area and the user settings swap the global links for their own list. Signed-in only. | 456 | // The admin area and the user settings swap the global links for their own list. Signed-in only. |
| 455 | - let mut section = if signed_in { | 457 | + let section = if signed_in { |
| 456 | section_for(lang, uri(__cx).path()) | 458 | section_for(lang, uri(__cx).path()) |
| 457 | } else { | 459 | } else { |
| 458 | None | 460 | None |
| 459 | }; | 461 | }; |
| 460 | - // An org's Settings link is for its owners only. | ||
| 461 | - if let (Some(sec), Some((user, _))) = (section.as_mut(), viewer) | ||
| 462 | - && sec.items.iter().any(|item| item.key == "settings") | ||
| 463 | - && sec.items.iter().any(|item| item.key == "teams") | ||
| 464 | - && let Some(state) = try_app_context::<AppState>(__cx) | ||
| 465 | - { | ||
| 466 | - let owner = state | ||
| 467 | - .store | ||
| 468 | - .orgs_for_user(&user.id) | ||
| 469 | - .await? | ||
| 470 | - .iter() | ||
| 471 | - .any(|(org, role)| { | ||
| 472 | - org.username == sec.title && *role == forge_core::store::orgs::OrgMemberRole::Owner | ||
| 473 | - }); | ||
| 474 | - if !owner { | ||
| 475 | - sec.items.retain(|item| item.key != "settings"); | ||
| 476 | - } | ||
| 477 | - } | ||
| 478 | let section_menu = section.clone(); | 462 | let section_menu = section.clone(); |
| 479 | let theme_attr = crate::theme::data_theme(__cx, viewer.map(|(user, _)| user)); | 463 | let theme_attr = crate::theme::data_theme(__cx, viewer.map(|(user, _)| user)); |
| 480 | // The relative-time wording and the server's clock, for nav.js to keep `<time data-rel>` labels current. | 464 | // The relative-time wording and the server's clock, for nav.js to keep `<time data-rel>` labels current. |
| @@ -641,7 +625,7 @@ pub async fn shell( | |||
| 641 | <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16"/></svg> | 625 | <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16"/></svg> |
| 642 | </summary> | 626 | </summary> |
| 643 | <div class="nav-panel"> | 627 | <div class="nav-panel"> |
| 644 | - section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live) | 628 | + section_nav(title: section.title.as_str(), back: section.back, back_href: section.back_href.as_str(), items: section.items, current: section.current, live: section.live) |
| 645 | </div> | 629 | </div> |
| 646 | </details> | 630 | </details> |
| 647 | } | 631 | } |
| @@ -676,6 +660,10 @@ pub async fn shell( | |||
| 676 | } | 660 | } |
| 677 | </nav> | 661 | </nav> |
| 678 | if signed_in { | 662 | if signed_in { |
| 663 | + <a class="topbar-link topbar-explore" href="/explore">(t(lang, Key::Explore))</a> | ||
| 664 | + <a class="icon-btn top-search-link" href="/explore" aria-label=(search_label) title=(search_label)> | ||
| 665 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> | ||
| 666 | + </a> | ||
| 679 | <div class="live-strip" data-activity="/-/activity" data-passed=(mi::t(lang, MK::Passed)) data-failed=(mi::t(lang, MK::Failed)) data-cancelled=(mi::t(lang, MK::Cancelled)) | 667 | <div class="live-strip" data-activity="/-/activity" data-passed=(mi::t(lang, MK::Passed)) data-failed=(mi::t(lang, MK::Failed)) data-cancelled=(mi::t(lang, MK::Cancelled)) |
| 680 | data-count-running=(running_tpl.as_str()) data-count-failed=(failed_tpl.as_str()) data-count-passed=(passed_tpl.as_str()) data-count-cancelled=(cancelled_tpl.as_str()) | 668 | data-count-running=(running_tpl.as_str()) data-count-failed=(failed_tpl.as_str()) data-count-passed=(passed_tpl.as_str()) data-count-cancelled=(cancelled_tpl.as_str()) |
| 681 | data-runs-label=(runs_label) aria-live="polite"> | 669 | data-runs-label=(runs_label) aria-live="polite"> |
| @@ -740,7 +728,7 @@ pub async fn shell( | |||
| 740 | <div class="shell"> | 728 | <div class="shell"> |
| 741 | if let Some(section) = section { | 729 | if let Some(section) = section { |
| 742 | <aside class="shell-sidebar"> | 730 | <aside class="shell-sidebar"> |
| 743 | - section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live) | 731 | + section_nav(title: section.title.as_str(), back: section.back, back_href: section.back_href.as_str(), items: section.items, current: section.current, live: section.live) |
| 744 | </aside> | 732 | </aside> |
| 745 | } | 733 | } |
| 746 | <div class="shell-body"> | 734 | <div class="shell-body"> |
| @@ -792,6 +780,8 @@ pub struct NavItem { | |||
| 792 | pub struct Section { | 780 | pub struct Section { |
| 793 | pub title: String, | 781 | pub title: String, |
| 794 | pub back: &'static str, | 782 | pub back: &'static str, |
| 783 | + /// Where the back link goes: the site for admin and settings, an organization's profile for its settings. | ||
| 784 | + pub back_href: String, | ||
| 795 | pub items: Vec<NavItem>, | 785 | pub items: Vec<NavItem>, |
| 796 | pub current: &'static str, | 786 | pub current: &'static str, |
| 797 | /// The stream the section's pages follow, or empty when they follow none. | 787 | /// The stream the section's pages follow, or empty when they follow none. |
| @@ -848,34 +838,95 @@ pub fn admin_items(lang: Lang) -> Vec<NavItem> { | |||
| 848 | ] | 838 | ] |
| 849 | } | 839 | } |
| 850 | 840 | ||
| 841 | +/// The organization's settings sidebar: General and Customize pins. Its profile, repositories, | ||
| 842 | +/// members and teams are reached from the profile tab bar, so they are not listed here. | ||
| 851 | fn org_items(lang: Lang, org: &str) -> Vec<NavItem> { | 843 | fn org_items(lang: Lang, org: &str) -> Vec<NavItem> { |
| 852 | - let item = |key, label, icon| NavItem { | ||
| 853 | - key, | ||
| 854 | - href: format!("/org/{org}/{key}"), | ||
| 855 | - label, | ||
| 856 | - icon, | ||
| 857 | - }; | ||
| 858 | - // Overview and Repositories go to the organization's profile, not to a page under `/org`. | ||
| 859 | - let profile = user_href(org); | ||
| 860 | vec![ | 844 | vec![ |
| 861 | NavItem { | 845 | NavItem { |
| 862 | - key: "overview", | 846 | + key: "settings", |
| 863 | - href: profile.clone(), | 847 | + href: format!("/org/{org}/settings"), |
| 864 | - label: o::t(lang, OK::Overview), | 848 | + label: o::t(lang, OK::General), |
| 865 | - icon: "profile", | 849 | + icon: "appearance", |
| 866 | }, | 850 | }, |
| 867 | NavItem { | 851 | NavItem { |
| 868 | - key: "repositories", | 852 | + key: "pins", |
| 869 | - href: format!("{profile}?tab=repositories"), | 853 | + href: format!("/org/{org}/settings/pins"), |
| 870 | - label: o::t(lang, OK::Repositories), | 854 | + label: o::t(lang, OK::CustomizePins), |
| 871 | - icon: "teams", | 855 | + icon: "pins", |
| 872 | }, | 856 | }, |
| 873 | - item("members", o::t(lang, OK::Members), "users"), | ||
| 874 | - item("teams", o::t(lang, OK::Teams), "teams"), | ||
| 875 | - item("settings", o::t(lang, OK::Settings), "appearance"), | ||
| 876 | ] | 857 | ] |
| 877 | } | 858 | } |
| 878 | 859 | ||
| 860 | +/// The profile tab bar in its order, for a person's or an organization's profile: overview, | ||
| 861 | +/// repositories, snippets and stars (people only), packages, organizations (the viewer's own | ||
| 862 | +/// profile only) and, for an organization the viewer belongs to, members and teams. The hrefs are | ||
| 863 | +/// the ones the profile page links to. The count badges are the caller's to add. | ||
| 864 | +pub fn profile_items( | ||
| 865 | + lang: Lang, | ||
| 866 | + username: &str, | ||
| 867 | + is_org: bool, | ||
| 868 | + own_profile: bool, | ||
| 869 | + org_member: bool, | ||
| 870 | +) -> Vec<NavItem> { | ||
| 871 | + let profile = format!("/{}", enc(username)); | ||
| 872 | + let tab = |key: &'static str, label: &'static str, icon: &'static str| NavItem { | ||
| 873 | + key, | ||
| 874 | + href: format!("{profile}?tab={key}"), | ||
| 875 | + label, | ||
| 876 | + icon, | ||
| 877 | + }; | ||
| 878 | + let mut items = vec![ | ||
| 879 | + tab("overview", o::t(lang, OK::TabOverview), "profile"), | ||
| 880 | + tab("repositories", o::t(lang, OK::Repositories), ""), | ||
| 881 | + ]; | ||
| 882 | + if !is_org { | ||
| 883 | + items.push(tab("snippets", cm::t(lang, CK::Snippets), "")); | ||
| 884 | + items.push(tab("stars", o::t(lang, OK::TabStars), "")); | ||
| 885 | + } | ||
| 886 | + items.push(tab("packages", pk::t(lang, PK::TabPackages), "")); | ||
| 887 | + if own_profile { | ||
| 888 | + items.push(tab("organizations", o::t(lang, OK::Organizations), "")); | ||
| 889 | + } | ||
| 890 | + if is_org && org_member { | ||
| 891 | + let org = format!("/org/{}", enc(username)); | ||
| 892 | + items.push(NavItem { | ||
| 893 | + key: "members", | ||
| 894 | + href: format!("{org}/members"), | ||
| 895 | + label: o::t(lang, OK::Members), | ||
| 896 | + icon: "users", | ||
| 897 | + }); | ||
| 898 | + items.push(NavItem { | ||
| 899 | + key: "teams", | ||
| 900 | + href: format!("{org}/teams"), | ||
| 901 | + label: o::t(lang, OK::Teams), | ||
| 902 | + icon: "teams", | ||
| 903 | + }); | ||
| 904 | + } | ||
| 905 | + items | ||
| 906 | +} | ||
| 907 | + | ||
| 908 | +/// The fixed site pages, for the command palette: Explore, notifications, review requests, new | ||
| 909 | +/// repository, import, and new organization when the viewer may create one. | ||
| 910 | +pub fn global_items(lang: Lang, can_create_org: bool) -> Vec<NavItem> { | ||
| 911 | + let item = |key: &'static str, href: &'static str, label: &'static str| NavItem { | ||
| 912 | + key, | ||
| 913 | + href: href.to_owned(), | ||
| 914 | + label, | ||
| 915 | + icon: "", | ||
| 916 | + }; | ||
| 917 | + let mut items = vec![ | ||
| 918 | + item("explore", "/explore", t(lang, Key::Explore)), | ||
| 919 | + item("notifications", "/notifications", t(lang, Key::Notifications)), | ||
| 920 | + item("reviews", "/review-requests", au::t(lang, AuK::ReviewRequests)), | ||
| 921 | + item("new", "/new", t(lang, Key::NewRepository)), | ||
| 922 | + item("import", "/new/import", mg::t(lang, MGK::ImportTitle)), | ||
| 923 | + ]; | ||
| 924 | + if can_create_org { | ||
| 925 | + items.push(item("new-org", "/org/new", o::t(lang, OK::NewOrganization))); | ||
| 926 | + } | ||
| 927 | + items | ||
| 928 | +} | ||
| 929 | + | ||
| 879 | pub fn settings_items(lang: Lang) -> Vec<NavItem> { | 930 | pub fn settings_items(lang: Lang) -> Vec<NavItem> { |
| 880 | let item = |key, href: &'static str, label, icon| NavItem { | 931 | let item = |key, href: &'static str, label, icon| NavItem { |
| 881 | key, | 932 | key, |
| @@ -947,19 +998,23 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { | |||
| 947 | let (title, items) = match first { | 998 | let (title, items) = match first { |
| 948 | "admin" => (ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), | 999 | "admin" => (ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), |
| 949 | "settings" => (o::t(lang, OK::Settings).to_owned(), settings_items(lang)), | 1000 | "settings" => (o::t(lang, OK::Settings).to_owned(), settings_items(lang)), |
| 950 | - // An organization's own pages (`/org/{name}/members`, `teams`, `settings`); `/org/new` is | 1001 | + // An organization's settings pages (`/org/{name}/settings` and `settings/pins`) keep a |
| 951 | - // the create form and keeps the global links. | 1002 | + // sidebar. Its profile, members and teams pages have none: the tab bar leads to them. `/org/new` |
| 1003 | + // is the create form and keeps the global links. | ||
| 952 | "org" if !second.is_empty() && second != "new" => { | 1004 | "org" if !second.is_empty() && second != "new" => { |
| 953 | - let third = parts.next().unwrap_or(""); | 1005 | + if parts.next() != Some("settings") { |
| 954 | - let items = org_items(lang, second); | 1006 | + return None; |
| 955 | - let current = items | 1007 | + } |
| 956 | - .iter() | 1008 | + let current = if parts.next() == Some("pins") { |
| 957 | - .find(|item| item.key == third) | 1009 | + "pins" |
| 958 | - .map_or("", |item| item.key); | 1010 | + } else { |
| 1011 | + "settings" | ||
| 1012 | + }; | ||
| 959 | return Some(Section { | 1013 | return Some(Section { |
| 960 | title: second.to_owned(), | 1014 | title: second.to_owned(), |
| 961 | - back: t(lang, Key::BackToSite), | 1015 | + back: o::t(lang, OK::BackToOrganization), |
| 962 | - items, | 1016 | + back_href: user_href(second), |
| 1017 | + items: org_items(lang, second), | ||
| 963 | current, | 1018 | current, |
| 964 | live: "", | 1019 | live: "", |
| 965 | }); | 1020 | }); |
| @@ -979,6 +1034,7 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { | |||
| 979 | Some(Section { | 1034 | Some(Section { |
| 980 | title, | 1035 | title, |
| 981 | back: t(lang, Key::BackToSite), | 1036 | back: t(lang, Key::BackToSite), |
| 1037 | + back_href: "/".to_owned(), | ||
| 982 | items, | 1038 | items, |
| 983 | current, | 1039 | current, |
| 984 | live, | 1040 | live, |
| @@ -991,6 +1047,7 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { | |||
| 991 | async fn section_nav( | 1047 | async fn section_nav( |
| 992 | title: &str, | 1048 | title: &str, |
| 993 | back: &str, | 1049 | back: &str, |
| 1050 | + back_href: &str, | ||
| 994 | items: Vec<NavItem>, | 1051 | items: Vec<NavItem>, |
| 995 | current: &str, | 1052 | current: &str, |
| 996 | live: &str, | 1053 | live: &str, |
| @@ -1006,7 +1063,7 @@ async fn section_nav( | |||
| 1006 | .collect(); | 1063 | .collect(); |
| 1007 | Ok(view! { | 1064 | Ok(view! { |
| 1008 | <nav class="side-links" aria-label=(back)> | 1065 | <nav class="side-links" aria-label=(back)> |
| 1009 | - <a class="side-link" href="/"> | 1066 | + <a class="side-link" href=(back_href)> |
| 1010 | nav_icon(name: "back") | 1067 | nav_icon(name: "back") |
| 1011 | (back) | 1068 | (back) |
| 1012 | </a> | 1069 | </a> |
style/_dashboard.scssmodified+76 -0
| @@ -177,3 +177,79 @@ | |||
| 177 | margin: 0; | 177 | margin: 0; |
| 178 | } | 178 | } |
| 179 | } | 179 | } |
| 180 | + | ||
| 181 | +// Organization header: the avatar is 96px (the person's is larger), and the Edit organization and | ||
| 182 | +// New repository buttons sit in one row under the description line. | ||
| 183 | +.profile-avatar.org-avatar { | ||
| 184 | + width: 96px; | ||
| 185 | + height: 96px; | ||
| 186 | +} | ||
| 187 | + | ||
| 188 | +.profile-org-actions .profile-edit { | ||
| 189 | + margin-top: 0; | ||
| 190 | +} | ||
| 191 | + | ||
| 192 | +// Overview of an organization: the pinned repos fill the left column, two to a row, and the members | ||
| 193 | +// card sits at the right, 320px wide. Below 900px the two stack, the repos first. A person's | ||
| 194 | +// overview wrapper adds no box of its own. | ||
| 195 | +.profile-overview { | ||
| 196 | + display: contents; | ||
| 197 | +} | ||
| 198 | + | ||
| 199 | +.org-overview { | ||
| 200 | + display: grid; | ||
| 201 | + grid-template-columns: minmax(0, 1fr); | ||
| 202 | + gap: 16px; | ||
| 203 | + align-items: start; | ||
| 204 | + | ||
| 205 | + .pin-grid { | ||
| 206 | + grid-template-columns: repeat(2, minmax(0, 1fr)); | ||
| 207 | + } | ||
| 208 | +} | ||
| 209 | + | ||
| 210 | +@media (min-width: 900px) { | ||
| 211 | + .org-overview { | ||
| 212 | + grid-template-columns: minmax(0, 1fr) 320px; | ||
| 213 | + } | ||
| 214 | +} | ||
| 215 | + | ||
| 216 | +.profile-org { | ||
| 217 | + display: flex; | ||
| 218 | + flex-direction: column; | ||
| 219 | + gap: 10px; | ||
| 220 | + | ||
| 221 | + p { | ||
| 222 | + margin: 0; | ||
| 223 | + } | ||
| 224 | +} | ||
| 225 | + | ||
| 226 | +// Members: two avatars with names per row, each name cut short rather than wrapped. | ||
| 227 | +.org-members { | ||
| 228 | + display: grid; | ||
| 229 | + grid-template-columns: repeat(2, minmax(0, 1fr)); | ||
| 230 | + gap: 8px 12px; | ||
| 231 | + list-style: none; | ||
| 232 | + margin: 0; | ||
| 233 | + padding: 0; | ||
| 234 | + | ||
| 235 | + a { | ||
| 236 | + display: flex; | ||
| 237 | + align-items: center; | ||
| 238 | + gap: 8px; | ||
| 239 | + min-width: 0; | ||
| 240 | + color: inherit; | ||
| 241 | + text-decoration: none; | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + span { | ||
| 245 | + overflow: hidden; | ||
| 246 | + text-overflow: ellipsis; | ||
| 247 | + white-space: nowrap; | ||
| 248 | + } | ||
| 249 | +} | ||
| 250 | + | ||
| 251 | +.org-member-avatar { | ||
| 252 | + width: 32px; | ||
| 253 | + height: 32px; | ||
| 254 | + flex: 0 0 auto; | ||
| 255 | +} | ||
style/_fit.scssadded+11 -0
| @@ -0,0 +1,11 @@ | |||
| 1 | +// A pane that takes the window's remaining height, so the page itself does not scroll: what is too | ||
| 2 | +// long for the window scrolls inside it. nav.js measures the top and the footer (syncShellTop). Below | ||
| 3 | +// 900px pages stack, so a pane is as tall as its content. | ||
| 4 | +@media (min-width: 900px) { | ||
| 5 | + .fit-pane { | ||
| 6 | + box-sizing: border-box; | ||
| 7 | + height: max(360px, calc(100dvh - var(--pane-top, 288px) - var(--pane-foot, 78px))); | ||
| 8 | + overflow: auto; | ||
| 9 | + overscroll-behavior: contain; | ||
| 10 | + } | ||
| 11 | +} | ||
style/_fit_admin.scssadded+117 -0
| @@ -0,0 +1,117 @@ | |||
| 1 | +// One-screen layout of admin dashboards and forms. See _fit.scss. | ||
| 2 | +// | ||
| 3 | +// The selectors here are compound on purpose: _account_admin.scss and main.scss load after this | ||
| 4 | +// partial, so a single class rule there would win on equal specificity. | ||
| 5 | + | ||
| 6 | +// A fit pane's bottom margin would add to the page height, so it goes. | ||
| 7 | +.card.fit-pane { | ||
| 8 | + margin-bottom: 0; | ||
| 9 | +} | ||
| 10 | + | ||
| 11 | +// Instance health (/admin/health): the alerts card pages four alerts at a time, so its pager sits | ||
| 12 | +// close under the list. | ||
| 13 | +.admin-alerts .pager { | ||
| 14 | + margin: 0 0 8px; | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +// Instance health (/admin/health): the storage and services cards sit side by side, under the | ||
| 18 | +// summary. The alerts and the footnote span both columns. | ||
| 19 | +@media (min-width: 900px) { | ||
| 20 | + .health-page { | ||
| 21 | + display: grid; | ||
| 22 | + grid-template-columns: repeat(2, minmax(0, 1fr)); | ||
| 23 | + column-gap: 16px; | ||
| 24 | + | ||
| 25 | + > .page-head, | ||
| 26 | + > .admin-alerts, | ||
| 27 | + > .health-meta { | ||
| 28 | + grid-column: 1 / -1; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + .health-row { | ||
| 32 | + padding: 8px 0; | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +// User detail (/admin/users/{id}): the actions and the danger zone side by side, under the header. | ||
| 38 | +@media (min-width: 900px) { | ||
| 39 | + .user-page { | ||
| 40 | + display: grid; | ||
| 41 | + grid-template-columns: repeat(2, minmax(0, 1fr)); | ||
| 42 | + column-gap: 16px; | ||
| 43 | + | ||
| 44 | + > .user-head { | ||
| 45 | + grid-column: 1 / -1; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + .action-row { | ||
| 49 | + padding: 10px 0; | ||
| 50 | + } | ||
| 51 | + } | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +// Org teams (/org/{org}/teams): the team list and the new-team form side by side. | ||
| 55 | +@media (min-width: 900px) { | ||
| 56 | + .teams-page { | ||
| 57 | + display: grid; | ||
| 58 | + grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); | ||
| 59 | + column-gap: 16px; | ||
| 60 | + align-items: start; | ||
| 61 | + | ||
| 62 | + > :not(.card) { | ||
| 63 | + grid-column: 1 / -1; | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | +// Server settings (/admin/server): the settings card takes the left column and fills the window, | ||
| 69 | +// and the restart card sits beside it. The settings card runs three across, and four from 1200px. | ||
| 70 | +@media (min-width: 900px) { | ||
| 71 | + .srv-page { | ||
| 72 | + display: grid; | ||
| 73 | + grid-template-columns: minmax(0, 1fr) 260px; | ||
| 74 | + column-gap: 16px; | ||
| 75 | + align-items: start; | ||
| 76 | + | ||
| 77 | + > .page-head, | ||
| 78 | + > .subnav, | ||
| 79 | + > .notice { | ||
| 80 | + grid-column: 1 / -1; | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + // Tighter cells: the field rows sit closer, and the help text lines are shorter. | ||
| 85 | + .srv-form .srv-grid { | ||
| 86 | + grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); | ||
| 87 | + gap: 8px 16px; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + .srv-form .srv-field { | ||
| 91 | + gap: 4px; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + .srv-form .srv-field > p.small { | ||
| 95 | + line-height: 1.3; | ||
| 96 | + } | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | +// From 1200px the settings take four across, so the card has fewer rows and less hidden height. | ||
| 100 | +@media (min-width: 1200px) { | ||
| 101 | + .srv-form .srv-grid { | ||
| 102 | + grid-template-columns: repeat(4, minmax(0, 1fr)); | ||
| 103 | + } | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +// Mail settings (/admin/mail): the SMTP form runs three fields across, the actions span the row. | ||
| 107 | +@media (min-width: 900px) { | ||
| 108 | + form.stack[action="/admin/mail"] { | ||
| 109 | + display: grid; | ||
| 110 | + grid-template-columns: repeat(3, minmax(0, 1fr)); | ||
| 111 | + gap: 14px 24px; | ||
| 112 | + | ||
| 113 | + > .actions { | ||
| 114 | + grid-column: 1 / -1; | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | +} | ||
style/_fit_code.scssadded+91 -0
| @@ -0,0 +1,91 @@ | |||
| 1 | +// One-screen layout of code, commits and CI logs. See _fit.scss. | ||
| 2 | + | ||
| 3 | +// File view (blob): the file header stays put and the code, the image or the rendered Markdown is | ||
| 4 | +// the pane under it. The line anchors (#L12) scroll that box, since it is the nearest scroller. | ||
| 5 | +@media (min-width: 900px) { | ||
| 6 | + .file.fit-pane { | ||
| 7 | + display: flex; | ||
| 8 | + flex-direction: column; | ||
| 9 | + overflow: hidden; | ||
| 10 | + | ||
| 11 | + .file-head { | ||
| 12 | + flex: none; | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + .file-view, | ||
| 16 | + .file-image, | ||
| 17 | + .markdown-body { | ||
| 18 | + flex: 1 1 auto; | ||
| 19 | + min-height: 0; | ||
| 20 | + overflow: auto; | ||
| 21 | + } | ||
| 22 | + } | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +// Commit page: the title and the commit card stay above, and the diff fills the rest of the window. | ||
| 26 | +// The header is tall, so the pane may get less than the usual 360px minimum. | ||
| 27 | +@media (min-width: 900px) { | ||
| 28 | + .commit-diff.fit-pane { | ||
| 29 | + height: max(240px, calc(100dvh - var(--pane-top, 288px) - var(--pane-foot, 78px))); | ||
| 30 | + } | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +// Job page: the job card and the artifacts sit in a side column; the log card fills the right side, | ||
| 34 | +// and its `pre` is the scroller (nav.js follows its scrollTop), so the log card itself never scrolls. | ||
| 35 | +@media (min-width: 900px) { | ||
| 36 | + .ci-job-grid.fit-pane { | ||
| 37 | + display: grid; | ||
| 38 | + grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); | ||
| 39 | + grid-template-rows: auto minmax(0, 1fr); | ||
| 40 | + gap: 16px; | ||
| 41 | + | ||
| 42 | + > .card:not(.ci-logcard) { | ||
| 43 | + align-self: start; | ||
| 44 | + min-width: 0; | ||
| 45 | + margin: 0; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + > .ci-logcard { | ||
| 49 | + grid-column: 2; | ||
| 50 | + grid-row: 1 / span 2; | ||
| 51 | + display: flex; | ||
| 52 | + flex-direction: column; | ||
| 53 | + min-width: 0; | ||
| 54 | + min-height: 0; | ||
| 55 | + margin: 0; | ||
| 56 | + overflow: hidden; | ||
| 57 | + | ||
| 58 | + > *:not(.ci-log) { | ||
| 59 | + flex: none; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + .ci-log { | ||
| 63 | + flex: 1 1 auto; | ||
| 64 | + min-height: 0; | ||
| 65 | + max-height: none; | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | +} | ||
| 70 | + | ||
| 71 | +// Run page and runs list: the selected run (the right column of the split) is the pane. The runs | ||
| 72 | +// list beside it (.ci-side, main.scss) uses the same height. | ||
| 73 | +@media (min-width: 761px) { | ||
| 74 | + .ci-main { | ||
| 75 | + max-height: max(320px, calc(100dvh - var(--pane-top, 288px) - var(--pane-foot, 78px))); | ||
| 76 | + overflow: auto; | ||
| 77 | + } | ||
| 78 | +} | ||
| 79 | + | ||
| 80 | +// Profile overview: a little less air between the header, the tabs, the calendar and the pins, and | ||
| 81 | +// a smaller avatar, so the calendar and the pinned repos fit one window. | ||
| 82 | +@media (min-width: 900px) { | ||
| 83 | + .profile-page { | ||
| 84 | + gap: 16px; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + .profile-avatar { | ||
| 88 | + width: 144px; | ||
| 89 | + height: 144px; | ||
| 90 | + } | ||
| 91 | +} | ||
style/_fit_forms.scssadded+111 -0
| @@ -0,0 +1,111 @@ | |||
| 1 | +// One-screen layout of editor forms. See _fit.scss. An editor form sits in a .fit-pane: its editor | ||
| 2 | +// takes the rest of the height, so the buttons stay under it without a page scroll. | ||
| 3 | + | ||
| 4 | +// Short fields of the new-release form share a row; the hint goes under them. | ||
| 5 | +.release-pair { | ||
| 6 | + display: flex; | ||
| 7 | + flex-wrap: wrap; | ||
| 8 | + align-items: flex-end; | ||
| 9 | + gap: 14px 16px; | ||
| 10 | + | ||
| 11 | + > label { | ||
| 12 | + flex: 1 1 12rem; | ||
| 13 | + min-width: 0; | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + > p { | ||
| 17 | + order: 1; | ||
| 18 | + flex: 1 0 100%; | ||
| 19 | + margin: 0; | ||
| 20 | + } | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +@media (min-width: 900px) { | ||
| 24 | + // A card that is a pane with a form in it: no bottom margin (the pane fills the window), and the | ||
| 25 | + // form takes the rest of the card under the heading. | ||
| 26 | + .fit-pane.card { | ||
| 27 | + margin-bottom: 0; | ||
| 28 | + | ||
| 29 | + &:has(> form) { | ||
| 30 | + display: flex; | ||
| 31 | + flex-direction: column; | ||
| 32 | + | ||
| 33 | + > form { | ||
| 34 | + flex: 1 1 auto; | ||
| 35 | + min-height: 0; | ||
| 36 | + } | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + // The editor's label takes the rest of the form, and its textarea fills the label. | ||
| 41 | + .fit-pane > form > label:has(> textarea) { | ||
| 42 | + flex: 1 1 0; | ||
| 43 | + min-height: 0; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + .fit-pane > form > label > textarea { | ||
| 47 | + flex: 1 1 0; | ||
| 48 | + min-height: 6rem; | ||
| 49 | + height: auto; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + // The snippet form is the pane itself: its doc, its file card and the active file fill it. | ||
| 53 | + .snippet-form.fit-pane { | ||
| 54 | + // The pane clips its overflow, so the focus ring of the card edges gets a little room. | ||
| 55 | + padding: 4px; | ||
| 56 | + | ||
| 57 | + .snippet-doc, | ||
| 58 | + .snippet-files { | ||
| 59 | + flex: 1 1 auto; | ||
| 60 | + min-height: 0; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + // The active file is shown by a :has() rule in main.scss (specificity 1,3,0). This one is one | ||
| 64 | + // class higher, so the file can be a flex column that its contents fill. | ||
| 65 | + @for $i from 0 through 9 { | ||
| 66 | + .snippet-files:has(#snippet-tab-#{$i}:checked) .snippet-panel-#{$i} { | ||
| 67 | + display: flex; | ||
| 68 | + flex-direction: column; | ||
| 69 | + flex: 1 1 auto; | ||
| 70 | + min-height: 0; | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + .snippet-content { | ||
| 75 | + flex: 1 1 0; | ||
| 76 | + min-height: 0; | ||
| 77 | + height: auto; | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + // The import page (pages/import.rs, import_home): the form and the recent imports side by side on | ||
| 82 | + // wide windows, each a pane that scrolls inside. | ||
| 83 | + .import-home { | ||
| 84 | + display: grid; | ||
| 85 | + grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem); | ||
| 86 | + align-items: start; | ||
| 87 | + gap: 16px; | ||
| 88 | + | ||
| 89 | + > .newrepo-form.fit-pane { | ||
| 90 | + max-width: none; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + > .import-recent { | ||
| 94 | + max-width: none; | ||
| 95 | + margin: 0; | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + // The form's two cards share a row on the widest windows; the header and the notes span both. | ||
| 100 | + @media (min-width: 1200px) { | ||
| 101 | + .import-home > .newrepo-form { | ||
| 102 | + display: grid; | ||
| 103 | + grid-template-columns: repeat(2, minmax(0, 1fr)); | ||
| 104 | + align-items: start; | ||
| 105 | + | ||
| 106 | + > :not(.newrepo-card) { | ||
| 107 | + grid-column: 1 / -1; | ||
| 108 | + } | ||
| 109 | + } | ||
| 110 | + } | ||
| 111 | +} | ||
style/_fit_lists.scssadded+27 -0
| @@ -0,0 +1,27 @@ | |||
| 1 | +// One-screen layout of notifications, security log and audit log. See _fit.scss. | ||
| 2 | +@media (min-width: 900px) { | ||
| 3 | + // The notifications pane holds the groups and the older link: it scrolls only in a page of many | ||
| 4 | + // small groups. Its bottom margin would add to the page's height, so it has none. | ||
| 5 | + .notif-pane.fit-pane { | ||
| 6 | + margin-bottom: 0; | ||
| 7 | + } | ||
| 8 | + | ||
| 9 | + // A table card (audit log, security log): the table scrolls inside the card and the pager stays | ||
| 10 | + // at its bottom, in the same column, so the paging is always in view. | ||
| 11 | + .fit-pane.fit-list { | ||
| 12 | + display: flex; | ||
| 13 | + flex-direction: column; | ||
| 14 | + overflow: hidden; | ||
| 15 | + margin-bottom: 0; | ||
| 16 | + | ||
| 17 | + > .table-wrap { | ||
| 18 | + flex: 1 1 auto; | ||
| 19 | + min-height: 0; | ||
| 20 | + overflow: auto; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + > .pager { | ||
| 24 | + flex: none; | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | +} | ||
style/_fit_settings.scssadded+55 -0
| @@ -0,0 +1,55 @@ | |||
| 1 | +// One-screen layout of repo and org settings. See _fit.scss. | ||
| 2 | + | ||
| 3 | +// A settings page that puts its cards side by side: the list and its add forms, or the general cards | ||
| 4 | +// in columns. Below 900px the cards stack. From 900px the cards share the row, and a card that does | ||
| 5 | +// not fit the pane's height scrolls inside it. | ||
| 6 | +.settings-split { | ||
| 7 | + display: grid; | ||
| 8 | + grid-template-columns: minmax(0, 1fr); | ||
| 9 | + align-items: start; | ||
| 10 | + align-content: start; | ||
| 11 | + gap: 16px; | ||
| 12 | + | ||
| 13 | + > .card { | ||
| 14 | + margin-bottom: 0; | ||
| 15 | + } | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +@media (min-width: 900px) { | ||
| 19 | + .settings-split { | ||
| 20 | + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); | ||
| 21 | + } | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +// A column of the general settings: its cards stack with the same gap as the row. | ||
| 25 | +.settings-col { | ||
| 26 | + display: flex; | ||
| 27 | + flex-direction: column; | ||
| 28 | + gap: 16px; | ||
| 29 | + min-width: 0; | ||
| 30 | + | ||
| 31 | + > .card { | ||
| 32 | + margin-bottom: 0; | ||
| 33 | + } | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +// The branch rule form is narrower in a column, so its pushes and merging switches stack. | ||
| 37 | +.settings-col .rule-pair { | ||
| 38 | + grid-template-columns: minmax(0, 1fr); | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +// The new webhook form: the fields in the left column, the event list in the right one. | ||
| 42 | +@media (min-width: 900px) { | ||
| 43 | + .settings-split .webhook-form { | ||
| 44 | + display: grid; | ||
| 45 | + grid-template-columns: repeat(2, minmax(0, 1fr)); | ||
| 46 | + align-items: start; | ||
| 47 | + gap: 14px 32px; | ||
| 48 | + max-width: none; | ||
| 49 | + | ||
| 50 | + > .event-choices { | ||
| 51 | + grid-column: 2; | ||
| 52 | + grid-row: 1 / span 6; | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | +} | ||
style/_fit_tables.scssadded+65 -0
| @@ -0,0 +1,65 @@ | |||
| 1 | +// One-screen layout of runners, labels, milestones and releases. See _fit.scss. | ||
| 2 | +// | ||
| 3 | +// A list card fills the pane (`.fit-pane`): its header stays put, its rows scroll inside `.fit-scroll`, | ||
| 4 | +// and the pager sits under them in the same column (`.fit-card`). Beside it, a narrow card (`.fit-side`) | ||
| 5 | +// holds the create form, so the form is in reach without scrolling. Below 900px the row stacks and | ||
| 6 | +// nothing has a fixed height. | ||
| 7 | + | ||
| 8 | +.fit-split { | ||
| 9 | + display: flex; | ||
| 10 | + align-items: stretch; | ||
| 11 | + gap: 20px; | ||
| 12 | + | ||
| 13 | + > .fit-main { | ||
| 14 | + flex: 1 1 auto; | ||
| 15 | + min-width: 0; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + > .fit-side { | ||
| 19 | + flex: 0 0 300px; | ||
| 20 | + min-width: 0; | ||
| 21 | + } | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +.fit-card { | ||
| 25 | + display: flex; | ||
| 26 | + flex-direction: column; | ||
| 27 | + min-height: 0; | ||
| 28 | + | ||
| 29 | + > .fit-scroll { | ||
| 30 | + flex: 1 1 auto; | ||
| 31 | + min-height: 0; | ||
| 32 | + overflow: auto; | ||
| 33 | + overscroll-behavior: contain; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + > .pager { | ||
| 37 | + flex: none; | ||
| 38 | + margin-top: 8px; | ||
| 39 | + } | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +// Runner rows reach 12px past the list on each side (see `.runner-row.is-linked`); the scroll box | ||
| 43 | +// takes that room so the hover background is not cut off. | ||
| 44 | +.fit-bleed { | ||
| 45 | + margin: 0 -12px; | ||
| 46 | + padding: 0 12px; | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +// Labels fill the card in columns, so twelve of them take three or four rows, not twelve. | ||
| 50 | +.fit-card .label-list { | ||
| 51 | + display: grid; | ||
| 52 | + grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); | ||
| 53 | + column-gap: 24px; | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +@media (max-width: 899px) { | ||
| 57 | + .fit-split { | ||
| 58 | + flex-direction: column; | ||
| 59 | + | ||
| 60 | + > .fit-side { | ||
| 61 | + flex: none; | ||
| 62 | + width: 100%; | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | +} | ||
style/_fit_threads.scssadded+17 -0
| @@ -0,0 +1,17 @@ | |||
| 1 | +// One-screen layout of issues, pull requests and discussions. See _fit.scss. | ||
| 2 | +// The conversation column and the side column carry .fit-pane in the markup: from 900px each scrolls | ||
| 3 | +// on its own and the page does not. The padding keeps a focus ring and the comment box's edge from | ||
| 4 | +// being cut by the scroller, and leaves room under the last item. | ||
| 5 | +@media (min-width: 900px) { | ||
| 6 | + .issue-column.fit-pane, | ||
| 7 | + .issue-sidebar.fit-pane { | ||
| 8 | + padding: 2px 8px 16px 2px; | ||
| 9 | + scrollbar-gutter: stable; | ||
| 10 | + } | ||
| 11 | + | ||
| 12 | + // A pull's files: the review bar and the diff scroll inside the pane. The header and tabs above it stay | ||
| 13 | + // in view, and the sticky file headers of the diff stick inside the pane. | ||
| 14 | + .fit-pane > .diff-section { | ||
| 15 | + padding: 2px 8px 16px 2px; | ||
| 16 | + } | ||
| 17 | +} | ||
style/_repo.scssmodified+49 -3
| @@ -263,9 +263,9 @@ | |||
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | .repo-home { | 265 | .repo-home { |
| 266 | - // The grid fills the viewport under the top bar and the repo header, so the page does not scroll; | 266 | + // The grid fills the window below the repo header and above the footer, so the page does not |
| 267 | - // each column scrolls on its own. | 267 | + // scroll; each column scrolls on its own. nav.js measures both ends (syncShellTop). |
| 268 | - --repo-home-h: max(480px, calc(100dvh - var(--topbar-h) - 236px)); | 268 | + --repo-home-h: max(480px, calc(100dvh - var(--pane-top, 288px) - var(--pane-foot, 78px))); |
| 269 | 269 | ||
| 270 | // One row: the branch, Go to file and, at the right end, Clone (which also holds the downloads). | 270 | // One row: the branch, Go to file and, at the right end, Clone (which also holds the downloads). |
| 271 | .browse-bar { | 271 | .browse-bar { |
| @@ -1456,3 +1456,49 @@ html.tree-resizing .repo-split::before { | |||
| 1456 | } | 1456 | } |
| 1457 | } | 1457 | } |
| 1458 | } | 1458 | } |
| 1459 | + | ||
| 1460 | +// A CI badge on forge's own pages (syncBadges in nav.js): the two halves of the SVG, in theme colours. | ||
| 1461 | +// The image stays hidden while its data is fetched, so it does not flash its own colours. | ||
| 1462 | +img.badge-wait { | ||
| 1463 | + visibility: hidden; | ||
| 1464 | +} | ||
| 1465 | + | ||
| 1466 | +.ci-chip { | ||
| 1467 | + --chip: var(--muted); | ||
| 1468 | + display: inline-flex; | ||
| 1469 | + overflow: hidden; | ||
| 1470 | + font-size: 11px; | ||
| 1471 | + font-weight: 600; | ||
| 1472 | + line-height: 18px; | ||
| 1473 | + vertical-align: middle; | ||
| 1474 | + border: 1px solid color-mix(in srgb, var(--chip) 45%, var(--border)); | ||
| 1475 | + border-radius: 6px; | ||
| 1476 | + | ||
| 1477 | + > span { | ||
| 1478 | + padding: 0 7px; | ||
| 1479 | + } | ||
| 1480 | + | ||
| 1481 | + > :first-child { | ||
| 1482 | + color: var(--muted); | ||
| 1483 | + background: var(--surface); | ||
| 1484 | + } | ||
| 1485 | + | ||
| 1486 | + > :last-child { | ||
| 1487 | + color: var(--chip); | ||
| 1488 | + background: color-mix(in srgb, var(--chip) 16%, var(--surface)); | ||
| 1489 | + } | ||
| 1490 | + | ||
| 1491 | + &[data-status="passing"] { | ||
| 1492 | + --chip: var(--ok); | ||
| 1493 | + } | ||
| 1494 | + | ||
| 1495 | + &[data-status="failing"], | ||
| 1496 | + &[data-status="error"] { | ||
| 1497 | + --chip: var(--bad); | ||
| 1498 | + } | ||
| 1499 | + | ||
| 1500 | + &[data-status="running"], | ||
| 1501 | + &[data-status="pending"] { | ||
| 1502 | + --chip: var(--heat-3); | ||
| 1503 | + } | ||
| 1504 | +} | ||
style/_shell.scssmodified+21 -1
| @@ -484,6 +484,20 @@ | |||
| 484 | } | 484 | } |
| 485 | } | 485 | } |
| 486 | 486 | ||
| 487 | +// Signed in, Explore sits right after the path bar, centred on the bar's line. It shows from 700px: | ||
| 488 | +// below that there is no room for it, and signed-in phones reach Explore through no icon. | ||
| 489 | +.topbar .topbar-explore { | ||
| 490 | + display: none; | ||
| 491 | + align-self: center; | ||
| 492 | + white-space: nowrap; | ||
| 493 | +} | ||
| 494 | + | ||
| 495 | +@media (min-width: 640px) { | ||
| 496 | + .topbar .topbar-explore { | ||
| 497 | + display: inline-block; | ||
| 498 | + } | ||
| 499 | +} | ||
| 500 | + | ||
| 487 | // The avatar menu: the avatar is the summary; the menu list keeps its links from main.scss. | 501 | // The avatar menu: the avatar is the summary; the menu list keeps its links from main.scss. |
| 488 | .topbar .menu { | 502 | .topbar .menu { |
| 489 | flex: none; | 503 | flex: none; |
| @@ -541,7 +555,7 @@ | |||
| 541 | .shell { | 555 | .shell { |
| 542 | display: grid; | 556 | display: grid; |
| 543 | grid-template-columns: minmax(0, 1fr); | 557 | grid-template-columns: minmax(0, 1fr); |
| 544 | - min-height: calc(100vh - var(--topbar-h)); | 558 | + flex: 1 0 auto; |
| 545 | } | 559 | } |
| 546 | 560 | ||
| 547 | .shell-sidebar { | 561 | .shell-sidebar { |
| @@ -758,6 +772,12 @@ a.chip { | |||
| 758 | border: 1px solid var(--border); | 772 | border: 1px solid var(--border); |
| 759 | border-radius: var(--radius-md); | 773 | border-radius: var(--radius-md); |
| 760 | box-shadow: var(--shadow); | 774 | box-shadow: var(--shadow); |
| 775 | + opacity: 0; | ||
| 776 | +} | ||
| 777 | + | ||
| 778 | +// Hidden until its list is in (loadPeek in nav.js), so it opens at its final height. | ||
| 779 | +.bell-pop.bell-ready { | ||
| 780 | + opacity: 1; | ||
| 761 | } | 781 | } |
| 762 | 782 | ||
| 763 | .bell-box { | 783 | .bell-box { |
style/main.scssmodified+12 -1
| @@ -192,6 +192,9 @@ html { | |||
| 192 | 192 | ||
| 193 | body { | 193 | body { |
| 194 | margin: 0; | 194 | margin: 0; |
| 195 | + display: flex; | ||
| 196 | + flex-direction: column; | ||
| 197 | + min-height: 100dvh; | ||
| 195 | background: var(--bg); | 198 | background: var(--bg); |
| 196 | color: var(--text); | 199 | color: var(--text); |
| 197 | font-family: var(--font); | 200 | font-family: var(--font); |
| @@ -5852,7 +5855,7 @@ html.js form.runner-load[data-dirty-form][data-dirty] .runner-save { | |||
| 5852 | top: calc(var(--topbar-h) + 16px); | 5855 | top: calc(var(--topbar-h) + 16px); |
| 5853 | display: flex; | 5856 | display: flex; |
| 5854 | flex-direction: column; | 5857 | flex-direction: column; |
| 5855 | - max-height: calc(100dvh - max(var(--topbar-h), var(--shell-top, 0px)) - 104px); | 5858 | + max-height: max(320px, calc(100dvh - var(--pane-top, 288px) - var(--pane-foot, 78px))); |
| 5856 | } | 5859 | } |
| 5857 | 5860 | ||
| 5858 | .ci-side-head, | 5861 | .ci-side-head, |
| @@ -7062,6 +7065,14 @@ button.ci-job-last { | |||
| 7062 | @import "repo"; | 7065 | @import "repo"; |
| 7063 | @import "pull"; | 7066 | @import "pull"; |
| 7064 | @import "dashboard"; | 7067 | @import "dashboard"; |
| 7068 | +@import "fit"; | ||
| 7069 | +@import "fit_lists"; | ||
| 7070 | +@import "fit_tables"; | ||
| 7071 | +@import "fit_admin"; | ||
| 7072 | +@import "fit_settings"; | ||
| 7073 | +@import "fit_forms"; | ||
| 7074 | +@import "fit_threads"; | ||
| 7075 | +@import "fit_code"; | ||
| 7065 | @import "wiki"; | 7076 | @import "wiki"; |
| 7066 | @import "browse"; | 7077 | @import "browse"; |
| 7067 | @import "import"; | 7078 | @import "import"; |