@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
|
@@ -3,16 +3,36 @@
|
|
|
3
3
|
// team's members and its invitations, a user's team memberships. From the
|
|
4
4
|
// model's own `hasMany` and `hasOne`, so nothing is set up per model.
|
|
5
5
|
//
|
|
6
|
-
// Each panel is the newest few with a count. The eye opens one
|
|
7
|
-
// opens that model's list narrowed to this record
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
// Each panel is the newest few with a count. The eye opens one and "View
|
|
7
|
+
// all" opens that model's list narrowed to this record.
|
|
8
|
+
//
|
|
9
|
+
// Where the related model lets the dashboard write its rows, they are managed
|
|
10
|
+
// here: "Add" and the pencil open a form over the page, with this record
|
|
11
|
+
// already chosen, and the trash asks first. Each save is one write through
|
|
12
|
+
// the related model, on its own, and the panels are read again after it.
|
|
13
|
+
import { modelFormattedValue } from '../../../../functions/dashboard-model-format'
|
|
14
|
+
import type { ModelFormValues, ModelRelatedEditor, ModelRelatedPanel } from '../../../../functions/dashboard-model-record'
|
|
15
|
+
import { deleteModelRecord, modelDeleteNotice, modelDeleteWarning, modelFormValues, modelRecordHref, modelRelatedAddsHere, modelRelatedCreateHref, modelRelatedListHref, modelRelatedRowActions, saveModelRelated } from '../../../../functions/dashboard-model-record'
|
|
16
|
+
import { pushToast } from '../../../../functions/toasts'
|
|
11
17
|
|
|
12
18
|
const panels = useReactiveProp<ModelRelatedPanel[]>('panels', [])
|
|
13
19
|
const parentId = useReactiveProp('parentId', '')
|
|
14
20
|
/** This page, for a create form to come back to. */
|
|
15
21
|
const from = useReactiveProp('from', '')
|
|
22
|
+
// Told when a row was added, changed or removed, so the page reads its panels again.
|
|
23
|
+
const emit = defineEmits(['changed'])
|
|
24
|
+
|
|
25
|
+
// The form over the page: a new row, or one being edited.
|
|
26
|
+
const editor = state<ModelRelatedEditor | null>(null)
|
|
27
|
+
const values = state<ModelFormValues>({})
|
|
28
|
+
/** What the form started with, so an edit sends only what was changed. */
|
|
29
|
+
const initial = state<ModelFormValues>({})
|
|
30
|
+
const saving = state(false)
|
|
31
|
+
const saveError = state('')
|
|
32
|
+
const saveErrors = state<Record<string, string[]>>({})
|
|
33
|
+
// The row waiting on its delete confirmation.
|
|
34
|
+
const removing = state<{ panel: ModelRelatedPanel, row: Record<string, unknown> } | null>(null)
|
|
35
|
+
const deleting = state(false)
|
|
16
36
|
|
|
17
37
|
/** Beside the heading. Nothing when the panel is empty: the line below already says so. */
|
|
18
38
|
function countLabel(panel: ModelRelatedPanel): string {
|
|
@@ -22,12 +42,12 @@ function countLabel(panel: ModelRelatedPanel): string {
|
|
|
22
42
|
}
|
|
23
43
|
|
|
24
44
|
/**
|
|
25
|
-
* The
|
|
26
|
-
* points at (a membership by its list), and "View Enterprise Leads"
|
|
27
|
-
* promise the list, not the membership.
|
|
45
|
+
* The row's buttons, named for what they act on. A row is often called by a
|
|
46
|
+
* record it points at (a membership by its list), and "View Enterprise Leads"
|
|
47
|
+
* would promise the list, not the membership.
|
|
28
48
|
*/
|
|
29
|
-
function
|
|
30
|
-
return
|
|
49
|
+
function rowActions(panel: ModelRelatedPanel) {
|
|
50
|
+
return modelRelatedRowActions(panel)
|
|
31
51
|
}
|
|
32
52
|
|
|
33
53
|
function emptyTitle(panel: ModelRelatedPanel): string {
|
|
@@ -39,30 +59,143 @@ function canAdd(panel: ModelRelatedPanel): boolean {
|
|
|
39
59
|
return panel.canCreate && (panel.kind === 'many' || panel.total === 0)
|
|
40
60
|
}
|
|
41
61
|
|
|
62
|
+
/** The formats the shared table draws itself, by the column type it knows them as. */
|
|
63
|
+
const TABLE_TYPES: Record<string, 'badge' | 'currency' | 'date' | 'datetime' | 'number'> = { badge: 'badge', date: 'date', datetime: 'datetime', money: 'currency', number: 'number' }
|
|
64
|
+
|
|
65
|
+
/** A column whose value this panel words before the table sees it: a size, a duration, a share. */
|
|
66
|
+
function worded(column: ModelRelatedPanel['columns'][number]): boolean {
|
|
67
|
+
return Boolean(column.format) && !TABLE_TYPES[column.format!.format]
|
|
68
|
+
}
|
|
69
|
+
|
|
42
70
|
function tableColumns(panel: ModelRelatedPanel) {
|
|
43
|
-
return panel.columns.map((column, index) =>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
type
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
:
|
|
53
|
-
|
|
71
|
+
return panel.columns.map((column, index) => {
|
|
72
|
+
// The related model's own say on how a value reads comes first.
|
|
73
|
+
const type = column.format ? TABLE_TYPES[column.format.format] ?? 'text' : column.type
|
|
74
|
+
const numeric = type === 'currency' || type === 'number' || ['bytes', 'duration', 'percent'].includes(column.format?.format ?? '')
|
|
75
|
+
return {
|
|
76
|
+
key: column.key,
|
|
77
|
+
label: column.label,
|
|
78
|
+
type,
|
|
79
|
+
...(type === 'currency' ? { currency: column.format?.currency, currencyKey: column.format?.currencyColumn } : {}),
|
|
80
|
+
align: type === 'datetime' || type === 'date' || numeric ? 'right' : 'left',
|
|
81
|
+
sortable: false,
|
|
82
|
+
emptyText: '-',
|
|
83
|
+
class: index === 0
|
|
84
|
+
? 'font-medium text-neutral-900 dark:text-white'
|
|
85
|
+
: type === 'datetime' || type === 'date' ? 'text-neutral-500 text-xs whitespace-nowrap dark:text-neutral-400' : 'text-neutral-600 dark:text-neutral-300',
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The panel's rows, with the values the table cannot word itself already worded. */
|
|
91
|
+
function tableRows(panel: ModelRelatedPanel) {
|
|
92
|
+
const columns = panel.columns.filter(worded)
|
|
93
|
+
if (columns.length === 0)
|
|
94
|
+
return panel.rows
|
|
95
|
+
return panel.rows.map((row) => {
|
|
96
|
+
const shown = { ...row }
|
|
97
|
+
for (const column of columns)
|
|
98
|
+
shown[column.key] = modelFormattedValue(row[column.key], column.format!, row)?.text ?? ''
|
|
99
|
+
return shown
|
|
100
|
+
})
|
|
54
101
|
}
|
|
55
102
|
|
|
56
|
-
function
|
|
57
|
-
|
|
103
|
+
function act(panel: ModelRelatedPanel, payload: { action: string, row: Record<string, unknown> }): void {
|
|
104
|
+
if (payload.action === 'edit')
|
|
105
|
+
edit(panel, payload.row)
|
|
106
|
+
else if (payload.action === 'delete')
|
|
107
|
+
removing.set({ panel, row: payload.row })
|
|
108
|
+
else
|
|
109
|
+
navigate(modelRecordHref(panel.slug, payload.row.id as number | string))
|
|
58
110
|
}
|
|
59
111
|
|
|
112
|
+
function openEditor(next: ModelRelatedEditor, start: ModelFormValues): void {
|
|
113
|
+
initial.set(start)
|
|
114
|
+
values.set({ ...start })
|
|
115
|
+
saveError.set('')
|
|
116
|
+
saveErrors.set({})
|
|
117
|
+
editor.set(next)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function edit(panel: ModelRelatedPanel, row: Record<string, unknown>): void {
|
|
121
|
+
const id = row.id as number | string
|
|
122
|
+
openEditor({ panel, id }, modelFormValues(panel.fields ?? [], panel.values?.[String(id)] ?? {}))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function closeEditor(): void {
|
|
126
|
+
if (!saving())
|
|
127
|
+
editor.set(null)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function setValue(change: { name: string, value: string | boolean }): void {
|
|
131
|
+
values.set({ ...values(), [change.name]: change.value })
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const editorTitle = derived(() => {
|
|
135
|
+
const current = editor()
|
|
136
|
+
if (!current)
|
|
137
|
+
return ''
|
|
138
|
+
return `${current.id === null ? 'Add' : 'Edit'} ${current.panel.label.toLowerCase()}`
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
async function save(): Promise<void> {
|
|
142
|
+
const current = editor()
|
|
143
|
+
if (!current || saving())
|
|
144
|
+
return
|
|
145
|
+
saving.set(true)
|
|
146
|
+
saveError.set('')
|
|
147
|
+
saveErrors.set({})
|
|
148
|
+
const result = await saveModelRelated(current, parentId(), values(), initial())
|
|
149
|
+
saving.set(false)
|
|
150
|
+
if (!result.ok) {
|
|
151
|
+
saveError.set(result.error)
|
|
152
|
+
saveErrors.set(result.errors)
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
editor.set(null)
|
|
156
|
+
if (!result.changed)
|
|
157
|
+
return
|
|
158
|
+
pushToast('success', current.id === null ? `${current.panel.label} added` : `${current.panel.label} ${current.id} updated`)
|
|
159
|
+
emit('changed')
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function remove(): Promise<void> {
|
|
163
|
+
const current = removing()
|
|
164
|
+
if (!current || deleting())
|
|
165
|
+
return
|
|
166
|
+
deleting.set(true)
|
|
167
|
+
try {
|
|
168
|
+
const outcome = await deleteModelRecord(current.panel.slug, current.row.id as number | string)
|
|
169
|
+
const notice = modelDeleteNotice(`${current.panel.label} ${current.row.id}`, outcome)
|
|
170
|
+
pushToast('success', notice.title, { detail: notice.detail })
|
|
171
|
+
removing.set(null)
|
|
172
|
+
emit('changed')
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
pushToast('error', 'Could not delete', { detail: error instanceof Error ? error.message : String(error) })
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
deleting.set(false)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const removeTitle = derived(() => `Delete this ${removing()?.panel.label.toLowerCase() ?? 'record'}?`)
|
|
183
|
+
const removeWarning = derived(() => {
|
|
184
|
+
const current = removing()
|
|
185
|
+
return current ? modelDeleteWarning(`${current.panel.label} ${current.row.id}`) : ''
|
|
186
|
+
})
|
|
187
|
+
|
|
60
188
|
function viewAll(panel: ModelRelatedPanel): void {
|
|
61
189
|
navigate(modelRelatedListHref(panel, parentId()))
|
|
62
190
|
}
|
|
63
191
|
|
|
192
|
+
// Here when the panel carries the related model's fields; on that model's
|
|
193
|
+
// create page, which comes back, when it does not.
|
|
64
194
|
function add(panel: ModelRelatedPanel): void {
|
|
65
|
-
|
|
195
|
+
if (modelRelatedAddsHere(panel))
|
|
196
|
+
openEditor({ panel, id: null }, modelFormValues(panel.fields ?? []))
|
|
197
|
+
else
|
|
198
|
+
navigate(modelRelatedCreateHref(panel, parentId(), from()))
|
|
66
199
|
}
|
|
67
200
|
</script>
|
|
68
201
|
|
|
@@ -86,14 +219,51 @@ function add(panel: ModelRelatedPanel): void {
|
|
|
86
219
|
<Table
|
|
87
220
|
:if="panel.rows.length > 0"
|
|
88
221
|
:columns="tableColumns(panel)"
|
|
89
|
-
:data="panel
|
|
222
|
+
:data="tableRows(panel)"
|
|
90
223
|
:framed="false"
|
|
91
|
-
:row-actions="
|
|
224
|
+
:row-actions="rowActions(panel)"
|
|
92
225
|
:action-label-key="panel.columns[0] ? panel.columns[0].key : 'id'"
|
|
93
|
-
@row-action="
|
|
226
|
+
@row-action="act(panel, $event)"
|
|
94
227
|
/>
|
|
95
228
|
|
|
96
229
|
<p :if="panel.rows.length === 0" class="px-6 py-5 text-neutral-500 text-sm dark:text-neutral-400">{{ emptyTitle(panel) }}</p>
|
|
97
230
|
</Card>
|
|
98
231
|
</div>
|
|
232
|
+
|
|
233
|
+
<Modal
|
|
234
|
+
:isOpen="Boolean(editor())"
|
|
235
|
+
:title="editorTitle()"
|
|
236
|
+
:closable="!saving()"
|
|
237
|
+
size="lg"
|
|
238
|
+
@close="closeEditor"
|
|
239
|
+
>
|
|
240
|
+
<form id="related-row-form" class="flex flex-col gap-5" data-related-editor @submit.prevent="save">
|
|
241
|
+
<div :if="saveError()" role="alert" class="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">{{ saveError() }}</div>
|
|
242
|
+
<ModelFieldInputs
|
|
243
|
+
:fields="editor()?.panel.fields ?? []"
|
|
244
|
+
:slug="editor()?.panel.slug ?? ''"
|
|
245
|
+
:values="values()"
|
|
246
|
+
:errors="saveErrors()"
|
|
247
|
+
:disabled="saving()"
|
|
248
|
+
@change="setValue"
|
|
249
|
+
/>
|
|
250
|
+
</form>
|
|
251
|
+
|
|
252
|
+
<template #footer>
|
|
253
|
+
<div class="flex gap-2 items-center justify-end w-full">
|
|
254
|
+
<Button variant="secondary" :disabled="saving()" @click="closeEditor">Cancel</Button>
|
|
255
|
+
<Button variant="primary" type="submit" form="related-row-form" :loading="saving()">{{ editor()?.id === null ? 'Add' : 'Save changes' }}</Button>
|
|
256
|
+
</div>
|
|
257
|
+
</template>
|
|
258
|
+
</Modal>
|
|
259
|
+
|
|
260
|
+
<ConfirmDialog
|
|
261
|
+
:isOpen="Boolean(removing())"
|
|
262
|
+
:title="removeTitle()"
|
|
263
|
+
:description="removeWarning()"
|
|
264
|
+
:busy="deleting()"
|
|
265
|
+
:confirmLabel="deleting() ? 'Deleting' : 'Delete'"
|
|
266
|
+
@close="removing.set(null)"
|
|
267
|
+
@confirm="remove"
|
|
268
|
+
/>
|
|
99
269
|
</div>
|
|
@@ -17,6 +17,8 @@ const name = useReactiveProp('name', '')
|
|
|
17
17
|
const required = useReactiveProp('required', false)
|
|
18
18
|
const disabled = useReactiveProp('disabled', false)
|
|
19
19
|
const error = useReactiveProp('error', '')
|
|
20
|
+
// A sentence under the search, from the model's own help for the field.
|
|
21
|
+
const hint = useReactiveProp('hint', '')
|
|
20
22
|
const emit = defineEmits(['update:value'])
|
|
21
23
|
const generatedId = useId('relation')
|
|
22
24
|
|
|
@@ -244,4 +246,5 @@ effect(() => {
|
|
|
244
246
|
</div>
|
|
245
247
|
|
|
246
248
|
<p :if="error()" class="mt-1.5 text-[12px] text-red-600 dark:text-red-400" :text="error()"></p>
|
|
249
|
+
<p :if="!error() && hint()" class="mt-1.5 text-[12px] text-stone-500 dark:text-neutral-400" :text="hint()"></p>
|
|
247
250
|
</div>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
// A field asked for as a file (`dashboard.fields.<name>.input: 'upload'`):
|
|
3
|
+
// a file chooser whose value is the address the chosen file was stored at.
|
|
4
|
+
//
|
|
5
|
+
// Choosing a file stores it straight away and puts its address in the form.
|
|
6
|
+
// Nothing about the record changes until the form is saved, so a file chosen
|
|
7
|
+
// and then abandoned costs nothing but its place in storage. What the field
|
|
8
|
+
// holds is shown, as a picture when it is one, and can be replaced or removed.
|
|
9
|
+
import { modelFileName, modelFileIsImage, uploadModelFile } from '../../../../functions/dashboard-model-record'
|
|
10
|
+
|
|
11
|
+
// The model the field belongs to, in a dashboard URL: where the file is sent.
|
|
12
|
+
const slug = useReactiveProp('slug', '')
|
|
13
|
+
const name = useReactiveProp('name', '')
|
|
14
|
+
const value = useReactiveProp('value', '')
|
|
15
|
+
const label = useReactiveProp('label', '')
|
|
16
|
+
// The kinds of file that may be chosen. The server holds to the same list.
|
|
17
|
+
const accept = useReactiveProp('accept', '')
|
|
18
|
+
const required = useReactiveProp('required', false)
|
|
19
|
+
const disabled = useReactiveProp('disabled', false)
|
|
20
|
+
const error = useReactiveProp('error', '')
|
|
21
|
+
const hint = useReactiveProp('hint', '')
|
|
22
|
+
const emit = defineEmits(['update:value'])
|
|
23
|
+
const generatedId = useId('upload')
|
|
24
|
+
|
|
25
|
+
const chooser = useRef<HTMLInputElement>('modelUploadChooser')
|
|
26
|
+
const uploading = state(false)
|
|
27
|
+
// Why the last file was not taken, in the server's words.
|
|
28
|
+
const failed = state('')
|
|
29
|
+
|
|
30
|
+
const inputId = derived(() => `${generatedId}-input`)
|
|
31
|
+
const isImage = derived(() => modelFileIsImage(value()) || /^image\//i.test(accept()))
|
|
32
|
+
const fileName = derived(() => modelFileName(value()))
|
|
33
|
+
const chooseLabel = derived(() => uploading() ? 'Uploading' : value() ? 'Replace file' : 'Choose file')
|
|
34
|
+
const problem = derived(() => failed() || error())
|
|
35
|
+
|
|
36
|
+
async function choose(event: Event): Promise<void> {
|
|
37
|
+
const file = (event.target as HTMLInputElement).files?.[0]
|
|
38
|
+
// The same file can be chosen again after a refusal.
|
|
39
|
+
if (chooser.current)
|
|
40
|
+
chooser.current.value = ''
|
|
41
|
+
if (!file || uploading() || disabled())
|
|
42
|
+
return
|
|
43
|
+
uploading.set(true)
|
|
44
|
+
failed.set('')
|
|
45
|
+
const stored = await uploadModelFile(slug(), name(), file)
|
|
46
|
+
uploading.set(false)
|
|
47
|
+
if (stored.ok)
|
|
48
|
+
emit('update:value', stored.url)
|
|
49
|
+
else
|
|
50
|
+
failed.set(stored.error)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function remove(): void {
|
|
54
|
+
if (disabled() || uploading())
|
|
55
|
+
return
|
|
56
|
+
failed.set('')
|
|
57
|
+
emit('update:value', '')
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<div class="w-full" data-upload-input>
|
|
62
|
+
<label :if="label()" :for="inputId()" class="block mb-1.5 font-medium text-[13px] tracking-tight" :class="problem() ? 'text-red-600 dark:text-red-400' : 'text-stone-600 dark:text-neutral-400'">
|
|
63
|
+
{{ label() }}
|
|
64
|
+
<span :if="required()" aria-hidden="true" class="ml-0.5 text-red-500">*</span>
|
|
65
|
+
</label>
|
|
66
|
+
|
|
67
|
+
<div class="flex gap-3 items-center p-2 border rounded-lg" :class="problem() ? 'border-red-400/60 dark:border-red-500/60' : 'border-stone-200/80 dark:border-white/15'">
|
|
68
|
+
<a :if="value() && isImage()" :href="value()" target="_blank" rel="noopener noreferrer" class="flex-none">
|
|
69
|
+
<img :src="value()" alt="" class="block object-cover h-12 w-12 bg-neutral-100 dark:bg-neutral-800 rounded" />
|
|
70
|
+
</a>
|
|
71
|
+
<span :if="value() && !isImage()" aria-hidden="true" class="flex-none h-6 w-6 text-neutral-400 i-hugeicons-file-01"></span>
|
|
72
|
+
<span :if="!value()" aria-hidden="true" class="flex-none h-6 w-6 text-neutral-400 i-hugeicons-upload-01"></span>
|
|
73
|
+
|
|
74
|
+
<div class="flex-1 min-w-0 text-[13px]">
|
|
75
|
+
<a :if="value()" :href="value()" target="_blank" rel="noopener noreferrer" class="block text-blue-600 truncate dark:text-blue-400 hover:underline" data-upload-current>{{ fileName() }}</a>
|
|
76
|
+
<span :if="!value()" class="text-neutral-500 dark:text-neutral-400">No file chosen</span>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<label class="inline-flex flex-none items-center px-2.5 h-7 font-medium text-[12px] text-neutral-700 dark:text-neutral-200 bg-white dark:bg-white/10 border border-black/10 rounded-md dark:border-white/15" :class="disabled() || uploading() ? 'opacity-40 cursor-not-allowed' : 'cursor-pointer hover:bg-neutral-50 dark:hover:bg-white/15'">
|
|
80
|
+
<span aria-live="polite">{{ chooseLabel() }}</span>
|
|
81
|
+
<input
|
|
82
|
+
ref="modelUploadChooser"
|
|
83
|
+
:id="inputId()"
|
|
84
|
+
type="file"
|
|
85
|
+
class="sr-only"
|
|
86
|
+
:accept="accept() || null"
|
|
87
|
+
:disabled="disabled() || uploading()"
|
|
88
|
+
:aria-invalid="problem() ? 'true' : null"
|
|
89
|
+
@change="choose($event)"
|
|
90
|
+
/>
|
|
91
|
+
</label>
|
|
92
|
+
<Button :if="value()" variant="ghost" size="sm" :disabled="disabled() || uploading()" @click="remove">Remove</Button>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<p :if="problem()" role="alert" class="mt-1.5 text-[12px] text-red-600 dark:text-red-400" :text="problem()"></p>
|
|
96
|
+
<p :if="!problem() && hint()" class="mt-1.5 text-[12px] text-stone-500 dark:text-neutral-400" :text="hint()"></p>
|
|
97
|
+
</div>
|
package/routes/dashboard-api.ts
CHANGED
|
@@ -525,6 +525,15 @@ route.group({ prefix: '/api/dashboard', apiResponse: true }, () => {
|
|
|
525
525
|
guard(route.post('/models/{slug}', 'Actions/Dashboard/Models/ModelStoreAction'))
|
|
526
526
|
guard(route.patch('/models/{slug}/{id}', 'Actions/Dashboard/Models/ModelUpdateAction'))
|
|
527
527
|
guard(route.delete('/models/{slug}/{id}', 'Actions/Dashboard/Models/ModelDestroyAction'))
|
|
528
|
+
// The actions a model lists under `dashboard.actions`, run on one record:
|
|
529
|
+
// "Mark as shipped". The parameters other than `id` are named so that an
|
|
530
|
+
// action validating a `slug` or a `name` of its own does not read these.
|
|
531
|
+
guard(route.post('/models/{dashboardModel}/{id}/actions/{dashboardAction}', 'Actions/Dashboard/Models/ModelActionRunAction'))
|
|
532
|
+
// The file chosen for a field a model asks for as one (`input: 'upload'`):
|
|
533
|
+
// stored, and its address answered for the form to hold. And how a field's
|
|
534
|
+
// Markdown reads, for the preview beside its editor. Neither writes a record.
|
|
535
|
+
guard(route.post('/models/{slug}/uploads', 'Actions/Dashboard/Models/ModelUploadAction'))
|
|
536
|
+
guard(route.post('/markdown', 'Actions/Dashboard/Models/ModelMarkdownAction'))
|
|
528
537
|
|
|
529
538
|
// Error monitoring - the same native Error model aggregation exposed by
|
|
530
539
|
// the token-authenticated `/api/monitoring` routes, projected through the
|
|
@@ -9,3 +9,10 @@ import { route } from '@stacksjs/router'
|
|
|
9
9
|
* manifest it gets is only as good as its signature.
|
|
10
10
|
*/
|
|
11
11
|
route.get('/api/updates/{platform}/{arch}', 'Actions/Desktop/UpdateFeedAction')
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The artifacts those manifests name, streamed from the updates disk. A
|
|
15
|
+
* release points here unless `webview.updates.artifactBaseUrl` names a bucket
|
|
16
|
+
* or CDN that serves the disk itself.
|
|
17
|
+
*/
|
|
18
|
+
route.get('/api/updates/files/{channel}/{target}/{version}/{file}', 'Actions/Desktop/UpdateArtifactAction')
|