feat(web): open a repository from anywhere on its row

The cards on the repository page already opened as a whole, but the tables
on the organisation and overview pages still only linked the name, so the
same object behaved differently depending on where it was listed.

A table row can now carry a destination. Controls inside it keep their own
behaviour, the row is reachable with the keyboard, and only the empty space
navigates.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
nocodeandClaude Opus 5 committed 2026-09-23 23:20:07 +02:00
1 parent 539b1506f4
commit 95b51ab428
4 files changed
+38 -8

No files matched your search

+24 -6
View File
@@ -80,7 +80,7 @@ export function toggle(checked, onChange, label) {
* Renders a table. Each column is `{ key, label, render?, className? }`; * Renders a table. Each column is `{ key, label, render?, className? }`;
* `render` returns a Node or a string. * `render` returns a Node or a string.
*/ */
export function table(columns, rows, { empty = 'Rien à afficher pour le moment.' } = {}) { export function table(columns, rows, { empty = 'Rien à afficher pour le moment.', rowHref = null } = {}) {
if (!rows || rows.length === 0) { if (!rows || rows.length === 0) {
// An empty state is where people look for the action that fills it, so it // An empty state is where people look for the action that fills it, so it
// accepts a node and not only a sentence. // accepts a node and not only a sentence.
@@ -107,10 +107,11 @@ export function table(columns, rows, { empty = 'Rien à afficher pour le moment.
h( h(
'tbody', 'tbody',
{}, {},
rows.map((row) => rows.map((row) => {
h( const target = rowHref?.(row) ?? null;
const line = h(
'tr', 'tr',
{}, target ? { class: 'row-link', tabindex: '0', role: 'link' } : {},
columns.map((column) => { columns.map((column) => {
const cell = h('td', { class: column.className ?? '' }); const cell = h('td', { class: column.className ?? '' });
const value = column.render ? column.render(row) : row[column.key]; const value = column.render ? column.render(row) : row[column.key];
@@ -118,8 +119,25 @@ export function table(columns, rows, { empty = 'Rien à afficher pour le moment.
else cell.textContent = value === null || value === undefined ? '—' : String(value); else cell.textContent = value === null || value === undefined ? '—' : String(value);
return cell; return cell;
}), }),
), );
),
if (target) {
// A control inside the row keeps its own behaviour; only the empty
// space navigates.
const open = (event) => {
if (event.target.closest('a, button, input, select, textarea, label')) return;
window.location.hash = target.replace(/^#/, '');
};
line.addEventListener('click', open);
line.addEventListener('keydown', (event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
open(event);
}
});
}
return line;
}),
), ),
), ),
); );
+8
View File
@@ -535,6 +535,14 @@ pre code {
.table tbody tr:hover { .table tbody tr:hover {
background: color-mix(in srgb, var(--blue) 6%, transparent); background: color-mix(in srgb, var(--blue) 6%, transparent);
} }
.table tbody tr.row-link {
cursor: pointer;
}
.table tbody tr.row-link:focus-visible {
outline: 2px solid var(--blue);
outline-offset: -2px;
}
.num { .num {
text-align: right; text-align: right;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
+5 -2
View File
@@ -164,7 +164,7 @@ export function render(host, { state }) {
card( card(
'Dépôts', 'Dépôts',
{ subtitle: 'Clique sur un dépôt pour le gérer en détail.' }, { subtitle: 'Clique sur une ligne pour gérer le dépôt en détail.' },
table( table(
[ [
{ {
@@ -207,7 +207,10 @@ export function render(host, { state }) {
}, },
], ],
data.repositories, data.repositories,
{ empty: 'Aucun dépôt dans cette organisation.' }, {
empty: 'Aucun dépôt dans cette organisation.',
rowHref: (repository) => `#/repos/${repository.fullName}`,
},
), ),
), ),
+1
View File
@@ -96,6 +96,7 @@ function giteaCard(gitea) {
}, },
], ],
gitea.repositories, gitea.repositories,
{ rowHref: (repository) => `#/repos/${repository.fullName}` },
), ),
); );
} }