Split the model admin into a list and a page per model

/admin/models rendered a full edit form for every model. With eight that
was merely long; with a hundred it was unusable, which is the report.

The list is now compact rows only -- avatar, name, badges, position,
reorder buttons, Edit link -- with search across id and display name,
filter tabs (All / Enabled / Disabled / Pinned / Restricted, each with a
count), a connection filter, and pagination at 40. Filters are links, so
a filtered view is a real URL you can keep. Editing moved to
/admin/models/{id}/edit, one model per page, with Previous/Next links so
a freshly imported connection can be tidied without returning to the
list each time.

Measured with 128 models: the list is 73 KB showing 40 rows over 4
pages, and a detail page is 17 KB. The old page would have rendered all
128 forms into one response.

Reordering needed rethinking at that size too. Up/down is fine for
nudging a model one place but hopeless for moving it sixty, so the
detail page has a position field you type into; the value is clamped and
a non-numeric one is ignored rather than throwing. The move buttons take
a `back` field so they return to whatever filtered, paginated view they
were pressed on instead of dumping you at page 1.

Also adds a select-all checkbox for the bulk bar, scoped to a container
selector rather than the page so a future list can carry more than one.

212 tests, ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaroslav Beneš
2026-07-21 13:43:00 +02:00
parent 29db54960e
commit 75edae039b
7 changed files with 702 additions and 162 deletions
+101 -11
View File
@@ -162,23 +162,70 @@
.status-dot.is-bad { background: var(--danger); }
.status-dot.is-off { background: var(--ink-faint); }
/* --- Model list ------------------------------------------------------------ */
/* --- Filter bar ------------------------------------------------------------ */
.filter-bar {
display: flex;
flex-direction: column;
gap: var(--sp-3);
margin-bottom: var(--sp-4);
}
.filter-tabs {
display: flex;
gap: var(--sp-1);
flex-wrap: wrap;
border-bottom: 1px solid var(--border);
}
.filter-tab {
display: inline-flex;
align-items: center;
gap: var(--sp-2);
height: var(--control-h);
padding: 0 var(--sp-3);
border-bottom: 2px solid transparent;
color: var(--ink-muted);
font-size: var(--text-sm);
font-weight: 500;
text-decoration: none;
white-space: nowrap;
}
.filter-tab:hover { color: var(--ink); }
.filter-tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.filter-tab__count {
font-size: var(--text-xs);
color: var(--ink-faint);
background: var(--surface-active);
border-radius: var(--radius-full);
padding: 0 0.4rem;
min-width: 1.4rem;
text-align: center;
}
.filter-tab.is-active .filter-tab__count { background: var(--accent-soft); color: var(--accent); }
.filter-form { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.filter-form .input { width: auto; flex: 1; min-width: 12rem; }
.filter-form .select { width: auto; min-width: 10rem; }
/* --- Model list ------------------------------------------------------------
Compact rows only. Editing is a page of its own -- a connection can advertise
a hundred models, and a list that renders a form for each is unusable.
*/
.bulk-bar {
display: flex;
align-items: center;
gap: var(--sp-2);
flex-wrap: wrap;
padding: var(--sp-3);
padding: var(--sp-2) var(--sp-3);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
background: var(--surface);
margin-bottom: var(--sp-4);
border-radius: var(--radius-lg) var(--radius-lg) 0 0;
border-bottom: 0;
background: var(--bg-sunken);
}
.bulk-bar__label { font-size: var(--text-sm); color: var(--ink-muted); margin-right: var(--sp-1); }
.bulk-bar__label { font-size: var(--text-sm); color: var(--ink-muted); }
.model-rows {
border: 1px solid var(--border);
border-radius: var(--radius-lg);
border-radius: 0 0 var(--radius-lg) var(--radius-lg);
overflow: hidden;
background: var(--surface);
}
@@ -186,21 +233,36 @@
display: flex;
align-items: center;
gap: var(--sp-3);
padding: var(--sp-3);
padding: var(--sp-2) var(--sp-3);
border-bottom: 1px solid var(--border);
}
.model-row:last-child { border-bottom: 0; }
.model-row.is-off { opacity: 0.5; }
.model-row:hover { background: var(--surface-hover); }
.model-row.is-off { opacity: 0.55; }
.model-row__check { accent-color: var(--accent); width: 1rem; height: 1rem; flex: none; }
.model-row__avatar { flex: none; width: 2rem; height: 2rem; }
.model-row__pos {
font-family: var(--font-mono);
font-size: var(--text-xs);
color: var(--ink-faint);
min-width: 1.75rem;
text-align: right;
flex: none;
}
.model-row__avatar { flex: none; width: 1.75rem; height: 1.75rem; }
.model-row__main { flex: 1; min-width: 0; }
.model-row__title {
display: flex;
align-items: center;
gap: var(--sp-2);
flex-wrap: wrap;
margin-bottom: 0.1rem;
}
.model-row__name {
color: var(--ink);
font-weight: 500;
font-size: var(--text-sm);
text-decoration: none;
}
.model-row__name:hover { color: var(--accent); text-decoration: underline; }
.model-row__id {
font-family: var(--font-mono);
font-size: var(--text-xs);
@@ -212,6 +274,34 @@
}
.model-row__actions { display: flex; align-items: center; gap: var(--sp-1); flex: none; }
.list-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--sp-3);
margin-top: var(--sp-3);
flex-wrap: wrap;
}
/* --- Model detail ---------------------------------------------------------- */
.crumbs {
display: flex;
align-items: center;
gap: var(--sp-2);
margin-bottom: var(--sp-4);
font-size: var(--text-sm);
}
.crumbs > a:first-child {
display: inline-flex;
align-items: center;
gap: var(--sp-1);
color: var(--ink-muted);
text-decoration: none;
}
.crumbs > a:first-child:hover { color: var(--ink); }
.crumbs__back { transform: rotate(180deg); }
.model-detail__avatar { width: 3rem; height: 3rem; flex: none; }
.model-list { list-style: none; margin: 0; padding: 0; }
.model-list__item {
display: flex;