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 commit1512ebbfc3168802ec6e7df88f3a74b0f6587f1aParent: 158fa0fAll checks have passed
Show checks
ci/buildSucceededDetails
- 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
17 changed files +925 -344
- crates/forge-web/assets/nav.js +177 -23
- crates/forge-web/src/pages/admin_mail.rs +2 -4
- crates/forge-web/src/pages/admin_runners.rs +1 -1
- crates/forge-web/src/pages/admin_server.rs +2 -2
- crates/forge-web/src/pages/invites.rs +2 -2
- crates/forge-web/src/pages/org_members.rs +3 -2
- crates/forge-web/src/pages/org_teams.rs +6 -6
- crates/forge-web/src/pages/palette.rs +382 -38
- crates/forge-web/src/pages/profile.rs +37 -13
- crates/forge-web/src/pages/profile_pins.rs +71 -173
- crates/forge-web/src/views/mod.rs +6 -22
- style/_canvas_repo.scss +7 -3
- style/_fit_forms.scss +2 -1
- style/_lang_admin.scss +10 -3
- style/_palette.scss +7 -0
- style/_system.scss +202 -14
- style/main.scss +8 -37
crates/forge-web/assets/nav.jsmodified+177 -23
| @@ -310,6 +310,9 @@ | |||
| 310 | var el = document.getElementById(id); | 310 | var el = document.getElementById(id); |
| 311 | if (!el) { return false; } | 311 | if (!el) { return false; } |
| 312 | el.scrollIntoView(); | 312 | 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 }); } | ||
| 313 | return true; | 316 | return true; |
| 314 | } | 317 | } |
| 315 | 318 | ||
| @@ -766,7 +769,7 @@ | |||
| 766 | 769 | ||
| 767 | // Dropdown menus: the <details> that float over the page (avatar menu, branch selector, clone | 770 | // Dropdown menus: the <details> that float over the page (avatar menu, branch selector, clone |
| 768 | // popover, section menu, profile corner). Inline disclosures are not listed: a click outside leaves them open. | 771 | // 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'; |
| 770 | 773 | ||
| 771 | // Closes every open dropdown that does not contain `from` (pass null to close them all). A click | 774 | // Closes every open dropdown that does not contain `from` (pass null to close them all). A click |
| 772 | // inside the floating corner keeps its own menu open. | 775 | // inside the floating corner keeps its own menu open. |
| @@ -4025,6 +4028,7 @@ | |||
| 4025 | var PALETTE_TTL = 60000; // ms a fetched list stays fresh | 4028 | var PALETTE_TTL = 60000; // ms a fetched list stays fresh |
| 4026 | var PALETTE_MAX = 50; // options shown at once | 4029 | var PALETTE_MAX = 50; // options shown at once |
| 4027 | var PALETTE_WORD = /[\s\/._\-·]/; // a character that starts a word, for the word-start match | 4030 | 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 | ||
| 4028 | // files: the current repo's file items, once its finder list is loaded (filesSrc names the finder | 4032 | // files: the current repo's file items, once its finder list is loaded (filesSrc names the finder |
| 4029 | // it came from); filesBusy names the source being fetched. | 4033 | // it came from); filesBusy names the source being fetched. |
| 4030 | // acts: the actions this page offers, read from its live elements at each open. busy: a state change | 4034 | // acts: the actions this page offers, read from its live elements at each open. busy: a state change |
| @@ -4079,42 +4083,180 @@ | |||
| 4079 | return out; | 4083 | return out; |
| 4080 | } | 4084 | } |
| 4081 | 4085 | ||
| 4082 | - // How well the lowercased query matches a label: 3 for a prefix, 2 for a match at a word start, | 4086 | + // Text for matching: lowercase, without accents, and with the dotless i, so "guvenlik" finds "Güvenlik". |
| 4083 | - // 1 for the letters in order anywhere, 0 for no match. A shorter label wins within a tier, and the | 4087 | + function paletteFold(text) { |
| 4084 | - // bonus stays under 0.5 so it never lifts a label into the tier above. An empty query matches all. | 4088 | + return text.toLowerCase().normalize('NFD').replace(/[̀-ͯ]/g, '').replace(/ı/g, 'i'); |
| 4085 | - function paletteScore(q, label) { | 4089 | + } |
| 4086 | - if (!q) { return 1; } | 4090 | + |
| 4087 | - var s = label.toLowerCase(); | 4091 | + // A text ready to match against: folded, split into words, and with its separators removed. |
| 4088 | - var bonus = 1 / (s.length + 2); | 4092 | + function paletteParts(text) { |
| 4089 | - var at = s.indexOf(q); | 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; | ||
| 4090 | while (at >= 0) { | 4143 | while (at >= 0) { |
| 4091 | - if (at === 0) { return 3 + bonus; } | 4144 | + if (PALETTE_WORD.test(x.s.charAt(at - 1))) { return 2; } |
| 4092 | - if (PALETTE_WORD.test(s.charAt(at - 1))) { return 2 + bonus; } | 4145 | + at = x.s.indexOf(t, at + 1); |
| 4093 | - at = s.indexOf(q, 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; } | ||
| 4094 | } | 4154 | } |
| 4095 | - var qi = 0; | 4155 | + if (x.words.length > 1 && t.length >= 6) { best = Math.min(best, paletteTypos(t, x.whole, max)); } |
| 4096 | - for (var i = 0; i < s.length && qi < q.length; i++) { | 4156 | + return best <= max ? 1.6 - best / 10 + (first ? 0.05 : 0) : 0; |
| 4097 | - if (s.charAt(i) === q.charAt(qi)) { qi++; } | ||
| 4098 | } | 4157 | } |
| 4099 | - return qi === q.length ? 1 + bonus : 0; | 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; | ||
| 4100 | } | 4185 | } |
| 4101 | 4186 | ||
| 4102 | - // The destinations to filter: the current repo's tabs first, then the fetched list. | 4187 | + // How well a query matches an item, 0 for no match. Each word of the query must match, in any order, |
| 4103 | - function paletteItems() { | 4188 | + // so "forge hooks" and "mail host" work. The whole query as a phrase counts too, and a shorter label |
| 4104 | - var items = []; | 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; | ||
| 4206 | + } | ||
| 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 | + }); | ||
| 4224 | + } | ||
| 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; | ||
| 4235 | + } | ||
| 4236 | + | ||
| 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; | ||
| 4105 | var tabs = document.querySelectorAll('.repo-tabs a'); | 4241 | var tabs = document.querySelectorAll('.repo-tabs a'); |
| 4106 | if (tabs.length) { | 4242 | if (tabs.length) { |
| 4107 | // The first tab is the repo's Code link, so its path starts with owner/name. | 4243 | // The first tab is the repo's Code link, so its path starts with owner/name. |
| 4108 | var parts = tabs[0].pathname.split('/'); | 4244 | var parts = tabs[0].pathname.split('/'); |
| 4109 | var repo = parts.length >= 3 ? parts[1] + '/' + parts[2] : ''; | 4245 | var repo = parts.length >= 3 ? parts[1] + '/' + parts[2] : ''; |
| 4110 | if (repo) { | 4246 | if (repo) { |
| 4247 | + var admin = false; | ||
| 4111 | Array.prototype.forEach.call(tabs, function (a) { | 4248 | Array.prototype.forEach.call(tabs, function (a) { |
| 4112 | // Counts sit in a span at the end of the tab ("Issues 3"); the name is the rest. | 4249 | // Counts sit in a span at the end of the tab ("Issues 3"); the name is the rest. |
| 4113 | var name = a.textContent.replace(/\s+/g, ' ').trim().replace(/ \d+$/, ''); | 4250 | var name = a.textContent.replace(/\s+/g, ' ').trim().replace(/ \d+$/, ''); |
| 4114 | items.push({ label: repo + ' · ' + name, href: a.getAttribute('href') || '', kind: 'repo' }); | 4251 | items.push({ label: repo + ' · ' + name, href: a.getAttribute('href') || '', kind: 'repo' }); |
| 4252 | + if (a.pathname === '/' + repo + '/settings') { admin = true; } | ||
| 4115 | }); | 4253 | }); |
| 4254 | + current = { name: repo, href: '/' + repo, admin: admin }; | ||
| 4116 | } | 4255 | } |
| 4117 | } | 4256 | } |
| 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]; })); | ||
| 4118 | if (pal.data) { items = items.concat(pal.data.items); } | 4260 | if (pal.data) { items = items.concat(pal.data.items); } |
| 4119 | return pal.acts.concat(items); | 4261 | return pal.acts.concat(items); |
| 4120 | } | 4262 | } |
| @@ -4150,6 +4292,7 @@ | |||
| 4150 | // The text a completed item leaves in the input: a tab's label is its repo, and a repo gets a "/". | 4292 | // The text a completed item leaves in the input: a tab's label is its repo, and a repo gets a "/". |
| 4151 | function paletteCompletion(item) { | 4293 | function paletteCompletion(item) { |
| 4152 | var label = item.label; | 4294 | var label = item.label; |
| 4295 | + if (item.kind !== 'repo' && item.kind !== 'org') { return label; } | ||
| 4153 | var at = label.indexOf(' \u00b7 '); | 4296 | var at = label.indexOf(' \u00b7 '); |
| 4154 | if (at >= 0) { label = label.slice(0, at); } | 4297 | if (at >= 0) { label = label.slice(0, at); } |
| 4155 | return label + (item.kind === 'repo' ? '/' : ''); | 4298 | return label + (item.kind === 'repo' ? '/' : ''); |
| @@ -4176,14 +4319,19 @@ | |||
| 4176 | var typed = pal.prefill && !idle && q.indexOf(pal.prefill.toLowerCase()) === 0 ? q.slice(pal.prefill.length) : ''; | 4319 | var typed = pal.prefill && !idle && q.indexOf(pal.prefill.toLowerCase()) === 0 ? q.slice(pal.prefill.length) : ''; |
| 4177 | // With a "/" the query is a path: an item matches when its label starts with it. | 4320 | // With a "/" the query is a path: an item matches when its label starts with it. |
| 4178 | var pathMode = q.indexOf('/') >= 0; | 4321 | 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()); | ||
| 4179 | var scored = []; | 4324 | var scored = []; |
| 4180 | - paletteItems().concat(paletteFiles(q)).forEach(function (item, idx) { | 4325 | + paletteItems(pathMode ? words : q).concat(paletteFiles(q)).forEach(function (item, idx) { |
| 4181 | if (!Object.prototype.hasOwnProperty.call(pal.str.heads, item.kind)) { return; } | 4326 | 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; } | ||
| 4183 | // Above a path match (3), which would otherwise fill the list and cut the actions off. Text typed | 4331 | // Above a path match (3), which would otherwise fill the list and cut the actions off. Text typed |
| 4184 | // after the opening path searches the page's actions by name. | 4332 | // after the opening path searches the page's actions by name. |
| 4185 | if (item.kind === 'action' && idle) { s = 4; } | 4333 | 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; } |
| 4187 | if (s > 0) { scored.push({ item: item, score: s, idx: idx }); } | 4335 | if (s > 0) { scored.push({ item: item, score: s, idx: idx }); } |
| 4188 | }); | 4336 | }); |
| 4189 | scored.sort(function (a, b) { return b.score - a.score || a.idx - b.idx; }); | 4337 | scored.sort(function (a, b) { return b.score - a.score || a.idx - b.idx; }); |
| @@ -4221,6 +4369,12 @@ | |||
| 4221 | li.setAttribute('aria-selected', 'false'); | 4369 | li.setAttribute('aria-selected', 'false'); |
| 4222 | li.setAttribute('data-n', String(n)); | 4370 | li.setAttribute('data-n', String(n)); |
| 4223 | li.textContent = item.label; | 4371 | 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 | + } | ||
| 4224 | pal.list.appendChild(li); | 4378 | pal.list.appendChild(li); |
| 4225 | }); | 4379 | }); |
| 4226 | }); | 4380 | }); |
| @@ -4248,7 +4402,7 @@ | |||
| 4248 | if (!r.ok) { throw new Error('status ' + r.status); } | 4402 | if (!r.ok) { throw new Error('status ' + r.status); } |
| 4249 | return r.json(); | 4403 | return r.json(); |
| 4250 | }).then(function (json) { | 4404 | }).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 : [] }; |
| 4252 | pal.request = null; | 4406 | pal.request = null; |
| 4253 | if (pal.dlg.open) { renderPalette(); } | 4407 | if (pal.dlg.open) { renderPalette(); } |
| 4254 | }).catch(function () { | 4408 | }).catch(function () { |
crates/forge-web/src/pages/admin_mail.rsmodified+2 -4
| @@ -268,13 +268,11 @@ async fn mail_view( | |||
| 268 | <label><input type="checkbox" name="enabled" value="on" checked=(data.enabled)>(g::t(lang, K::SendMailCheckbox))</label> | 268 | <label><input type="checkbox" name="enabled" value="on" checked=(data.enabled)>(g::t(lang, K::SendMailCheckbox))</label> |
| 269 | <div class="actions"> | 269 | <div class="actions"> |
| 270 | <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> | 270 | <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> |
| 271 | + <button type="submit" form="mail-test">(g::t(lang, K::SendTestMailToMe))</button> | ||
| 271 | </div> | 272 | </div> |
| 272 | </form> | 273 | </form> |
| 273 | - <form method="post" action="/admin/mail/test"> | 274 | + <form id="mail-test" method="post" action="/admin/mail/test"> |
| 274 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 275 | <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> | ||
| 278 | </form> | 276 | </form> |
| 279 | </section> | 277 | </section> |
| 280 | </div> | 278 | </div> |
crates/forge-web/src/pages/admin_runners.rsmodified+1 -1
| @@ -1656,7 +1656,7 @@ async fn runner_detail_view( | |||
| 1656 | // A runner that has reported nothing has no figures to show, only the note below. | 1656 | // A runner that has reported nothing has no figures to show, only the note below. |
| 1657 | let has_host = !metrics.empty || runner.reported.cpus.is_some(); | 1657 | let has_host = !metrics.empty || runner.reported.cpus.is_some(); |
| 1658 | Ok(view! { | 1658 | Ok(view! { |
| 1659 | - <div data-live="/admin/runners/events"> | 1659 | + <div data-live="/admin/runners/events" class="runner-detail"> |
| 1660 | <section class="page-head"> | 1660 | <section class="page-head"> |
| 1661 | <div class="runner-head"> | 1661 | <div class="runner-head"> |
| 1662 | <h1>(runner.name.as_str())</h1> | 1662 | <h1>(runner.name.as_str())</h1> |
crates/forge-web/src/pages/admin_server.rsmodified+2 -2
| @@ -109,7 +109,7 @@ struct Row { | |||
| 109 | fixed: bool, | 109 | fixed: bool, |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | -fn tab_label(lang: Lang, group: Group) -> &'static str { | 112 | +pub(crate) fn tab_label(lang: Lang, group: Group) -> &'static str { |
| 113 | g::t( | 113 | g::t( |
| 114 | lang, | 114 | lang, |
| 115 | match group { | 115 | match group { |
| @@ -263,7 +263,7 @@ async fn server_view( | |||
| 263 | <input type="hidden" name="tab" value=(tab)> | 263 | <input type="hidden" name="tab" value=(tab)> |
| 264 | <div class="srv-grid"> | 264 | <div class="srv-grid"> |
| 265 | for r in rows.iter() { | 265 | for r in rows.iter() { |
| 266 | - <div class="srv-field"> | 266 | + <div class="srv-field" id=(format!("srv-{}", r.key))> |
| 267 | <div class="srv-head"> | 267 | <div class="srv-head"> |
| 268 | <span class="srv-label" title=(r.label)>(r.label)</span> | 268 | <span class="srv-label" title=(r.label)>(r.label)</span> |
| 269 | <span class=(r.kind_class)>(r.kind_label)</span> | 269 | <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( | |||
| 37 | Ok(view! { | 37 | Ok(view! { |
| 38 | <section class="page-head"> | 38 | <section class="page-head"> |
| 39 | <h1>(t(lang, Key::InvitesTitle))</h1> | 39 | <h1>(t(lang, Key::InvitesTitle))</h1> |
| 40 | - <p class="muted">(t(lang, Key::InvitesSub))</p> | ||
| 41 | </section> | 40 | </section> |
| 41 | + <p class="muted page-lede">(t(lang, Key::InvitesSub))</p> | ||
| 42 | if let Some(message) = notice { | 42 | if let Some(message) = notice { |
| 43 | <section class="card notice" role="status"> | 43 | <section class="card notice" role="status"> |
| 44 | <p>(message)</p> | 44 | <p>(message)</p> |
| 45 | </section> | 45 | </section> |
| 46 | } | 46 | } |
| 47 | - <section class="card narrow"> | 47 | + <section class="card"> |
| 48 | if let Some(message) = error { | 48 | if let Some(message) = error { |
| 49 | alert(message: message.as_str()) | 49 | alert(message: message.as_str()) |
| 50 | } | 50 | } |
crates/forge-web/src/pages/org_members.rsmodified+3 -2
| @@ -90,8 +90,8 @@ async fn members_body( | |||
| 90 | org_head(name: name.clone(), 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) | 91 | org_tabs(lang: lang, name: name, current: "members".to_owned(), repo_count: repo_count, package_count: package_count) |
| 92 | org_notice(notice: notice) | 92 | org_notice(notice: notice) |
| 93 | + <div class="org-split"> | ||
| 93 | <section class="card"> | 94 | <section class="card"> |
| 94 | - <h2>(g::t(lang, K::Members))</h2> | ||
| 95 | <div class="table-wrap"> | 95 | <div class="table-wrap"> |
| 96 | <table class="table collaborators members-table"> | 96 | <table class="table collaborators members-table"> |
| 97 | <thead> | 97 | <thead> |
| @@ -163,12 +163,13 @@ async fn members_body( | |||
| 163 | </label> | 163 | </label> |
| 164 | <p class="muted small">(g::t(lang, K::OwnersHelp))</p> | 164 | <p class="muted small">(g::t(lang, K::OwnersHelp))</p> |
| 165 | <div> | 165 | <div> |
| 166 | - <button type="submit">(g::t(lang, K::AddMemberButton))</button> | 166 | + <button type="submit" class="primary">(g::t(lang, K::AddMemberButton))</button> |
| 167 | </div> | 167 | </div> |
| 168 | </form> | 168 | </form> |
| 169 | </section> | 169 | </section> |
| 170 | } | 170 | } |
| 171 | </div> | 171 | </div> |
| 172 | + </div> | ||
| 172 | }) | 173 | }) |
| 173 | } | 174 | } |
| 174 | 175 | ||
crates/forge-web/src/pages/org_teams.rsmodified+6 -6
| @@ -201,14 +201,10 @@ async fn teams_body( | |||
| 201 | org_head(name: name.clone(), 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) | 202 | org_tabs(lang: lang, name: name, current: "teams".to_owned(), repo_count: repo_count, package_count: package_count) |
| 203 | org_notice(notice: notice) | 203 | org_notice(notice: notice) |
| 204 | + <div class="org-split"> | ||
| 204 | <section class="card"> | 205 | <section class="card"> |
| 205 | - <h2>(g::t(lang, K::Teams))</h2> | ||
| 206 | - <p class="muted small">(g::t(lang, K::TeamsIntro))</p> | ||
| 207 | if rows.is_empty() { | 206 | if rows.is_empty() { |
| 208 | - empty_state(title: g::t(lang, K::NoTeamsYet), | 207 | + 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 | - }) | ||
| 212 | } else { | 208 | } else { |
| 213 | <ul class="item-list"> | 209 | <ul class="item-list"> |
| 214 | for row in rows.iter() { | 210 | for row in rows.iter() { |
| @@ -224,6 +220,7 @@ async fn teams_body( | |||
| 224 | } | 220 | } |
| 225 | </ul> | 221 | </ul> |
| 226 | } | 222 | } |
| 223 | + <p class="muted small">(g::t(lang, K::TeamsIntro))</p> | ||
| 227 | </section> | 224 | </section> |
| 228 | if owner { | 225 | if owner { |
| 229 | <section class="card" id="new-team"> | 226 | <section class="card" id="new-team"> |
| @@ -257,6 +254,7 @@ async fn teams_body( | |||
| 257 | </section> | 254 | </section> |
| 258 | } | 255 | } |
| 259 | </div> | 256 | </div> |
| 257 | + </div> | ||
| 260 | }) | 258 | }) |
| 261 | } | 259 | } |
| 262 | 260 | ||
| @@ -317,6 +315,7 @@ async fn team_body( | |||
| 317 | org_head(name: data.org_name.clone(), description: data.org_description.clone()) | 315 | 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) | 316 | org_tabs(lang: lang, name: data.org_name.clone(), current: "teams".to_owned(), repo_count: data.repo_count, package_count: data.package_count) |
| 319 | org_notice(notice: notice) | 317 | org_notice(notice: notice) |
| 318 | + <div class="org-split team-split"> | ||
| 320 | <section class="card"> | 319 | <section class="card"> |
| 321 | <h2>(data.team_name.as_str())</h2> | 320 | <h2>(data.team_name.as_str())</h2> |
| 322 | if has_description { | 321 | if has_description { |
| @@ -440,6 +439,7 @@ async fn team_body( | |||
| 440 | } | 439 | } |
| 441 | </section> | 440 | </section> |
| 442 | </div> | 441 | </div> |
| 442 | + </div> | ||
| 443 | }) | 443 | }) |
| 444 | } | 444 | } |
| 445 | 445 | ||
crates/forge-web/src/pages/palette.rsmodified+382 -38
| @@ -1,15 +1,21 @@ | |||
| 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 with that org's members, teams and (for owners) settings, | 2 | +//! Their repos, the orgs they belong to with each org's tabs, teams and (for owners) settings, and the |
| 3 | -//! and the pages the navigation links to: their own profile's tabs, the fixed site pages and the | 3 | +//! pages the navigation links to: their own profile's tabs, the fixed site pages and the settings and |
| 4 | -//! settings and admin pages. Those pages come from the same lists the navigation is built from | 4 | +//! admin pages. For an admin it also lists every tab and every field of the server settings. Those |
| 5 | -//! (`views::profile_items`, `views::global_items`, `views::settings_items`, `views::admin_items`), | 5 | +//! pages come from the same lists the navigation is built from (`views::profile_items`, |
| 6 | -//! so a page the sidebar or a tab bar links to is found here too. Each href is listed once, the | 6 | +//! `views::global_items`, `views::settings_items`, `views::admin_items`), so a page the sidebar or a |
| 7 | -//! first time it appears. The palette itself, its filtering and keys live in `assets/nav.js`. The | 7 | +//! tab bar links to is found here too. Each href is listed once, the first time it appears. |
| 8 | -//! actions of the page it is opened on are not listed here: a control marked `data-palette-action` | 8 | +//! |
| 9 | -//! is rendered only for a viewer who may use it, and the palette reads those controls from the page. | 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. | ||
| 10 | 15 | ||
| 11 | use std::collections::HashSet; | 16 | use std::collections::HashSet; |
| 12 | 17 | ||
| 18 | +use forge_core::server_settings::{FIELDS, Group}; | ||
| 13 | use forge_core::store::orgs::OrgMemberRole; | 19 | use forge_core::store::orgs::OrgMemberRole; |
| 14 | use http::header::{CACHE_CONTROL, CONTENT_TYPE, X_CONTENT_TYPE_OPTIONS}; | 20 | use http::header::{CACHE_CONTROL, CONTENT_TYPE, X_CONTENT_TYPE_OPTIONS}; |
| 15 | use serde_json::{Value, json}; | 21 | use serde_json::{Value, json}; |
| @@ -19,9 +25,13 @@ use topcoat::router::response::Response; | |||
| 19 | use topcoat::router::{Body, HeaderValue, StatusCode, route}; | 25 | use topcoat::router::{Body, HeaderValue, StatusCode, route}; |
| 20 | 26 | ||
| 21 | use crate::auth::current_user; | 27 | use crate::auth::current_user; |
| 22 | -use crate::i18n; | 28 | +use crate::i18n::code::{self, K as CK}; |
| 23 | use crate::i18n::orgs::{self as g, K}; | 29 | 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; | ||
| 24 | use crate::pages::org_new::may_create_org; | 33 | use crate::pages::org_new::may_create_org; |
| 34 | +use crate::pages::passkeys::s; | ||
| 25 | use crate::state::AppState; | 35 | use crate::state::AppState; |
| 26 | use crate::views::{ | 36 | use crate::views::{ |
| 27 | admin_items, enc, global_items, profile_items, repo_href, settings_items, user_href, | 37 | admin_items, enc, global_items, profile_items, repo_href, settings_items, user_href, |
| @@ -30,20 +40,271 @@ use crate::views::{ | |||
| 30 | /// Repos listed at most. The palette filters in the browser, so a longer list would only cost time. | 40 | /// Repos listed at most. The palette filters in the browser, so a longer list would only cost time. |
| 31 | pub const MAX_REPOS: u64 = 500; | 41 | pub const MAX_REPOS: u64 = 500; |
| 32 | 42 | ||
| 33 | -/// One destination: its label, its path and what it is (`repo`, `org` or `page`). | 43 | +/// What each settings page holds and other words for it, in both languages. |
| 34 | -fn destination(label: &str, href: &str, kind: &str) -> Value { | 44 | +const SETTINGS_TERMS: &[(&str, &[&str])] = &[ |
| 35 | - json!({ "label": label, "href": href, "kind": kind }) | 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 | ||
| 36 | } | 195 | } |
| 37 | 196 | ||
| 38 | /// Adds a destination unless its href is already listed. | 197 | /// Adds a destination unless its href is already listed. |
| 39 | fn push(items: &mut Vec<Value>, seen: &mut HashSet<String>, label: &str, href: &str, kind: &str) { | 198 | 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 | +) { | ||
| 40 | if seen.insert(href.to_owned()) { | 211 | if seen.insert(href.to_owned()) { |
| 41 | - items.push(destination(label, href, kind)); | 212 | + items.push(destination(label, href, kind, terms)); |
| 42 | } | 213 | } |
| 43 | } | 214 | } |
| 44 | 215 | ||
| 45 | -/// `{"items": [{"label", "href", "kind"}, ...]}` for the signed-in viewer. Anonymous visitors get | 216 | +/// The other words listed for an href. |
| 46 | -/// 401, as the other signed-in-only JSON routes do. | 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. | ||
| 47 | #[route(GET "/-/palette")] | 308 | #[route(GET "/-/palette")] |
| 48 | async fn palette(cx: &Cx) -> Result<Response> { | 309 | async fn palette(cx: &Cx) -> Result<Response> { |
| 49 | let Some((user, _)) = current_user(cx).await? else { | 310 | let Some((user, _)) = current_user(cx).await? else { |
| @@ -53,42 +314,50 @@ async fn palette(cx: &Cx) -> Result<Response> { | |||
| 53 | }; | 314 | }; |
| 54 | let state = app_context::<AppState>(cx); | 315 | let state = app_context::<AppState>(cx); |
| 55 | let lang = i18n::lang(cx, Some(&user)); | 316 | let lang = i18n::lang(cx, Some(&user)); |
| 317 | + let orgs = state.store.orgs_for_user(&user.id).await?; | ||
| 56 | 318 | ||
| 57 | let mut items = Vec::new(); | 319 | let mut items = Vec::new(); |
| 58 | let mut seen = HashSet::new(); | 320 | let mut seen = HashSet::new(); |
| 59 | for repo in state.store.list_viewer_repos(&user, MAX_REPOS).await? { | 321 | for repo in state.store.list_viewer_repos(&user, MAX_REPOS).await? { |
| 60 | let label = format!("{}/{}", repo.owner_name, repo.name); | 322 | let label = format!("{}/{}", repo.owner_name, repo.name); |
| 61 | let href = repo_href(&repo.owner_name, &repo.name, "", ""); | 323 | 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 | + } | ||
| 63 | } | 336 | } |
| 64 | - for (org, role) in state.store.orgs_for_user(&user.id).await? { | 337 | + for (org, role) in &orgs { |
| 65 | let name = &org.username; | 338 | let name = &org.username; |
| 66 | let base = format!("/org/{}", enc(name)); | 339 | let base = format!("/org/{}", enc(name)); |
| 67 | push(&mut items, &mut seen, name, &user_href(name), "org"); | 340 | push(&mut items, &mut seen, name, &user_href(name), "org"); |
| 68 | - let members = format!("{name} \u{b7} {}", g::t(lang, K::Members)); | 341 | + for tab in profile_items(lang, name, true, false, true) { |
| 69 | - push( | 342 | + if tab.key != "overview" { |
| 70 | - &mut items, | 343 | + let label = format!("{name} \u{b7} {}", tab.label); |
| 71 | - &mut seen, | 344 | + push(&mut items, &mut seen, &label, &tab.href, "page"); |
| 72 | - &members, | 345 | + } |
| 73 | - &format!("{base}/members"), | 346 | + } |
| 74 | - "page", | 347 | + for team in state.store.teams_for_org(&org.id).await? { |
| 75 | - ); | 348 | + let label = format!("{name} \u{b7} {}", team.name); |
| 76 | - let teams = format!("{name} \u{b7} {}", g::t(lang, K::Teams)); | 349 | + let href = format!("{base}/teams/{}", team.id); |
| 77 | - push( | 350 | + push(&mut items, &mut seen, &label, &href, "page"); |
| 78 | - &mut items, | 351 | + } |
| 79 | - &mut seen, | 352 | + if *role == OrgMemberRole::Owner { |
| 80 | - &teams, | ||
| 81 | - &format!("{base}/teams"), | ||
| 82 | - "page", | ||
| 83 | - ); | ||
| 84 | - if role == OrgMemberRole::Owner { | ||
| 85 | let settings = format!("{name} \u{b7} {}", g::t(lang, K::Settings)); | 353 | let settings = format!("{name} \u{b7} {}", g::t(lang, K::Settings)); |
| 86 | - push( | 354 | + push_terms( |
| 87 | &mut items, | 355 | &mut items, |
| 88 | &mut seen, | 356 | &mut seen, |
| 89 | &settings, | 357 | &settings, |
| 90 | &format!("{base}/settings"), | 358 | &format!("{base}/settings"), |
| 91 | "page", | 359 | "page", |
| 360 | + &["Avatar", "Delete organization", "Organizasyonu sil"], | ||
| 92 | ); | 361 | ); |
| 93 | } | 362 | } |
| 94 | } | 363 | } |
| @@ -99,16 +368,52 @@ async fn palette(cx: &Cx) -> Result<Response> { | |||
| 99 | for item in global_items(lang, may_create_org(state, &user)) { | 368 | for item in global_items(lang, may_create_org(state, &user)) { |
| 100 | push(&mut items, &mut seen, item.label, &item.href, "page"); | 369 | push(&mut items, &mut seen, item.label, &item.href, "page"); |
| 101 | } | 370 | } |
| 371 | + let settings_area = g::t(lang, K::Settings); | ||
| 102 | for item in settings_items(lang) { | 372 | 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); | ||
| 104 | } | 376 | } |
| 105 | if user.is_admin { | 377 | if user.is_admin { |
| 378 | + let admin_area = crate::i18n::admin::t(lang, crate::i18n::admin::K::AdminArea); | ||
| 106 | for item in admin_items(lang) { | 379 | 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); | ||
| 108 | } | 413 | } |
| 109 | } | 414 | } |
| 110 | 415 | ||
| 111 | - let body = json!({ "items": items }); | 416 | + let body = json!({ "items": items, "repoPages": repo_pages(lang) }); |
| 112 | let mut response = Response::new(Body::from(body.to_string().into_bytes())); | 417 | let mut response = Response::new(Body::from(body.to_string().into_bytes())); |
| 113 | let headers = response.headers_mut(); | 418 | let headers = response.headers_mut(); |
| 114 | headers.insert( | 419 | headers.insert( |
| @@ -129,6 +434,45 @@ mod tests { | |||
| 129 | use crate::i18n::Lang; | 434 | use crate::i18n::Lang; |
| 130 | use crate::views::profile_items; | 435 | use crate::views::profile_items; |
| 131 | 436 | ||
| 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 | + | ||
| 132 | /// Every tab of the viewer's own profile is in the palette, so a tab is found by its name. | 476 | /// Every tab of the viewer's own profile is in the palette, so a tab is found by its name. |
| 133 | #[tokio::test] | 477 | #[tokio::test] |
| 134 | async fn palette_lists_every_profile_tab() { | 478 | async fn palette_lists_every_profile_tab() { |
crates/forge-web/src/pages/profile.rsmodified+37 -13
| @@ -30,6 +30,7 @@ use crate::live::{Topic, stream_changes}; | |||
| 30 | use crate::pages::org_new::may_create_org; | 30 | use crate::pages::org_new::may_create_org; |
| 31 | use crate::pages::packages::{self as packages, PackageRow}; | 31 | use crate::pages::packages::{self as packages, PackageRow}; |
| 32 | use crate::pages::profile_calendar::{calendar_since, load_calendar}; | 32 | use crate::pages::profile_calendar::{calendar_since, load_calendar}; |
| 33 | +use crate::pages::profile_pins::{PinOption, pin_options, pins_menu}; | ||
| 33 | use crate::pages::repo_settings::{notice_banner_for, take_notice}; | 34 | use crate::pages::repo_settings::{notice_banner_for, take_notice}; |
| 34 | use crate::pages::snippets::{ListRow, list_row, snippet_rows}; | 35 | use crate::pages::snippets::{ListRow, list_row, snippet_rows}; |
| 35 | use crate::render::markdown::render_markdown; | 36 | use crate::render::markdown::render_markdown; |
| @@ -46,6 +47,13 @@ path_param!(username); | |||
| 46 | 47 | ||
| 47 | /// Repos per page on the repositories and stars tabs. | 48 | /// Repos per page on the repositories and stars tabs. |
| 48 | const PER_PAGE: u64 = 30; | 49 | 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 | + | ||
| 49 | /// Repos the overview shows when the owner has no visible pins. | 57 | /// Repos the overview shows when the owner has no visible pins. |
| 50 | const POPULAR_COUNT: usize = 6; | 58 | const POPULAR_COUNT: usize = 6; |
| 51 | /// Members an organization's overview lists; a longer list links to the members page. | 59 | /// Members an organization's overview lists; a longer list links to the members page. |
| @@ -61,6 +69,8 @@ struct ProfileQuery { | |||
| 61 | page: Option<String>, | 69 | page: Option<String>, |
| 62 | /// A calendar day whose contributions to list under the calendar on the overview. | 70 | /// A calendar day whose contributions to list under the calendar on the overview. |
| 63 | day: Option<String>, | 71 | day: Option<String>, |
| 72 | + /// `too_many` after a save with more pins than the limit. | ||
| 73 | + pins: Option<String>, | ||
| 64 | } | 74 | } |
| 65 | 75 | ||
| 66 | /// Sort keys of the repo tabs in the order their chips are shown, with the label of each. The | 76 | /// 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> { | |||
| 178 | Some(u) => u.id == user.id, | 188 | Some(u) => u.id == user.id, |
| 179 | None => false, | 189 | None => false, |
| 180 | }; | 190 | }; |
| 181 | - let pins_edit_href = can_edit_pins.then(|| { | 191 | + let mut pins_menu_data = None; |
| 182 | - if user.is_org() { | 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() { | ||
| 183 | format!("/org/{}/settings/pins", user.username) | 196 | format!("/org/{}/settings/pins", user.username) |
| 184 | } else { | 197 | } else { |
| 185 | "/settings/pins".to_owned() | 198 | "/settings/pins".to_owned() |
| 186 | - } | 199 | + }; |
| 200 | + pins_menu_data = Some(PinsMenu { | ||
| 201 | + action, | ||
| 202 | + csrf: session.csrf_token.clone(), | ||
| 203 | + options, | ||
| 187 | }); | 204 | }); |
| 205 | + } | ||
| 206 | + } | ||
| 207 | + let pins_error = can_edit_pins && query.pins.as_deref() == Some("too_many"); | ||
| 188 | 208 | ||
| 189 | // The contribution calendar on the overview, for a person only. Its counts and day links use | 209 | // The contribution calendar on the overview, for a person only. Its counts and day links use |
| 190 | // public repos alone, so anyone may see it. | 210 | // public repos alone, so anyone may see it. |
| @@ -320,7 +340,7 @@ async fn profile_page(cx: &Cx) -> Result<impl View> { | |||
| 320 | profile_card(user: user, avatar: avatar, about_html: about_html, local_time: local_time, | 340 | profile_card(user: user, avatar: avatar, about_html: about_html, local_time: local_time, |
| 321 | org: org, lang: lang, tab: tab.to_owned(), q: q, sort: sort, repo_total: repo_total, | 341 | org: org, lang: lang, tab: tab.to_owned(), q: q, sort: sort, repo_total: repo_total, |
| 322 | star_total: star_total, cards: cards, from_pins: from_pins, | 342 | 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, |
| 324 | packages_on: packages_on, package_rows: package_rows, | 344 | packages_on: packages_on, package_rows: package_rows, |
| 325 | org_member: org_member, org_owner: org_owner, org_can_create: org_can_create, | 345 | org_member: org_member, org_owner: org_owner, org_can_create: org_can_create, |
| 326 | heat: heat, snippets: snippets, orgs: orgs, org_create_allowed: org_create_allowed, | 346 | heat: heat, snippets: snippets, orgs: orgs, org_create_allowed: org_create_allowed, |
| @@ -557,7 +577,8 @@ async fn profile_card( | |||
| 557 | star_total: u64, | 577 | star_total: u64, |
| 558 | cards: Vec<PinCard>, | 578 | cards: Vec<PinCard>, |
| 559 | from_pins: bool, | 579 | from_pins: bool, |
| 560 | - pins_edit_href: Option<String>, | 580 | + pins_menu_data: Option<PinsMenu>, |
| 581 | + pins_error: bool, | ||
| 561 | edit_profile: bool, | 582 | edit_profile: bool, |
| 562 | listing: Listing, | 583 | listing: Listing, |
| 563 | packages_on: bool, | 584 | packages_on: bool, |
| @@ -677,10 +698,13 @@ async fn profile_card( | |||
| 677 | <section class="profile-pinned"> | 698 | <section class="profile-pinned"> |
| 678 | <div class="profile-section-head"> | 699 | <div class="profile-section-head"> |
| 679 | <h2>(pinned_heading)</h2> | 700 | <h2>(pinned_heading)</h2> |
| 680 | - if let Some(href) = pins_edit_href { | 701 | + if let Some(menu) = pins_menu_data { |
| 681 | - <a class="small" href=(href.as_str())>(g::t(lang, K::CustomizePins))</a> | 702 | + pins_menu(lang: lang, action: menu.action, csrf: menu.csrf, options: menu.options) |
| 682 | } | 703 | } |
| 683 | </div> | 704 | </div> |
| 705 | + if pins_error { | ||
| 706 | + <p class="alert" role="alert">(g::t(lang, K::PinsTooMany))</p> | ||
| 707 | + } | ||
| 684 | if has_cards { | 708 | if has_cards { |
| 685 | <ul class="pin-grid"> | 709 | <ul class="pin-grid"> |
| 686 | for card in cards.into_iter() { | 710 | for card in cards.into_iter() { |
| @@ -1156,8 +1180,8 @@ mod tests { | |||
| 1156 | // Settings keeps a sidebar of its own pages, and its back link goes to the profile. | 1180 | // Settings keeps a sidebar of its own pages, and its back link goes to the profile. |
| 1157 | let (_, settings) = get(&site.router, "/org/forge-org/settings", Some(&owner_cookie)).await; | 1181 | let (_, settings) = get(&site.router, "/org/forge-org/settings", Some(&owner_cookie)).await; |
| 1158 | assert!( | 1182 | assert!( |
| 1159 | - settings.contains("href=\"/org/forge-org/settings/pins\""), | 1183 | + !settings.contains("/org/forge-org/settings/pins"), |
| 1160 | - "org settings: sidebar lists Customize pins" | 1184 | + "org settings: pins live on the profile" |
| 1161 | ); | 1185 | ); |
| 1162 | assert!( | 1186 | assert!( |
| 1163 | !settings.contains("href=\"/org/forge-org/members\""), | 1187 | !settings.contains("href=\"/org/forge-org/members\""), |
| @@ -1182,8 +1206,8 @@ mod tests { | |||
| 1182 | let (_, owner) = get(&site.router, "/acme", Some(&owner_cookie)).await; | 1206 | let (_, owner) = get(&site.router, "/acme", Some(&owner_cookie)).await; |
| 1183 | assert!(owner.contains("acme/lib"), "org pins: owner sees pin"); | 1207 | assert!(owner.contains("acme/lib"), "org pins: owner sees pin"); |
| 1184 | assert!( | 1208 | assert!( |
| 1185 | - owner.contains("href=\"/org/acme/settings/pins\""), | 1209 | + owner.contains("action=\"/org/acme/settings/pins\""), |
| 1186 | - "org pins: owner edit link" | 1210 | + "org pins: owner edits them on the profile" |
| 1187 | ); | 1211 | ); |
| 1188 | let (_, anon) = get(&site.router, "/acme", None).await; | 1212 | let (_, anon) = get(&site.router, "/acme", None).await; |
| 1189 | assert!(anon.contains("acme/lib"), "org pins: anonymous sees pin"); | 1213 | assert!(anon.contains("acme/lib"), "org pins: anonymous sees pin"); |
| @@ -1251,8 +1275,8 @@ mod tests { | |||
| 1251 | "pins: owner customize link" | 1275 | "pins: owner customize link" |
| 1252 | ); | 1276 | ); |
| 1253 | assert!( | 1277 | assert!( |
| 1254 | - owner.contains("href=\"/settings/pins\""), | 1278 | + owner.contains("action=\"/settings/pins\""), |
| 1255 | - "pins: owner settings link" | 1279 | + "pins: owner edits them on the profile" |
| 1256 | ); | 1280 | ); |
| 1257 | 1281 | ||
| 1258 | // Fallback: with no visible pin, the overview shows popular repos instead. | 1282 | // Fallback: with no visible pin, the overview shows popular repos instead. |
crates/forge-web/src/pages/profile_pins.rsmodified+71 -173
| @@ -1,38 +1,48 @@ | |||
| 1 | -//! Pages: where a profile's owner picks the repos pinned on it, at most six. `/settings/pins` is for | 1 | +//! Picking the repos pinned on a profile, at most six. The menu sits on the profile itself and |
| 2 | -//! the signed-in user. `/org/{org}/settings/pins` is for an organization, and only its owners may | 2 | +//! posts to `/settings/pins` for the signed-in user, or to `/org/{org}/settings/pins` for an |
| 3 | -//! use it. Both show a form of checkboxes, one per repo the owner has, and redirect to the profile | 3 | +//! organization, whose owners alone may use it. Both redirect to the profile after a save. |
| 4 | -//! after a save. | ||
| 5 | 4 | ||
| 6 | use forge_core::store::profile_pins::MAX_PROFILE_PINS; | 5 | use forge_core::store::profile_pins::MAX_PROFILE_PINS; |
| 7 | -use forge_core::{Repo, Session, Store, User}; | 6 | +use forge_core::{Repo, Store, User}; |
| 8 | use topcoat::Result; | 7 | use topcoat::Result; |
| 9 | use topcoat::context::{Cx, app_context}; | 8 | use topcoat::context::{Cx, app_context}; |
| 10 | use topcoat::router::content::RawForm; | 9 | use topcoat::router::content::RawForm; |
| 11 | -use topcoat::router::error::see_other; | 10 | +use topcoat::router::error::{SeeOther, see_other}; |
| 12 | -use topcoat::router::response::Response; | 11 | +use topcoat::router::{path_param, route}; |
| 13 | -use topcoat::router::{page, path_param, route}; | ||
| 14 | use topcoat::view::{View, component, view}; | 12 | use topcoat::view::{View, component, view}; |
| 15 | 13 | ||
| 16 | use crate::auth::{require_csrf, require_user}; | 14 | use crate::auth::{require_csrf, require_user}; |
| 15 | +use crate::i18n::Lang; | ||
| 17 | use crate::i18n::orgs::{self as g, K}; | 16 | use crate::i18n::orgs::{self as g, K}; |
| 18 | -use crate::i18n::{self, Lang}; | ||
| 19 | -use crate::live::{Topic, stream_changes}; | ||
| 20 | use crate::pages::issue_meta::{form_all, form_field, form_pairs}; | 17 | use crate::pages::issue_meta::{form_all, form_field, form_pairs}; |
| 21 | use crate::pages::org_ctx::{load_org, require_form_csrf, require_owner}; | 18 | use crate::pages::org_ctx::{load_org, require_form_csrf, require_owner}; |
| 22 | use crate::state::AppState; | 19 | use crate::state::AppState; |
| 23 | -use crate::views::{empty_state, shell}; | ||
| 24 | 20 | ||
| 25 | path_param!(org); | 21 | path_param!(org); |
| 26 | 22 | ||
| 27 | /// A repo the owner may pin, and whether it is pinned now. | 23 | /// A repo the owner may pin, and whether it is pinned now. |
| 28 | -struct PinOption { | 24 | +pub(crate) struct PinOption { |
| 29 | repo: Repo, | 25 | repo: Repo, |
| 30 | checked: bool, | 26 | checked: bool, |
| 31 | } | 27 | } |
| 32 | 28 | ||
| 33 | -/// The repo ids pinned, in order. | 29 | +/// Each repo `owner_id` may pin, with the pinned ones ticked. |
| 34 | -fn ids(repos: Vec<Repo>) -> Vec<String> { | 30 | +pub(crate) async fn pin_options(store: &Store, owner_id: &str) -> Result<Vec<PinOption>> { |
| 35 | - repos.into_iter().map(|repo| repo.id).collect() | 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()) | ||
| 36 | } | 46 | } |
| 37 | 47 | ||
| 38 | /// The repo ids a form chose: blanks and repeats are dropped, the order is kept. | 48 | /// 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> { | |||
| 46 | out | 56 | out |
| 47 | } | 57 | } |
| 48 | 58 | ||
| 49 | -/// The pin form for `owner`, with the `chosen` repos ticked. `error` is shown above the form. | 59 | +/// The menu on the profile that picks the pins. It saves through the server, and the profile shows |
| 50 | -/// The values are owned so the returned view borrows nothing from the caller. | 60 | +/// the result after the redirect. |
| 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 | - | ||
| 82 | #[component] | 61 | #[component] |
| 83 | -async fn pins_body( | 62 | +pub(crate) async fn pins_menu( |
| 84 | lang: Lang, | 63 | lang: Lang, |
| 85 | action: String, | 64 | action: String, |
| 86 | - live: String, | ||
| 87 | csrf: String, | 65 | csrf: String, |
| 88 | options: Vec<PinOption>, | 66 | options: Vec<PinOption>, |
| 89 | - error: Option<String>, | ||
| 90 | ) -> Result<impl View> { | 67 | ) -> 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); | ||
| 95 | Ok(view! { | 68 | Ok(view! { |
| 96 | - <section class="profile-pins-edit" data-live=(live.as_str())> | 69 | + <details class="pop pins-menu"> |
| 97 | - <h1>(g::t(lang, K::CustomizePins))</h1> | 70 | + <summary class="button small">(g::t(lang, K::CustomizePins))</summary> |
| 98 | - <p class="muted">(intro)</p> | 71 | + <form method="post" action=(action.as_str()) class="pop-panel"> |
| 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())> | 72 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 73 | + <p class="muted small">(g::t(lang, K::PinsIntro))</p> | ||
| 105 | <ul class="pin-options"> | 74 | <ul class="pin-options"> |
| 106 | for option in options.into_iter() { | 75 | for option in options.into_iter() { |
| 107 | <li> | 76 | <li> |
| 108 | <label> | 77 | <label> |
| 109 | <input type="checkbox" name="repo" value=(option.repo.id.as_str()) checked=(option.checked)> | 78 | <input type="checkbox" name="repo" value=(option.repo.id.as_str()) checked=(option.checked)> |
| 110 | - (format!("{}/{}", option.repo.owner_name, option.repo.name)) | 79 | + <span>(option.repo.name.as_str())</span> |
| 111 | </label> | 80 | </label> |
| 112 | </li> | 81 | </li> |
| 113 | } | 82 | } |
| 114 | </ul> | 83 | </ul> |
| 115 | - <div> | 84 | + <button type="submit" class="primary">(g::t(lang, K::SavePins))</button> |
| 116 | - <button type="submit" class="primary">(save)</button> | ||
| 117 | - </div> | ||
| 118 | </form> | 85 | </form> |
| 119 | - } else { | 86 | + </details> |
| 120 | - empty_state(title: empty, | ||
| 121 | - <a class="button" href="/new">(g::t(lang, K::NewRepository))</a>) | ||
| 122 | - } | ||
| 123 | - </section> | ||
| 124 | }) | 87 | }) |
| 125 | } | 88 | } |
| 126 | 89 | ||
| 127 | -/// Stores the chosen pins for `owner` and redirects to `back`. More than the limit re-shows the | 90 | +/// Stores the chosen pins for `owner` and redirects to `back`. More than the limit changes nothing, |
| 128 | -/// form with the error and changes nothing. | 91 | +/// and the profile says why. |
| 129 | async fn save_pins( | 92 | async fn save_pins( |
| 130 | - cx: &Cx, | 93 | + state: &AppState, |
| 131 | - viewer: (User, Session), | ||
| 132 | owner: User, | 94 | owner: User, |
| 133 | - action: String, | ||
| 134 | chosen: Vec<String>, | 95 | chosen: Vec<String>, |
| 135 | back: String, | 96 | back: String, |
| 136 | -) -> Result<impl View> { | 97 | +) -> Result<SeeOther> { |
| 137 | if chosen.len() > MAX_PROFILE_PINS { | 98 | if chosen.len() > MAX_PROFILE_PINS { |
| 138 | - let lang = i18n::lang(cx, Some(&viewer.0)); | 99 | + return Err(see_other(format!("{back}?pins=too_many")).into()); |
| 139 | - let error = g::t(lang, K::PinsTooMany); | ||
| 140 | - return pins_form(cx, viewer, owner, action, chosen, Some(error)).await; | ||
| 141 | } | 100 | } |
| 142 | - let state = app_context::<AppState>(cx); | ||
| 143 | state.store.set_profile_pins(&owner.id, &chosen).await?; | 101 | state.store.set_profile_pins(&owner.id, &chosen).await?; |
| 144 | state.live.bump(&crate::live::Topic::User(owner.id.clone())); | 102 | state.live.bump(&crate::live::Topic::User(owner.id.clone())); |
| 145 | Err(see_other(back).into()) | 103 | Err(see_other(back).into()) |
| 146 | } | 104 | } |
| 147 | 105 | ||
| 148 | -/// What the pin form shows: the owner's pinned repos in order, then each repo the owner may pin. | 106 | +/// Pins are picked on the profile; an old link lands there. |
| 149 | -async fn pins_fingerprint(store: &Store, owner_id: &str) -> Result<String> { | 107 | +#[route(GET "/settings/pins")] |
| 150 | - let mut lines = Vec::new(); | 108 | +async fn pins_page(cx: &Cx) -> Result<SeeOther> { |
| 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?; | 109 | let viewer = require_user(cx).await?; |
| 167 | - let state = app_context::<AppState>(cx); | 110 | + Err(see_other(format!("/{}", viewer.0.username)).into()) |
| 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> { | ||
| 186 | - 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 | ||
| 191 | } | 111 | } |
| 192 | 112 | ||
| 193 | /// Saves the signed-in user's pins, then back to the profile. | 113 | /// Saves the signed-in user's pins, then back to the profile. |
| 194 | -#[page(POST "/settings/pins")] | 114 | +#[route(POST "/settings/pins")] |
| 195 | -async fn pins_save(cx: &Cx, RawForm(raw): RawForm) -> Result<impl View> { | 115 | +async fn pins_save(cx: &Cx, RawForm(raw): RawForm) -> Result<SeeOther> { |
| 196 | let pairs = form_pairs(&raw[..]); | 116 | let pairs = form_pairs(&raw[..]); |
| 197 | let viewer = require_csrf(cx, &form_field(&pairs, "csrf")).await?; | 117 | let viewer = require_csrf(cx, &form_field(&pairs, "csrf")).await?; |
| 198 | let chosen = selection(form_all(&pairs, "repo")); | 118 | let chosen = selection(form_all(&pairs, "repo")); |
| 199 | let back = format!("/{}", viewer.0.username); | 119 | let back = format!("/{}", viewer.0.username); |
| 200 | let owner = viewer.0.clone(); | 120 | let owner = viewer.0.clone(); |
| 201 | - save_pins(cx, viewer, owner, "/settings/pins".to_owned(), chosen, back).await | 121 | + save_pins(app_context::<AppState>(cx), owner, 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 | ||
| 223 | } | 122 | } |
| 224 | 123 | ||
| 225 | -/// Gets the pin form for an organization. Owners only. | 124 | +/// Pins are picked on the profile; an old link lands there. Owners only, as the form was. |
| 226 | -#[page("/org/{org}/settings/pins")] | 125 | +#[route(GET "/org/{org}/settings/pins")] |
| 227 | -async fn org_pins_page(cx: &Cx) -> Result<impl View> { | 126 | +async fn org_pins_page(cx: &Cx) -> Result<SeeOther> { |
| 228 | let ctx = load_org(cx, path_param::<Org>(cx)).await?; | 127 | let ctx = load_org(cx, path_param::<Org>(cx)).await?; |
| 229 | require_owner(&ctx)?; | 128 | require_owner(&ctx)?; |
| 230 | - let store = &app_context::<AppState>(cx).store; | 129 | + Err(see_other(format!("/{}", ctx.org.username)).into()) |
| 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 | ||
| 234 | } | 130 | } |
| 235 | 131 | ||
| 236 | /// Saves an organization's pins, then back to the org profile. Owners only. | 132 | /// Saves an organization's pins, then back to the org profile. Owners only. |
| 237 | -#[page(POST "/org/{org}/settings/pins")] | 133 | +#[route(POST "/org/{org}/settings/pins")] |
| 238 | -async fn org_pins_save(cx: &Cx, RawForm(raw): RawForm) -> Result<impl View> { | 134 | +async fn org_pins_save(cx: &Cx, RawForm(raw): RawForm) -> Result<SeeOther> { |
| 239 | let ctx = load_org(cx, path_param::<Org>(cx)).await?; | 135 | let ctx = load_org(cx, path_param::<Org>(cx)).await?; |
| 240 | let pairs = form_pairs(&raw[..]); | 136 | let pairs = form_pairs(&raw[..]); |
| 241 | require_form_csrf(&ctx, &form_field(&pairs, "csrf"))?; | 137 | require_form_csrf(&ctx, &form_field(&pairs, "csrf"))?; |
| 242 | require_owner(&ctx)?; | 138 | require_owner(&ctx)?; |
| 243 | let chosen = selection(form_all(&pairs, "repo")); | 139 | let chosen = selection(form_all(&pairs, "repo")); |
| 244 | - let action = ctx.href("/settings/pins"); | ||
| 245 | let back = format!("/{}", ctx.org.username); | 140 | 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 |
| 247 | } | 142 | } |
| 248 | 143 | ||
| 249 | #[cfg(test)] | 144 | #[cfg(test)] |
| @@ -379,7 +274,7 @@ mod tests { | |||
| 379 | .collect() | 274 | .collect() |
| 380 | } | 275 | } |
| 381 | 276 | ||
| 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 |
| 383 | /// (too many pins, a wrong CSRF token, a foreign repo, another user) must leave the saved | 278 | /// (too many pins, a wrong CSRF token, a foreign repo, another user) must leave the saved |
| 384 | /// pins alone. The scenarios run in order on one seed, and each reads the state before it. | 279 | /// pins alone. The scenarios run in order on one seed, and each reads the state before it. |
| 385 | #[tokio::test] | 280 | #[tokio::test] |
| @@ -417,16 +312,18 @@ mod tests { | |||
| 417 | "save: stored pins" | 312 | "save: stored pins" |
| 418 | ); | 313 | ); |
| 419 | 314 | ||
| 420 | - // The form ticks the pinned repos. | 315 | + // The profile's menu ticks the pinned repos, and the old page leads there. |
| 421 | - let form = send(&s.site, "GET", "/settings/pins", Some(&cookie), &[]).await; | 316 | + let profile = send(&s.site, "GET", "/tahinli", Some(&cookie), &[]).await; |
| 422 | - assert_eq!(form.status, 200, "form: status"); | 317 | + assert!(profile.body.contains("pins-menu"), "menu on the profile"); |
| 423 | - assert!( | 318 | + assert!(profile.body.contains("checked"), "pinned repos are ticked"); |
| 424 | - form.body.contains("checked"), | 319 | + let old = send(&s.site, "GET", "/settings/pins", Some(&cookie), &[]).await; |
| 425 | - "form: pinned repos are ticked" | 320 | + assert_eq!( |
| 321 | + old.location.as_deref(), | ||
| 322 | + Some("/tahinli"), | ||
| 323 | + "old page redirects" | ||
| 426 | ); | 324 | ); |
| 427 | - assert!(form.body.contains("tahinli/open-repo"), "form: lists repos"); | ||
| 428 | 325 | ||
| 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. |
| 430 | let repos = s.site.store.list_repos_by_owner(&s.tahinli).await.unwrap(); | 327 | let repos = s.site.store.list_repos_by_owner(&s.tahinli).await.unwrap(); |
| 431 | assert!(repos.len() >= 7, "seed has enough repos"); | 328 | assert!(repos.len() >= 7, "seed has enough repos"); |
| 432 | let ids: Vec<String> = repos.iter().map(|r| r.id.clone()).collect(); | 329 | let ids: Vec<String> = repos.iter().map(|r| r.id.clone()).collect(); |
| @@ -434,13 +331,14 @@ mod tests { | |||
| 434 | fields.extend(ids.iter().map(|id| ("repo", id.as_str()))); | 331 | fields.extend(ids.iter().map(|id| ("repo", id.as_str()))); |
| 435 | let six = send(&s.site, "POST", "/settings/pins", Some(&cookie), &fields).await; | 332 | let six = send(&s.site, "POST", "/settings/pins", Some(&cookie), &fields).await; |
| 436 | assert_eq!( | 333 | assert_eq!( |
| 437 | - six.status, 200, | 334 | + six.location.as_deref(), |
| 438 | - "six limit: form shown again, not redirected" | 335 | + Some("/tahinli?pins=too_many"), |
| 336 | + "six limit: the profile says why" | ||
| 439 | ); | 337 | ); |
| 338 | + let told = send(&s.site, "GET", "/tahinli?pins=too_many", Some(&cookie), &[]).await; | ||
| 440 | assert!( | 339 | assert!( |
| 441 | - six.body.contains("at most six"), | 340 | + told.body.contains("at most six"), |
| 442 | - "six limit: friendly error: {}", | 341 | + "six limit: friendly error" |
| 443 | - six.body | ||
| 444 | ); | 342 | ); |
| 445 | assert_eq!( | 343 | assert_eq!( |
| 446 | pinned_names(&s.site.store, &s.tahinli).await, | 344 | pinned_names(&s.site.store, &s.tahinli).await, |
crates/forge-web/src/views/mod.rsmodified+6 -22
| @@ -916,23 +916,15 @@ pub fn admin_items(lang: Lang) -> Vec<NavItem> { | |||
| 916 | ] | 916 | ] |
| 917 | } | 917 | } |
| 918 | 918 | ||
| 919 | -/// The organization's settings sidebar: General and Customize pins. Its profile, repositories, | 919 | +/// The organization's settings sidebar. Its profile, repositories, |
| 920 | /// members and teams are reached from the profile tab bar, so they are not listed here. | 920 | /// members and teams are reached from the profile tab bar, so they are not listed here. |
| 921 | fn org_items(lang: Lang, org: &str) -> Vec<NavItem> { | 921 | fn org_items(lang: Lang, org: &str) -> Vec<NavItem> { |
| 922 | - vec![ | 922 | + vec![NavItem { |
| 923 | - NavItem { | ||
| 924 | key: "settings", | 923 | key: "settings", |
| 925 | href: format!("/org/{org}/settings"), | 924 | href: format!("/org/{org}/settings"), |
| 926 | label: o::t(lang, OK::General), | 925 | label: o::t(lang, OK::General), |
| 927 | icon: "appearance", | 926 | icon: "appearance", |
| 928 | - }, | 927 | + }] |
| 929 | - NavItem { | ||
| 930 | - key: "pins", | ||
| 931 | - href: format!("/org/{org}/settings/pins"), | ||
| 932 | - label: o::t(lang, OK::CustomizePins), | ||
| 933 | - icon: "pins", | ||
| 934 | - }, | ||
| 935 | - ] | ||
| 936 | } | 928 | } |
| 937 | 929 | ||
| 938 | /// The profile tab bar in its order, for a person's or an organization's profile: overview, | 930 | /// 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> { | |||
| 1064 | mi::t(lang, MK::Appearance), | 1056 | mi::t(lang, MK::Appearance), |
| 1065 | "appearance", | 1057 | "appearance", |
| 1066 | ), | 1058 | ), |
| 1067 | - item( | ||
| 1068 | - "pins", | ||
| 1069 | - "/settings/pins", | ||
| 1070 | - o::t(lang, OK::CustomizePins), | ||
| 1071 | - "pins", | ||
| 1072 | - ), | ||
| 1073 | item( | 1059 | item( |
| 1074 | "export", | 1060 | "export", |
| 1075 | "/settings/export", | 1061 | "/settings/export", |
| @@ -1089,7 +1075,7 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { | |||
| 1089 | let (title, items) = match first { | 1075 | let (title, items) = match first { |
| 1090 | "admin" => (ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), | 1076 | "admin" => (ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), |
| 1091 | "settings" => (o::t(lang, OK::Settings).to_owned(), settings_items(lang)), | 1077 | "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 |
| 1093 | // sidebar. Its profile, members and teams pages have none: the tab bar leads to them. `/org/new` | 1079 | // sidebar. Its profile, members and teams pages have none: the tab bar leads to them. `/org/new` |
| 1094 | // is the create form and keeps the global links. | 1080 | // is the create form and keeps the global links. |
| 1095 | "org" if !second.is_empty() && second != "new" => { | 1081 | "org" if !second.is_empty() && second != "new" => { |
| @@ -1790,7 +1776,6 @@ pub async fn ref_selector( | |||
| 1790 | <input type="text" class="ref-filter" data-ref-filter="" autocomplete="off" spellcheck="false" | 1776 | <input type="text" class="ref-filter" data-ref-filter="" autocomplete="off" spellcheck="false" |
| 1791 | placeholder=(g::t(lang, K::FilterRefs)) aria-label=(g::t(lang, K::FilterRefs)) | 1777 | placeholder=(g::t(lang, K::FilterRefs)) aria-label=(g::t(lang, K::FilterRefs)) |
| 1792 | role="combobox" aria-expanded="true" aria-autocomplete="list" aria-controls="ref-results"> | 1778 | role="combobox" aria-expanded="true" aria-autocomplete="list" aria-controls="ref-results"> |
| 1793 | - <kbd>"esc"</kbd> | ||
| 1794 | </label> | 1779 | </label> |
| 1795 | <div class="ref-results" id="ref-results" role="listbox"> | 1780 | <div class="ref-results" id="ref-results" role="listbox"> |
| 1796 | ref_group(lang: lang, kind: "branches", heading: g::t(lang, K::BranchesTitle), links: branches, now: now) | 1781 | 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( | |||
| 1800 | </p> | 1785 | </p> |
| 1801 | </div> | 1786 | </div> |
| 1802 | <div class="ref-foot"> | 1787 | <div class="ref-foot"> |
| 1803 | - <span class="ref-keys" aria-hidden="true"><kbd>"↑"</kbd><kbd>"↓"</kbd><kbd>"↵"</kbd></span> | 1788 | + <a href=(branches_href) title=(g::t(lang, K::ViewAllBranches))>(g::t(lang, K::ViewAllBranches))</a> |
| 1804 | - <a href=(branches_href) title=(g::t(lang, K::ViewAllBranches))>(g::t(lang, K::BranchesTitle))" ↗"</a> | 1789 | + <a href=(tags_href) title=(g::t(lang, K::ViewAllTags))>(g::t(lang, K::ViewAllTags))</a> |
| 1805 | - <a href=(tags_href) title=(g::t(lang, K::ViewAllTags))>(g::t(lang, K::TagsTitle))" ↗"</a> | ||
| 1806 | </div> | 1790 | </div> |
| 1807 | </div> | 1791 | </div> |
| 1808 | </details> | 1792 | </details> |
style/_canvas_repo.scssmodified+7 -3
| @@ -518,12 +518,16 @@ | |||
| 518 | opacity: 1; | 518 | opacity: 1; |
| 519 | } | 519 | } |
| 520 | 520 | ||
| 521 | - // The newest commit is the accent, at full strength, whether or not its run goes. | 521 | + // Accent means a run is going. The newest commit is only brighter: a bar says nothing of a result |
| 522 | - > a.hs-live, | 522 | + // unless a run failed, and a repo with no CI has none. |
| 523 | - > a:last-child:not(.hs-bad) { | 523 | + > a.hs-live { |
| 524 | background: var(--accent); | 524 | background: var(--accent); |
| 525 | opacity: 1; | 525 | opacity: 1; |
| 526 | } | 526 | } |
| 527 | + | ||
| 528 | + > a:last-child:not(.hs-bad, .hs-live) { | ||
| 529 | + opacity: 1; | ||
| 530 | + } | ||
| 527 | } | 531 | } |
| 528 | 532 | ||
| 529 | // Narrow windows: the panes stack and the page grows; the strip, which needs the width, is left out. | 533 | // 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 @@ | |||
| 100 | @media (min-width: 1200px) { | 100 | @media (min-width: 1200px) { |
| 101 | .import-home > .newrepo-form { | 101 | .import-home > .newrepo-form { |
| 102 | display: grid; | 102 | display: grid; |
| 103 | - grid-template-columns: repeat(2, minmax(0, 1fr)); | 103 | + grid-template-columns: repeat(2, minmax(0, 720px)); |
| 104 | + justify-content: start; | ||
| 104 | align-items: start; | 105 | align-items: start; |
| 105 | 106 | ||
| 106 | > :not(.newrepo-card) { | 107 | > :not(.newrepo-card) { |
style/_lang_admin.scssmodified+10 -3
| @@ -1,6 +1,6 @@ | |||
| 1 | // Settings and admin pages: the pages behind the site section sidebar (`.shell-site`, see views/mod.rs). | 1 | // 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 | 2 | +// Main takes the window's full width. From 900px its one pane fills it, or a second pane sits beside |
| 3 | -// across the window, and anything that is not a pane (the head, a notice) spans the row. Forms stop at | 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 |
| 4 | // 720px and stay left aligned. Repo, org and other pages are not affected. | 4 | // 720px and stay left aligned. Repo, org and other pages are not affected. |
| 5 | 5 | ||
| 6 | // The page's column: main itself, or the `data-live` wrapper that most admin pages put inside it. | 6 | // 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 | |||
| 14 | @media (min-width: 900px) { | 14 | @media (min-width: 900px) { |
| 15 | #{$page-column} { | 15 | #{$page-column} { |
| 16 | display: grid; | 16 | 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; | ||
| 18 | align-items: start; | 19 | align-items: start; |
| 19 | gap: 16px; | 20 | gap: 16px; |
| 20 | 21 | ||
| @@ -22,6 +23,12 @@ $page-column: ".shell-site > .shell-body > main, .shell-site > .shell-body > mai | |||
| 22 | grid-column: 1 / -1; | 23 | grid-column: 1 / -1; |
| 23 | } | 24 | } |
| 24 | } | 25 | } |
| 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 | + } | ||
| 25 | } | 32 | } |
| 26 | 33 | ||
| 27 | // Settings pages wrap their sections in one `.settings-layout`; it fills main and takes no max width. | 34 | // 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 { | |||
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | +.palette-why { | ||
| 124 | + float: right; | ||
| 125 | + margin-left: 12px; | ||
| 126 | + color: var(--muted); | ||
| 127 | + font-size: 0.75rem; | ||
| 128 | +} | ||
| 129 | + | ||
| 123 | .palette-note { | 130 | .palette-note { |
| 124 | flex: none; | 131 | flex: none; |
| 125 | margin: 0; | 132 | margin: 0; |
style/_system.scssmodified+202 -14
| @@ -130,7 +130,7 @@ input[type="checkbox"] { | |||
| 130 | background: var(--accent); | 130 | background: var(--accent); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | - &:checked::before { | 133 | + &:checked:not(.switch-row *)::before { |
| 134 | content: ""; | 134 | content: ""; |
| 135 | position: absolute; | 135 | position: absolute; |
| 136 | inset: 0; | 136 | inset: 0; |
| @@ -341,7 +341,6 @@ main .side-picker > legend { | |||
| 341 | &.active, | 341 | &.active, |
| 342 | &[aria-current="page"] { | 342 | &[aria-current="page"] { |
| 343 | color: var(--text); | 343 | color: var(--text); |
| 344 | - font-weight: 600; | ||
| 345 | } | 344 | } |
| 346 | } | 345 | } |
| 347 | 346 | ||
| @@ -466,12 +465,10 @@ main .side-picker > legend { | |||
| 466 | } | 465 | } |
| 467 | } | 466 | } |
| 468 | 467 | ||
| 469 | -// Settings and admin pages lay panes side by side, and the head spans that grid, which keeps two | 468 | +// A filter stays above the list it filters. |
| 470 | -// tracks open. A page with one pane takes both, and so does a filter with the list it filters. | ||
| 471 | @media (min-width: 900px) { | 469 | @media (min-width: 900px) { |
| 472 | .shell-site > .shell-body > main, | 470 | .shell-site > .shell-body > main, |
| 473 | .shell-site > .shell-body > main > [data-live] { | 471 | .shell-site > .shell-body > main > [data-live] { |
| 474 | - > .card:not(.card ~ .card):not(:has(~ .card)), | ||
| 475 | > .card:has(> .filter-bar), | 472 | > .card:has(> .filter-bar), |
| 476 | > .card:has(> .filter-bar) ~ .card { | 473 | > .card:has(> .filter-bar) ~ .card { |
| 477 | grid-column: 1 / -1; | 474 | grid-column: 1 / -1; |
| @@ -529,13 +526,6 @@ main .side-picker > legend { | |||
| 529 | align-self: start; | 526 | align-self: start; |
| 530 | } | 527 | } |
| 531 | 528 | ||
| 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 | - | ||
| 539 | // A folder with no README: the list is what the page is for, so it takes the width and its last | 529 | // A folder with no README: the list is what the page is for, so it takes the width and its last |
| 540 | // commit column comes back. | 530 | // commit column comes back. |
| 541 | @media (min-width: 900px) { | 531 | @media (min-width: 900px) { |
| @@ -567,7 +557,8 @@ main .side-picker > legend { | |||
| 567 | // Disclosure rows use the same chevron as every other menu, not the browser's triangle. | 557 | // Disclosure rows use the same chevron as every other menu, not the browser's triangle. |
| 568 | .checks-details > summary, | 558 | .checks-details > summary, |
| 569 | .commit-full-message > summary, | 559 | .commit-full-message > summary, |
| 570 | -.ci-tl-more > summary { | 560 | +.ci-tl-more > summary, |
| 561 | +.mx-table > summary { | ||
| 571 | display: inline-flex; | 562 | display: inline-flex; |
| 572 | align-items: center; | 563 | align-items: center; |
| 573 | gap: 4px; | 564 | gap: 4px; |
| @@ -590,7 +581,8 @@ main .side-picker > legend { | |||
| 590 | 581 | ||
| 591 | .checks-details[open] > summary::before, | 582 | .checks-details[open] > summary::before, |
| 592 | .commit-full-message[open] > summary::before, | 583 | .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 { | ||
| 594 | transform: rotate(180deg); | 586 | transform: rotate(180deg); |
| 595 | } | 587 | } |
| 596 | 588 | ||
| @@ -651,3 +643,199 @@ main .side-picker > legend { | |||
| 651 | white-space: normal; | 643 | white-space: normal; |
| 652 | } | 644 | } |
| 653 | } | 645 | } |
| 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 { | |||
| 1260 | // A <label>, so undo the global column layout: icon, field and esc hint sit on one row. | 1260 | // A <label>, so undo the global column layout: icon, field and esc hint sit on one row. |
| 1261 | flex-direction: row; | 1261 | flex-direction: row; |
| 1262 | align-items: center; | 1262 | align-items: center; |
| 1263 | - gap: 10px; | 1263 | + gap: 8px; |
| 1264 | padding: 0 12px; | 1264 | padding: 0 12px; |
| 1265 | color: var(--muted); | 1265 | color: var(--muted); |
| 1266 | border-bottom: 1px solid var(--border); | 1266 | border-bottom: 1px solid var(--border); |
| 1267 | - | ||
| 1268 | - &:focus-within { | ||
| 1269 | - color: var(--accent); | ||
| 1270 | - } | ||
| 1271 | } | 1267 | } |
| 1272 | 1268 | ||
| 1273 | .ref-filter { | 1269 | .ref-filter { |
| 1274 | flex: 1 1 auto; | 1270 | flex: 1 1 auto; |
| 1275 | min-width: 0; | 1271 | min-width: 0; |
| 1276 | - height: 46px; | 1272 | + height: 36px; |
| 1277 | padding: 0; | 1273 | padding: 0; |
| 1278 | font: inherit; | 1274 | font: inherit; |
| 1279 | - font-size: 15px; | 1275 | + font-size: 14px; |
| 1280 | color: var(--text); | 1276 | color: var(--text); |
| 1281 | background: transparent; | 1277 | background: transparent; |
| 1282 | border: 0; | 1278 | border: 0; |
| @@ -1331,7 +1327,7 @@ code { | |||
| 1331 | } | 1327 | } |
| 1332 | 1328 | ||
| 1333 | // Rows: kind icon, the name in mono, an optional default chip, and the tip's age pushed right. | 1329 | // 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. |
| 1335 | .ref-list { | 1331 | .ref-list { |
| 1336 | list-style: none; | 1332 | list-style: none; |
| 1337 | margin: 0; | 1333 | margin: 0; |
| @@ -1353,19 +1349,7 @@ code { | |||
| 1353 | } | 1349 | } |
| 1354 | 1350 | ||
| 1355 | li[aria-current="true"] a { | 1351 | li[aria-current="true"] a { |
| 1356 | - color: var(--accent); | 1352 | + background: var(--surface-2); |
| 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 | - } | ||
| 1369 | 1353 | ||
| 1370 | .ref-text { | 1354 | .ref-text { |
| 1371 | font-weight: 600; | 1355 | font-weight: 600; |
| @@ -1425,9 +1409,8 @@ code { | |||
| 1425 | display: flex; | 1409 | display: flex; |
| 1426 | align-items: center; | 1410 | align-items: center; |
| 1427 | gap: 14px; | 1411 | gap: 14px; |
| 1428 | - padding: 8px 12px; | 1412 | + padding: 8px 14px; |
| 1429 | - font-size: 12px; | 1413 | + font-size: 13px; |
| 1430 | - background: var(--surface-2); | ||
| 1431 | border-top: 1px solid var(--border); | 1414 | border-top: 1px solid var(--border); |
| 1432 | 1415 | ||
| 1433 | a { | 1416 | a { |
| @@ -1440,12 +1423,6 @@ code { | |||
| 1440 | } | 1423 | } |
| 1441 | } | 1424 | } |
| 1442 | 1425 | ||
| 1443 | -.ref-keys { | ||
| 1444 | - display: inline-flex; | ||
| 1445 | - gap: 4px; | ||
| 1446 | - margin-right: auto; | ||
| 1447 | -} | ||
| 1448 | - | ||
| 1449 | .crumbs { | 1426 | .crumbs { |
| 1450 | min-width: 0; | 1427 | min-width: 0; |
| 1451 | font-size: 0.9375rem; | 1428 | font-size: 0.9375rem; |
| @@ -2182,7 +2159,7 @@ code { | |||
| 2182 | } | 2159 | } |
| 2183 | 2160 | ||
| 2184 | .ref-filter { | 2161 | .ref-filter { |
| 2185 | - height: 52px; | 2162 | + height: 44px; |
| 2186 | font-size: 16px; | 2163 | font-size: 16px; |
| 2187 | } | 2164 | } |
| 2188 | 2165 | ||
| @@ -2190,13 +2167,7 @@ code { | |||
| 2190 | padding: 12px 10px 12px 12px; | 2167 | padding: 12px 10px 12px 12px; |
| 2191 | } | 2168 | } |
| 2192 | 2169 | ||
| 2193 | - // No keyboard on a phone: the footer keeps only the links. | ||
| 2194 | - .ref-keys { | ||
| 2195 | - display: none; | ||
| 2196 | - } | ||
| 2197 | - | ||
| 2198 | .ref-foot { | 2170 | .ref-foot { |
| 2199 | - justify-content: flex-end; | ||
| 2200 | padding: 12px 16px; | 2171 | padding: 12px 16px; |
| 2201 | } | 2172 | } |
| 2202 | } | 2173 | } |