@stacksjs/defaults 0.75.640 → 0.75.647
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-buddy/SKILL.md +11 -1
- package/ai/skills/stacks-native/CATALOG.md +2 -2
- package/ai/skills/stacks-testing/SKILL.md +3 -1
- package/app/Actions/Dashboard/Models/ModelShowAction.ts +21 -7
- package/functions/dashboard-model-record.ts +8 -4
- package/functions/dashboard-sidebar-order.ts +1 -1
- package/ide/vscode/package.json +1 -1
- package/package.json +5 -5
- package/resources/components/Dashboard/Auth/Login.stx +2 -1
- package/resources/components/Dashboard/Auth/LoginDashboard.stx +11 -4
- package/resources/components/Dashboard/Auth/TwoFactorLogin.stx +3 -2
- package/resources/components/Dashboard/Models/ModelRecordDetail.stx +4 -1
- package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +22 -15
- package/resources/components/Dashboard/UI/Button.stx +4 -4
- package/views/dashboard/layouts/default.stx +29 -5
|
@@ -57,7 +57,7 @@ config.
|
|
|
57
57
|
|
|
58
58
|
Machine-level commands are never handed to a project and run from any
|
|
59
59
|
directory: `new`, `create`, `projects`, `projects:*`, `cd`, `daemon`,
|
|
60
|
-
`daemon:*`, `dashboard`.
|
|
60
|
+
`daemon:*`, `dashboard`, `tray`.
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
63
|
buddy projects # the projects on this machine, most recently used first
|
|
@@ -72,6 +72,7 @@ buddy cd <name> # print a project's path (--eval for a shell func
|
|
|
72
72
|
buddy dashboard [project] # open a project's dashboard, started in the background if needed
|
|
73
73
|
--no-open # print the address without opening a browser
|
|
74
74
|
--stop # stop that project's background dashboard
|
|
75
|
+
buddy tray # native macOS menu-bar app (requires Craft)
|
|
75
76
|
|
|
76
77
|
buddy daemon # is buddy running in the background, and what is it running
|
|
77
78
|
buddy daemon:start # start it to watch opted-in projects
|
|
@@ -108,6 +109,15 @@ takes precedence over `generation.autoCommit`.
|
|
|
108
109
|
missed. Approval-enabled generation protects local edits to its artifacts
|
|
109
110
|
and retains successful outputs when another generator fails.
|
|
110
111
|
|
|
112
|
+
`buddy tray` uses a Craft popover and an stx view for machine-wide generation
|
|
113
|
+
status, project dashboards, and pending reviews. The tray connects to the
|
|
114
|
+
existing daemon and opens the project’s `generate:review` in Terminal. It
|
|
115
|
+
uses a private loopback server and quitting it leaves the daemon running.
|
|
116
|
+
The Overview pane samples CPU and memory while visible. The Pantry pane
|
|
117
|
+
uses `ts-pantry/desktop` for installed inventory and package jobs, and
|
|
118
|
+
`ts-pantry/catalog` for local catalog search. Pair with the user’s existing
|
|
119
|
+
Pantry Desktop service and keep the connection credential in Keychain.
|
|
120
|
+
|
|
111
121
|
## Architecture
|
|
112
122
|
|
|
113
123
|
### Lazy Loading System
|
|
@@ -21,7 +21,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
21
21
|
| `@stacksjs/auth` | [`stacks-auth`](../stacks-auth/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/auth/src/index.ts) | 136 |
|
|
22
22
|
| `@stacksjs/browser` | [`stacks-browser`](../stacks-browser/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/browser/src/index.ts) | 10 |
|
|
23
23
|
| `@stacksjs/browser-extension` | [`stacks-browser-extension`](../stacks-browser-extension/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/browser-extension/src/index.ts) | 9 |
|
|
24
|
-
| `@stacksjs/buddy` | [`stacks-buddy`](../stacks-buddy/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/index.ts) |
|
|
24
|
+
| `@stacksjs/buddy` | [`stacks-buddy`](../stacks-buddy/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/index.ts) | 219 |
|
|
25
25
|
| `@stacksjs/build` | [`stacks-build`](../stacks-build/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/build/src/index.ts) | 7 |
|
|
26
26
|
| `@stacksjs/cache` | [`stacks-cache`](../stacks-cache/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/cache/src/index.ts) | 24 |
|
|
27
27
|
| `@stacksjs/calendar-api` | [`stacks-calendar`](../stacks-calendar/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/calendar-api/src/index.ts) | 5 |
|
|
@@ -223,7 +223,7 @@ Read the entrypoint and package export map for re-exported or type-only surfaces
|
|
|
223
223
|
|
|
224
224
|
Local source modules: [src/commands/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/commands/index.ts).
|
|
225
225
|
|
|
226
|
-
Evidence directory: [
|
|
226
|
+
Evidence directory: [219 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
227
227
|
|
|
228
228
|
### @stacksjs/build
|
|
229
229
|
|
|
@@ -371,7 +371,9 @@ profiles and requires every category to meet `--min-score` (100 by default).
|
|
|
371
371
|
`--device mobile|desktop|both` selects profiles; `--output` selects the directory
|
|
372
372
|
for HTML, JSON and an incremental `summary.json`. A failed collection is recorded
|
|
373
373
|
as failed, never as a passing score. When performance falls below the budget,
|
|
374
|
-
the terminal reports the metric that cost the most points.
|
|
374
|
+
the terminal reports the metric that cost the most points. For a Total Blocking Time miss,
|
|
375
|
+
it also shows the longest main-thread task and the audit host's CPU benchmark when available.
|
|
376
|
+
Sitemap canonical hosts are mapped onto
|
|
375
377
|
`--base` so a production sitemap can audit a local build. Set `CHROME_PATH` if
|
|
376
378
|
Chrome is not installed at a standard path. Reports retain real audits and use
|
|
377
379
|
Lighthouse default throttling.
|
|
@@ -57,6 +57,7 @@ interface ResponseShape {
|
|
|
57
57
|
/** The model's name as a person reads it: "Social Post" for `SocialPost`. */
|
|
58
58
|
modelLabel: string
|
|
59
59
|
tableName: string
|
|
60
|
+
primaryKey: string
|
|
60
61
|
rows: Array<Record<string, unknown>>
|
|
61
62
|
columns: string[]
|
|
62
63
|
displayColumns: string[]
|
|
@@ -188,6 +189,9 @@ export default new Action({
|
|
|
188
189
|
const requestedSort = queryValue(request, 'sort').trim()
|
|
189
190
|
const dir: 'asc' | 'desc' = queryValue(request, 'dir') === 'asc' ? 'asc' : 'desc'
|
|
190
191
|
const q = queryValue(request, 'q').trim()
|
|
192
|
+
const record = queryValue(request, 'record')
|
|
193
|
+
if (record.length > 512)
|
|
194
|
+
return routerResponse.json({ message: 'The record key is too long.' }, 422)
|
|
191
195
|
let filters: Record<string, ModelFilterValue>
|
|
192
196
|
try {
|
|
193
197
|
filters = parseFilters(queryValue(request, 'filters') || null)
|
|
@@ -202,6 +206,7 @@ export default new Action({
|
|
|
202
206
|
modelName,
|
|
203
207
|
modelLabel: humanizeIdentifier(modelName),
|
|
204
208
|
tableName,
|
|
209
|
+
primaryKey: 'id',
|
|
205
210
|
rows: [],
|
|
206
211
|
columns: [],
|
|
207
212
|
displayColumns: [],
|
|
@@ -247,7 +252,10 @@ export default new Action({
|
|
|
247
252
|
|
|
248
253
|
try {
|
|
249
254
|
response.tableName = String(Model.table || tableName)
|
|
250
|
-
const
|
|
255
|
+
const schemaColumns = modelSchemaColumns(Model)
|
|
256
|
+
const primaryKey = schemaColumns[0] || 'id'
|
|
257
|
+
response.primaryKey = primaryKey
|
|
258
|
+
const probe = await Model.orderByDesc(primaryKey).take(1).get() as Array<Record<string, unknown>>
|
|
251
259
|
const first = Array.isArray(probe) ? probe[0] : undefined
|
|
252
260
|
const shape = first && typeof first === 'object'
|
|
253
261
|
? ((first as { attributes?: Record<string, unknown> }).attributes ?? first)
|
|
@@ -255,9 +263,11 @@ export default new Action({
|
|
|
255
263
|
const hiddenColumns = hiddenModelColumns(Model)
|
|
256
264
|
response.columns = Object.keys(shape).filter(k => typeof k === 'string' && !k.startsWith('_') && !hiddenColumns.has(k))
|
|
257
265
|
if (response.columns.length === 0)
|
|
258
|
-
response.columns =
|
|
266
|
+
response.columns = schemaColumns.filter(column => !hiddenColumns.has(column))
|
|
259
267
|
|
|
260
268
|
const allowed = new Set(response.columns)
|
|
269
|
+
if (record && (!allowed.has(primaryKey) || (primaryKey === 'id' && !/^\d+$/.test(record))))
|
|
270
|
+
return routerResponse.json({ message: 'Record not found.' }, 404)
|
|
261
271
|
const unknownFilter = Object.keys(filters).find(column => !isSafeColumn(column, allowed))
|
|
262
272
|
if (unknownFilter)
|
|
263
273
|
return routerResponse.json({ message: `Unknown model filter column "${unknownFilter}".` }, 422)
|
|
@@ -266,7 +276,7 @@ export default new Action({
|
|
|
266
276
|
|
|
267
277
|
const sort = isSafeColumn(requestedSort, allowed)
|
|
268
278
|
? requestedSort
|
|
269
|
-
:
|
|
279
|
+
: primaryKey
|
|
270
280
|
response.sort = sort
|
|
271
281
|
const searchColumns = searchColumnsFor(allowed, first)
|
|
272
282
|
|
|
@@ -289,6 +299,8 @@ export default new Action({
|
|
|
289
299
|
|
|
290
300
|
const build = () => {
|
|
291
301
|
let chain = applyModelFilters(Model.query() as any, filters, offered.filters).query as any
|
|
302
|
+
if (record)
|
|
303
|
+
chain = chain.where(primaryKey, record)
|
|
292
304
|
if (q && searchColumns.length > 0) {
|
|
293
305
|
// Lowercased on both sides, so the search ignores case on every
|
|
294
306
|
// dialect. A model query's whereLike is a plain LIKE, which is
|
|
@@ -335,7 +347,7 @@ export default new Action({
|
|
|
335
347
|
console.warn(`[dashboard/api] ModelShowAction: could not tell which ${modelName} rows are anonymized:`, error)
|
|
336
348
|
return [] as boolean[]
|
|
337
349
|
})
|
|
338
|
-
response.anonymizedIds = response.rows.filter((_row, index) => erased[index] === true).map(row => row
|
|
350
|
+
response.anonymizedIds = response.rows.filter((_row, index) => erased[index] === true).map(row => row[primaryKey] as number | string)
|
|
339
351
|
if (response.anonymizedIds.length > 0) {
|
|
340
352
|
const personal = await personalColumns(modelName).catch(() => [] as string[])
|
|
341
353
|
response.anonymizedColumns = personal.filter(column => response.columns.includes(column))
|
|
@@ -350,7 +362,9 @@ export default new Action({
|
|
|
350
362
|
return dashboardOperationalError(error, `${modelName} records could not be loaded.`, 'ModelShowAction.query')
|
|
351
363
|
}
|
|
352
364
|
|
|
353
|
-
|
|
365
|
+
// The mutating dashboard routes still require a numeric id.
|
|
366
|
+
if (response.primaryKey === 'id')
|
|
367
|
+
response.writeCapabilities = modelWriteCapabilities(Model)
|
|
354
368
|
response.writable = Object.values(response.writeCapabilities).some(Boolean)
|
|
355
369
|
// A relation is only worth a picker when the dashboard can list the model
|
|
356
370
|
// it points at. One whose feature is off, or that is kept out of the
|
|
@@ -412,11 +426,11 @@ export default new Action({
|
|
|
412
426
|
// The model's own actions, and the rows each is for. Decided here, where
|
|
413
427
|
// the whole row is, so the page never has to be sent the rule. An erased
|
|
414
428
|
// account is offered none: there is nobody left to act on.
|
|
415
|
-
const actions = await modelActions(Model, modelName)
|
|
429
|
+
const actions = response.primaryKey === 'id' ? await modelActions(Model, modelName) : []
|
|
416
430
|
response.actions = actions.map(publicModelAction)
|
|
417
431
|
const erased = new Set((response.anonymizedIds ?? []).map(String))
|
|
418
432
|
for (const [index, row] of stored.entries()) {
|
|
419
|
-
const id = String(response.rows[index]?.
|
|
433
|
+
const id = String(response.rows[index]?.[response.primaryKey] ?? '')
|
|
420
434
|
const offered = id && !erased.has(id) ? actions.filter(action => modelActionApplies(action, row)).map(action => action.name) : []
|
|
421
435
|
if (offered.length > 0)
|
|
422
436
|
response.rowActions[id] = offered
|
|
@@ -65,6 +65,7 @@ export interface ModelColumn {
|
|
|
65
65
|
|
|
66
66
|
export interface ModelRecord {
|
|
67
67
|
modelName: string
|
|
68
|
+
primaryKey?: string
|
|
68
69
|
/** The model's table, e.g. `product_categories`. Names the list in the breadcrumb. */
|
|
69
70
|
tableName?: string
|
|
70
71
|
row: Record<string, unknown>
|
|
@@ -86,6 +87,7 @@ export interface ModelRecord {
|
|
|
86
87
|
|
|
87
88
|
interface ModelShowResponse {
|
|
88
89
|
modelName?: string
|
|
90
|
+
primaryKey?: string
|
|
89
91
|
modelLabel?: string
|
|
90
92
|
tableName?: string
|
|
91
93
|
createFields?: ModelCreateField[]
|
|
@@ -191,16 +193,18 @@ export async function fetchModelCreateForm(slug: string): Promise<ModelCreateFor
|
|
|
191
193
|
|
|
192
194
|
/** Every stored column of one record, with what an edit may change. */
|
|
193
195
|
export async function fetchModelRecord(slug: string, id: string | number): Promise<ModelRecord> {
|
|
194
|
-
const
|
|
195
|
-
const data = await dashboardApi<ModelShowResponse>(`${modelPath(slug)}
|
|
196
|
+
const params = new URLSearchParams({ per_page: '1', record: String(id) })
|
|
197
|
+
const data = await dashboardApi<ModelShowResponse>(`${modelPath(slug)}?${params}`)
|
|
196
198
|
if (data.error)
|
|
197
199
|
throw new Error(data.error)
|
|
198
|
-
const
|
|
200
|
+
const primaryKey = data.primaryKey ?? 'id'
|
|
201
|
+
const row = data.rows?.find(candidate => String(candidate[primaryKey]) === String(id))
|
|
199
202
|
if (!row)
|
|
200
203
|
throw new Error(`${data.modelName || 'Record'} ${id} was not found.`)
|
|
201
204
|
return {
|
|
202
205
|
// What the pages call the model: "Social Post", not the class name.
|
|
203
206
|
modelName: data.modelLabel || data.modelName || 'Record',
|
|
207
|
+
primaryKey,
|
|
204
208
|
tableName: data.tableName,
|
|
205
209
|
row,
|
|
206
210
|
columns: data.columnMeta ?? [],
|
|
@@ -385,7 +389,7 @@ export function modelRecordTitle(record: ModelRecord): string {
|
|
|
385
389
|
if (typeof value === 'string' && value.trim())
|
|
386
390
|
return value
|
|
387
391
|
}
|
|
388
|
-
return `${record.modelName} ${text(record.row.id)}`
|
|
392
|
+
return `${record.modelName} ${text(record.row[record.primaryKey ?? 'id'])}`
|
|
389
393
|
}
|
|
390
394
|
|
|
391
395
|
/** The record's own page. `from` is the list to go back to, when it is not the model's own. */
|
|
@@ -251,7 +251,7 @@ export function createDashboardSidebarOrder(options: {
|
|
|
251
251
|
order = acknowledged = parseSidebarOrder(result.order)
|
|
252
252
|
scope = result.scope
|
|
253
253
|
ready = true
|
|
254
|
-
message = result.warning || '
|
|
254
|
+
message = result.warning || ''
|
|
255
255
|
apply()
|
|
256
256
|
}
|
|
257
257
|
catch (error) { if (!destroyed) message = error instanceof Error ? error.message : 'Sidebar order could not be loaded.' }
|
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.647",
|
|
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.647",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@iconify-json/f7": "^1.2.2",
|
|
47
47
|
"@iconify-json/hugeicons": "^1.2.35",
|
|
48
|
-
"@stacksjs/mobile": "0.75.
|
|
48
|
+
"@stacksjs/mobile": "0.75.647",
|
|
49
49
|
"@stacksjs/sanitizer": "^0.2.908",
|
|
50
50
|
"@stacksjs/stx": "^0.2.908",
|
|
51
|
-
"@stacksjs/strings": "0.75.
|
|
51
|
+
"@stacksjs/strings": "0.75.647",
|
|
52
52
|
"@xterm/addon-fit": "^0.11.0",
|
|
53
53
|
"@xterm/xterm": "^6.0.0",
|
|
54
54
|
"ts-qr-codes": "^0.1.8",
|
|
55
|
-
"@stacksjs/support": "0.75.
|
|
56
|
-
"@stacksjs/browser": "0.75.
|
|
55
|
+
"@stacksjs/support": "0.75.647",
|
|
56
|
+
"@stacksjs/browser": "0.75.647"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -47,6 +47,7 @@ function validatePassword(): boolean {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function handleSubmit(): void {
|
|
50
|
+
if (isLoading()) return
|
|
50
51
|
if (!validateEmail() || !validatePassword())
|
|
51
52
|
return
|
|
52
53
|
|
|
@@ -119,7 +120,7 @@ function handleSubmit(): void {
|
|
|
119
120
|
:loading="isLoading()"
|
|
120
121
|
:disabled="isLoading() || !email() || !password()"
|
|
121
122
|
>
|
|
122
|
-
<span :if="isLoading()">Signing in
|
|
123
|
+
<span :if="isLoading()">Signing in…</span>
|
|
123
124
|
<span :if="!isLoading()">Sign in</span>
|
|
124
125
|
</Button>
|
|
125
126
|
</form>
|
|
@@ -18,8 +18,10 @@ function safeRedirect(): string {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
async function handleLogin(credentials: AuthUser): Promise<void> {
|
|
21
|
+
if (isLoading()) return
|
|
21
22
|
isLoading.set(true)
|
|
22
23
|
error.set('')
|
|
24
|
+
let handedOff = false
|
|
23
25
|
|
|
24
26
|
try {
|
|
25
27
|
const result = await login(credentials)
|
|
@@ -34,19 +36,22 @@ async function handleLogin(credentials: AuthUser): Promise<void> {
|
|
|
34
36
|
return
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
navigate(safeRedirect())
|
|
39
|
+
navigate(safeRedirect(), { replace: true, reload: true })
|
|
40
|
+
handedOff = true
|
|
38
41
|
}
|
|
39
42
|
catch (err) {
|
|
40
43
|
error.set(err instanceof Error ? err.message : 'An error occurred during login')
|
|
41
44
|
}
|
|
42
45
|
finally {
|
|
43
|
-
isLoading.set(false)
|
|
46
|
+
if (!handedOff) isLoading.set(false)
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
async function handleTwoFactor(code: string): Promise<void> {
|
|
51
|
+
if (isLoading() || !challengeToken()) return
|
|
48
52
|
isLoading.set(true)
|
|
49
53
|
error.set('')
|
|
54
|
+
let handedOff = false
|
|
50
55
|
|
|
51
56
|
try {
|
|
52
57
|
const result = await verifyTwoFactorLogin(challengeToken(), code)
|
|
@@ -56,17 +61,19 @@ async function handleTwoFactor(code: string): Promise<void> {
|
|
|
56
61
|
return
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
navigate(safeRedirect())
|
|
64
|
+
navigate(safeRedirect(), { replace: true, reload: true })
|
|
65
|
+
handedOff = true
|
|
60
66
|
}
|
|
61
67
|
catch (err) {
|
|
62
68
|
error.set(err instanceof Error ? err.message : 'Unable to verify the authentication code')
|
|
63
69
|
}
|
|
64
70
|
finally {
|
|
65
|
-
isLoading.set(false)
|
|
71
|
+
if (!handedOff) isLoading.set(false)
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
function restartLogin(): void {
|
|
76
|
+
if (isLoading()) return
|
|
70
77
|
challengeToken.set('')
|
|
71
78
|
error.set('')
|
|
72
79
|
}
|
|
@@ -8,7 +8,7 @@ const code = state('')
|
|
|
8
8
|
const codeError = derived(() => code() && !/^\d{6}$/.test(code()) ? 'Enter the 6-digit code from your authenticator app' : '')
|
|
9
9
|
|
|
10
10
|
function submit(): void {
|
|
11
|
-
if (!/^\d{6}$/.test(code()))
|
|
11
|
+
if (isLoading() || !/^\d{6}$/.test(code()))
|
|
12
12
|
return
|
|
13
13
|
emit('submit', code())
|
|
14
14
|
}
|
|
@@ -51,7 +51,8 @@ function submit(): void {
|
|
|
51
51
|
:loading="isLoading()"
|
|
52
52
|
:disabled="isLoading() || !/^\d{6}$/.test(code())"
|
|
53
53
|
>
|
|
54
|
-
|
|
54
|
+
<span :if="isLoading()">Verifying…</span>
|
|
55
|
+
<span :if="!isLoading()">Verify and sign in</span>
|
|
55
56
|
</Button>
|
|
56
57
|
<Button type="button" variant="ghost" size="lg" fullWidth :disabled="isLoading()" @click="emit('restart')">
|
|
57
58
|
Back to sign in
|
|
@@ -76,7 +76,10 @@ async function loadRecord(): Promise<void> {
|
|
|
76
76
|
// For a component the app placed on this page: it follows the record.
|
|
77
77
|
modelPageStore.showRecord(slug(), recordId(), loaded)
|
|
78
78
|
// Not awaited, and a page whose panels cannot be read is still the record's page.
|
|
79
|
-
|
|
79
|
+
if ((loaded.primaryKey ?? 'id') === 'id')
|
|
80
|
+
void fetchModelRelated(slug(), recordId()).then(panels => related.set(panels)).catch(() => related.set([]))
|
|
81
|
+
else
|
|
82
|
+
related.set([])
|
|
80
83
|
}
|
|
81
84
|
catch (error) {
|
|
82
85
|
record.set(null)
|
|
@@ -34,6 +34,7 @@ interface ColumnMeta {
|
|
|
34
34
|
|
|
35
35
|
interface ResponseShape {
|
|
36
36
|
modelName: string
|
|
37
|
+
primaryKey?: string
|
|
37
38
|
modelLabel?: string
|
|
38
39
|
tableName: string
|
|
39
40
|
rows: Array<Record<string, unknown>>
|
|
@@ -82,7 +83,12 @@ const modelName = state('')
|
|
|
82
83
|
// The class name, for the one message that tells a developer what was looked for.
|
|
83
84
|
const modelClass = state('')
|
|
84
85
|
const tableName = state('')
|
|
86
|
+
const primaryKey = state('id')
|
|
85
87
|
const rows = state<Array<Record<string, unknown>>>([])
|
|
88
|
+
function rowId(row: Record<string, unknown>): string {
|
|
89
|
+
return String(row[primaryKey()] ?? '')
|
|
90
|
+
}
|
|
91
|
+
|
|
86
92
|
const anonymizedIds = state<string[]>([])
|
|
87
93
|
// Columns that hold another model's id, and what those records are called.
|
|
88
94
|
const relations = state<Record<string, ModelRelationTarget>>({})
|
|
@@ -144,7 +150,7 @@ const actionErrors = state<Record<string, string[]>>({})
|
|
|
144
150
|
const bulkActions = derived(() => modelBulkActions(actions()))
|
|
145
151
|
// A tick box is only drawn when there is something to do with a tick.
|
|
146
152
|
const selectable = derived(() => migrated() && (bulkActions().length > 0 || writeCapabilities().destroy))
|
|
147
|
-
const allSelected = derived(() => rows().length > 0 && rows().every(row => selected().includes(
|
|
153
|
+
const allSelected = derived(() => rows().length > 0 && rows().every(row => selected().includes(rowId(row))))
|
|
148
154
|
const selectionLabel = derived(() => `${selected().length} selected`)
|
|
149
155
|
const bulkBusy = derived(() => bulkProgress() !== null)
|
|
150
156
|
const bulkProgressLabel = derived(() => {
|
|
@@ -210,7 +216,7 @@ const deleteDescription = derived(() => {
|
|
|
210
216
|
const row = confirmingDelete()
|
|
211
217
|
if (!row)
|
|
212
218
|
return ''
|
|
213
|
-
return modelDeleteWarning(`Row ${row
|
|
219
|
+
return modelDeleteWarning(`Row ${rowId(row)}`, writeCapabilities().anonymize)
|
|
214
220
|
})
|
|
215
221
|
|
|
216
222
|
// While a query is in flight the rows already there stay, dimmed and out of
|
|
@@ -352,6 +358,7 @@ async function load() {
|
|
|
352
358
|
modelName.set(data.modelLabel ?? data.modelName ?? '')
|
|
353
359
|
modelClass.set(data.modelName ?? '')
|
|
354
360
|
tableName.set(data.tableName ?? '')
|
|
361
|
+
primaryKey.set(data.primaryKey ?? 'id')
|
|
355
362
|
rows.set(data.rows ?? [])
|
|
356
363
|
anonymizedIds.set((data.anonymizedIds ?? []).map(String))
|
|
357
364
|
anonymizedColumns.set(data.anonymizedColumns ?? [])
|
|
@@ -447,17 +454,17 @@ function onPerPageChange() {
|
|
|
447
454
|
// An anonymized account keeps its eye and loses its pencil and trash: there
|
|
448
455
|
// is nothing left to edit, and deleting it again changes nothing.
|
|
449
456
|
function isAnonymized(row: Record<string, unknown>): boolean {
|
|
450
|
-
return anonymizedIds().includes(
|
|
457
|
+
return anonymizedIds().includes(rowId(row))
|
|
451
458
|
}
|
|
452
459
|
|
|
453
460
|
// The eye and the pencil each open a page of the record's own, which comes
|
|
454
461
|
// back to this list wherever it is hosted.
|
|
455
462
|
function startEdit(row: Record<string, unknown>) {
|
|
456
|
-
navigate(modelRecordEditHref(slug(),
|
|
463
|
+
navigate(modelRecordEditHref(slug(), rowId(row), { from: home() || undefined }))
|
|
457
464
|
}
|
|
458
465
|
|
|
459
466
|
function startView(row: Record<string, unknown>) {
|
|
460
|
-
navigate(modelRecordHref(slug(),
|
|
467
|
+
navigate(modelRecordHref(slug(), rowId(row), home() || undefined))
|
|
461
468
|
}
|
|
462
469
|
|
|
463
470
|
// Creating has a page of its own too.
|
|
@@ -472,13 +479,13 @@ function openInvite(): void {
|
|
|
472
479
|
|
|
473
480
|
/** The model's own actions this row is offered in a list. */
|
|
474
481
|
function actionsFor(row: Record<string, unknown>): ModelCustomAction[] {
|
|
475
|
-
return modelActionsFor(actions(), rowActions(),
|
|
482
|
+
return modelActionsFor(actions(), rowActions(), rowId(row), 'row')
|
|
476
483
|
}
|
|
477
484
|
|
|
478
485
|
/** The name of the action running on this row, if one is. */
|
|
479
486
|
function runningOn(row: Record<string, unknown>): string {
|
|
480
487
|
const current = runningAction()
|
|
481
|
-
return current && current.id ===
|
|
488
|
+
return current && current.id === rowId(row) ? current.name : ''
|
|
482
489
|
}
|
|
483
490
|
|
|
484
491
|
function openActionForm(action: ModelCustomAction, row: Record<string, unknown> | null): void {
|
|
@@ -501,8 +508,8 @@ function startAction(payload: { action: ModelCustomAction, record: Record<string
|
|
|
501
508
|
async function runAction(action: ModelCustomAction, row: Record<string, unknown>, input: Record<string, unknown> = {}): Promise<void> {
|
|
502
509
|
if (runningAction())
|
|
503
510
|
return
|
|
504
|
-
runningAction.set({ name: action.name, id:
|
|
505
|
-
const result = await runModelAction(slug(),
|
|
511
|
+
runningAction.set({ name: action.name, id: rowId(row) })
|
|
512
|
+
const result = await runModelAction(slug(), rowId(row), action.name, input)
|
|
506
513
|
runningAction.set(null)
|
|
507
514
|
confirmingAction.set(null)
|
|
508
515
|
// A refusal of what was typed is answered where it was typed.
|
|
@@ -531,16 +538,16 @@ function confirmAction(): void {
|
|
|
531
538
|
}
|
|
532
539
|
|
|
533
540
|
function isSelected(row: Record<string, unknown>): boolean {
|
|
534
|
-
return selected().includes(
|
|
541
|
+
return selected().includes(rowId(row))
|
|
535
542
|
}
|
|
536
543
|
|
|
537
544
|
function toggleSelected(row: Record<string, unknown>): void {
|
|
538
|
-
const id =
|
|
545
|
+
const id = rowId(row)
|
|
539
546
|
selected.set(isSelected(row) ? selected().filter(candidate => candidate !== id) : [...selected(), id])
|
|
540
547
|
}
|
|
541
548
|
|
|
542
549
|
function toggleAllSelected(): void {
|
|
543
|
-
selected.set(allSelected() ? [] : rows().map(row =>
|
|
550
|
+
selected.set(allSelected() ? [] : rows().map(row => rowId(row)))
|
|
544
551
|
}
|
|
545
552
|
|
|
546
553
|
/** The selected rows an action is for: the server has said which rows it applies to. */
|
|
@@ -622,8 +629,8 @@ async function confirmDelete() {
|
|
|
622
629
|
if (!row) return
|
|
623
630
|
saving.set(true)
|
|
624
631
|
try {
|
|
625
|
-
const outcome = await deleteModelRecord(slug(),
|
|
626
|
-
const notice = modelDeleteNotice(`${modelName()} ${row
|
|
632
|
+
const outcome = await deleteModelRecord(slug(), rowId(row))
|
|
633
|
+
const notice = modelDeleteNotice(`${modelName()} ${rowId(row)}`, outcome)
|
|
627
634
|
pushToast('success', notice.title, { detail: notice.detail })
|
|
628
635
|
confirmingDelete.set(null)
|
|
629
636
|
// Deleting the last row of the final page would strand the viewer on an
|
|
@@ -841,7 +848,7 @@ onDestroy(() => {
|
|
|
841
848
|
<td :if="selectable()" class="pl-3 pr-1 py-2 w-8">
|
|
842
849
|
<input
|
|
843
850
|
type="checkbox"
|
|
844
|
-
:aria-label="'Select ' + modelName() + ' ' + row
|
|
851
|
+
:aria-label="'Select ' + modelName() + ' ' + rowId(row)"
|
|
845
852
|
:checked="isSelected(row)"
|
|
846
853
|
:disabled="bulkBusy()"
|
|
847
854
|
class="block h-4 w-4 text-blue-600 border-neutral-300 rounded"
|
|
@@ -57,7 +57,7 @@ const buttonClass = [
|
|
|
57
57
|
'transition-all duration-150',
|
|
58
58
|
'select-none',
|
|
59
59
|
'focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/40 focus-visible:ring-offset-0',
|
|
60
|
-
'disabled:opacity-40 disabled:cursor-not-allowed disabled:pointer-events-none aria-disabled:opacity-40 aria-disabled:cursor-not-allowed aria-disabled:pointer-events-none',
|
|
60
|
+
'disabled:opacity-40 disabled:cursor-not-allowed disabled:pointer-events-none aria-disabled:opacity-40 aria-disabled:cursor-not-allowed aria-disabled:pointer-events-none disabled:aria-busy:opacity-100 aria-disabled:aria-busy:opacity-100',
|
|
61
61
|
'active:scale-[0.98]',
|
|
62
62
|
interaction === 'toggle'
|
|
63
63
|
? 'aria-pressed:text-blue-700 dark:aria-pressed:text-blue-300 aria-pressed:bg-blue-50 dark:aria-pressed:bg-blue-950/40 aria-pressed:border-blue-200 dark:aria-pressed:border-blue-900'
|
|
@@ -124,7 +124,7 @@ const liveAriaExpanded = useReactiveProp('ariaExpanded', '')
|
|
|
124
124
|
:tabindex="liveDisabled() || liveLoading() ? -1 : undefined"
|
|
125
125
|
>
|
|
126
126
|
<template :if="liveLoading()">
|
|
127
|
-
<span aria-hidden="true" class="
|
|
127
|
+
<span aria-hidden="true" class="shrink-0 h-3.5 w-3.5 motion-safe:animate-spin i-hugeicons-loading-03 {{ iconOnly ? '' : '-ml-0.5 mr-1.5' }}"></span>
|
|
128
128
|
</template>
|
|
129
129
|
<slot />
|
|
130
130
|
</a>
|
|
@@ -142,7 +142,7 @@ const liveAriaExpanded = useReactiveProp('ariaExpanded', '')
|
|
|
142
142
|
:disabled="liveDisabled() || liveLoading()"
|
|
143
143
|
>
|
|
144
144
|
<template :if="liveLoading()">
|
|
145
|
-
<span aria-hidden="true" class="
|
|
145
|
+
<span aria-hidden="true" class="shrink-0 h-3.5 w-3.5 motion-safe:animate-spin i-hugeicons-loading-03 {{ iconOnly ? '' : '-ml-0.5 mr-1.5' }}"></span>
|
|
146
146
|
</template>
|
|
147
147
|
<slot />
|
|
148
148
|
</button>
|
|
@@ -160,7 +160,7 @@ const liveAriaExpanded = useReactiveProp('ariaExpanded', '')
|
|
|
160
160
|
:disabled="liveDisabled() || liveLoading()"
|
|
161
161
|
>
|
|
162
162
|
<template :if="liveLoading()">
|
|
163
|
-
<span aria-hidden="true" class="
|
|
163
|
+
<span aria-hidden="true" class="shrink-0 h-3.5 w-3.5 motion-safe:animate-spin i-hugeicons-loading-03 {{ iconOnly ? '' : '-ml-0.5 mr-1.5' }}"></span>
|
|
164
164
|
</template>
|
|
165
165
|
<slot />
|
|
166
166
|
</button>
|
|
@@ -465,18 +465,39 @@ html[data-appearance="arc"] [data-sidebar-section] > div:first-child {
|
|
|
465
465
|
place-items: center;
|
|
466
466
|
border-radius: 4px;
|
|
467
467
|
color: currentColor;
|
|
468
|
-
opacity:
|
|
468
|
+
opacity: 0;
|
|
469
|
+
pointer-events: none;
|
|
469
470
|
cursor: grab;
|
|
470
471
|
touch-action: none;
|
|
471
472
|
}
|
|
472
473
|
.dashboard-sidebar-order-grip[data-sidebar-order-handle="section"] { right: 23px; top: 7px; }
|
|
473
474
|
[data-section-id="top"] > .dashboard-sidebar-order-grip { right: 1px; top: 2px; }
|
|
474
475
|
.dashboard-sidebar-order-grip > span { display: block; width: 14px; height: 14px; }
|
|
475
|
-
.dashboard-sidebar-order-grip
|
|
476
|
+
[data-dashboard-sidebar-order]:has([data-sidebar-order-editing="true"]) .dashboard-sidebar-order-grip,
|
|
477
|
+
[data-sidebar-row]:has(> [data-sidebar-item]:focus-visible) > .dashboard-sidebar-order-grip,
|
|
478
|
+
[data-sidebar-section]:has(> [data-sidebar-section-header]:focus-visible) > .dashboard-sidebar-order-grip,
|
|
479
|
+
.dashboard-sidebar-order-grip:focus-visible { opacity: .72; pointer-events: auto; }
|
|
476
480
|
.dashboard-sidebar-order-grip:focus-visible { opacity: 1; background: rgba(127, 127, 127, .16); }
|
|
477
481
|
.dashboard-sidebar-order-grip:focus-visible { outline: 2px solid #3b82f6; outline-offset: -2px; }
|
|
478
|
-
.dashboard-sidebar-order-grip:disabled { cursor: wait;
|
|
479
|
-
[data-order-dragging="true"] > .dashboard-sidebar-order-grip { cursor: grabbing; opacity: 1; }
|
|
482
|
+
.dashboard-sidebar-order-grip:disabled { cursor: wait; }
|
|
483
|
+
[data-order-dragging="true"] > .dashboard-sidebar-order-grip { cursor: grabbing; opacity: 1; pointer-events: auto; }
|
|
484
|
+
@media (any-hover: hover) {
|
|
485
|
+
[data-sidebar-row]:hover > .dashboard-sidebar-order-grip,
|
|
486
|
+
[data-sidebar-section]:has(> :first-child:hover) > .dashboard-sidebar-order-grip,
|
|
487
|
+
.dashboard-sidebar-order-grip:hover { opacity: .72; pointer-events: auto; }
|
|
488
|
+
.dashboard-sidebar-order-grip:hover { opacity: 1; background: rgba(127, 127, 127, .16); }
|
|
489
|
+
}
|
|
490
|
+
@media (pointer: coarse) {
|
|
491
|
+
.dashboard-sidebar-order-mode { min-height: 44px; }
|
|
492
|
+
[data-dashboard-sidebar-order]:has([data-sidebar-order-editing="true"]) [data-sidebar-item],
|
|
493
|
+
[data-dashboard-sidebar-order]:has([data-sidebar-order-editing="true"]) [data-sidebar-section-header] { min-height: 44px; }
|
|
494
|
+
[data-dashboard-sidebar-order]:has([data-sidebar-order-editing="true"]) [data-sidebar-item] { padding-right: 50px; }
|
|
495
|
+
[data-dashboard-sidebar-order]:has([data-sidebar-order-editing="true"]) [data-sidebar-section-header] { padding-right: 68px; }
|
|
496
|
+
[data-dashboard-sidebar-order]:has([data-sidebar-order-editing="true"]) .dashboard-sidebar-order-grip { top: 0; width: 44px; height: 44px; }
|
|
497
|
+
}
|
|
498
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
499
|
+
.dashboard-sidebar-order-grip { transition: opacity 120ms ease; }
|
|
500
|
+
}
|
|
480
501
|
[data-order-drop="before"] { box-shadow: 0 -2px #3b82f6; }
|
|
481
502
|
[data-order-drop="after"] { box-shadow: 0 2px #3b82f6; }
|
|
482
503
|
</style>
|
|
@@ -533,6 +554,7 @@ const route = useRoute()
|
|
|
533
554
|
const sidebarHost = useRef('dashboardSidebarHost')
|
|
534
555
|
const mobileSidebarHost = useRef('dashboardMobileSidebarHost')
|
|
535
556
|
const sidebarOrderStatus = state({ ready: false, saving: false, custom: false, message: 'Loading sidebar order…' })
|
|
557
|
+
const sidebarReordering = state(false)
|
|
536
558
|
const sidebarOrder = createDashboardSidebarOrder({
|
|
537
559
|
pane: () => sidebarPanes()[0],
|
|
538
560
|
sections: sidebarSections,
|
|
@@ -703,6 +725,7 @@ function showSidebarInDrawer() {
|
|
|
703
725
|
// markup is already gone by now, so the Sidebar is put back from the
|
|
704
726
|
// reference kept above rather than looked up.
|
|
705
727
|
function returnSidebarFromDrawer() {
|
|
728
|
+
sidebarReordering.set(false)
|
|
706
729
|
if (!lentSidebar) return
|
|
707
730
|
const { element, parent, next } = lentSidebar
|
|
708
731
|
lentSidebar = null
|
|
@@ -777,8 +800,9 @@ onDestroy(() => {
|
|
|
777
800
|
@endif
|
|
778
801
|
</template>
|
|
779
802
|
<template #footer>
|
|
780
|
-
<div class="px-3 py-2 text-neutral-600 text-xs dark:text-neutral-300" data-sidebar-order-controls>
|
|
803
|
+
<div class="px-3 py-2 text-neutral-600 text-xs dark:text-neutral-300" data-sidebar-order-controls :data-sidebar-order-editing="sidebarReordering() ? 'true' : 'false'">
|
|
781
804
|
<p role="status" aria-live="polite" :text="sidebarOrderStatus.message"></p>
|
|
805
|
+
<Button :if="sidebarOrderStatus.ready" class="dashboard-sidebar-order-mode" variant="ghost" size="xs" @click="sidebarReordering.set(!sidebarReordering())">{{ sidebarReordering() ? 'Done reordering' : 'Reorder sidebar' }}</Button>
|
|
782
806
|
<Button :if="!sidebarOrderStatus.ready" variant="ghost" size="xs" @click="sidebarOrder.load()">Retry loading order</Button>
|
|
783
807
|
<Button :if="sidebarOrderStatus.ready" variant="ghost" size="xs" :disabled="sidebarOrderStatus.saving" @click="sidebarOrder.reset()">Reset order</Button>
|
|
784
808
|
</div>
|