forge
Explore
Log in

Don't you dare go Hollow

Search forgives typos and reaches everywhere: letters missing, extra, wrong or swapped still match, accents do not matter, and words match in any order, so secuirty, pasword and forge webhoks land where they should

Browse files at this commit

1512ebbfc3168802ec6e7df88f3a74b0f6587f1aAhmet Kaan GümüşParent: 158fa0f
All checks have passed
Show checks
  • feat
    • search forgives typos and reaches everywhere: letters missing, extra, wrong or swapped still match, accents do not matter, and words match in any order, so secuirty, pasword and forge webhoks land where they should
    • it finds what is on a settings page, every organization tab and team, every admin page and each server setting, landing in that field, and the pages of the current repo or any repo named in the query
    • a row says which word matched
  • refactor
    • pins are chosen from a menu on the profile and the separate pins page is gone
  • style
    • pages hold up on wide windows with real data: one-pane pages fill the window and a list keeps its form beside it, org Members and Teams are a list with a form with no repeated heading, invites, mail, import and the runner page lose their gaps, mail's test button sits by Save, profile and org tabs no longer hug their underline, the branch picker drops its key hints and accent, and explore lists organizations on one row
  • fix
    • the on state of a toggle shows its knob again, and the newest commit in the history bars is no longer green unless a run says so
