@stacksjs/defaults 0.75.552 → 0.75.555
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-actions/SKILL.md +1 -1
- package/ai/skills/stacks-dashboard/SKILL.md +347 -14
- package/ai/skills/stacks-desktop/SKILL.md +19 -0
- package/ai/skills/stacks-models/SKILL.md +19 -0
- package/ai/skills/stacks-native/CATALOG.md +5 -5
- package/app/Actions/Dashboard/Content/file-manager.ts +9 -3
- package/app/Actions/Dashboard/Data/SubscriberIndexAction.ts +6 -3
- package/app/Actions/Dashboard/Data/TeamIndexAction.ts +6 -3
- package/app/Actions/Dashboard/Data/UserIndexAction.ts +6 -3
- package/app/Actions/Dashboard/Data/data-records.ts +12 -0
- package/app/Actions/Dashboard/Models/ModelActionRunAction.ts +77 -0
- package/app/Actions/Dashboard/Models/ModelMarkdownAction.ts +42 -0
- package/app/Actions/Dashboard/Models/ModelShowAction.ts +63 -21
- package/app/Actions/Dashboard/Models/ModelUploadAction.ts +83 -0
- package/app/Actions/Dashboard/Models/model-actions.ts +393 -0
- package/app/Actions/Dashboard/Models/model-fields.ts +198 -0
- package/app/Actions/Dashboard/Models/model-forms.ts +36 -0
- package/app/Actions/Dashboard/Models/model-related.ts +62 -11
- package/app/Actions/Dashboard/Models/model-upload.ts +81 -0
- package/app/Actions/Dashboard/Models/model-write.ts +92 -5
- package/app/Actions/Dashboard/Users/UserPasswordResetAction.ts +50 -0
- package/app/Actions/Desktop/UpdateArtifactAction.ts +37 -0
- package/app/Models/CardAttachment.ts +5 -0
- package/app/Models/Deployment.ts +5 -0
- package/app/Models/QueryLog.ts +5 -0
- package/app/Models/Request.ts +4 -0
- package/app/Models/Team.ts +4 -0
- package/app/Models/User.ts +18 -0
- package/functions/dashboard-markdown.ts +132 -0
- package/functions/dashboard-model-bulk.ts +224 -0
- package/functions/dashboard-model-format.ts +201 -0
- package/functions/dashboard-model-record.test.ts +53 -30
- package/functions/dashboard-model-record.ts +267 -19
- package/functions/data.ts +9 -0
- package/ide/vscode/package.json +1 -1
- package/package.json +3 -3
- package/resources/components/Dashboard/Data/ActivityLog.stx +212 -0
- package/resources/components/Dashboard/Data/DataModelRecords.stx +89 -0
- package/resources/components/Dashboard/Models/ModelActionForm.stx +85 -0
- package/resources/components/Dashboard/Models/ModelBadge.stx +22 -0
- package/resources/components/Dashboard/Models/ModelFieldInputs.stx +43 -9
- package/resources/components/Dashboard/Models/ModelMarkdownInput.stx +139 -0
- package/resources/components/Dashboard/Models/ModelRecordActions.stx +32 -1
- package/resources/components/Dashboard/Models/ModelRecordCreate.stx +1 -1
- package/resources/components/Dashboard/Models/ModelRecordDetail.stx +114 -7
- package/resources/components/Dashboard/Models/ModelRecordEdit.stx +1 -1
- package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +387 -20
- package/resources/components/Dashboard/Models/ModelRelatedPanels.stx +197 -27
- package/resources/components/Dashboard/Models/ModelRelationPicker.stx +3 -0
- package/resources/components/Dashboard/Models/ModelUploadInput.stx +97 -0
- package/routes/dashboard-api.ts +9 -0
- package/routes/desktop-updates.ts +7 -0
- package/views/dashboard/data/activity/index.stx +1 -1
- package/views/dashboard/data/subscribers.stx +1 -3
- package/views/dashboard/data/teams.stx +1 -3
- package/views/dashboard/data/users.stx +1 -3
- package/resources/components/Dashboard/Data/DataRecords.stx +0 -427
|
@@ -1,12 +1,43 @@
|
|
|
1
1
|
<script client>
|
|
2
|
+
import type { ModelCustomAction } from '../../../../functions/dashboard-model-record'
|
|
3
|
+
import { modelActionIconClass } from '../../../../functions/dashboard-model-record'
|
|
4
|
+
|
|
2
5
|
const record = useReactiveProp('record', {} as Record<string, unknown>)
|
|
3
6
|
const modelName = useReactiveProp('modelName', 'Record')
|
|
4
7
|
const canUpdate = useReactiveProp('canUpdate', false)
|
|
5
8
|
const canDestroy = useReactiveProp('canDestroy', false)
|
|
6
|
-
|
|
9
|
+
// The model's own actions this row is offered: `dashboard.actions`, narrowed
|
|
10
|
+
// by the server to the ones this record's values allow.
|
|
11
|
+
const actions = useReactiveProp('actions', [] as ModelCustomAction[])
|
|
12
|
+
// The one that is running, by name, on this row.
|
|
13
|
+
const running = useReactiveProp('running', '')
|
|
14
|
+
const emit = defineEmits(['view', 'edit', 'delete', 'action'])
|
|
15
|
+
|
|
16
|
+
// The loop below is on a wrapper and not on the button itself, as the shared
|
|
17
|
+
// table's row actions are. This component is drawn once per row of a list,
|
|
18
|
+
// and a loop placed on a component inside one does not hand its item to what
|
|
19
|
+
// the component wraps: the icon's class came out empty.
|
|
20
|
+
function iconClass(action: ModelCustomAction): string {
|
|
21
|
+
return running() === action.name
|
|
22
|
+
? 'h-4 w-4 text-neutral-400 animate-spin i-hugeicons-loading-03'
|
|
23
|
+
: modelActionIconClass(action)
|
|
24
|
+
}
|
|
7
25
|
</script>
|
|
8
26
|
|
|
9
27
|
<div class="flex gap-1 items-center justify-end">
|
|
28
|
+
<span :for="action in actions()" class="contents">
|
|
29
|
+
<Button
|
|
30
|
+
variant="ghost"
|
|
31
|
+
size="sm"
|
|
32
|
+
iconOnly
|
|
33
|
+
:disabled="running() !== ''"
|
|
34
|
+
:ariaLabel="action.label + ': ' + modelName() + ' ' + record().id"
|
|
35
|
+
:title="action.label"
|
|
36
|
+
@click="emit('action', { action, record: record() })"
|
|
37
|
+
>
|
|
38
|
+
<span aria-hidden="true" :class="iconClass(action)"></span>
|
|
39
|
+
</Button>
|
|
40
|
+
</span>
|
|
10
41
|
<Button
|
|
11
42
|
variant="ghost"
|
|
12
43
|
size="sm"
|
|
@@ -138,7 +138,7 @@ onMount(() => {
|
|
|
138
138
|
<p class="mt-1 text-neutral-500 text-xs dark:text-neutral-400">The fields a new {{ modelName().toLowerCase() }} can be given. Anything else is set by the application.</p>
|
|
139
139
|
</div>
|
|
140
140
|
<div class="p-6">
|
|
141
|
-
<ModelFieldInputs :fields="fields()" :values="values()" :errors="createErrors()" :disabled="creating()" @change="setValue" />
|
|
141
|
+
<ModelFieldInputs :fields="fields()" :slug="slug()" :values="values()" :errors="createErrors()" :disabled="creating()" @change="setValue" />
|
|
142
142
|
</div>
|
|
143
143
|
</Card>
|
|
144
144
|
</div>
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
// leads. A breadcrumb back to the list, "View User", and the record's fields
|
|
4
4
|
// as titled cards two across: what it is, its settings, its identifiers and
|
|
5
5
|
// its timestamps, each field a label over its value. Edit (which opens the
|
|
6
|
-
// record's edit page) and Delete appear where the model
|
|
7
|
-
//
|
|
6
|
+
// record's edit page) and Delete appear where the model allows them, and so
|
|
7
|
+
// do the model's own actions ("Mark as shipped"), each a button that runs an
|
|
8
|
+
// action of the app's. A page rather than a dialog, so a record has an
|
|
9
|
+
// address to share, open in a tab and come back to.
|
|
8
10
|
import { useNavigation } from '@stacksjs/defaults/views/dashboard/composables/useNavigation'
|
|
9
|
-
import type { ModelRecord, ModelRelatedPanel } from '../../../../functions/dashboard-model-record'
|
|
10
|
-
import { deleteModelRecord, fetchModelRecord, fetchModelRelated, modelDeleteNotice, modelDeleteWarning, modelRecordBackHref, modelRecordEditHref, modelRecordHref, modelRecordListLabel, modelRecordSections, modelRecordTitle } from '../../../../functions/dashboard-model-record'
|
|
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'
|
|
11
13
|
import { pushToast } from '../../../../functions/toasts'
|
|
12
14
|
|
|
13
15
|
const navigation = useNavigation()
|
|
@@ -16,6 +18,14 @@ const loading = state(true)
|
|
|
16
18
|
const loadError = state('')
|
|
17
19
|
const confirmingDelete = state(false)
|
|
18
20
|
const working = state(false)
|
|
21
|
+
// One of the model's own actions, waiting on its confirmation.
|
|
22
|
+
const confirmingAction = state<ModelCustomAction | null>(null)
|
|
23
|
+
// The action that is running, by name: its button waits, the others stay.
|
|
24
|
+
const running = state('')
|
|
25
|
+
// One that takes input, with its form open, and what its last try was refused for.
|
|
26
|
+
const askingAction = state<ModelCustomAction | null>(null)
|
|
27
|
+
const actionError = state('')
|
|
28
|
+
const actionErrors = state<Record<string, string[]>>({})
|
|
19
29
|
|
|
20
30
|
// `/models/{slug}/{id}`: the last two segments of the address.
|
|
21
31
|
function slug(): string {
|
|
@@ -43,6 +53,9 @@ const sections = derived(() => record() ? modelRecordSections(record()!) : [])
|
|
|
43
53
|
// would only anonymize what already is. The note below says what it is.
|
|
44
54
|
const canEdit = derived(() => Boolean(record()?.writeCapabilities.update) && !record()?.anonymized)
|
|
45
55
|
const canDelete = derived(() => Boolean(record()?.writeCapabilities.destroy) && !record()?.anonymized)
|
|
56
|
+
// The model's own actions this record is offered: the server has already
|
|
57
|
+
// left out the ones its `when` rules out.
|
|
58
|
+
const actions = derived(() => record()?.actions ?? [])
|
|
46
59
|
|
|
47
60
|
async function loadRecord(): Promise<void> {
|
|
48
61
|
loading.set(true)
|
|
@@ -63,6 +76,12 @@ async function loadRecord(): Promise<void> {
|
|
|
63
76
|
}
|
|
64
77
|
}
|
|
65
78
|
|
|
79
|
+
// A row was added, changed or removed in a panel: the panels are read again.
|
|
80
|
+
// The record is left as it is on screen; only what points at it changed.
|
|
81
|
+
function reloadRelated(): void {
|
|
82
|
+
void fetchModelRelated(slug(), recordId()).then(panels => related.set(panels)).catch(() => {})
|
|
83
|
+
}
|
|
84
|
+
|
|
66
85
|
// The edit page comes back here after saving or cancelling.
|
|
67
86
|
function editRecord(): void {
|
|
68
87
|
navigate(modelRecordEditHref(slug(), recordId(), { from: backHref() === from ? from : undefined, via: 'view' }))
|
|
@@ -88,6 +107,61 @@ async function deleteRecord(): Promise<void> {
|
|
|
88
107
|
}
|
|
89
108
|
}
|
|
90
109
|
|
|
110
|
+
// An action that takes input opens its form, one that asks first its
|
|
111
|
+
// confirmation, and any other runs.
|
|
112
|
+
function startAction(action: ModelCustomAction): void {
|
|
113
|
+
if (modelActionAsks(action)) {
|
|
114
|
+
actionError.set('')
|
|
115
|
+
actionErrors.set({})
|
|
116
|
+
askingAction.set(action)
|
|
117
|
+
}
|
|
118
|
+
else if (action.confirm) {
|
|
119
|
+
confirmingAction.set(action)
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
void runAction(action)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function runAction(action: ModelCustomAction, input: Record<string, unknown> = {}): Promise<void> {
|
|
127
|
+
if (running())
|
|
128
|
+
return
|
|
129
|
+
running.set(action.name)
|
|
130
|
+
const result = await runModelAction(slug(), recordId(), action.name, input)
|
|
131
|
+
running.set('')
|
|
132
|
+
confirmingAction.set(null)
|
|
133
|
+
// A refusal of what was typed is answered where it was typed: the form
|
|
134
|
+
// stays open with the reason, under the field it is about.
|
|
135
|
+
if (!result.ok && askingAction()) {
|
|
136
|
+
actionError.set(result.error)
|
|
137
|
+
actionErrors.set(result.errors ?? {})
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
askingAction.set(null)
|
|
141
|
+
const notice = modelActionNotice(action, result)
|
|
142
|
+
pushToast(notice.tone, notice.title, { detail: notice.detail })
|
|
143
|
+
if (!result.ok)
|
|
144
|
+
return
|
|
145
|
+
if (result.redirect)
|
|
146
|
+
navigate(result.redirect)
|
|
147
|
+
else
|
|
148
|
+
// What the action changed is what the page should now show, and which
|
|
149
|
+
// actions the record is still offered may have changed with it.
|
|
150
|
+
await loadRecord()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function confirmAction(): void {
|
|
154
|
+
const action = confirmingAction()
|
|
155
|
+
if (action)
|
|
156
|
+
void runAction(action)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function submitAction(input: Record<string, unknown>): void {
|
|
160
|
+
const action = askingAction()
|
|
161
|
+
if (action)
|
|
162
|
+
void runAction(action, input)
|
|
163
|
+
}
|
|
164
|
+
|
|
91
165
|
onMount(() => {
|
|
92
166
|
void loadRecord()
|
|
93
167
|
})
|
|
@@ -103,7 +177,11 @@ onMount(() => {
|
|
|
103
177
|
</nav>
|
|
104
178
|
<h1 class="font-bold text-3xl text-neutral-900 tracking-tight truncate dark:text-white">View {{ modelName() }}</h1>
|
|
105
179
|
</div>
|
|
106
|
-
<div :if="record()" class="flex flex-
|
|
180
|
+
<div :if="record()" class="flex flex-wrap gap-2 items-center sm:justify-end">
|
|
181
|
+
<Button :for="action in actions()" variant="outline" :disabled="running() !== ''" @click="startAction(action)">
|
|
182
|
+
<span aria-hidden="true" :class="running() === action.name ? 'h-4 w-4 animate-spin i-hugeicons-loading-03' : modelActionIconClass(action)"></span>
|
|
183
|
+
{{ action.label }}
|
|
184
|
+
</Button>
|
|
107
185
|
<Button :if="canDelete()" variant="outline" @click="confirmingDelete.set(true)">
|
|
108
186
|
<span aria-hidden="true" class="h-4 w-4 text-red-500 i-hugeicons-delete-02"></span>
|
|
109
187
|
Delete
|
|
@@ -139,13 +217,21 @@ onMount(() => {
|
|
|
139
217
|
<span aria-hidden="true" :class="detail.yes ? 'h-5 w-5 text-green-600 dark:text-green-400 i-hugeicons-checkmark-circle-02' : 'h-5 w-5 text-neutral-400 dark:text-neutral-500 i-hugeicons-cancel-circle'"></span>
|
|
140
218
|
{{ detail.value }}
|
|
141
219
|
</span>
|
|
142
|
-
<
|
|
220
|
+
<ModelBadge :if="detail.kind === 'badge'" :text="detail.value" :tone="detail.tone || 'neutral'" />
|
|
143
221
|
<pre :if="detail.kind === 'json'" class="overflow-x-auto p-3 font-mono text-neutral-800 text-xs dark:text-neutral-200 bg-neutral-50 dark:bg-neutral-900 rounded-lg">{{ detail.value }}</pre>
|
|
144
222
|
<StxLink :if="detail.kind === 'link'" :to="detail.href" class="inline-flex gap-1.5 items-center font-medium text-blue-600 dark:text-blue-400 hover:underline">
|
|
145
223
|
{{ detail.value }}
|
|
146
224
|
<span aria-hidden="true" class="h-3.5 w-3.5 i-hugeicons-arrow-right-01"></span>
|
|
147
225
|
</StxLink>
|
|
148
|
-
<
|
|
226
|
+
<a :if="detail.kind === 'external'" :href="detail.href" target="_blank" rel="noopener noreferrer" class="inline-flex gap-1.5 items-center max-w-full font-medium text-blue-600 dark:text-blue-400 hover:underline">
|
|
227
|
+
<span class="truncate">{{ detail.value }}</span>
|
|
228
|
+
<span aria-hidden="true" class="flex-none h-3.5 w-3.5 i-hugeicons-link-square-02"></span>
|
|
229
|
+
</a>
|
|
230
|
+
<a :if="detail.kind === 'image'" :href="detail.href" target="_blank" rel="noopener noreferrer" class="inline-block">
|
|
231
|
+
<img :src="detail.href" :alt="detail.label" loading="lazy" class="object-contain max-h-40 max-w-full bg-neutral-100 dark:bg-neutral-800 border border-neutral-200 rounded-lg dark:border-neutral-700" />
|
|
232
|
+
</a>
|
|
233
|
+
<code :if="detail.kind === 'code'" class="px-1.5 py-0.5 break-all font-mono text-[13px] text-neutral-800 dark:text-neutral-200 bg-neutral-100 dark:bg-neutral-800 rounded">{{ detail.value }}</code>
|
|
234
|
+
<span :if="detail.kind === 'text'" :class="detail.empty ? 'text-neutral-400 dark:text-neutral-500' : 'break-words whitespace-pre-line text-neutral-700 dark:text-neutral-200'">{{ detail.value }}</span>
|
|
149
235
|
</dd>
|
|
150
236
|
</div>
|
|
151
237
|
</dl>
|
|
@@ -158,6 +244,7 @@ onMount(() => {
|
|
|
158
244
|
:panels="related()"
|
|
159
245
|
:parentId="recordId()"
|
|
160
246
|
:from="selfHref()"
|
|
247
|
+
@changed="reloadRelated"
|
|
161
248
|
/>
|
|
162
249
|
|
|
163
250
|
<ConfirmDialog
|
|
@@ -169,4 +256,24 @@ onMount(() => {
|
|
|
169
256
|
@close="confirmingDelete.set(false)"
|
|
170
257
|
@confirm="deleteRecord"
|
|
171
258
|
/>
|
|
259
|
+
|
|
260
|
+
<ConfirmDialog
|
|
261
|
+
:isOpen="Boolean(confirmingAction())"
|
|
262
|
+
:title="(confirmingAction()?.label || 'Run this action') + '?'"
|
|
263
|
+
:description="confirmingAction()?.confirm || ''"
|
|
264
|
+
:variant="confirmingAction()?.destructive ? 'danger' : 'warning'"
|
|
265
|
+
:busy="running() !== ''"
|
|
266
|
+
:confirmLabel="confirmingAction()?.label || 'Run'"
|
|
267
|
+
@close="confirmingAction.set(null)"
|
|
268
|
+
@confirm="confirmAction"
|
|
269
|
+
/>
|
|
270
|
+
|
|
271
|
+
<ModelActionForm
|
|
272
|
+
:action="askingAction()"
|
|
273
|
+
:busy="running() !== ''"
|
|
274
|
+
:error="actionError()"
|
|
275
|
+
:errors="actionErrors()"
|
|
276
|
+
@close="askingAction.set(null)"
|
|
277
|
+
@submit="submitAction"
|
|
278
|
+
/>
|
|
172
279
|
</div>
|
|
@@ -154,7 +154,7 @@ onMount(() => {
|
|
|
154
154
|
<Card padding="none">
|
|
155
155
|
<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">{{ modelName() }} Details</h2>
|
|
156
156
|
<div class="p-6">
|
|
157
|
-
<ModelFieldInputs :fields="writable()" :values="values()" :errors="saveErrors()" :disabled="saving()" @change="setValue" />
|
|
157
|
+
<ModelFieldInputs :fields="writable()" :slug="slug()" :values="values()" :errors="saveErrors()" :disabled="saving()" @change="setValue" />
|
|
158
158
|
</div>
|
|
159
159
|
</Card>
|
|
160
160
|
|