@stacksjs/defaults 0.75.556 → 0.75.557
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/skills/stacks-dashboard/SKILL.md +27 -2
- package/ai/skills/stacks-native/CATALOG.md +2 -2
- package/functions/dashboard-loading.ts +36 -0
- package/functions/dashboard-model-record.ts +11 -0
- package/ide/vscode/package.json +1 -1
- package/package.json +5 -5
- package/resources/components/Dashboard/Data/DataModelRecords.stx +6 -3
- package/resources/components/Dashboard/Models/ModelRecordCreate.stx +9 -6
- package/resources/components/Dashboard/Models/ModelRecordDetail.stx +17 -10
- package/resources/components/Dashboard/Models/ModelRecordEdit.stx +9 -6
- package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +38 -25
- package/resources/components/Dashboard/Models/ModelsOverview.stx +30 -11
- package/resources/components/Dashboard/UI/QuietLoader.stx +24 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: stacks-dashboard
|
|
3
|
-
description: Use when building or customizing the Stacks admin dashboard, including dashboard pages, model management views, analytics widgets, commerce dashboards, content management, settings panels, deployment monitoring, job/queue management, or the
|
|
3
|
+
description: Use when building or customizing the Stacks admin dashboard, including dashboard pages, model management views, analytics widgets, commerce dashboards, content management, settings panels, deployment monitoring, job/queue management, or the 427 built-in dashboard components. Covers the dashboard system at storage/framework/defaults/.
|
|
4
4
|
license: MIT
|
|
5
5
|
compatibility: Bun >= 1.3.0, TypeScript
|
|
6
6
|
allowed-tools: Read Edit Write Bash Grep Glob
|
|
@@ -8,7 +8,7 @@ allowed-tools: Read Edit Write Bash Grep Glob
|
|
|
8
8
|
|
|
9
9
|
# Stacks Dashboard
|
|
10
10
|
|
|
11
|
-
The Stacks admin dashboard provides a full-featured admin panel with 100+ route views,
|
|
11
|
+
The Stacks admin dashboard provides a full-featured admin panel with 100+ route views, 427 components, and a multi-section layout.
|
|
12
12
|
|
|
13
13
|
## Key Paths
|
|
14
14
|
- Dashboard components: `storage/framework/defaults/resources/components/Dashboard/`
|
|
@@ -1192,6 +1192,31 @@ says so: active, paid, published are positive; inactive, failed, cancelled
|
|
|
1192
1192
|
negative; pending, draft, queued pending; anything else (a role, a plan)
|
|
1193
1193
|
neutral. A field's own `format` still comes first (`modelCellDisplay`).
|
|
1194
1194
|
|
|
1195
|
+
### How a model page loads
|
|
1196
|
+
|
|
1197
|
+
No model page draws a skeleton (the list, a record's page, its edit and create
|
|
1198
|
+
forms, and the models overview). Three rules, the same on each:
|
|
1199
|
+
|
|
1200
|
+
- **It does not say it is loading at once.** `dashboardLoaderTimer(slow)` in
|
|
1201
|
+
`functions/dashboard-loading.ts` sets `slow` only after 250ms
|
|
1202
|
+
(`DASHBOARD_LOADER_DELAY`); call what it returns in `finally`. A page that
|
|
1203
|
+
answers at once never flashes a loader.
|
|
1204
|
+
- **Before a first answer it is one quiet panel**, `UI/QuietLoader.stx`
|
|
1205
|
+
(`:slow`, `label`, `:framed="false"` inside a card), where the content will
|
|
1206
|
+
be. Nothing is known yet, so nothing is drawn that claims otherwise: no
|
|
1207
|
+
table, footer, count or empty state, a stat card reads `-` and never 0, and
|
|
1208
|
+
a heading is worded from the address (`modelNameFromSlug`) so "View User"
|
|
1209
|
+
does not start as "View Record".
|
|
1210
|
+
- **Asked again, what is on the page stays**, dimmed and out of reach
|
|
1211
|
+
(`dashboardReloadingClass(loading(), base)` with `aria-busy`), and is
|
|
1212
|
+
swapped when the answer comes: a sort or a keystroke in the list, a record
|
|
1213
|
+
read again after one of its actions (its related panels stay too), Refresh
|
|
1214
|
+
on the overview.
|
|
1215
|
+
|
|
1216
|
+
Do not bring back placeholder rows or blocks. Before the columns are known
|
|
1217
|
+
the list's were a lone bar each under "Actions" over a footer that said "No
|
|
1218
|
+
records".
|
|
1219
|
+
|
|
1195
1220
|
The Activity log is not a list of editable records and stays its own page.
|
|
1196
1221
|
|
|
1197
1222
|
### Users are invited, not typed in
|
|
@@ -39,7 +39,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
39
39
|
| `@stacksjs/datetime` | [`stacks-datetime`](../stacks-datetime/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/datetime/src/index.ts) | 22 |
|
|
40
40
|
| `@stacksjs/defaults` | [`stacks-build`](../stacks-build/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/defaults/package.json) | 3 |
|
|
41
41
|
| `@stacksjs/deploy` | [`stacks-deploy`](../stacks-deploy/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/deploy/package.json) | 1 |
|
|
42
|
-
| `@stacksjs/desktop-build` | [`stacks-desktop`](../stacks-desktop/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/index.ts) |
|
|
42
|
+
| `@stacksjs/desktop-build` | [`stacks-desktop`](../stacks-desktop/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/index.ts) | 20 |
|
|
43
43
|
| `@stacksjs/development` | [`stacks-development`](../stacks-development/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/development/package.json) | 1 |
|
|
44
44
|
| `@stacksjs/dns` | [`stacks-dns`](../stacks-dns/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/dns/src/index.ts) | 4 |
|
|
45
45
|
| `@stacksjs/docs` | [`stacks-docs`](../stacks-docs/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/docs/src/index.ts) | 3 |
|
|
@@ -394,7 +394,7 @@ Declared runtime exports: `BUN_EXECUTABLE_MARKER`, `RESERVED_PLIST_KEYS`, `USERL
|
|
|
394
394
|
|
|
395
395
|
Local source modules: [src/agent-launcher.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/agent-launcher.ts), [src/agent.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/agent.ts), [src/invites.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/invites.ts), [src/macos-app.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/macos-app.ts), [src/macos-bundle.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/macos-bundle.ts), [src/support.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/support.ts), [src/update-feed.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-feed.ts), [src/update-install.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-install.ts), [src/update-signing.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-signing.ts), [src/updater.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/updater.ts), [src/webview-agent.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-agent.ts), [src/webview-app.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-app.ts), [src/webview-launcher.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-launcher.ts).
|
|
396
396
|
|
|
397
|
-
Evidence directory: [
|
|
397
|
+
Evidence directory: [20 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
398
398
|
|
|
399
399
|
### @stacksjs/development
|
|
400
400
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a page says it is loading.
|
|
3
|
+
*
|
|
4
|
+
* Not at once. Most dashboard requests answer in a few tens of milliseconds,
|
|
5
|
+
* and a loader drawn for that long is a flash: something appears, means
|
|
6
|
+
* nothing, and is gone. A page waits this long first, and says it is loading
|
|
7
|
+
* only if the answer has still not come.
|
|
8
|
+
*
|
|
9
|
+
* What a page shows meanwhile is its own: one quiet panel where the content
|
|
10
|
+
* will be before a first answer (`UI/QuietLoader.stx`), and the content it
|
|
11
|
+
* already has, dimmed, when it is asking again. Never placeholder shapes, and
|
|
12
|
+
* never a number or an empty state it does not know to be true.
|
|
13
|
+
*/
|
|
14
|
+
export const DASHBOARD_LOADER_DELAY = 250
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Start waiting on a request. `slow` is set once it has taken long enough to
|
|
18
|
+
* say so, and the function this returns ends the wait: call it when the
|
|
19
|
+
* answer (or the failure) comes.
|
|
20
|
+
*
|
|
21
|
+
* const settle = dashboardLoaderTimer(slow)
|
|
22
|
+
* try { ... } finally { settle() }
|
|
23
|
+
*/
|
|
24
|
+
export function dashboardLoaderTimer(slow: { set: (value: boolean) => void }, delay: number = DASHBOARD_LOADER_DELAY): () => void {
|
|
25
|
+
const timer = setTimeout(() => slow.set(true), delay)
|
|
26
|
+
return () => {
|
|
27
|
+
clearTimeout(timer)
|
|
28
|
+
slow.set(false)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The classes of content that stays on screen while it is asked for again. */
|
|
33
|
+
export function dashboardReloadingClass(loading: boolean, base: string = ''): string {
|
|
34
|
+
const classes = loading ? 'opacity-50 pointer-events-none transition-opacity duration-150' : 'transition-opacity duration-150'
|
|
35
|
+
return base ? `${base} ${classes}` : classes
|
|
36
|
+
}
|
|
@@ -357,6 +357,17 @@ export function modelRecordListLabel(record: { tableName?: string } | null, back
|
|
|
357
357
|
return record?.tableName ? titleCase(record.tableName) : 'Records'
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
+
/**
|
|
361
|
+
* What a model is called before its record has come, from the page's address:
|
|
362
|
+
* `social-post` is "Social Post". The heading says "View Social Post" from
|
|
363
|
+
* the first paint and does not change when the answer arrives. (The server's
|
|
364
|
+
* own word wins once it does; it differs only where it spells an initialism,
|
|
365
|
+
* "GDPR Request".)
|
|
366
|
+
*/
|
|
367
|
+
export function modelNameFromSlug(slug: string): string {
|
|
368
|
+
return titleCase(slug.trim()) || 'Record'
|
|
369
|
+
}
|
|
370
|
+
|
|
360
371
|
/** What to call a record in a heading: its name, title or email, else its id. */
|
|
361
372
|
export function modelRecordTitle(record: ModelRecord): string {
|
|
362
373
|
for (const key of ['name', 'title', 'email', 'subject']) {
|
package/ide/vscode/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"publisher": "Stacks",
|
|
3
3
|
"name": "vscode-stacks",
|
|
4
4
|
"displayName": "Stacks",
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.557",
|
|
6
6
|
"description": "Stacks, built into VS Code: stx templates, pickier linting and formatting, encrypted env files, the dev server preview and every buddy command. No other extensions required.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/defaults",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.557",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@iconify-json/f7": "^1.2.2",
|
|
47
47
|
"@iconify-json/hugeicons": "^1.2.35",
|
|
48
|
-
"@stacksjs/mobile": "0.75.
|
|
49
|
-
"@stacksjs/sanitizer": "^0.2.
|
|
50
|
-
"@stacksjs/stx": "^0.2.
|
|
51
|
-
"@stacksjs/strings": "0.75.
|
|
48
|
+
"@stacksjs/mobile": "0.75.557",
|
|
49
|
+
"@stacksjs/sanitizer": "^0.2.864",
|
|
50
|
+
"@stacksjs/stx": "^0.2.864",
|
|
51
|
+
"@stacksjs/strings": "0.75.557",
|
|
52
52
|
"@xterm/addon-fit": "^0.11.0",
|
|
53
53
|
"@xterm/xterm": "^6.0.0",
|
|
54
54
|
"ts-qr-codes": "^0.1.8"
|
|
@@ -17,7 +17,9 @@ import { fetchDashboardStats } from '../../../../functions/data'
|
|
|
17
17
|
type RecordsPage = 'users' | 'teams' | 'subscribers'
|
|
18
18
|
|
|
19
19
|
const pageMode = useReactiveProp<RecordsPage>('mode', 'users')
|
|
20
|
-
|
|
20
|
+
// Null until the numbers have come. A card says nothing until then: a 0 is a
|
|
21
|
+
// count, and "no users" is not what is known while the page is still asking.
|
|
22
|
+
const pageStats = state<DataStats | null>(null)
|
|
21
23
|
|
|
22
24
|
const PAGES: Record<RecordsPage, { model: string, title: string, description: string, icon: string, cards: 3 | 4 }> = {
|
|
23
25
|
users: { model: 'user', title: 'Users', description: 'Review registered application users.', icon: 'i-hugeicons-user-group', cards: 3 },
|
|
@@ -29,8 +31,9 @@ const recordsPage = derived(() => PAGES[pageMode()] ?? PAGES.users)
|
|
|
29
31
|
/** Each page's stats fill their row: three cards in a four-column grid left a hole. */
|
|
30
32
|
const pageStatsGrid = derived(() => recordsPage().cards === 3 ? 'grid-cols-1 sm:grid-cols-3' : 'grid-cols-2 lg:grid-cols-4')
|
|
31
33
|
|
|
32
|
-
function pageStat(key: string):
|
|
33
|
-
|
|
34
|
+
function pageStat(key: string): string {
|
|
35
|
+
const numbers = pageStats()
|
|
36
|
+
return numbers ? Number(numbers[key] || 0).toLocaleString() : '-'
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
async function loadPageStats(): Promise<void> {
|
|
@@ -7,13 +7,16 @@
|
|
|
7
7
|
// page.
|
|
8
8
|
import { useNavigation } from '@stacksjs/defaults/views/dashboard/composables/useNavigation'
|
|
9
9
|
import type { ModelCreateForm, ModelFormValues } from '../../../../functions/dashboard-model-record'
|
|
10
|
-
import { createModelRecord, fetchModelCreateForm, modelFormPayload, modelFormPrefill, modelFormValues, modelRecordBackHref, modelRecordHref, modelRecordListLabel, userInviteHref } from '../../../../functions/dashboard-model-record'
|
|
10
|
+
import { createModelRecord, fetchModelCreateForm, modelNameFromSlug, modelFormPayload, modelFormPrefill, modelFormValues, modelRecordBackHref, modelRecordHref, modelRecordListLabel, userInviteHref } from '../../../../functions/dashboard-model-record'
|
|
11
|
+
import { dashboardLoaderTimer } from '../../../../functions/dashboard-loading'
|
|
11
12
|
import { pushToast } from '../../../../functions/toasts'
|
|
12
13
|
|
|
13
14
|
const navigation = useNavigation()
|
|
14
15
|
const form = state<ModelCreateForm | null>(null)
|
|
15
16
|
const values = state<ModelFormValues>({})
|
|
16
17
|
const loading = state(true)
|
|
18
|
+
// Set once the request has taken long enough to say so (dashboard-loading.ts).
|
|
19
|
+
const slow = state(false)
|
|
17
20
|
const loadError = state('')
|
|
18
21
|
const creating = state(false)
|
|
19
22
|
const createError = state('')
|
|
@@ -27,7 +30,8 @@ function slug(): string {
|
|
|
27
30
|
const from = navigation.urlQuery('from')
|
|
28
31
|
const listHref = derived(() => modelRecordBackHref(slug(), from))
|
|
29
32
|
const listLabel = derived(() => modelRecordListLabel(form(), listHref()))
|
|
30
|
-
|
|
33
|
+
// Known from the address before the form comes, so the heading does not change.
|
|
34
|
+
const modelName = derived(() => form()?.modelName || modelNameFromSlug(slug()))
|
|
31
35
|
const fields = derived(() => form()?.fields ?? [])
|
|
32
36
|
const canCreate = derived(() => Boolean(form()?.canCreate) && fields().length > 0)
|
|
33
37
|
/** A model added by invitation has no form here; the page points at the one that does. */
|
|
@@ -44,6 +48,7 @@ function setValue(change: { name: string, value: string | boolean }): void {
|
|
|
44
48
|
async function loadForm(): Promise<void> {
|
|
45
49
|
loading.set(true)
|
|
46
50
|
loadError.set('')
|
|
51
|
+
const settle = dashboardLoaderTimer(slow)
|
|
47
52
|
try {
|
|
48
53
|
const loaded = await fetchModelCreateForm(slug())
|
|
49
54
|
form.set(loaded)
|
|
@@ -55,6 +60,7 @@ async function loadForm(): Promise<void> {
|
|
|
55
60
|
loadError.set(error instanceof Error ? error.message : 'This form could not be loaded.')
|
|
56
61
|
}
|
|
57
62
|
finally {
|
|
63
|
+
settle()
|
|
58
64
|
loading.set(false)
|
|
59
65
|
}
|
|
60
66
|
}
|
|
@@ -100,10 +106,7 @@ onMount(() => {
|
|
|
100
106
|
<h1 class="font-bold text-3xl text-neutral-900 tracking-tight truncate dark:text-white">Create {{ modelName() }}</h1>
|
|
101
107
|
</header>
|
|
102
108
|
|
|
103
|
-
<
|
|
104
|
-
<span aria-hidden="true" class="mr-2 h-5 w-5 animate-spin i-hugeicons-loading-03"></span>
|
|
105
|
-
Loading form
|
|
106
|
-
</div>
|
|
109
|
+
<QuietLoader :if="loading()" :slow="slow()" label="Loading form" />
|
|
107
110
|
|
|
108
111
|
<div :if="!loading() && loadError()" role="alert" class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between px-4 py-3 text-red-700 text-sm dark:text-red-300 bg-red-50 dark:bg-red-950/40 border border-red-200 rounded-lg dark:border-red-900">
|
|
109
112
|
<span>{{ loadError() }}</span>
|
|
@@ -9,12 +9,16 @@
|
|
|
9
9
|
// address to share, open in a tab and come back to.
|
|
10
10
|
import { useNavigation } from '@stacksjs/defaults/views/dashboard/composables/useNavigation'
|
|
11
11
|
import type { ModelCustomAction, ModelRecord, ModelRelatedPanel } from '../../../../functions/dashboard-model-record'
|
|
12
|
-
import { deleteModelRecord, fetchModelRecord, fetchModelRelated, modelActionAsks, modelActionIconClass, modelActionNotice, modelDeleteNotice, modelDeleteWarning, modelRecordBackHref, modelRecordEditHref, modelRecordHref, modelRecordListLabel, modelRecordSections, modelRecordTitle, runModelAction } from '../../../../functions/dashboard-model-record'
|
|
12
|
+
import { deleteModelRecord, fetchModelRecord, fetchModelRelated, modelActionAsks, modelActionIconClass, modelActionNotice, modelDeleteNotice, modelDeleteWarning, modelNameFromSlug, modelRecordBackHref, modelRecordEditHref, modelRecordHref, modelRecordListLabel, modelRecordSections, modelRecordTitle, runModelAction } from '../../../../functions/dashboard-model-record'
|
|
13
|
+
import { dashboardLoaderTimer, dashboardReloadingClass } from '../../../../functions/dashboard-loading'
|
|
13
14
|
import { pushToast } from '../../../../functions/toasts'
|
|
14
15
|
|
|
15
16
|
const navigation = useNavigation()
|
|
16
17
|
const record = state<ModelRecord | null>(null)
|
|
17
18
|
const loading = state(true)
|
|
19
|
+
// Set once a request has taken long enough to say so. The record's page
|
|
20
|
+
// waits quietly before that (see dashboard-loading.ts).
|
|
21
|
+
const slow = state(false)
|
|
18
22
|
const loadError = state('')
|
|
19
23
|
const confirmingDelete = state(false)
|
|
20
24
|
const working = state(false)
|
|
@@ -43,7 +47,11 @@ const selfHref = derived(() => modelRecordHref(slug(), recordId()))
|
|
|
43
47
|
/** The list in the breadcrumb: "Users" for /data/users, else the model's table. */
|
|
44
48
|
const listLabel = derived(() => modelRecordListLabel(record(), backHref()))
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
// Known from the address before the record comes, so the heading does not change.
|
|
51
|
+
const modelName = derived(() => record()?.modelName || modelNameFromSlug(slug()))
|
|
52
|
+
// The record stays on the page while it is read again (after one of its
|
|
53
|
+
// actions), dimmed, and is swapped when the answer comes.
|
|
54
|
+
const contentClass = derived(() => dashboardReloadingClass(loading(), 'grid gap-6 grid-cols-1 items-start lg:grid-cols-2'))
|
|
47
55
|
const title = derived(() => record() ? modelRecordTitle(record()!) : '')
|
|
48
56
|
// Who points at this record: its panels. Also after the record itself.
|
|
49
57
|
const related = state<ModelRelatedPanel[]>([])
|
|
@@ -60,18 +68,20 @@ const actions = derived(() => record()?.actions ?? [])
|
|
|
60
68
|
async function loadRecord(): Promise<void> {
|
|
61
69
|
loading.set(true)
|
|
62
70
|
loadError.set('')
|
|
71
|
+
const settle = dashboardLoaderTimer(slow)
|
|
63
72
|
try {
|
|
64
73
|
const loaded = await fetchModelRecord(slug(), recordId())
|
|
65
|
-
related.set([])
|
|
66
74
|
record.set(loaded)
|
|
67
75
|
// Not awaited, and a page whose panels cannot be read is still the record's page.
|
|
68
76
|
void fetchModelRelated(slug(), recordId()).then(panels => related.set(panels)).catch(() => related.set([]))
|
|
69
77
|
}
|
|
70
78
|
catch (error) {
|
|
71
79
|
record.set(null)
|
|
80
|
+
related.set([])
|
|
72
81
|
loadError.set(error instanceof Error ? error.message : 'This record could not be loaded.')
|
|
73
82
|
}
|
|
74
83
|
finally {
|
|
84
|
+
settle()
|
|
75
85
|
loading.set(false)
|
|
76
86
|
}
|
|
77
87
|
}
|
|
@@ -190,22 +200,19 @@ onMount(() => {
|
|
|
190
200
|
</div>
|
|
191
201
|
</header>
|
|
192
202
|
|
|
193
|
-
<
|
|
194
|
-
<span aria-hidden="true" class="mr-2 h-5 w-5 animate-spin i-hugeicons-loading-03"></span>
|
|
195
|
-
Loading record
|
|
196
|
-
</div>
|
|
203
|
+
<QuietLoader :if="loading() && !record()" :slow="slow()" label="Loading record" />
|
|
197
204
|
|
|
198
205
|
<div :if="!loading() && loadError()" role="alert" class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between px-4 py-3 text-red-700 text-sm dark:text-red-300 bg-red-50 dark:bg-red-950/40 border border-red-200 rounded-lg dark:border-red-900">
|
|
199
206
|
<span>{{ loadError() }}</span>
|
|
200
207
|
<Button variant="secondary" size="sm" @click="loadRecord">Try again</Button>
|
|
201
208
|
</div>
|
|
202
209
|
|
|
203
|
-
<div :if="
|
|
210
|
+
<div :if="record()?.anonymized" role="note" class="flex gap-3 items-start px-4 py-3 text-neutral-700 text-sm dark:text-neutral-200 bg-neutral-100 dark:bg-white/5 border border-neutral-200 rounded-lg dark:border-neutral-700">
|
|
204
211
|
<span aria-hidden="true" class="flex-none mt-0.5 h-4 w-4 text-neutral-500 i-hugeicons-user-remove-01"></span>
|
|
205
212
|
<span>This account was anonymized. Its name and email were removed and it can no longer sign in. Records that refer to it were kept.</span>
|
|
206
213
|
</div>
|
|
207
214
|
|
|
208
|
-
<div :if="
|
|
215
|
+
<div :if="record()" :class="contentClass()" :aria-busy="loading() ? 'true' : null" data-record-content>
|
|
209
216
|
<div :for="section in sections()" class="min-w-0">
|
|
210
217
|
<Card padding="none">
|
|
211
218
|
<h2 class="px-6 py-4 font-semibold text-base text-neutral-900 dark:text-white border-b border-neutral-200 dark:border-neutral-700">{{ section.title }}</h2>
|
|
@@ -240,7 +247,7 @@ onMount(() => {
|
|
|
240
247
|
</div>
|
|
241
248
|
|
|
242
249
|
<ModelRelatedPanels
|
|
243
|
-
:if="
|
|
250
|
+
:if="record() && related().length > 0"
|
|
244
251
|
:panels="related()"
|
|
245
252
|
:parentId="recordId()"
|
|
246
253
|
:from="selfHref()"
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
// to where the visitor came from: the record's page, or the list.
|
|
7
7
|
import { useNavigation } from '@stacksjs/defaults/views/dashboard/composables/useNavigation'
|
|
8
8
|
import type { ModelFormValues, ModelRecord } from '../../../../functions/dashboard-model-record'
|
|
9
|
-
import { fetchModelRecord, modelFormPayload, modelFormValues, modelRecordBackHref, modelRecordHref, modelRecordListLabel, modelRecordSections, updateModelRecord } from '../../../../functions/dashboard-model-record'
|
|
9
|
+
import { fetchModelRecord, modelNameFromSlug, modelFormPayload, modelFormValues, modelRecordBackHref, modelRecordHref, modelRecordListLabel, modelRecordSections, updateModelRecord } from '../../../../functions/dashboard-model-record'
|
|
10
|
+
import { dashboardLoaderTimer } from '../../../../functions/dashboard-loading'
|
|
10
11
|
import { pushToast } from '../../../../functions/toasts'
|
|
11
12
|
|
|
12
13
|
const navigation = useNavigation()
|
|
@@ -15,6 +16,8 @@ const values = state<ModelFormValues>({})
|
|
|
15
16
|
/** What the form started with, so a save sends only what was changed. */
|
|
16
17
|
const initial = state<ModelFormValues>({})
|
|
17
18
|
const loading = state(true)
|
|
19
|
+
// Set once the request has taken long enough to say so (dashboard-loading.ts).
|
|
20
|
+
const slow = state(false)
|
|
18
21
|
const loadError = state('')
|
|
19
22
|
const saving = state(false)
|
|
20
23
|
const saveError = state('')
|
|
@@ -36,7 +39,8 @@ const viewHref = derived(() => modelRecordHref(slug(), recordId(), listHref() ==
|
|
|
36
39
|
/** After saving or cancelling: the page the visitor came from. */
|
|
37
40
|
const returnHref = derived(() => cameFromView ? viewHref() : listHref())
|
|
38
41
|
const listLabel = derived(() => modelRecordListLabel(record(), listHref()))
|
|
39
|
-
|
|
42
|
+
// Known from the address before the record comes, so the heading does not change.
|
|
43
|
+
const modelName = derived(() => record()?.modelName || modelNameFromSlug(slug()))
|
|
40
44
|
|
|
41
45
|
const writable = derived(() => record()?.fields ?? [])
|
|
42
46
|
/** What cannot be changed here, formatted as the record's page shows it. */
|
|
@@ -58,6 +62,7 @@ function setValue(change: { name: string, value: string | boolean }): void {
|
|
|
58
62
|
async function loadRecord(): Promise<void> {
|
|
59
63
|
loading.set(true)
|
|
60
64
|
loadError.set('')
|
|
65
|
+
const settle = dashboardLoaderTimer(slow)
|
|
61
66
|
try {
|
|
62
67
|
const loaded = await fetchModelRecord(slug(), recordId())
|
|
63
68
|
record.set(loaded)
|
|
@@ -70,6 +75,7 @@ async function loadRecord(): Promise<void> {
|
|
|
70
75
|
loadError.set(error instanceof Error ? error.message : 'This record could not be loaded.')
|
|
71
76
|
}
|
|
72
77
|
finally {
|
|
78
|
+
settle()
|
|
73
79
|
loading.set(false)
|
|
74
80
|
}
|
|
75
81
|
}
|
|
@@ -121,10 +127,7 @@ onMount(() => {
|
|
|
121
127
|
<h1 class="font-bold text-3xl text-neutral-900 tracking-tight truncate dark:text-white">Edit {{ modelName() }}</h1>
|
|
122
128
|
</header>
|
|
123
129
|
|
|
124
|
-
<
|
|
125
|
-
<span aria-hidden="true" class="mr-2 h-5 w-5 animate-spin i-hugeicons-loading-03"></span>
|
|
126
|
-
Loading record
|
|
127
|
-
</div>
|
|
130
|
+
<QuietLoader :if="loading()" :slow="slow()" label="Loading record" />
|
|
128
131
|
|
|
129
132
|
<div :if="!loading() && loadError()" role="alert" class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between px-4 py-3 text-red-700 text-sm dark:text-red-300 bg-red-50 dark:bg-red-950/40 border border-red-200 rounded-lg dark:border-red-900">
|
|
130
133
|
<span>{{ loadError() }}</span>
|
|
@@ -18,6 +18,7 @@ import type { ModelBulkResult } from '@stacksjs/defaults/functions/dashboard-mod
|
|
|
18
18
|
import { deleteModelRecords, modelBulkActionConfirm, modelBulkActionScope, modelBulkActions, modelBulkDeleteConfirm, modelBulkDeleteTargets, modelBulkNotice, modelBulkTargets, runModelActionOnEach } from '@stacksjs/defaults/functions/dashboard-model-bulk'
|
|
19
19
|
import type { ModelFieldDisplay, ModelFormattedValue } from '@stacksjs/defaults/functions/dashboard-model-format'
|
|
20
20
|
import { modelCellDisplay, modelColumnIsNumeric } from '@stacksjs/defaults/functions/dashboard-model-format'
|
|
21
|
+
import { dashboardLoaderTimer, dashboardReloadingClass } from '@stacksjs/defaults/functions/dashboard-loading'
|
|
21
22
|
import { pushToast } from '@stacksjs/defaults/functions/toasts'
|
|
22
23
|
|
|
23
24
|
interface ColumnMeta {
|
|
@@ -97,6 +98,13 @@ const error = state<string | null>(null)
|
|
|
97
98
|
// catalog after the query failed, so this is never a guess from an error.
|
|
98
99
|
const migrated = state(true)
|
|
99
100
|
const loading = state(true)
|
|
101
|
+
// Whether a first answer has come. Until it has, nothing is known about the
|
|
102
|
+
// model: not its columns, not how many rows it has. Nothing is drawn that
|
|
103
|
+
// would say otherwise ("No records", a table of one column).
|
|
104
|
+
const loaded = state(false)
|
|
105
|
+
// Said only once a query has taken long enough to wonder about. A list that
|
|
106
|
+
// answers at once never flashes a loader (`dashboardLoaderTimer`).
|
|
107
|
+
const slow = state(false)
|
|
100
108
|
// Open when it arrives filtered, so what narrowed the list can be seen and cleared.
|
|
101
109
|
const showFilters = state(Object.keys(filters()).length > 0)
|
|
102
110
|
|
|
@@ -162,9 +170,14 @@ const filterLabel = derived(() => {
|
|
|
162
170
|
return n === 0 ? 'Filter' : `Filter (${n})`
|
|
163
171
|
})
|
|
164
172
|
|
|
165
|
-
|
|
173
|
+
// Not hidden while a query is in flight: what is on the page stays until the
|
|
174
|
+
// answer replaces it.
|
|
175
|
+
const isEmpty = derived(() => loaded() && !error() && migrated() && rows().length === 0)
|
|
166
176
|
|
|
167
177
|
const subtitle = derived(() => {
|
|
178
|
+
// A page's own description is known from the start; a count is not.
|
|
179
|
+
if (!loaded())
|
|
180
|
+
return description()
|
|
168
181
|
if (!migrated())
|
|
169
182
|
return `The ${tableName()} table has not been created yet`
|
|
170
183
|
return description() || `${recordLabel()} in the ${tableName()} table`
|
|
@@ -177,9 +190,14 @@ const deleteDescription = derived(() => {
|
|
|
177
190
|
return modelDeleteWarning(`Row ${row.id}`, writeCapabilities().anonymize)
|
|
178
191
|
})
|
|
179
192
|
|
|
180
|
-
//
|
|
181
|
-
//
|
|
182
|
-
|
|
193
|
+
// While a query is in flight the rows already there stay, dimmed and out of
|
|
194
|
+
// reach, and are swapped when the answer comes. Nothing collapses or jumps on
|
|
195
|
+
// a keystroke, and there is no placeholder to draw.
|
|
196
|
+
const bodyClass = derived(() => dashboardReloadingClass(loading(), 'divide-black/5 divide-y dark:divide-white/8'))
|
|
197
|
+
// A hosting page's heading is known from the first paint, so the box does not
|
|
198
|
+
// change its wording when the answer comes.
|
|
199
|
+
const searchPlaceholder = derived(() => `Search ${(heading() || modelName() || 'records').toLowerCase()}`)
|
|
200
|
+
const loadingLabel = derived(() => `Loading ${(title() || 'records').toLowerCase()}`)
|
|
183
201
|
|
|
184
202
|
function formatDate(value: unknown): string {
|
|
185
203
|
const date = new Date(value as string | number)
|
|
@@ -285,6 +303,7 @@ async function load() {
|
|
|
285
303
|
error.set(null)
|
|
286
304
|
// The rows about to arrive may not be the ones that were ticked.
|
|
287
305
|
selected.set([])
|
|
306
|
+
const settle = dashboardLoaderTimer(slow)
|
|
288
307
|
try {
|
|
289
308
|
const params = new URLSearchParams({
|
|
290
309
|
page: String(page()),
|
|
@@ -330,7 +349,9 @@ async function load() {
|
|
|
330
349
|
error.set(e instanceof Error ? e.message : String(e))
|
|
331
350
|
}
|
|
332
351
|
finally {
|
|
352
|
+
settle()
|
|
333
353
|
loading.set(false)
|
|
354
|
+
loaded.set(true)
|
|
334
355
|
}
|
|
335
356
|
}
|
|
336
357
|
|
|
@@ -631,7 +652,7 @@ onMount(() => {
|
|
|
631
652
|
type="search"
|
|
632
653
|
x-model="search"
|
|
633
654
|
@input="onSearchInput"
|
|
634
|
-
:placeholder="
|
|
655
|
+
:placeholder="searchPlaceholder()"
|
|
635
656
|
class="block pl-9 pr-3 py-1.5 w-full text-[13px] text-neutral-900 dark:text-neutral-100 placeholder:text-neutral-400 dark:placeholder:text-neutral-500 bg-white dark:bg-white/10 border border-black/10 rounded-lg dark:border-white/15 focus:border-blue-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 transition-all"
|
|
636
657
|
>
|
|
637
658
|
</div>
|
|
@@ -700,7 +721,7 @@ onMount(() => {
|
|
|
700
721
|
</div>
|
|
701
722
|
</div>
|
|
702
723
|
|
|
703
|
-
<div :if="!loading() && !error() && !migrated()" role="status" class="p-12 text-center bg-white dark:bg-neutral-900 border border-black/8 rounded-xl dark:border-white/10">
|
|
724
|
+
<div :if="loaded() && !loading() && !error() && !migrated()" role="status" class="p-12 text-center bg-white dark:bg-neutral-900 border border-black/8 rounded-xl dark:border-white/10">
|
|
704
725
|
<span aria-hidden="true" class="mx-auto h-10 w-10 text-neutral-300 dark:text-neutral-600 i-hugeicons-database-sync-01"></span>
|
|
705
726
|
<h3 class="mt-3 font-medium text-[15px] text-neutral-900 dark:text-white">
|
|
706
727
|
The <code :text="tableName()"></code> table has not been created yet
|
|
@@ -722,7 +743,12 @@ onMount(() => {
|
|
|
722
743
|
</p>
|
|
723
744
|
</div>
|
|
724
745
|
|
|
725
|
-
|
|
746
|
+
<!-- Before the first answer: one quiet card where the table will be. No
|
|
747
|
+
column is known yet, so no table is drawn, and it says it is loading
|
|
748
|
+
only if that takes long enough to notice. -->
|
|
749
|
+
<QuietLoader :if="!loaded()" :slow="slow()" :label="loadingLabel()" />
|
|
750
|
+
|
|
751
|
+
<div :if="loaded() && !error() && migrated() && rows().length > 0" class="overflow-hidden bg-white dark:bg-neutral-900 border border-black/8 rounded-xl dark:border-white/10">
|
|
726
752
|
<div class="overflow-x-auto">
|
|
727
753
|
<table class="min-w-full">
|
|
728
754
|
<thead class="bg-neutral-50 dark:bg-white/5">
|
|
@@ -762,23 +788,7 @@ onMount(() => {
|
|
|
762
788
|
</tr>
|
|
763
789
|
</thead>
|
|
764
790
|
|
|
765
|
-
|
|
766
|
-
collapse and jump back on every keystroke. Two <tbody> elements
|
|
767
|
-
rather than one: `:if` and `:for` on the same <template> do not
|
|
768
|
-
compose, and a table may legally carry several bodies. -->
|
|
769
|
-
<tbody :if="loading()" class="divide-black/5 divide-y dark:divide-white/8">
|
|
770
|
-
<tr :for="i in skeletonRows()">
|
|
771
|
-
<td :if="selectable()" class="pl-3 pr-1 py-2 w-8"></td>
|
|
772
|
-
<td :for="column in columnMeta()" class="px-3 py-2">
|
|
773
|
-
<div class="h-3 bg-neutral-200 dark:bg-white/10 rounded animate-pulse"></div>
|
|
774
|
-
</td>
|
|
775
|
-
<td class="right-0 sticky z-10 px-3 py-2 bg-white dark:bg-neutral-900 border-black/5 border-l dark:border-white/10">
|
|
776
|
-
<div class="ml-auto h-3 w-16 bg-neutral-200 dark:bg-white/10 rounded animate-pulse"></div>
|
|
777
|
-
</td>
|
|
778
|
-
</tr>
|
|
779
|
-
</tbody>
|
|
780
|
-
|
|
781
|
-
<tbody :if="!loading()" class="divide-black/5 divide-y dark:divide-white/8">
|
|
791
|
+
<tbody :class="bodyClass()" :aria-busy="loading() ? 'true' : null">
|
|
782
792
|
<tr :for="row in rows()" class="hover:bg-neutral-50 dark:hover:bg-white/5 transition-colors group">
|
|
783
793
|
<td :if="selectable()" class="pl-3 pr-1 py-2 w-8">
|
|
784
794
|
<input
|
|
@@ -819,7 +829,10 @@ onMount(() => {
|
|
|
819
829
|
</div>
|
|
820
830
|
|
|
821
831
|
<div class="flex flex-wrap gap-3 items-center justify-between px-3 py-2 bg-neutral-50 dark:bg-white/5 border-black/5 border-t dark:border-white/10">
|
|
822
|
-
<p class="text-[12px] text-neutral-500 dark:text-neutral-400"
|
|
832
|
+
<p class="flex gap-2 items-center text-[12px] text-neutral-500 dark:text-neutral-400">
|
|
833
|
+
<span :text="rangeLabel()"></span>
|
|
834
|
+
<span :if="slow()" role="status" aria-label="Loading" class="h-3.5 w-3.5 animate-spin i-hugeicons-loading-03"></span>
|
|
835
|
+
</p>
|
|
823
836
|
<div class="flex gap-1 items-center">
|
|
824
837
|
<Button variant="secondary" size="xs" :disabled="page() === 1" @click="goToPage(1)">First</Button>
|
|
825
838
|
<Button variant="secondary" size="xs" :disabled="page() === 1" @click="goToPage(page() - 1)">Previous</Button>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script client>
|
|
2
2
|
import { dashboardApi } from '../../../../functions/dashboard-api'
|
|
3
|
+
import { dashboardLoaderTimer, dashboardReloadingClass } from '../../../../functions/dashboard-loading'
|
|
3
4
|
|
|
4
5
|
interface ModelRow {
|
|
5
6
|
name: string
|
|
@@ -41,6 +42,12 @@ const unavailableModels = state(0)
|
|
|
41
42
|
const unmigratedModels = state(0)
|
|
42
43
|
const categoryGroups = state<ModelGroup[]>([])
|
|
43
44
|
const loading = state(true)
|
|
45
|
+
// Whether the registry has been read. Until it has (and after a read that
|
|
46
|
+
// failed) nothing is known about it: the cards say "-" and not 0, and no
|
|
47
|
+
// count of matching models is given.
|
|
48
|
+
const known = state(false)
|
|
49
|
+
// Set once a request has taken long enough to say so (dashboard-loading.ts).
|
|
50
|
+
const slow = state(false)
|
|
44
51
|
const loadError = state('')
|
|
45
52
|
const search = state('')
|
|
46
53
|
const selectedCategory = state('all')
|
|
@@ -73,9 +80,20 @@ const visibleGroups = derived(() => {
|
|
|
73
80
|
|
|
74
81
|
const visibleModelCount = derived(() => visibleGroups().reduce((total, group) => total + group.models.length, 0))
|
|
75
82
|
|
|
83
|
+
/** A card's number, or "-" while it is not known. */
|
|
84
|
+
function registryCount(value: number): string {
|
|
85
|
+
return known() ? value.toLocaleString() : '-'
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const matchingLabel = derived(() => known() ? `${visibleModelCount()} matching ${visibleModelCount() === 1 ? 'model' : 'models'}` : '')
|
|
89
|
+
// Refreshing keeps the models that are there, dimmed, until the answer swaps them.
|
|
90
|
+
const refreshing = derived(() => loading() && known())
|
|
91
|
+
const groupsClass = derived(() => dashboardReloadingClass(loading(), 'p-5 space-y-7'))
|
|
92
|
+
|
|
76
93
|
async function loadModels(): Promise<void> {
|
|
77
94
|
loading.set(true)
|
|
78
95
|
loadError.set('')
|
|
96
|
+
const settle = dashboardLoaderTimer(slow)
|
|
79
97
|
try {
|
|
80
98
|
const response = await dashboardApi<ModelsResponse>('/api/dashboard/models')
|
|
81
99
|
totalModels.set(response.totalModels || 0)
|
|
@@ -84,8 +102,10 @@ async function loadModels(): Promise<void> {
|
|
|
84
102
|
unavailableModels.set(response.unavailableModels || 0)
|
|
85
103
|
unmigratedModels.set(response.unmigratedModels || 0)
|
|
86
104
|
categoryGroups.set(response.categoryGroups || [])
|
|
105
|
+
known.set(true)
|
|
87
106
|
}
|
|
88
107
|
catch (error) {
|
|
108
|
+
known.set(false)
|
|
89
109
|
totalModels.set(0)
|
|
90
110
|
totalRecords.set(0)
|
|
91
111
|
userlandCount.set(0)
|
|
@@ -95,6 +115,7 @@ async function loadModels(): Promise<void> {
|
|
|
95
115
|
loadError.set(error instanceof Error ? error.message : 'Models could not be loaded.')
|
|
96
116
|
}
|
|
97
117
|
finally {
|
|
118
|
+
settle()
|
|
98
119
|
loading.set(false)
|
|
99
120
|
}
|
|
100
121
|
}
|
|
@@ -110,21 +131,21 @@ onMount(() => {
|
|
|
110
131
|
<h1 class="font-bold text-2xl text-neutral-900 tracking-tight dark:text-white">{{ title() }}</h1>
|
|
111
132
|
<p class="mt-1 max-w-3xl text-neutral-500 text-sm dark:text-neutral-400">{{ description() }}</p>
|
|
112
133
|
</div>
|
|
113
|
-
<Button variant="secondary" :loading="loading()" @click="loadModels">
|
|
114
|
-
<span :if="!
|
|
134
|
+
<Button variant="secondary" :loading="refreshing()" :disabled="loading()" @click="loadModels">
|
|
135
|
+
<span :if="!refreshing()" class="h-4 w-4 i-hugeicons-refresh"></span>
|
|
115
136
|
Refresh
|
|
116
137
|
</Button>
|
|
117
138
|
</header>
|
|
118
139
|
|
|
119
140
|
<div class="grid gap-4 grid-cols-1 sm:grid-cols-3">
|
|
120
141
|
<StatsCard title="Total Models" icon="i-hugeicons-database" iconBg="primary">
|
|
121
|
-
<template #value>{{ totalModels() }}</template>
|
|
142
|
+
<template #value>{{ registryCount(totalModels()) }}</template>
|
|
122
143
|
</StatsCard>
|
|
123
144
|
<StatsCard title="Total Records" icon="i-hugeicons-table-rows-split" iconBg="success">
|
|
124
|
-
<template #value>{{ totalRecords()
|
|
145
|
+
<template #value>{{ registryCount(totalRecords()) }}</template>
|
|
125
146
|
</StatsCard>
|
|
126
147
|
<StatsCard title="App Overrides" icon="i-hugeicons-folder-02" iconBg="info">
|
|
127
|
-
<template #value>{{ userlandCount() }}</template>
|
|
148
|
+
<template #value>{{ registryCount(userlandCount()) }}</template>
|
|
128
149
|
</StatsCard>
|
|
129
150
|
</div>
|
|
130
151
|
|
|
@@ -147,7 +168,7 @@ onMount(() => {
|
|
|
147
168
|
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between p-5 border-b border-neutral-200 dark:border-neutral-700">
|
|
148
169
|
<div>
|
|
149
170
|
<h2 class="font-semibold text-neutral-900 dark:text-white">Model Registry</h2>
|
|
150
|
-
<p class="mt-1 text-neutral-500 text-xs dark:text-neutral-400"
|
|
171
|
+
<p class="mt-1 min-h-4 text-neutral-500 text-xs dark:text-neutral-400" :text="matchingLabel()"></p>
|
|
151
172
|
</div>
|
|
152
173
|
<div class="flex flex-col gap-2 sm:flex-row w-full sm:w-auto">
|
|
153
174
|
<label class="block relative w-full sm:w-64">
|
|
@@ -165,11 +186,9 @@ onMount(() => {
|
|
|
165
186
|
</div>
|
|
166
187
|
</div>
|
|
167
188
|
|
|
168
|
-
<
|
|
169
|
-
<div :for="index in [1, 2, 3, 4, 5, 6]" class="h-40 bg-neutral-100 dark:bg-neutral-800 rounded-xl animate-pulse"></div>
|
|
170
|
-
</div>
|
|
189
|
+
<QuietLoader :if="loading() && !known()" :slow="slow()" label="Loading models" :framed="false" />
|
|
171
190
|
|
|
172
|
-
<div :if="
|
|
191
|
+
<div :if="known() && visibleModelCount() === 0">
|
|
173
192
|
<EmptyState
|
|
174
193
|
icon="i-hugeicons-database-01"
|
|
175
194
|
:title="totalModels() === 0 ? 'No models were discovered' : 'No models match these filters'"
|
|
@@ -177,7 +196,7 @@ onMount(() => {
|
|
|
177
196
|
/>
|
|
178
197
|
</div>
|
|
179
198
|
|
|
180
|
-
<div :if="
|
|
199
|
+
<div :if="known() && visibleModelCount() > 0" :class="groupsClass()" :aria-busy="loading() ? 'true' : null" data-model-groups>
|
|
181
200
|
<section :for="group in visibleGroups()" class="space-y-3">
|
|
182
201
|
<div class="flex items-baseline justify-between">
|
|
183
202
|
<h3 class="font-semibold text-neutral-900 dark:text-white">{{ group.label }}</h3>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
// Where a page's content will be, before its first answer. An empty panel of
|
|
3
|
+
// about the content's size, so the page does not jump twice, that says what
|
|
4
|
+
// it is waiting for only once that has taken long enough to notice
|
|
5
|
+
// (`dashboardLoaderTimer`). A page that answers at once never shows a loader.
|
|
6
|
+
//
|
|
7
|
+
// Not a skeleton: nothing is known yet, so there is nothing to draw the
|
|
8
|
+
// shape of.
|
|
9
|
+
const slow = useReactiveProp('slow', false)
|
|
10
|
+
const label = useReactiveProp('label', 'Loading')
|
|
11
|
+
// Off inside something that already has an edge, such as a card.
|
|
12
|
+
const framed = useReactiveProp('framed', true)
|
|
13
|
+
|
|
14
|
+
const panelClass = derived(() => framed()
|
|
15
|
+
? 'flex items-center justify-center h-64 bg-white dark:bg-neutral-900 border border-black/8 rounded-xl dark:border-white/10'
|
|
16
|
+
: 'flex items-center justify-center h-64')
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div role="status" aria-live="polite" data-quiet-loader :class="panelClass()">
|
|
20
|
+
<p :if="slow()" class="flex gap-2 items-center text-[13px] text-neutral-500 dark:text-neutral-400">
|
|
21
|
+
<span aria-hidden="true" class="h-4 w-4 animate-spin i-hugeicons-loading-03"></span>
|
|
22
|
+
<span :text="label()"></span>
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|