Show full message
✨ feat: search forgives typos and reaches everywhere: letters missing, extra, wrong or swapped still match, accents do not matter, and words match in any order, so secuirty, pasword and forge webhoks land where they should; it finds what is on a settings page, every organization tab and team, every admin page and each server setting, landing in that field, and the pages of the current repo or any repo named in the query; a row says which word matched; ♻️ refactor: pins are chosen from a menu on the profile and the separate pins page is gone; 💄 style: pages hold up on wide windows with real data: one-pane pages fill the window and a list keeps its form beside it, org Members and Teams are a list with a form with no repeated heading, invites, mail, import and the runner page lose their gaps, mail's test button sits by Save, profile and org tabs no longer hug their underline, the branch picker drops its key hints and accent, and explore lists organizations on one row; 🐛 fix: the on state of a toggle shows its knob again, and the newest commit in the history bars is no longer green unless a run says so
crates/forge-web/assets/nav.jsmodified+177 -23
@@ -310,6 +310,9 @@
310310 var el = document.getElementById(id);
311311 if (!el) { return false; }
312312 el.scrollIntoView();
313+ // A palette shortcut to a server setting lands in its field.
314+ var field = el.matches('.srv-field') ? el.querySelector('input:not([type="hidden"]), select, textarea') : null;
315+ if (field) { field.focus({ preventScroll: true }); }
313316 return true;
314317 }
315318
@@ -766,7 +769,7 @@
766769
767770 // Dropdown menus: the <details> that float over the page (avatar menu, branch selector, clone
768771 // popover, section menu, profile corner). Inline disclosures are not listed: a click outside leaves them open.
769- var DROPDOWN = 'details.menu, details.ref-select, details.clone, details.nav-toggle, details.corner, details.strip-runs, details.dock-expand';
772+ var DROPDOWN = 'details.menu, details.pins-menu, details.ref-select, details.clone, details.nav-toggle, details.corner, details.strip-runs, details.dock-expand';
770773
771774 // Closes every open dropdown that does not contain `from` (pass null to close them all). A click
772775 // inside the floating corner keeps its own menu open.
@@ -4025,6 +4028,7 @@
40254028 var PALETTE_TTL = 60000; // ms a fetched list stays fresh
40264029 var PALETTE_MAX = 50; // options shown at once
40274030 var PALETTE_WORD = /[\s\/._\-·]/; // a character that starts a word, for the word-start match
4031+ var PALETTE_SPLIT = /[\s\/._\-·]+/; // the same characters, to split a text into words
40284032 // files: the current repo's file items, once its finder list is loaded (filesSrc names the finder
40294033 // it came from); filesBusy names the source being fetched.
40304034 // acts: the actions this page offers, read from its live elements at each open. busy: a state change
@@ -4079,42 +4083,180 @@
40794083 return out;
40804084 }
40814085
4082- // How well the lowercased query matches a label: 3 for a prefix, 2 for a match at a word start,
4083- // 1 for the letters in order anywhere, 0 for no match. A shorter label wins within a tier, and the
4084- // bonus stays under 0.5 so it never lifts a label into the tier above. An empty query matches all.
4085- function paletteScore(q, label) {
4086- if (!q) { return 1; }
4087- var s = label.toLowerCase();
4088- var bonus = 1 / (s.length + 2);
4089- var at = s.indexOf(q);
4086+ // Text for matching: lowercase, without accents, and with the dotless i, so "guvenlik" finds "Güvenlik".
4087+ function paletteFold(text) {
4088+ return text.toLowerCase().normalize('NFD').replace(/[̀-ͯ]/g, '').replace(/ı/g, 'i');
4089+ }
4090+
4091+ // A text ready to match against: folded, split into words, and with its separators removed.
4092+ function paletteParts(text) {
4093+ var s = paletteFold(text);
4094+ var words = s.split(PALETTE_SPLIT).filter(Boolean);
4095+ return { text: text, s: s, words: words, whole: words.join('') };
4096+ }
4097+
4098+ // An item's label and other words, folded once.
4099+ function paletteMeta(item) {
4100+ if (!item.meta) {
4101+ item.meta = { label: paletteParts(item.label), terms: (item.terms || []).map(paletteParts) };
4102+ }
4103+ return item.meta;
4104+ }
4105+
4106+ // The fewest single-letter typos (a missing, extra or wrong letter, or two letters swapped) between
4107+ // the token and the start of the word, or more than max when there are too many.
4108+ function paletteTypos(t, w, max) {
4109+ if (w.length < t.length - max) { return max + 1; }
4110+ var size = Math.min(w.length, t.length + max) + 1;
4111+ var before = null, prev = [], row = [], i, j;
4112+ for (j = 0; j < size; j++) { prev[j] = j; }
4113+ for (i = 1; i <= t.length; i++) {
4114+ row = [i];
4115+ var low = i;
4116+ for (j = 1; j < size; j++) {
4117+ var cost = t.charAt(i - 1) === w.charAt(j - 1) ? 0 : 1;
4118+ var v = Math.min(prev[j] + 1, row[j - 1] + 1, prev[j - 1] + cost);
4119+ if (before && j > 1 && t.charAt(i - 1) === w.charAt(j - 2) && t.charAt(i - 2) === w.charAt(j - 1)) {
4120+ v = Math.min(v, before[j - 2] + 1);
4121+ }
4122+ row[j] = v;
4123+ if (v < low) { low = v; }
4124+ }
4125+ if (low > max) { return max + 1; }
4126+ before = prev;
4127+ prev = row;
4128+ }
4129+ var best = max + 1;
4130+ for (j = Math.max(0, t.length - max); j < size; j++) { if (row[j] < best) { best = row[j]; } }
4131+ return best;
4132+ }
4133+
4134+ // How well one token matches a text: 4 exact, 3 prefix, 2.6 a whole word, 2 a word's start,
4135+ // 1.8 inside a word, then 1.5 or 1.4 for one or two typos. A long token may have more typos,
4136+ // and one under four letters has none, or "ssh" would match half the list.
4137+ function paletteField(t, x) {
4138+ if (x.s === t) { return 4; }
4139+ var at = x.s.indexOf(t);
4140+ if (at === 0) { return 3; }
4141+ if (x.words.indexOf(t) >= 0) { return 2.6; }
4142+ var mid = at >= 0 ? 1.8 : 0;
40904143 while (at >= 0) {
4091- if (at === 0) { return 3 + bonus; }
4092- if (PALETTE_WORD.test(s.charAt(at - 1))) { return 2 + bonus; }
4093- at = s.indexOf(q, at + 1);
4144+ if (PALETTE_WORD.test(x.s.charAt(at - 1))) { return 2; }
4145+ at = x.s.indexOf(t, at + 1);
4146+ }
4147+ if (mid) { return mid; }
4148+ var max = t.length < 4 ? 0 : t.length < 8 ? 1 : 2;
4149+ if (!max) { return 0; }
4150+ var best = max + 1, first = false;
4151+ for (var i = 0; i < x.words.length; i++) {
4152+ var d = paletteTypos(t, x.words[i], max);
4153+ if (d < best) { best = d; first = i === 0; }
4154+ }
4155+ if (x.words.length > 1 && t.length >= 6) { best = Math.min(best, paletteTypos(t, x.whole, max)); }
4156+ return best <= max ? 1.6 - best / 10 + (first ? 0.05 : 0) : 0;
4157+ }
4158+
4159+ // The letters of the token in order, close together, so "gk" finds "GPG Keys" and a long label
4160+ // does not match by holding every letter somewhere.
4161+ function paletteInOrder(t, s) {
4162+ var ti = 0, from = -1;
4163+ for (var i = 0; i < s.length && ti < t.length; i++) {
4164+ if (s.charAt(i) === t.charAt(ti)) {
4165+ if (!ti) { from = i; }
4166+ ti++;
4167+ if (ti === t.length) { return i - from < t.length * 3; }
4168+ }
4169+ }
4170+ return false;
4171+ }
4172+
4173+ // How well one token matches an item: its label first, then its other words at four fifths of the
4174+ // score. Sets item.why to the other word that matched, so the row can say why it is listed.
4175+ function paletteToken(t, item) {
4176+ var m = paletteMeta(item);
4177+ var best = paletteField(t, m.label), why = '';
4178+ m.terms.forEach(function (term) {
4179+ var v = paletteField(t, term) * 0.8;
4180+ if (v > best) { best = v; why = /[._]/.test(term.text) || m.label.s.indexOf(term.s) >= 0 ? '' : term.text; }
4181+ });
4182+ if (!best && paletteInOrder(t, m.label.s)) { best = 1; }
4183+ if (why) { item.why = why; }
4184+ return best;
4185+ }
4186+
4187+ // How well a query matches an item, 0 for no match. Each word of the query must match, in any order,
4188+ // so "forge hooks" and "mail host" work. The whole query as a phrase counts too, and a shorter label
4189+ // wins within a tier: the bonus stays under 0.5. An empty query matches all.
4190+ function paletteScore(q, item) {
4191+ item.why = '';
4192+ if (!q) { return 1; }
4193+ var fq = paletteFold(q).trim();
4194+ var m = paletteMeta(item);
4195+ var bonus = 1 / (m.label.s.length + 2);
4196+ var tokens = fq.split(/\s+/);
4197+ var sum = 0;
4198+ for (var i = 0; i < tokens.length; i++) {
4199+ var v = paletteToken(tokens[i], item);
4200+ if (!v) {
4201+ if (tokens.length < 2 || m.label.s.indexOf(fq) < 0) { return 0; }
4202+ sum = 0;
4203+ break;
4204+ }
4205+ sum += v;
40944206 }
4095- var qi = 0;
4096- for (var i = 0; i < s.length && qi < q.length; i++) {
4097- if (s.charAt(i) === q.charAt(qi)) { qi++; }
4207+ var best = sum / tokens.length;
4208+ if (tokens.length > 1) { best = Math.max(best, paletteField(fq, m.label)); }
4209+ return best + bonus;
4210+ }
4211+
4212+ // The pages of a repo the query is about: the current repo's always, and with two or more words,
4213+ // those of up to four repos one word names, so "forge hooks" works from any page.
4214+ function paletteRepoPages(q, current) {
4215+ var pages = (pal.data && pal.data.pages) || [];
4216+ var out = [], seen = {};
4217+ function add(label, base, admin) {
4218+ pages.forEach(function (p) {
4219+ var href = base + '/' + p.path;
4220+ if ((p.admin && !admin) || seen[href]) { return; }
4221+ seen[href] = true;
4222+ out.push({ label: label + ' · ' + p.label, href: href, kind: 'repo', terms: p.terms });
4223+ });
40984224 }
4099- return qi === q.length ? 1 + bonus : 0;
4225+ if (current) { add(current.name, current.href, current.admin); }
4226+ var tokens = paletteFold(q).split(/\s+/).filter(Boolean);
4227+ if (tokens.length < 2 || !pal.data) { return out; }
4228+ var found = 0;
4229+ pal.data.items.forEach(function (item) {
4230+ if (item.kind !== 'repo' || found >= 4) { return; }
4231+ var named = tokens.some(function (t) { return paletteField(t, paletteMeta(item).label) >= 1.4; });
4232+ if (named) { found++; add(item.label, item.href, item.admin); }
4233+ });
4234+ return out;
41004235 }
41014236
4102- // The destinations to filter: the current repo's tabs first, then the fetched list.
4103- function paletteItems() {
4104- var items = [];
4237+ // The destinations to filter: the current repo's tabs first, its other pages, then the fetched list.
4238+ // The query picks which other repos' pages are worth building.
4239+ function paletteItems(q) {
4240+ var items = [], current = null;
41054241 var tabs = document.querySelectorAll('.repo-tabs a');
41064242 if (tabs.length) {
41074243 // The first tab is the repo's Code link, so its path starts with owner/name.
41084244 var parts = tabs[0].pathname.split('/');
41094245 var repo = parts.length >= 3 ? parts[1] + '/' + parts[2] : '';
41104246 if (repo) {
4247+ var admin = false;
41114248 Array.prototype.forEach.call(tabs, function (a) {
41124249 // Counts sit in a span at the end of the tab ("Issues 3"); the name is the rest.
41134250 var name = a.textContent.replace(/\s+/g, ' ').trim().replace(/ \d+$/, '');
41144251 items.push({ label: repo + ' · ' + name, href: a.getAttribute('href') || '', kind: 'repo' });
4252+ if (a.pathname === '/' + repo + '/settings') { admin = true; }
41154253 });
4254+ current = { name: repo, href: '/' + repo, admin: admin };
41164255 }
41174256 }
4257+ var known = {};
4258+ items.forEach(function (i) { known[i.href] = true; });
4259+ items = items.concat(paletteRepoPages(q, current).filter(function (i) { return !known[i.href]; }));
41184260 if (pal.data) { items = items.concat(pal.data.items); }
41194261 return pal.acts.concat(items);
41204262 }
@@ -4150,6 +4292,7 @@
41504292 // The text a completed item leaves in the input: a tab's label is its repo, and a repo gets a "/".
41514293 function paletteCompletion(item) {
41524294 var label = item.label;
4295+ if (item.kind !== 'repo' && item.kind !== 'org') { return label; }
41534296 var at = label.indexOf(' \u00b7 ');
41544297 if (at >= 0) { label = label.slice(0, at); }
41554298 return label + (item.kind === 'repo' ? '/' : '');
@@ -4176,14 +4319,19 @@
41764319 var typed = pal.prefill && !idle && q.indexOf(pal.prefill.toLowerCase()) === 0 ? q.slice(pal.prefill.length) : '';
41774320 // With a "/" the query is a path: an item matches when its label starts with it.
41784321 var pathMode = q.indexOf('/') >= 0;
4322+ // After the opening path, text with no "/" of its own searches by name, as it would with no path.
4323+ var words = typed && typed.indexOf('/') < 0 ? typed : (typed || idle ? '' : q.replace(/\//g, ' ').trim());
41794324 var scored = [];
4180- paletteItems().concat(paletteFiles(q)).forEach(function (item, idx) {
4325+ paletteItems(pathMode ? words : q).concat(paletteFiles(q)).forEach(function (item, idx) {
41814326 if (!Object.prototype.hasOwnProperty.call(pal.str.heads, item.kind)) { return; }
4182- var s = pathMode ? (item.label.toLowerCase().indexOf(q) === 0 ? 3 : 0) : paletteScore(q, item.label);
4327+ var s;
4328+ if (!pathMode) { s = paletteScore(q, item); }
4329+ else if (item.label.toLowerCase().indexOf(q) === 0) { s = item.label.length === q.length ? 3.5 : 3; item.why = ''; }
4330+ else { s = words && item.kind !== 'file' && item.kind !== 'action' ? paletteScore(words, item) : 0; }
41834331 // Above a path match (3), which would otherwise fill the list and cut the actions off. Text typed
41844332 // after the opening path searches the page's actions by name.
41854333 if (item.kind === 'action' && idle) { s = 4; }
4186- else if (item.kind === 'action' && typed) { var m = paletteScore(typed, item.label); s = m ? m + 3 : 0; }
4334+ else if (item.kind === 'action' && typed) { var m = paletteScore(typed, item); s = m ? m + 3 : 0; }
41874335 if (s > 0) { scored.push({ item: item, score: s, idx: idx }); }
41884336 });
41894337 scored.sort(function (a, b) { return b.score - a.score || a.idx - b.idx; });
@@ -4221,6 +4369,12 @@
42214369 li.setAttribute('aria-selected', 'false');
42224370 li.setAttribute('data-n', String(n));
42234371 li.textContent = item.label;
4372+ if (item.why) {
4373+ var why = document.createElement('span');
4374+ why.className = 'palette-why';
4375+ why.textContent = item.why;
4376+ li.appendChild(why);
4377+ }
42244378 pal.list.appendChild(li);
42254379 });
42264380 });
@@ -4248,7 +4402,7 @@
42484402 if (!r.ok) { throw new Error('status ' + r.status); }
42494403 return r.json();
42504404 }).then(function (json) {
4251- pal.data = { at: Date.now(), items: Array.isArray(json.items) ? json.items : [] };
4405+ pal.data = { at: Date.now(), items: Array.isArray(json.items) ? json.items : [], pages: Array.isArray(json.repoPages) ? json.repoPages : [] };
42524406 pal.request = null;
42534407 if (pal.dlg.open) { renderPalette(); }
42544408 }).catch(function () {
crates/forge-web/src/pages/admin_mail.rsmodified+2 -4
@@ -268,13 +268,11 @@ async fn mail_view(
268268 <label><input type="checkbox" name="enabled" value="on" checked=(data.enabled)>(g::t(lang, K::SendMailCheckbox))</label>
269269 <div class="actions">
270270 <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button>
271+ <button type="submit" form="mail-test">(g::t(lang, K::SendTestMailToMe))</button>
271272 </div>
272273 </form>
273- <form method="post" action="/admin/mail/test">
274+ <form id="mail-test" method="post" action="/admin/mail/test">
274275 <input type="hidden" name="csrf" value=(csrf.as_str())>
275- <div class="actions">
276- <button type="submit">(g::t(lang, K::SendTestMailToMe))</button>
277- </div>
278276 </form>
279277 </section>
280278 </div>
crates/forge-web/src/pages/admin_runners.rsmodified+1 -1
@@ -1656,7 +1656,7 @@ async fn runner_detail_view(
16561656 // A runner that has reported nothing has no figures to show, only the note below.
16571657 let has_host = !metrics.empty || runner.reported.cpus.is_some();
16581658 Ok(view! {
1659- <div data-live="/admin/runners/events">
1659+ <div data-live="/admin/runners/events" class="runner-detail">
16601660 <section class="page-head">
16611661 <div class="runner-head">
16621662 <h1>(runner.name.as_str())</h1>
crates/forge-web/src/pages/admin_server.rsmodified+2 -2
@@ -109,7 +109,7 @@ struct Row {
109109 fixed: bool,
110110 }
111111
112-fn tab_label(lang: Lang, group: Group) -> &'static str {
112+pub(crate) fn tab_label(lang: Lang, group: Group) -> &'static str {
113113 g::t(
114114 lang,
115115 match group {
@@ -263,7 +263,7 @@ async fn server_view(
263263 <input type="hidden" name="tab" value=(tab)>
264264 <div class="srv-grid">
265265 for r in rows.iter() {
266- <div class="srv-field">
266+ <div class="srv-field" id=(format!("srv-{}", r.key))>
267267 <div class="srv-head">
268268 <span class="srv-label" title=(r.label)>(r.label)</span>
269269 <span class=(r.kind_class)>(r.kind_label)</span>
crates/forge-web/src/pages/invites.rsmodified+2 -2
@@ -37,14 +37,14 @@ async fn invite_body(
3737 Ok(view! {
3838 <section class="page-head">
3939 <h1>(t(lang, Key::InvitesTitle))</h1>
40- <p class="muted">(t(lang, Key::InvitesSub))</p>
4140 </section>
41+ <p class="muted page-lede">(t(lang, Key::InvitesSub))</p>
4242 if let Some(message) = notice {
4343 <section class="card notice" role="status">
4444 <p>(message)</p>
4545 </section>
4646 }
47- <section class="card narrow">
47+ <section class="card">
4848 if let Some(message) = error {
4949 alert(message: message.as_str())
5050 }
crates/forge-web/src/pages/org_members.rsmodified+3 -2
@@ -90,8 +90,8 @@ async fn members_body(
9090 org_head(name: name.clone(), description: description)
9191 org_tabs(lang: lang, name: name, current: "members".to_owned(), repo_count: repo_count, package_count: package_count)
9292 org_notice(notice: notice)
93+ <div class="org-split">
9394 <section class="card">
94- <h2>(g::t(lang, K::Members))</h2>
9595 <div class="table-wrap">
9696 <table class="table collaborators members-table">
9797 <thead>
@@ -163,11 +163,12 @@ async fn members_body(
163163 </label>
164164 <p class="muted small">(g::t(lang, K::OwnersHelp))</p>
165165 <div>
166- <button type="submit">(g::t(lang, K::AddMemberButton))</button>
166+ <button type="submit" class="primary">(g::t(lang, K::AddMemberButton))</button>
167167 </div>
168168 </form>
169169 </section>
170170 }
171+ </div>
171172 </div>
172173 })
173174 }
crates/forge-web/src/pages/org_teams.rsmodified+6 -6
@@ -201,14 +201,10 @@ async fn teams_body(
201201 org_head(name: name.clone(), description: description)
202202 org_tabs(lang: lang, name: name, current: "teams".to_owned(), repo_count: repo_count, package_count: package_count)
203203 org_notice(notice: notice)
204+ <div class="org-split">
204205 <section class="card">
205- <h2>(g::t(lang, K::Teams))</h2>
206- <p class="muted small">(g::t(lang, K::TeamsIntro))</p>
207206 if rows.is_empty() {
208- empty_state(title: g::t(lang, K::NoTeamsYet),
209- if owner {
210- <a class="button" href="#new-team">(g::t(lang, K::NewTeam))</a>
211- })
207+ empty_state(title: g::t(lang, K::NoTeamsYet))
212208 } else {
213209 <ul class="item-list">
214210 for row in rows.iter() {
@@ -224,6 +220,7 @@ async fn teams_body(
224220 }
225221 </ul>
226222 }
223+ <p class="muted small">(g::t(lang, K::TeamsIntro))</p>
227224 </section>
228225 if owner {
229226 <section class="card" id="new-team">
@@ -256,6 +253,7 @@ async fn teams_body(
256253 </form>
257254 </section>
258255 }
256+ </div>
259257 </div>
260258 })
261259 }
@@ -317,6 +315,7 @@ async fn team_body(
317315 org_head(name: data.org_name.clone(), description: data.org_description.clone())
318316 org_tabs(lang: lang, name: data.org_name.clone(), current: "teams".to_owned(), repo_count: data.repo_count, package_count: data.package_count)
319317 org_notice(notice: notice)
318+ <div class="org-split team-split">
320319 <section class="card">
321320 <h2>(data.team_name.as_str())</h2>
322321 if has_description {
@@ -439,6 +438,7 @@ async fn team_body(
439438 </form>
440439 }
441440 </section>
441+ </div>
442442 </div>
443443 })
444444 }
crates/forge-web/src/pages/palette.rsmodified+382 -38
@@ -1,15 +1,21 @@
11 //! The command palette's destinations: `GET /-/palette` lists what the signed-in viewer can jump to.
2-//! Their repos, the orgs they belong to with that org's members, teams and (for owners) settings,
3-//! and the pages the navigation links to: their own profile's tabs, the fixed site pages and the
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`. The
8-//! actions of the page it is opened on are not listed here: a control marked `data-palette-action`
9-//! is rendered only for a viewer who may use it, and the palette reads those controls from the page.
2+//! Their repos, the orgs they belong to with each org's tabs, teams and (for owners) settings, and the
3+//! pages the navigation links to: their own profile's tabs, the fixed site pages and the settings and
4+//! admin pages. For an admin it also lists every tab and every field of the server settings. Those
5+//! pages come from the same lists the navigation is built from (`views::profile_items`,
6+//! `views::global_items`, `views::settings_items`, `views::admin_items`), so a page the sidebar or a
7+//! tab bar links to is found here too. Each href is listed once, the first time it appears.
8+//!
9+//! An item may carry `terms`: what is on that page and other words for it, in both languages, so
10+//! "password" finds Security. `repoPages` lists the pages of a repo as paths: `assets/nav.js` applies
11+//! them to the current repo, and to a repo named in the query. The palette itself, its typo-tolerant
12+//! matching and keys live in `assets/nav.js`. The actions of the page it is opened on are not listed
13+//! here: a control marked `data-palette-action` is rendered only for a viewer who may use it, and the
14+//! palette reads those controls from the page.
1015
1116 use std::collections::HashSet;
1217
18+use forge_core::server_settings::{FIELDS, Group};
1319 use forge_core::store::orgs::OrgMemberRole;
1420 use http::header::{CACHE_CONTROL, CONTENT_TYPE, X_CONTENT_TYPE_OPTIONS};
1521 use serde_json::{Value, json};
@@ -19,9 +25,13 @@ use topcoat::router::response::Response;
1925 use topcoat::router::{Body, HeaderValue, StatusCode, route};
2026
2127 use crate::auth::current_user;
22-use crate::i18n;
28+use crate::i18n::code::{self, K as CK};
2329 use crate::i18n::orgs::{self as g, K};
30+use crate::i18n::repo_admin::{self as ra, K as RK};
31+use crate::i18n::{self, Lang};
32+use crate::pages::admin_server::tab_label;
2433 use crate::pages::org_new::may_create_org;
34+use crate::pages::passkeys::s;
2535 use crate::state::AppState;
2636 use crate::views::{
2737 admin_items, enc, global_items, profile_items, repo_href, settings_items, user_href,
@@ -30,20 +40,271 @@ use crate::views::{
3040 /// Repos listed at most. The palette filters in the browser, so a longer list would only cost time.
3141 pub const MAX_REPOS: u64 = 500;
3242
33-/// One destination: its label, its path and what it is (`repo`, `org` or `page`).
34-fn destination(label: &str, href: &str, kind: &str) -> Value {
35- json!({ "label": label, "href": href, "kind": kind })
43+/// What each settings page holds and other words for it, in both languages.
44+const SETTINGS_TERMS: &[(&str, &[&str])] = &[
45+ (
46+ "/settings/profile",
47+ &[
48+ "Display name",
49+ "Görünen ad",
50+ "Username",
51+ "Kullanıcı adı",
52+ "About",
53+ "Bio",
54+ "Hakkında",
55+ "Time zone",
56+ "Saat dilimi",
57+ "Avatar",
58+ "Picture",
59+ "Photo",
60+ "Fotoğraf",
61+ "Resim",
62+ ],
63+ ),
64+ ("/settings/keys", &["SSH", "Public key", "Açık anahtar"]),
65+ (
66+ "/settings/gpg",
67+ &[
68+ "GPG",
69+ "Signing key",
70+ "Signature",
71+ "İmza",
72+ "Verified commits",
73+ ],
74+ ),
75+ (
76+ "/settings/tokens",
77+ &["API", "PAT", "Personal access token", "Erişim belirteci"],
78+ ),
79+ (
80+ "/settings/sessions",
81+ &["Devices", "Cihazlar", "Sign out", "Logged in", "Oturumlar"],
82+ ),
83+ (
84+ "/settings/security",
85+ &[
86+ "Password",
87+ "Parola",
88+ "Şifre",
89+ "Email",
90+ "E-posta",
91+ "Mail",
92+ "Two-factor",
93+ "2FA",
94+ "TOTP",
95+ "İki adımlı",
96+ "Passkey",
97+ "Geçiş anahtarı",
98+ "Recovery codes",
99+ "Kurtarma kodları",
100+ "Delete account",
101+ "Hesabı sil",
102+ "Security log",
103+ ],
104+ ),
105+ (
106+ "/settings/notifications",
107+ &[
108+ "Email notifications",
109+ "Bildirim",
110+ "Push",
111+ "Browser notifications",
112+ "Tarayıcı bildirimi",
113+ ],
114+ ),
115+ (
116+ "/settings/appearance",
117+ &[
118+ "Theme",
119+ "Tema",
120+ "Dark mode",
121+ "Light mode",
122+ "Koyu",
123+ "Açık",
124+ "Accent",
125+ "Vurgu rengi",
126+ "Colour",
127+ "Color",
128+ "Renk",
129+ "Background",
130+ "Arka plan",
131+ "Language",
132+ "Dil",
133+ "Sidebar",
134+ "Sound",
135+ "Ses",
136+ "Tones",
137+ ],
138+ ),
139+ (
140+ "/settings/export",
141+ &[
142+ "Download my data",
143+ "Verilerimi indir",
144+ "Archive",
145+ "Dışa aktar",
146+ ],
147+ ),
148+];
149+
150+/// What each admin page holds and other words for it, in both languages.
151+const ADMIN_TERMS: &[(&str, &[&str])] = &[
152+ (
153+ "/admin/users",
154+ &["Accounts", "Hesaplar", "Suspend", "Askıya al"],
155+ ),
156+ (
157+ "/admin/health",
158+ &[
159+ "Status",
160+ "Durum",
161+ "Disk",
162+ "Monitoring",
163+ "Alerts",
164+ "Uyarılar",
165+ ],
166+ ),
167+ ("/admin/invites", &["Invite someone", "Davet et"]),
168+ ("/admin/audit", &["Log", "Günlük", "History", "Geçmiş"]),
169+ (
170+ "/admin/runners",
171+ &["CI", "Actions", "Agents", "Workers", "Çalıştırıcılar"],
172+ ),
173+ (
174+ "/admin/mail",
175+ &["SMTP", "Email", "E-posta", "Sender", "Gönderen"],
176+ ),
177+ (
178+ "/admin/server",
179+ &["Configuration", "Config", "Yapılandırma", "Ayarlar"],
180+ ),
181+ ("/admin/backups", &["Restore", "Geri yükle", "S3", "R2"]),
182+ (
183+ "/admin/replication",
184+ &["Standby", "Failover", "Yedek sunucu"],
185+ ),
186+];
187+
188+/// One destination: its label, its path, what it is (`repo`, `org` or `page`) and its other words.
189+fn destination(label: &str, href: &str, kind: &str, terms: &[&str]) -> Value {
190+ let mut item = json!({ "label": label, "href": href, "kind": kind });
191+ if !terms.is_empty() {
192+ item["terms"] = json!(terms);
193+ }
194+ item
36195 }
37196
38197 /// Adds a destination unless its href is already listed.
39198 fn push(items: &mut Vec<Value>, seen: &mut HashSet<String>, label: &str, href: &str, kind: &str) {
199+ push_terms(items, seen, label, href, kind, &[]);
200+}
201+
202+/// Adds a destination with its other words unless its href is already listed.
203+fn push_terms(
204+ items: &mut Vec<Value>,
205+ seen: &mut HashSet<String>,
206+ label: &str,
207+ href: &str,
208+ kind: &str,
209+ terms: &[&str],
210+) {
40211 if seen.insert(href.to_owned()) {
41- items.push(destination(label, href, kind));
212+ items.push(destination(label, href, kind, terms));
42213 }
43214 }
44215
45-/// `{"items": [{"label", "href", "kind"}, ...]}` for the signed-in viewer. Anonymous visitors get
46-/// 401, as the other signed-in-only JSON routes do.
216+/// The other words listed for an href.
217+fn terms_for(table: &'static [(&str, &[&str])], href: &str) -> &'static [&'static str] {
218+ table
219+ .iter()
220+ .find(|(path, _)| *path == href)
221+ .map_or(&[], |(_, terms)| terms)
222+}
223+
224+/// One page of a repo, relative to the repo's path. `admin` pages are offered only to people who
225+/// may manage the repo.
226+fn repo_page(label: &str, path: &str, admin: bool, terms: &[&str]) -> Value {
227+ json!({ "label": label, "path": path, "admin": admin, "terms": terms })
228+}
229+
230+/// The pages every repo has, and its settings pages.
231+fn repo_pages(lang: Lang) -> Vec<Value> {
232+ let code = |key| code::t(lang, key);
233+ let admin = |key| ra::t(lang, key);
234+ let settings = format!("{} \u{b7} {}", code(CK::TabSettings), admin(RK::General));
235+ vec![
236+ repo_page(code(CK::TabIssues), "issues", false, &["Bugs", "Tickets"]),
237+ repo_page(
238+ code(CK::TabPulls),
239+ "pulls",
240+ false,
241+ &["PR", "Merge requests"],
242+ ),
243+ repo_page(
244+ code(CK::TabCi),
245+ "ci",
246+ false,
247+ &["Actions", "Runs", "Workflows", "Pipelines", "Builds"],
248+ ),
249+ repo_page(code(CK::BranchesTitle), "branches", false, &[]),
250+ repo_page(code(CK::TagsTitle), "tags", false, &[]),
251+ repo_page(code(CK::TabReleases), "releases", false, &[]),
252+ repo_page(
253+ &settings,
254+ "settings",
255+ true,
256+ &[
257+ "Visibility",
258+ "Görünürlük",
259+ "Archive",
260+ "Arşiv",
261+ "Description",
262+ "Açıklama",
263+ ],
264+ ),
265+ repo_page(
266+ admin(RK::BranchProtection),
267+ "settings?section=branches",
268+ true,
269+ &["Rules", "Kurallar"],
270+ ),
271+ repo_page(
272+ admin(RK::Collaborators),
273+ "settings/collaborators",
274+ true,
275+ &["Access", "Erişim", "Members"],
276+ ),
277+ repo_page(
278+ admin(RK::RenameTransferNav),
279+ "settings/rename",
280+ true,
281+ &["Rename", "Transfer"],
282+ ),
283+ repo_page(admin(RK::Webhooks), "settings/hooks", true, &["Hooks"]),
284+ repo_page(
285+ admin(RK::Mirrors),
286+ "settings/mirrors",
287+ true,
288+ &["Sync", "Mirror"],
289+ ),
290+ repo_page(
291+ admin(RK::Secrets),
292+ "settings/secrets",
293+ true,
294+ &["Variables", "Env"],
295+ ),
296+ repo_page(code(CK::TabWiki), "settings/wiki", true, &[]),
297+ repo_page(
298+ admin(RK::DangerZone),
299+ "settings?section=danger",
300+ true,
301+ &["Delete repository", "Depoyu sil"],
302+ ),
303+ ]
304+}
305+
306+/// `{"items": [{"label", "href", "kind", "terms"?, "admin"?}, ...], "repoPages": [...]}` for the
307+/// signed-in viewer. Anonymous visitors get 401, as the other signed-in-only JSON routes do.
47308 #[route(GET "/-/palette")]
48309 async fn palette(cx: &Cx) -> Result<Response> {
49310 let Some((user, _)) = current_user(cx).await? else {
@@ -53,42 +314,50 @@ async fn palette(cx: &Cx) -> Result<Response> {
53314 };
54315 let state = app_context::<AppState>(cx);
55316 let lang = i18n::lang(cx, Some(&user));
317+ let orgs = state.store.orgs_for_user(&user.id).await?;
56318
57319 let mut items = Vec::new();
58320 let mut seen = HashSet::new();
59321 for repo in state.store.list_viewer_repos(&user, MAX_REPOS).await? {
60322 let label = format!("{}/{}", repo.owner_name, repo.name);
61323 let href = repo_href(&repo.owner_name, &repo.name, "", "");
62- push(&mut items, &mut seen, &label, &href, "repo");
324+ // Enough to offer the settings pages. A collaborator with Admin gets them on the repo itself,
325+ // where the page's own Settings tab says so.
326+ let admin = user.is_admin
327+ || repo.owner_id == user.id
328+ || orgs
329+ .iter()
330+ .any(|(org, role)| org.id == repo.owner_id && *role == OrgMemberRole::Owner);
331+ if seen.insert(href.clone()) {
332+ let mut item = destination(&label, &href, "repo", &[]);
333+ item["admin"] = json!(admin);
334+ items.push(item);
335+ }
63336 }
64- for (org, role) in state.store.orgs_for_user(&user.id).await? {
337+ for (org, role) in &orgs {
65338 let name = &org.username;
66339 let base = format!("/org/{}", enc(name));
67340 push(&mut items, &mut seen, name, &user_href(name), "org");
68- let members = format!("{name} \u{b7} {}", g::t(lang, K::Members));
69- push(
70- &mut items,
71- &mut seen,
72- &members,
73- &format!("{base}/members"),
74- "page",
75- );
76- let teams = format!("{name} \u{b7} {}", g::t(lang, K::Teams));
77- push(
78- &mut items,
79- &mut seen,
80- &teams,
81- &format!("{base}/teams"),
82- "page",
83- );
84- if role == OrgMemberRole::Owner {
341+ for tab in profile_items(lang, name, true, false, true) {
342+ if tab.key != "overview" {
343+ let label = format!("{name} \u{b7} {}", tab.label);
344+ push(&mut items, &mut seen, &label, &tab.href, "page");
345+ }
346+ }
347+ for team in state.store.teams_for_org(&org.id).await? {
348+ let label = format!("{name} \u{b7} {}", team.name);
349+ let href = format!("{base}/teams/{}", team.id);
350+ push(&mut items, &mut seen, &label, &href, "page");
351+ }
352+ if *role == OrgMemberRole::Owner {
85353 let settings = format!("{name} \u{b7} {}", g::t(lang, K::Settings));
86- push(
354+ push_terms(
87355 &mut items,
88356 &mut seen,
89357 &settings,
90358 &format!("{base}/settings"),
91359 "page",
360+ &["Avatar", "Delete organization", "Organizasyonu sil"],
92361 );
93362 }
94363 }
@@ -99,16 +368,52 @@ async fn palette(cx: &Cx) -> Result<Response> {
99368 for item in global_items(lang, may_create_org(state, &user)) {
100369 push(&mut items, &mut seen, item.label, &item.href, "page");
101370 }
371+ let settings_area = g::t(lang, K::Settings);
102372 for item in settings_items(lang) {
103- push(&mut items, &mut seen, item.label, &item.href, "page");
373+ let label = format!("{settings_area} \u{b7} {}", item.label);
374+ let terms = terms_for(SETTINGS_TERMS, &item.href);
375+ push_terms(&mut items, &mut seen, &label, &item.href, "page", terms);
104376 }
105377 if user.is_admin {
378+ let admin_area = crate::i18n::admin::t(lang, crate::i18n::admin::K::AdminArea);
106379 for item in admin_items(lang) {
107- push(&mut items, &mut seen, item.label, &item.href, "page");
380+ let label = format!("{admin_area} \u{b7} {}", item.label);
381+ let terms = terms_for(ADMIN_TERMS, &item.href);
382+ push_terms(&mut items, &mut seen, &label, &item.href, "page", terms);
383+ }
384+ let queue = format!(
385+ "{admin_area} \u{b7} {}",
386+ s(lang, "Mail queue", "E-posta kuyruğu")
387+ );
388+ push(
389+ &mut items,
390+ &mut seen,
391+ &queue,
392+ "/admin/mail?tab=queue",
393+ "page",
394+ );
395+ let server = crate::i18n::admin::t(lang, crate::i18n::admin::K::ServerSettings);
396+ for group in Group::ALL {
397+ let label = format!("{server} \u{b7} {}", tab_label(lang, group));
398+ let href = format!("/admin/server?tab={}", group.slug());
399+ push(&mut items, &mut seen, &label, &href, "page");
400+ }
401+ for field in FIELDS {
402+ let name = match (lang, crate::i18n::server_settings::field_tr(field.key)) {
403+ (Lang::Tr, Some((tr, _))) => tr,
404+ _ => field.label,
405+ };
406+ let label = format!(
407+ "{server} \u{b7} {} \u{b7} {name}",
408+ tab_label(lang, field.group)
409+ );
410+ let href = format!("/admin/server?tab={}#srv-{}", field.group.slug(), field.key);
411+ let terms = [field.key, field.label];
412+ push_terms(&mut items, &mut seen, &label, &href, "page", &terms);
108413 }
109414 }
110415
111- let body = json!({ "items": items });
416+ let body = json!({ "items": items, "repoPages": repo_pages(lang) });
112417 let mut response = Response::new(Body::from(body.to_string().into_bytes()));
113418 let headers = response.headers_mut();
114419 headers.insert(
@@ -129,6 +434,45 @@ mod tests {
129434 use crate::i18n::Lang;
130435 use crate::views::profile_items;
131436
437+ /// Every admin page and setting is offered to an admin, and none of them to anyone else.
438+ #[tokio::test]
439+ async fn admin_destinations_reach_admins_only() {
440+ let dir = tempfile::tempdir().expect("tempdir");
441+ let state = crate::test_support::test_state(dir.path()).await;
442+ let store = state.store.clone();
443+ let router = crate::test_support::app_router(state);
444+ let admin = store
445+ .create_user("boss", None, "not-a-real-hash", true)
446+ .await
447+ .unwrap();
448+ let plain = store
449+ .create_user("plain", None, "not-a-real-hash", false)
450+ .await
451+ .unwrap();
452+ crate::test_support::create_session(&store, &admin.id, "boss-token", "boss-csrf").await;
453+ crate::test_support::create_session(&store, &plain.id, "plain-token", "plain-csrf").await;
454+ for (token, is_admin) in [("boss-token", true), ("plain-token", false)] {
455+ let request = Request::builder()
456+ .method("GET")
457+ .uri("/-/palette")
458+ .header("cookie", format!("__Host-{SESSION_COOKIE}={token}"))
459+ .body(Body::empty())
460+ .unwrap();
461+ let res = router.handle(request).await;
462+ let bytes = to_bytes(res.into_body(), usize::MAX).await.unwrap();
463+ let body: serde_json::Value = serde_json::from_slice(&bytes).unwrap();
464+ let hrefs: Vec<&str> = body["items"]
465+ .as_array()
466+ .unwrap()
467+ .iter()
468+ .map(|item| item["href"].as_str().unwrap())
469+ .collect();
470+ assert!(hrefs.contains(&"/settings/security"));
471+ assert_eq!(hrefs.contains(&"/admin/mail"), is_admin);
472+ assert_eq!(hrefs.iter().any(|href| href.contains("#srv-")), is_admin);
473+ }
474+ }
475+
132476 /// Every tab of the viewer's own profile is in the palette, so a tab is found by its name.
133477 #[tokio::test]
134478 async fn palette_lists_every_profile_tab() {
crates/forge-web/src/pages/profile.rsmodified+40 -16
@@ -30,6 +30,7 @@ use crate::live::{Topic, stream_changes};
3030 use crate::pages::org_new::may_create_org;
3131 use crate::pages::packages::{self as packages, PackageRow};
3232 use crate::pages::profile_calendar::{calendar_since, load_calendar};
33+use crate::pages::profile_pins::{PinOption, pin_options, pins_menu};
3334 use crate::pages::repo_settings::{notice_banner_for, take_notice};
3435 use crate::pages::snippets::{ListRow, list_row, snippet_rows};
3536 use crate::render::markdown::render_markdown;
@@ -46,6 +47,13 @@ path_param!(username);
4647
4748 /// Repos per page on the repositories and stars tabs.
4849 const PER_PAGE: u64 = 30;
50+/// What the pin menu needs: shown to whoever may edit the pins, on the overview.
51+struct PinsMenu {
52+ action: String,
53+ csrf: String,
54+ options: Vec<PinOption>,
55+}
56+
4957 /// Repos the overview shows when the owner has no visible pins.
5058 const POPULAR_COUNT: usize = 6;
5159 /// Members an organization's overview lists; a longer list links to the members page.
@@ -61,6 +69,8 @@ struct ProfileQuery {
6169 page: Option<String>,
6270 /// A calendar day whose contributions to list under the calendar on the overview.
6371 day: Option<String>,
72+ /// `too_many` after a save with more pins than the limit.
73+ pins: Option<String>,
6474 }
6575
6676 /// Sort keys of the repo tabs in the order their chips are shown, with the label of each. The
@@ -178,13 +188,23 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
178188 Some(u) => u.id == user.id,
179189 None => false,
180190 };
181- let pins_edit_href = can_edit_pins.then(|| {
182- if user.is_org() {
183- format!("/org/{}/settings/pins", user.username)
184- } else {
185- "/settings/pins".to_owned()
191+ let mut pins_menu_data = None;
192+ if can_edit_pins && tab == "overview" {
193+ let options = pin_options(&state.store, &user.id).await?;
194+ if let (false, Some((_, session))) = (options.is_empty(), viewer.as_ref()) {
195+ let action = if user.is_org() {
196+ format!("/org/{}/settings/pins", user.username)
197+ } else {
198+ "/settings/pins".to_owned()
199+ };
200+ pins_menu_data = Some(PinsMenu {
201+ action,
202+ csrf: session.csrf_token.clone(),
203+ options,
204+ });
186205 }
187- });
206+ }
207+ let pins_error = can_edit_pins && query.pins.as_deref() == Some("too_many");
188208
189209 // The contribution calendar on the overview, for a person only. Its counts and day links use
190210 // public repos alone, so anyone may see it.
@@ -320,7 +340,7 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
320340 profile_card(user: user, avatar: avatar, about_html: about_html, local_time: local_time,
321341 org: org, lang: lang, tab: tab.to_owned(), q: q, sort: sort, repo_total: repo_total,
322342 star_total: star_total, cards: cards, from_pins: from_pins,
323- pins_edit_href: pins_edit_href, edit_profile: own, listing: listing,
343+ pins_menu_data: pins_menu_data, pins_error: pins_error, edit_profile: own, listing: listing,
324344 packages_on: packages_on, package_rows: package_rows,
325345 org_member: org_member, org_owner: org_owner, org_can_create: org_can_create,
326346 heat: heat, snippets: snippets, orgs: orgs, org_create_allowed: org_create_allowed,
@@ -557,7 +577,8 @@ async fn profile_card(
557577 star_total: u64,
558578 cards: Vec<PinCard>,
559579 from_pins: bool,
560- pins_edit_href: Option<String>,
580+ pins_menu_data: Option<PinsMenu>,
581+ pins_error: bool,
561582 edit_profile: bool,
562583 listing: Listing,
563584 packages_on: bool,
@@ -677,10 +698,13 @@ async fn profile_card(
677698 <section class="profile-pinned">
678699 <div class="profile-section-head">
679700 <h2>(pinned_heading)</h2>
680- if let Some(href) = pins_edit_href {
681- <a class="small" href=(href.as_str())>(g::t(lang, K::CustomizePins))</a>
701+ if let Some(menu) = pins_menu_data {
702+ pins_menu(lang: lang, action: menu.action, csrf: menu.csrf, options: menu.options)
682703 }
683704 </div>
705+ if pins_error {
706+ <p class="alert" role="alert">(g::t(lang, K::PinsTooMany))</p>
707+ }
684708 if has_cards {
685709 <ul class="pin-grid">
686710 for card in cards.into_iter() {
@@ -1156,8 +1180,8 @@ mod tests {
11561180 // Settings keeps a sidebar of its own pages, and its back link goes to the profile.
11571181 let (_, settings) = get(&site.router, "/org/forge-org/settings", Some(&owner_cookie)).await;
11581182 assert!(
1159- settings.contains("href=\"/org/forge-org/settings/pins\""),
1160- "org settings: sidebar lists Customize pins"
1183+ !settings.contains("/org/forge-org/settings/pins"),
1184+ "org settings: pins live on the profile"
11611185 );
11621186 assert!(
11631187 !settings.contains("href=\"/org/forge-org/members\""),
@@ -1182,8 +1206,8 @@ mod tests {
11821206 let (_, owner) = get(&site.router, "/acme", Some(&owner_cookie)).await;
11831207 assert!(owner.contains("acme/lib"), "org pins: owner sees pin");
11841208 assert!(
1185- owner.contains("href=\"/org/acme/settings/pins\""),
1186- "org pins: owner edit link"
1209+ owner.contains("action=\"/org/acme/settings/pins\""),
1210+ "org pins: owner edits them on the profile"
11871211 );
11881212 let (_, anon) = get(&site.router, "/acme", None).await;
11891213 assert!(anon.contains("acme/lib"), "org pins: anonymous sees pin");
@@ -1251,8 +1275,8 @@ mod tests {
12511275 "pins: owner customize link"
12521276 );
12531277 assert!(
1254- owner.contains("href=\"/settings/pins\""),
1255- "pins: owner settings link"
1278+ owner.contains("action=\"/settings/pins\""),
1279+ "pins: owner edits them on the profile"
12561280 );
12571281
12581282 // Fallback: with no visible pin, the overview shows popular repos instead.
crates/forge-web/src/pages/profile_pins.rsmodified+82 -184
@@ -1,38 +1,48 @@
1-//! Pages: where a profile's owner picks the repos pinned on it, at most six. `/settings/pins` is for
2-//! the signed-in user. `/org/{org}/settings/pins` is for an organization, and only its owners may
3-//! use it. Both show a form of checkboxes, one per repo the owner has, and redirect to the profile
4-//! after a save.
1+//! Picking the repos pinned on a profile, at most six. The menu sits on the profile itself and
2+//! posts to `/settings/pins` for the signed-in user, or to `/org/{org}/settings/pins` for an
3+//! organization, whose owners alone may use it. Both redirect to the profile after a save.
54
65 use forge_core::store::profile_pins::MAX_PROFILE_PINS;
7-use forge_core::{Repo, Session, Store, User};
6+use forge_core::{Repo, Store, User};
87 use topcoat::Result;
98 use topcoat::context::{Cx, app_context};
109 use topcoat::router::content::RawForm;
11-use topcoat::router::error::see_other;
12-use topcoat::router::response::Response;
13-use topcoat::router::{page, path_param, route};
10+use topcoat::router::error::{SeeOther, see_other};
11+use topcoat::router::{path_param, route};
1412 use topcoat::view::{View, component, view};
1513
1614 use crate::auth::{require_csrf, require_user};
15+use crate::i18n::Lang;
1716 use crate::i18n::orgs::{self as g, K};
18-use crate::i18n::{self, Lang};
19-use crate::live::{Topic, stream_changes};
2017 use crate::pages::issue_meta::{form_all, form_field, form_pairs};
2118 use crate::pages::org_ctx::{load_org, require_form_csrf, require_owner};
2219 use crate::state::AppState;
23-use crate::views::{empty_state, shell};
2420
2521 path_param!(org);
2622
2723 /// A repo the owner may pin, and whether it is pinned now.
28-struct PinOption {
24+pub(crate) struct PinOption {
2925 repo: Repo,
3026 checked: bool,
3127 }
3228
33-/// The repo ids pinned, in order.
34-fn ids(repos: Vec<Repo>) -> Vec<String> {
35- repos.into_iter().map(|repo| repo.id).collect()
29+/// Each repo `owner_id` may pin, with the pinned ones ticked.
30+pub(crate) async fn pin_options(store: &Store, owner_id: &str) -> Result<Vec<PinOption>> {
31+ let chosen: Vec<String> = store
32+ .profile_pins(owner_id)
33+ .await?
34+ .into_iter()
35+ .map(|repo| repo.id)
36+ .collect();
37+ Ok(store
38+ .list_repos_by_owner(owner_id)
39+ .await?
40+ .into_iter()
41+ .map(|repo| {
42+ let checked = chosen.contains(&repo.id);
43+ PinOption { repo, checked }
44+ })
45+ .collect())
3646 }
3747
3848 /// The repo ids a form chose: blanks and repeats are dropped, the order is kept.
@@ -46,204 +56,89 @@ fn selection(raw: Vec<String>) -> Vec<String> {
4656 out
4757 }
4858
49-/// The pin form for `owner`, with the `chosen` repos ticked. `error` is shown above the form.
50-/// The values are owned so the returned view borrows nothing from the caller.
51-async fn pins_form(
52- cx: &Cx,
53- viewer: (User, Session),
54- owner: User,
55- action: String,
56- chosen: Vec<String>,
57- error: Option<&'static str>,
58-) -> Result<impl View> {
59- let state = app_context::<AppState>(cx);
60- let lang = i18n::lang(cx, Some(&viewer.0));
61- let options: Vec<PinOption> = state
62- .store
63- .list_repos_by_owner(&owner.id)
64- .await?
65- .into_iter()
66- .map(|repo| {
67- let checked = chosen.contains(&repo.id);
68- PinOption { repo, checked }
69- })
70- .collect();
71- let csrf = viewer.1.csrf_token.clone();
72- let title = g::t(lang, K::CustomizePins);
73- let error = error.map(str::to_owned);
74- // The form follows the owner's topic: a pin or a repo of the owner changed elsewhere re-renders it.
75- let live = format!("{action}/events");
76- Ok(view! { cx =>
77- shell(title: title, viewer: Some(&viewer),
78- pins_body(lang: lang, action: action, live: live, csrf: csrf, options: options, error: error))
79- })
80-}
81-
59+/// The menu on the profile that picks the pins. It saves through the server, and the profile shows
60+/// the result after the redirect.
8261 #[component]
83-async fn pins_body(
62+pub(crate) async fn pins_menu(
8463 lang: Lang,
8564 action: String,
86- live: String,
8765 csrf: String,
8866 options: Vec<PinOption>,
89- error: Option<String>,
9067 ) -> Result<impl View> {
91- let has_options = !options.is_empty();
92- let intro = g::t(lang, K::PinsIntro);
93- let empty = g::t(lang, K::NoPinnableRepos);
94- let save = g::t(lang, K::SavePins);
9568 Ok(view! {
96- <section class="profile-pins-edit" data-live=(live.as_str())>
97- <h1>(g::t(lang, K::CustomizePins))</h1>
98- <p class="muted">(intro)</p>
99- if let Some(message) = error {
100- <p class="alert" role="alert">(message.as_str())</p>
101- }
102- if has_options {
103- <form method="post" action=(action.as_str()) class="stack">
104- <input type="hidden" name="csrf" value=(csrf.as_str())>
105- <ul class="pin-options">
106- for option in options.into_iter() {
107- <li>
108- <label>
109- <input type="checkbox" name="repo" value=(option.repo.id.as_str()) checked=(option.checked)>
110- (format!("{}/{}", option.repo.owner_name, option.repo.name))
111- </label>
112- </li>
113- }
114- </ul>
115- <div>
116- <button type="submit" class="primary">(save)</button>
117- </div>
118- </form>
119- } else {
120- empty_state(title: empty,
121- <a class="button" href="/new">(g::t(lang, K::NewRepository))</a>)
122- }
123- </section>
69+ <details class="pop pins-menu">
70+ <summary class="button small">(g::t(lang, K::CustomizePins))</summary>
71+ <form method="post" action=(action.as_str()) class="pop-panel">
72+ <input type="hidden" name="csrf" value=(csrf.as_str())>
73+ <p class="muted small">(g::t(lang, K::PinsIntro))</p>
74+ <ul class="pin-options">
75+ for option in options.into_iter() {
76+ <li>
77+ <label>
78+ <input type="checkbox" name="repo" value=(option.repo.id.as_str()) checked=(option.checked)>
79+ <span>(option.repo.name.as_str())</span>
80+ </label>
81+ </li>
82+ }
83+ </ul>
84+ <button type="submit" class="primary">(g::t(lang, K::SavePins))</button>
85+ </form>
86+ </details>
12487 })
12588 }
12689
127-/// Stores the chosen pins for `owner` and redirects to `back`. More than the limit re-shows the
128-/// form with the error and changes nothing.
90+/// Stores the chosen pins for `owner` and redirects to `back`. More than the limit changes nothing,
91+/// and the profile says why.
12992 async fn save_pins(
130- cx: &Cx,
131- viewer: (User, Session),
93+ state: &AppState,
13294 owner: User,
133- action: String,
13495 chosen: Vec<String>,
13596 back: String,
136-) -> Result<impl View> {
97+) -> Result<SeeOther> {
13798 if chosen.len() > MAX_PROFILE_PINS {
138- let lang = i18n::lang(cx, Some(&viewer.0));
139- let error = g::t(lang, K::PinsTooMany);
140- return pins_form(cx, viewer, owner, action, chosen, Some(error)).await;
99+ return Err(see_other(format!("{back}?pins=too_many")).into());
141100 }
142- let state = app_context::<AppState>(cx);
143101 state.store.set_profile_pins(&owner.id, &chosen).await?;
144102 state.live.bump(&crate::live::Topic::User(owner.id.clone()));
145103 Err(see_other(back).into())
146104 }
147105
148-/// What the pin form shows: the owner's pinned repos in order, then each repo the owner may pin.
149-async fn pins_fingerprint(store: &Store, owner_id: &str) -> Result<String> {
150- let mut lines = Vec::new();
151- for repo in store.profile_pins(owner_id).await? {
152- lines.push(format!("pin {}", repo.id));
153- }
154- for repo in store.list_repos_by_owner(owner_id).await? {
155- lines.push(format!(
156- "repo {} {}/{}",
157- repo.id, repo.owner_name, repo.name
158- ));
159- }
160- Ok(lines.join("\n"))
161-}
162-
163-/// The pin form's change stream for the signed-in user. Its own page only, as the form.
164-#[route(GET "/settings/pins/events")]
165-async fn pins_events(cx: &Cx) -> Result<Response> {
166- let viewer = require_user(cx).await?;
167- let state = app_context::<AppState>(cx);
168- let owner_id = viewer.0.id.clone();
169- let store = state.store.clone();
170- stream_changes(
171- cx,
172- &state.live,
173- &[Topic::User(owner_id.clone())],
174- move || {
175- let store = store.clone();
176- let owner_id = owner_id.clone();
177- async move { pins_fingerprint(&store, &owner_id).await }
178- },
179- )
180- .await
181-}
182-
183-/// Gets the pin form for the signed-in user's own profile.
184-#[page("/settings/pins")]
185-async fn pins_page(cx: &Cx) -> Result<impl View> {
106+/// Pins are picked on the profile; an old link lands there.
107+#[route(GET "/settings/pins")]
108+async fn pins_page(cx: &Cx) -> Result<SeeOther> {
186109 let viewer = require_user(cx).await?;
187- let store = &app_context::<AppState>(cx).store;
188- let chosen = ids(store.profile_pins(&viewer.0.id).await?);
189- let owner = viewer.0.clone();
190- pins_form(cx, viewer, owner, "/settings/pins".to_owned(), chosen, None).await
110+ Err(see_other(format!("/{}", viewer.0.username)).into())
191111 }
192112
193113 /// Saves the signed-in user's pins, then back to the profile.
194-#[page(POST "/settings/pins")]
195-async fn pins_save(cx: &Cx, RawForm(raw): RawForm) -> Result<impl View> {
114+#[route(POST "/settings/pins")]
115+async fn pins_save(cx: &Cx, RawForm(raw): RawForm) -> Result<SeeOther> {
196116 let pairs = form_pairs(&raw[..]);
197117 let viewer = require_csrf(cx, &form_field(&pairs, "csrf")).await?;
198118 let chosen = selection(form_all(&pairs, "repo"));
199119 let back = format!("/{}", viewer.0.username);
200120 let owner = viewer.0.clone();
201- save_pins(cx, viewer, owner, "/settings/pins".to_owned(), chosen, back).await
202-}
203-
204-/// The pin form's change stream for an organization. Owners only, as the form.
205-#[route(GET "/org/{org}/settings/pins/events")]
206-async fn org_pins_events(cx: &Cx) -> Result<Response> {
207- let ctx = load_org(cx, path_param::<Org>(cx)).await?;
208- require_owner(&ctx)?;
209- let state = app_context::<AppState>(cx);
210- let owner_id = ctx.org.id.clone();
211- let store = state.store.clone();
212- stream_changes(
213- cx,
214- &state.live,
215- &[Topic::User(owner_id.clone())],
216- move || {
217- let store = store.clone();
218- let owner_id = owner_id.clone();
219- async move { pins_fingerprint(&store, &owner_id).await }
220- },
221- )
222- .await
121+ save_pins(app_context::<AppState>(cx), owner, chosen, back).await
223122 }
224123
225-/// Gets the pin form for an organization. Owners only.
226-#[page("/org/{org}/settings/pins")]
227-async fn org_pins_page(cx: &Cx) -> Result<impl View> {
124+/// Pins are picked on the profile; an old link lands there. Owners only, as the form was.
125+#[route(GET "/org/{org}/settings/pins")]
126+async fn org_pins_page(cx: &Cx) -> Result<SeeOther> {
228127 let ctx = load_org(cx, path_param::<Org>(cx)).await?;
229128 require_owner(&ctx)?;
230- let store = &app_context::<AppState>(cx).store;
231- let chosen = ids(store.profile_pins(&ctx.org.id).await?);
232- let action = ctx.href("/settings/pins");
233- pins_form(cx, ctx.viewer, ctx.org, action, chosen, None).await
129+ Err(see_other(format!("/{}", ctx.org.username)).into())
234130 }
235131
236132 /// Saves an organization's pins, then back to the org profile. Owners only.
237-#[page(POST "/org/{org}/settings/pins")]
238-async fn org_pins_save(cx: &Cx, RawForm(raw): RawForm) -> Result<impl View> {
133+#[route(POST "/org/{org}/settings/pins")]
134+async fn org_pins_save(cx: &Cx, RawForm(raw): RawForm) -> Result<SeeOther> {
239135 let ctx = load_org(cx, path_param::<Org>(cx)).await?;
240136 let pairs = form_pairs(&raw[..]);
241137 require_form_csrf(&ctx, &form_field(&pairs, "csrf"))?;
242138 require_owner(&ctx)?;
243139 let chosen = selection(form_all(&pairs, "repo"));
244- let action = ctx.href("/settings/pins");
245140 let back = format!("/{}", ctx.org.username);
246- save_pins(cx, ctx.viewer, ctx.org, action, chosen, back).await
141+ save_pins(app_context::<AppState>(cx), ctx.org, chosen, back).await
247142 }
248143
249144 #[cfg(test)]
@@ -379,7 +274,7 @@ mod tests {
379274 .collect()
380275 }
381276
382- /// The owner saves pins and the form reflects them. The bad submissions that follow
277+ /// The owner saves pins and the profile reflects them. The bad submissions that follow
383278 /// (too many pins, a wrong CSRF token, a foreign repo, another user) must leave the saved
384279 /// pins alone. The scenarios run in order on one seed, and each reads the state before it.
385280 #[tokio::test]
@@ -417,16 +312,18 @@ mod tests {
417312 "save: stored pins"
418313 );
419314
420- // The form ticks the pinned repos.
421- let form = send(&s.site, "GET", "/settings/pins", Some(&cookie), &[]).await;
422- assert_eq!(form.status, 200, "form: status");
423- assert!(
424- form.body.contains("checked"),
425- "form: pinned repos are ticked"
315+ // The profile's menu ticks the pinned repos, and the old page leads there.
316+ let profile = send(&s.site, "GET", "/tahinli", Some(&cookie), &[]).await;
317+ assert!(profile.body.contains("pins-menu"), "menu on the profile");
318+ assert!(profile.body.contains("checked"), "pinned repos are ticked");
319+ let old = send(&s.site, "GET", "/settings/pins", Some(&cookie), &[]).await;
320+ assert_eq!(
321+ old.location.as_deref(),
322+ Some("/tahinli"),
323+ "old page redirects"
426324 );
427- assert!(form.body.contains("tahinli/open-repo"), "form: lists repos");
428325
429- // Seven pins is one too many: the form is shown again and the saved pins stay.
326+ // Seven pins is one too many: the saved pins stay.
430327 let repos = s.site.store.list_repos_by_owner(&s.tahinli).await.unwrap();
431328 assert!(repos.len() >= 7, "seed has enough repos");
432329 let ids: Vec<String> = repos.iter().map(|r| r.id.clone()).collect();
@@ -434,13 +331,14 @@ mod tests {
434331 fields.extend(ids.iter().map(|id| ("repo", id.as_str())));
435332 let six = send(&s.site, "POST", "/settings/pins", Some(&cookie), &fields).await;
436333 assert_eq!(
437- six.status, 200,
438- "six limit: form shown again, not redirected"
334+ six.location.as_deref(),
335+ Some("/tahinli?pins=too_many"),
336+ "six limit: the profile says why"
439337 );
338+ let told = send(&s.site, "GET", "/tahinli?pins=too_many", Some(&cookie), &[]).await;
440339 assert!(
441- six.body.contains("at most six"),
442- "six limit: friendly error: {}",
443- six.body
340+ told.body.contains("at most six"),
341+ "six limit: friendly error"
444342 );
445343 assert_eq!(
446344 pinned_names(&s.site.store, &s.tahinli).await,
crates/forge-web/src/views/mod.rsmodified+10 -26
@@ -916,23 +916,15 @@ pub fn admin_items(lang: Lang) -> Vec<NavItem> {
916916 ]
917917 }
918918
919-/// The organization's settings sidebar: General and Customize pins. Its profile, repositories,
919+/// The organization's settings sidebar. Its profile, repositories,
920920 /// members and teams are reached from the profile tab bar, so they are not listed here.
921921 fn org_items(lang: Lang, org: &str) -> Vec<NavItem> {
922- vec![
923- NavItem {
924- key: "settings",
925- href: format!("/org/{org}/settings"),
926- label: o::t(lang, OK::General),
927- icon: "appearance",
928- },
929- NavItem {
930- key: "pins",
931- href: format!("/org/{org}/settings/pins"),
932- label: o::t(lang, OK::CustomizePins),
933- icon: "pins",
934- },
935- ]
922+ vec![NavItem {
923+ key: "settings",
924+ href: format!("/org/{org}/settings"),
925+ label: o::t(lang, OK::General),
926+ icon: "appearance",
927+ }]
936928 }
937929
938930 /// The profile tab bar in its order, for a person's or an organization's profile: overview,
@@ -1064,12 +1056,6 @@ pub fn settings_items(lang: Lang) -> Vec<NavItem> {
10641056 mi::t(lang, MK::Appearance),
10651057 "appearance",
10661058 ),
1067- item(
1068- "pins",
1069- "/settings/pins",
1070- o::t(lang, OK::CustomizePins),
1071- "pins",
1072- ),
10731059 item(
10741060 "export",
10751061 "/settings/export",
@@ -1089,7 +1075,7 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> {
10891075 let (title, items) = match first {
10901076 "admin" => (ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)),
10911077 "settings" => (o::t(lang, OK::Settings).to_owned(), settings_items(lang)),
1092- // An organization's settings pages (`/org/{name}/settings` and `settings/pins`) keep a
1078+ // An organization's settings pages (`/org/{name}/settings`) keep a
10931079 // sidebar. Its profile, members and teams pages have none: the tab bar leads to them. `/org/new`
10941080 // is the create form and keeps the global links.
10951081 "org" if !second.is_empty() && second != "new" => {
@@ -1790,7 +1776,6 @@ pub async fn ref_selector(
17901776 <input type="text" class="ref-filter" data-ref-filter="" autocomplete="off" spellcheck="false"
17911777 placeholder=(g::t(lang, K::FilterRefs)) aria-label=(g::t(lang, K::FilterRefs))
17921778 role="combobox" aria-expanded="true" aria-autocomplete="list" aria-controls="ref-results">
1793- <kbd>"esc"</kbd>
17941779 </label>
17951780 <div class="ref-results" id="ref-results" role="listbox">
17961781 ref_group(lang: lang, kind: "branches", heading: g::t(lang, K::BranchesTitle), links: branches, now: now)
@@ -1800,9 +1785,8 @@ pub async fn ref_selector(
18001785 </p>
18011786 </div>
18021787 <div class="ref-foot">
1803- <span class="ref-keys" aria-hidden="true"><kbd>"↑"</kbd><kbd>"↓"</kbd><kbd>"↵"</kbd></span>
1804- <a href=(branches_href) title=(g::t(lang, K::ViewAllBranches))>(g::t(lang, K::BranchesTitle))" ↗"</a>
1805- <a href=(tags_href) title=(g::t(lang, K::ViewAllTags))>(g::t(lang, K::TagsTitle))" ↗"</a>
1788+ <a href=(branches_href) title=(g::t(lang, K::ViewAllBranches))>(g::t(lang, K::ViewAllBranches))</a>
1789+ <a href=(tags_href) title=(g::t(lang, K::ViewAllTags))>(g::t(lang, K::ViewAllTags))</a>
18061790 </div>
18071791 </div>
18081792 </details>
style/_canvas_repo.scssmodified+7 -3
@@ -518,12 +518,16 @@
518518 opacity: 1;
519519 }
520520
521- // The newest commit is the accent, at full strength, whether or not its run goes.
522- > a.hs-live,
523- > a:last-child:not(.hs-bad) {
521+ // Accent means a run is going. The newest commit is only brighter: a bar says nothing of a result
522+ // unless a run failed, and a repo with no CI has none.
523+ > a.hs-live {
524524 background: var(--accent);
525525 opacity: 1;
526526 }
527+
528+ > a:last-child:not(.hs-bad, .hs-live) {
529+ opacity: 1;
530+ }
527531 }
528532
529533 // Narrow windows: the panes stack and the page grows; the strip, which needs the width, is left out.
style/_fit_forms.scssmodified+2 -1
@@ -100,7 +100,8 @@
100100 @media (min-width: 1200px) {
101101 .import-home > .newrepo-form {
102102 display: grid;
103- grid-template-columns: repeat(2, minmax(0, 1fr));
103+ grid-template-columns: repeat(2, minmax(0, 720px));
104+ justify-content: start;
104105 align-items: start;
105106
106107 > :not(.newrepo-card) {
style/_lang_admin.scssmodified+10 -3
@@ -1,6 +1,6 @@
11 // Settings and admin pages: the pages behind the site section sidebar (`.shell-site`, see views/mod.rs).
2-// Main takes the window's full width. From 900px its direct children are panes that sit side by side
3-// across the window, and anything that is not a pane (the head, a notice) spans the row. Forms stop at
2+// Main takes the window's full width. From 900px its one pane fills it, or a second pane sits beside
3+// the first at a form's width, and anything that is not a pane (the head, a notice) spans the row. Forms stop at
44 // 720px and stay left aligned. Repo, org and other pages are not affected.
55
66 // The page's column: main itself, or the `data-live` wrapper that most admin pages put inside it.
@@ -14,7 +14,8 @@ $page-column: ".shell-site > .shell-body > main, .shell-site > .shell-body > mai
1414 @media (min-width: 900px) {
1515 #{$page-column} {
1616 display: grid;
17- grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
17+ grid-template-columns: minmax(0, 1fr);
18+ align-content: start;
1819 align-items: start;
1920 gap: 16px;
2021
@@ -22,6 +23,12 @@ $page-column: ".shell-site > .shell-body > main, .shell-site > .shell-body > mai
2223 grid-column: 1 / -1;
2324 }
2425 }
26+
27+ // Two panes: the list takes the window, and the form beside it stays a form's width.
28+ .shell-site > .shell-body > main:has(> .card ~ .card),
29+ .shell-site > .shell-body > main > [data-live]:not(.srv-page):not(.health-page):not(.user-page):not(.teams-page):not(.runner-detail):has(> .card ~ .card) {
30+ grid-template-columns: minmax(0, 1fr) minmax(20rem, 24rem);
31+ }
2532 }
2633
2734 // Settings pages wrap their sections in one `.settings-layout`; it fills main and takes no max width.
style/_palette.scssmodified+7 -0
@@ -120,6 +120,13 @@ dialog.palette {
120120 }
121121 }
122122
123+.palette-why {
124+ float: right;
125+ margin-left: 12px;
126+ color: var(--muted);
127+ font-size: 0.75rem;
128+}
129+
123130 .palette-note {
124131 flex: none;
125132 margin: 0;
style/_system.scssmodified+202 -14
@@ -130,7 +130,7 @@ input[type="checkbox"] {
130130 background: var(--accent);
131131 }
132132
133- &:checked::before {
133+ &:checked:not(.switch-row *)::before {
134134 content: "";
135135 position: absolute;
136136 inset: 0;
@@ -341,7 +341,6 @@ main .side-picker > legend {
341341 &.active,
342342 &[aria-current="page"] {
343343 color: var(--text);
344- font-weight: 600;
345344 }
346345 }
347346
@@ -466,12 +465,10 @@ main .side-picker > legend {
466465 }
467466 }
468467
469-// Settings and admin pages lay panes side by side, and the head spans that grid, which keeps two
470-// tracks open. A page with one pane takes both, and so does a filter with the list it filters.
468+// A filter stays above the list it filters.
471469 @media (min-width: 900px) {
472470 .shell-site > .shell-body > main,
473471 .shell-site > .shell-body > main > [data-live] {
474- > .card:not(.card ~ .card):not(:has(~ .card)),
475472 > .card:has(> .filter-bar),
476473 > .card:has(> .filter-bar) ~ .card {
477474 grid-column: 1 / -1;
@@ -529,13 +526,6 @@ main .side-picker > legend {
529526 align-self: start;
530527 }
531528
532-// The page column's rows start under the head and do not share out the window's height.
533-@media (min-width: 900px) {
534- .shell-site > .shell-body > main {
535- align-content: start;
536- }
537-}
538-
539529 // A folder with no README: the list is what the page is for, so it takes the width and its last
540530 // commit column comes back.
541531 @media (min-width: 900px) {
@@ -567,7 +557,8 @@ main .side-picker > legend {
567557 // Disclosure rows use the same chevron as every other menu, not the browser's triangle.
568558 .checks-details > summary,
569559 .commit-full-message > summary,
570-.ci-tl-more > summary {
560+.ci-tl-more > summary,
561+.mx-table > summary {
571562 display: inline-flex;
572563 align-items: center;
573564 gap: 4px;
@@ -590,7 +581,8 @@ main .side-picker > legend {
590581
591582 .checks-details[open] > summary::before,
592583 .commit-full-message[open] > summary::before,
593-.ci-tl-more[open] > summary::before {
584+.ci-tl-more[open] > summary::before,
585+.mx-table[open] > summary::before {
594586 transform: rotate(180deg);
595587 }
596588
@@ -651,3 +643,199 @@ main .side-picker > legend {
651643 white-space: normal;
652644 }
653645 }
646+
647+.profile-tabs .tab {
648+ display: inline-flex;
649+ align-items: center;
650+ gap: 6px;
651+ height: 36px;
652+}
653+
654+// Organization pages: the name, the tabs on one rule, then the panes a little below it.
655+.page-head.org-head {
656+ margin-bottom: 0;
657+ border-bottom: 0;
658+}
659+
660+.org-head + .profile-tabs {
661+ margin-bottom: 16px;
662+}
663+
664+.org-split {
665+ display: grid;
666+ grid-template-columns: minmax(0, 1fr);
667+ align-items: start;
668+ gap: 16px;
669+
670+ > .card {
671+ margin: 0;
672+ }
673+
674+ > .card > h3 {
675+ margin: 0 0 12px;
676+ color: var(--muted);
677+ font-family: var(--mono);
678+ font-size: 12px;
679+ font-weight: 500;
680+ letter-spacing: 0.08em;
681+ text-transform: uppercase;
682+ }
683+}
684+
685+@media (min-width: 900px) {
686+ .org-split:has(> .card ~ .card) {
687+ grid-template-columns: minmax(0, 1fr) minmax(20rem, 24rem);
688+ }
689+}
690+
691+// Forms that are a grid do not share out their pane's height.
692+form.stack[action="/admin/mail"],
693+.import-home > .newrepo-form {
694+ align-content: start;
695+}
696+
697+@media (min-width: 900px) {
698+ form.stack[action="/admin/mail"] {
699+ max-width: 960px;
700+ }
701+
702+ // The note and the switch in the third column stand on the fields' line.
703+ form.stack[action="/admin/mail"] > p,
704+ form.stack[action="/admin/mail"] > label:has(> input[type="checkbox"]) {
705+ align-self: end;
706+ min-height: var(--control-h);
707+ margin: 0;
708+ display: flex;
709+ align-items: center;
710+ gap: 8px;
711+ }
712+}
713+
714+// Charts: a figure wraps inside its own column and never runs over the next.
715+.mx-caption {
716+ white-space: normal;
717+ overflow-wrap: anywhere;
718+}
719+
720+.srv-field > label,
721+.srv-label {
722+ flex-wrap: wrap;
723+}
724+
725+// Profile pins: the menu sits on the section's head.
726+.pins-menu {
727+ position: relative;
728+ font-family: var(--font);
729+ font-size: 13px;
730+ font-weight: 400;
731+ letter-spacing: 0;
732+ text-transform: none;
733+}
734+
735+.pins-menu > summary {
736+ list-style: none;
737+ cursor: pointer;
738+
739+ &::-webkit-details-marker {
740+ display: none;
741+ }
742+}
743+
744+.pins-menu > .pop-panel {
745+ position: absolute;
746+ top: 100%;
747+ right: 0;
748+ left: auto;
749+ z-index: 30;
750+ display: grid;
751+ gap: 10px;
752+ width: min(20rem, calc(100vw - 32px));
753+ margin-top: 6px;
754+ padding: 12px;
755+ max-height: min(60vh, 28rem);
756+ overflow-y: auto;
757+}
758+
759+.pins-menu > .pop-panel > p {
760+ margin: 0;
761+}
762+
763+.pins-menu > .pop-panel > .primary {
764+ justify-content: center;
765+ text-align: center;
766+}
767+
768+.pins-menu .pin-options {
769+ display: grid;
770+ gap: 2px;
771+ margin: 0;
772+ padding: 0;
773+ list-style: none;
774+
775+ li {
776+ border: 0;
777+ }
778+
779+ label {
780+ display: flex;
781+ align-items: center;
782+ gap: 8px;
783+ min-height: 32px;
784+ border: 0;
785+ font-weight: 400;
786+ }
787+}
788+
789+// Explore: organizations are one row of links above the list.
790+.explore-orgs {
791+ display: flex;
792+ align-items: center;
793+ flex-wrap: wrap;
794+ gap: 8px 16px;
795+ padding: 8px 14px;
796+ border-bottom: 1px solid var(--border);
797+
798+ > h2 {
799+ margin: 0;
800+ color: var(--muted);
801+ font-family: var(--mono);
802+ font-size: 12px;
803+ font-weight: 500;
804+ letter-spacing: 0.08em;
805+ text-transform: uppercase;
806+ }
807+
808+ > .item-list {
809+ display: flex;
810+ flex-wrap: wrap;
811+ gap: 16px;
812+ margin: 0;
813+ }
814+}
815+
816+.mx-table > summary {
817+ display: inline-flex;
818+ align-items: center;
819+ gap: 4px;
820+ list-style: none;
821+ cursor: pointer;
822+}
823+
824+// A team: its members and repositories are the page; its own settings stand beside them.
825+@media (min-width: 900px) {
826+ .team-split {
827+ > .card:first-child {
828+ grid-column: 2;
829+ grid-row: 1 / span 2;
830+ }
831+
832+ > .card:nth-child(n + 2) {
833+ grid-column: 1;
834+ }
835+ }
836+}
837+
838+.org-split > .card > h2 {
839+ margin: 0 0 4px;
840+ font-size: 16px;
841+}
style/main.scssmodified+8 -37
@@ -1260,23 +1260,19 @@ code {
12601260 // A <label>, so undo the global column layout: icon, field and esc hint sit on one row.
12611261 flex-direction: row;
12621262 align-items: center;
1263- gap: 10px;
1263+ gap: 8px;
12641264 padding: 0 12px;
12651265 color: var(--muted);
12661266 border-bottom: 1px solid var(--border);
1267-
1268- &:focus-within {
1269- color: var(--accent);
1270- }
12711267 }
12721268
12731269 .ref-filter {
12741270 flex: 1 1 auto;
12751271 min-width: 0;
1276- height: 46px;
1272+ height: 36px;
12771273 padding: 0;
12781274 font: inherit;
1279- font-size: 15px;
1275+ font-size: 14px;
12801276 color: var(--text);
12811277 background: transparent;
12821278 border: 0;
@@ -1331,7 +1327,7 @@ code {
13311327 }
13321328
13331329 // Rows: kind icon, the name in mono, an optional default chip, and the tip's age pushed right.
1334-// The selected row (keys or pointer) gets a soft fill; the current ref an accent rail and name.
1330+// The selected row (keys or pointer) gets a soft fill; the current ref is in bold on that fill.
13351331 .ref-list {
13361332 list-style: none;
13371333 margin: 0;
@@ -1353,19 +1349,7 @@ code {
13531349 }
13541350
13551351 li[aria-current="true"] a {
1356- color: var(--accent);
1357- background: var(--accent-soft);
1358-
1359- &::before {
1360- content: "";
1361- position: absolute;
1362- left: 0;
1363- top: 7px;
1364- bottom: 7px;
1365- width: 3px;
1366- background: var(--accent);
1367- border-radius: var(--radius-full);
1368- }
1352+ background: var(--surface-2);
13691353
13701354 .ref-text {
13711355 font-weight: 600;
@@ -1425,9 +1409,8 @@ code {
14251409 display: flex;
14261410 align-items: center;
14271411 gap: 14px;
1428- padding: 8px 12px;
1429- font-size: 12px;
1430- background: var(--surface-2);
1412+ padding: 8px 14px;
1413+ font-size: 13px;
14311414 border-top: 1px solid var(--border);
14321415
14331416 a {
@@ -1440,12 +1423,6 @@ code {
14401423 }
14411424 }
14421425
1443-.ref-keys {
1444- display: inline-flex;
1445- gap: 4px;
1446- margin-right: auto;
1447-}
1448-
14491426 .crumbs {
14501427 min-width: 0;
14511428 font-size: 0.9375rem;
@@ -2182,7 +2159,7 @@ code {
21822159 }
21832160
21842161 .ref-filter {
2185- height: 52px;
2162+ height: 44px;
21862163 font-size: 16px;
21872164 }
21882165
@@ -2190,13 +2167,7 @@ code {
21902167 padding: 12px 10px 12px 12px;
21912168 }
21922169
2193- // No keyboard on a phone: the footer keeps only the links.
2194- .ref-keys {
2195- display: none;
2196- }
2197-
21982170 .ref-foot {
2199- justify-content: flex-end;
22002171 padding: 12px 16px;
22012172 }
22022173 }