@stacksjs/defaults 0.75.712 → 0.75.716

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.
Files changed (45) hide show
  1. package/ai/skills/stacks-dashboard/SKILL.md +20 -6
  2. package/ai/skills/stacks-dns/SKILL.md +17 -2
  3. package/ai/skills/stacks-native/CATALOG.md +5 -5
  4. package/app/Actions/Dashboard/Infrastructure/dns-overview.ts +2 -2
  5. package/app/Actions/Dashboard/Infrastructure/environment-file.ts +1 -12
  6. package/functions/dashboard-api.ts +5 -0
  7. package/ide/vscode/package.json +1 -1
  8. package/package.json +6 -5
  9. package/resources/components/Dashboard/Buddy/BuddyAssistant.stx +1 -1
  10. package/resources/components/Dashboard/DashboardSectionSidebar.stx +12 -3
  11. package/resources/components/Dashboard/Environment/EnvironmentDashboard.stx +88 -68
  12. package/resources/components/Dashboard/Infrastructure/DnsDashboard.stx +1 -0
  13. package/resources/components/Dashboard/Projects/GitHubIssuesDashboard.stx +165 -0
  14. package/resources/components/Dashboard/Settings/DashboardSettingsIntro.stx +10 -0
  15. package/resources/components/Dashboard/Settings/DashboardSettingsSearch.stx +32 -0
  16. package/resources/components/Dashboard/Settings/DnsRecordsSettings.stx +181 -0
  17. package/resources/components/Dashboard/Settings/MailSettingsDashboard.stx +7 -5
  18. package/resources/components/Dashboard/Settings/SettingsCodeEditor.stx +27 -0
  19. package/resources/components/Dashboard/Settings/SettingsDashboard.stx +187 -270
  20. package/resources/components/Dashboard/Settings/SettingsPicker.stx +87 -0
  21. package/resources/functions/dashboard/environment-value.ts +11 -0
  22. package/resources/functions/dashboard/page-availability.ts +1 -1
  23. package/resources/functions/dashboard/project-config-sections.ts +105 -0
  24. package/resources/functions/dashboard/section-landing.ts +1 -1
  25. package/resources/functions/dashboard/settings-panes.ts +26 -0
  26. package/resources/functions/dashboard/sidebar.ts +7 -7
  27. package/styles/dashboard-theme.css +281 -25
  28. package/views/dashboard/composables/dashboard-theme-bootstrap.ts +7 -0
  29. package/views/dashboard/composables/settings-dialog.ts +22 -0
  30. package/views/dashboard/composables/settings-window.ts +10 -4
  31. package/views/dashboard/composables/useProjectConfigEditor.ts +244 -0
  32. package/views/dashboard/composables/useSettingsWindow.ts +23 -1
  33. package/views/dashboard/github-issues.stx +18 -0
  34. package/views/dashboard/layouts/default.stx +1 -1
  35. package/views/dashboard/layouts/settings.stx +147 -10
  36. package/views/dashboard/settings/appearance.stx +2 -3
  37. package/views/dashboard/settings/billing.stx +2 -3
  38. package/views/dashboard/settings/config/[section].stx +22 -0
  39. package/views/dashboard/{environment/index.stx → settings/environment.stx} +1 -1
  40. package/views/dashboard/settings/index.stx +1 -3
  41. package/views/dashboard/settings/mail.stx +2 -3
  42. package/views/dashboard/settings/software-update.stx +2 -3
  43. package/resources/components/Dashboard/CodeEditor.stx +0 -73
  44. package/resources/components/Dashboard/Settings/DashboardSettingsFrame.stx +0 -101
  45. package/resources/functions/dashboard/config-io.ts +0 -401
@@ -1,319 +1,236 @@
1
- <script client>
2
- import { dashboardApi } from '@stacksjs/defaults/functions/dashboard-api'
3
-
4
- interface ConfigFile {
5
- name: string
6
- title: string
7
- size: number
8
- }
9
-
10
- interface ConfigField {
11
- key: string
12
- value: string | number | boolean | null | unknown[] | Record<string, unknown>
13
- type: string
14
- editable: boolean
15
- reason?: string
16
- }
17
-
18
- interface ConfigListResponse {
19
- ok: boolean
20
- files: ConfigFile[]
21
- error?: string
22
- }
1
+ <script server>
2
+ import type { ProjectConfigSection } from '@stacksjs/defaults/resources/functions/dashboard/project-config-sections'
23
3
 
24
- interface ConfigReadResponse {
25
- ok: boolean
26
- fields: ConfigField[]
27
- error?: string
28
- }
4
+ const { section } = defineProps<{ section?: ProjectConfigSection }>()
5
+ export const configSectionId = section ?? 'general'
6
+ defineClientPayload({ configSectionId })
7
+ </script>
29
8
 
30
- interface ConfigUpdateResult {
31
- ok: boolean
32
- error?: string
33
- }
9
+ <script client>
10
+ import type { ConfigField, EditorMode } from '@stacksjs/defaults/views/dashboard/composables/useProjectConfigEditor'
11
+ import { configLabel, projectConfigSection } from '@stacksjs/defaults/resources/functions/dashboard/project-config-sections'
12
+ import { confirmSettingsDiscard } from '@stacksjs/defaults/views/dashboard/composables/settings-dialog'
13
+ import { projectConfigEditor, rememberProjectConfigFile, requestedProjectConfigFile } from '@stacksjs/defaults/views/dashboard/composables/useProjectConfigEditor'
14
+
15
+ const configSection = projectConfigSection({{ configSectionId }})
16
+ const { files, current, drafts, sourceDraft, selected, mode, setMode, loading, saving, message, error, isDirty, setDocument, selectFile, save, initialize } = projectConfigEditor({{ configSectionId }})
17
+
18
+ const pending = state<'reload' | EditorMode | null>(null)
19
+ const confirming = state(false)
20
+ const visibleMode = state<EditorMode>('fields')
21
+ const fieldQuery = state('')
22
+ const fieldLimit = state(40)
23
+ const dnsFile = derived(() => selected() === 'dns')
24
+
25
+ const fileOptions = derived(() => files().map(file => ({ value: file.name, label: file.title })))
26
+ const editorModes = derived(() => [
27
+ { value: 'fields', label: dnsFile() ? 'Records' : 'Fields' },
28
+ { value: 'source', label: 'TypeScript' },
29
+ ])
30
+ const selectedFile = derived(() => files().find(file => file.name === selected()))
31
+ const discardTitle = 'Discard unsaved changes?'
32
+ const discardDescription = 'Your changes to this configuration file will be lost.'
33
+ effect(() => visibleMode.set(mode()))
34
34
 
35
- interface ConfigUpdateResponse {
36
- ok: boolean
37
- results?: ConfigUpdateResult[]
38
- error?: string
35
+ function displayPart(part: string | number): string {
36
+ return typeof part === 'number' ? `Item ${part + 1}` : configLabel(part)
39
37
  }
40
38
 
41
- const files = state<ConfigFile[]>([])
42
- const fields = state<ConfigField[]>([])
43
- const drafts = reactive<Record<string, string | number | boolean>>({})
44
- const selected = state('')
45
- const pendingSelection = state('')
46
- // Not `query`: the render context has one of its own (the request's query
47
- // string), and a component binding resolved to it.
48
- const configQuery = state('')
49
- const loading = state(true)
50
- const saving = state(false)
51
- const message = state('')
52
- const error = state('')
53
-
54
- const filteredFiles = derived(() => {
55
- const needle = configQuery().trim().toLowerCase()
56
- if (!needle)
57
- return files()
58
-
59
- return files().filter(file => file.name.includes(needle) || file.title.toLowerCase().includes(needle))
39
+ const fields = derived(() => (current()?.fields ?? []).map((field) => {
40
+ const labels = field.path.map(displayPart)
41
+ const label = labels.at(-1) ?? 'Value'
42
+ return { ...field, label, group: JSON.stringify(field.path.slice(0, -1)), heading: labels.slice(0, -1).join(' › '), accessibleLabel: labels.join(' › ') || label }
43
+ }))
44
+ const filteredFields = derived(() => {
45
+ const needle = fieldQuery().trim().toLowerCase()
46
+ return fields().filter(field => `${field.key} ${field.accessibleLabel} ${field.description ?? ''}`.toLowerCase().includes(needle))
47
+ })
48
+ const displayRows = derived(() => {
49
+ const groups = new Map<string, ReturnType<typeof filteredFields>>()
50
+ for (const field of filteredFields()) {
51
+ const group = groups.get(field.group)
52
+ if (group)
53
+ group.push(field)
54
+ else
55
+ groups.set(field.group, [field])
56
+ }
57
+ let remaining = fieldLimit()
58
+ return [...groups.values()].flatMap((group) => {
59
+ const chosen = group.slice(0, remaining)
60
+ remaining -= chosen.length
61
+ return chosen.map((field, index) => ({
62
+ ...field,
63
+ sectionHeading: index === 0 && groups.size > 1 ? field.heading || 'General' : '',
64
+ }))
65
+ })
60
66
  })
61
67
 
62
- const selectedFile = derived(() => files().find(file => file.name === selected()))
63
- const editableCount = derived(() => fields().filter(field => field.editable).length)
64
- const isDirty = derived(() => fields().some(field => field.editable && drafts[field.key] !== field.value))
65
-
66
- function displayValue(field: ConfigField): string | number {
67
- if (field.editable)
68
- return drafts[field.key] as string | number
69
- if (field.type === 'object' || field.type === 'array')
70
- return JSON.stringify(field.value)
71
- return String(field.value ?? '')
68
+ function openFile(name: string, reload = false): Promise<void> {
69
+ if (name !== selected()) {
70
+ fieldQuery.set('')
71
+ fieldLimit.set(40)
72
+ rememberProjectConfigFile(name)
73
+ }
74
+ return selectFile(name, { reload })
72
75
  }
73
76
 
74
- async function loadFiles(): Promise<void> {
75
- loading.set(true)
76
- error.set('')
77
- try {
78
- const body = await dashboardApi<ConfigListResponse>('/api/config/list')
79
- if (!body.ok)
80
- throw new Error(body.error || 'Unable to list configuration files')
81
- if (!Array.isArray(body.files))
82
- throw new TypeError('Configuration files were not returned in the expected shape.')
83
-
84
- files.set(body.files)
85
- const first = body.files[0]?.name
86
- if (first)
87
- await selectFile(first)
77
+ function requestMode(next: EditorMode): void {
78
+ if (saving() || next === mode())
79
+ return
80
+ if (isDirty()) {
81
+ visibleMode.set(mode())
82
+ void requestDiscard(next)
88
83
  }
89
- catch (cause) {
90
- error.set(cause instanceof Error ? cause.message : 'Unable to load configuration')
91
- }
92
- finally {
93
- loading.set(false)
84
+ else {
85
+ setMode(next)
94
86
  }
95
87
  }
96
88
 
97
- async function selectFile(name: string): Promise<void> {
98
- selected.set(name)
99
- fields.set([])
100
- message.set('')
101
- error.set('')
102
- loading.set(true)
89
+ async function requestDiscard(destination: 'reload' | EditorMode): Promise<void> {
90
+ if (confirming() || pending())
91
+ return
92
+ const file = selected()
93
+ confirming.set(true)
103
94
  try {
104
- const body = await dashboardApi<ConfigReadResponse>(`/api/config/read?name=${encodeURIComponent(name)}`)
105
- if (!body.ok)
106
- throw new Error(body.error || `Unable to read config/${name}.ts`)
107
-
108
- for (const key of Object.keys(drafts))
109
- delete drafts[key]
110
- Object.assign(
111
- drafts,
112
- Object.fromEntries(
113
- body.fields
114
- .filter((field: ConfigField) => field.editable)
115
- .map((field: ConfigField) => [field.key, field.value]),
116
- ),
117
- )
118
- fields.set(body.fields)
119
- }
120
- catch (cause) {
121
- error.set(cause instanceof Error ? cause.message : `Unable to read config/${name}.ts`)
95
+ const confirmed = await confirmSettingsDiscard(discardTitle, discardDescription, 'Discard Changes')
96
+ if (selected() !== file || saving())
97
+ return
98
+ if (confirmed === null)
99
+ pending.set(destination)
100
+ else if (confirmed)
101
+ discardAndContinue(destination)
122
102
  }
123
103
  finally {
124
- loading.set(false)
104
+ confirming.set(false)
125
105
  }
126
106
  }
127
107
 
128
- function requestSelectFile(name: string): void {
129
- if (name === selected())
130
- return
131
- if (isDirty()) {
132
- pendingSelection.set(name)
108
+ function discardAndContinue(destination = pending()): void {
109
+ pending.set(null)
110
+ if (destination === 'reload') {
111
+ void openFile(selected(), true)
133
112
  return
134
113
  }
135
- void selectFile(name)
136
- }
137
-
138
- function cancelPendingSelection(): void {
139
- pendingSelection.set('')
114
+ const loaded = current()
115
+ if (destination && loaded) {
116
+ setDocument(loaded)
117
+ setMode(destination)
118
+ error.set('')
119
+ }
140
120
  }
141
121
 
142
- function discardAndSelect(): void {
143
- const name = pendingSelection()
144
- pendingSelection.set('')
145
- if (name)
146
- void selectFile(name)
122
+ function fieldInputType(field: ConfigField): string {
123
+ return /password|secret|api[-_]?key|private[-_]?key|access[-_]?token/i.test(field.key) ? 'password' : 'text'
147
124
  }
148
125
 
149
- function handleBeforeUnload(event: BeforeUnloadEvent): void {
150
- if (!isDirty())
151
- return
152
- event.preventDefault()
153
- event.returnValue = ''
126
+ function loadSection(): Promise<void> {
127
+ return initialize(requestedProjectConfigFile())
154
128
  }
155
129
 
156
- async function save(): Promise<void> {
157
- const file = selected()
158
- if (!file || saving())
159
- return
160
-
161
- saving.set(true)
162
- message.set('')
163
- error.set('')
164
- try {
165
- const updates = fields()
166
- .filter(field => field.editable)
167
- .map(field => ({ key: field.key, value: drafts[field.key] }))
168
- const body = await dashboardApi<ConfigUpdateResponse>('/api/config/update', {
169
- method: 'POST',
170
- body: { file, updates },
171
- })
172
- if (!body.ok) {
173
- const failed = body.results?.filter((result: { ok: boolean }) => !result.ok)
174
- throw new Error(failed?.map((result: { error?: string }) => result.error).filter(Boolean).join(', ') || body.error || 'Unable to save configuration')
175
- }
176
-
177
- message.set(`Saved config/${file}.ts`)
178
- await selectFile(file)
179
- message.set(`Saved config/${file}.ts`)
180
- }
181
- catch (cause) {
182
- error.set(cause instanceof Error ? cause.message : 'Unable to save configuration')
183
- }
184
- finally {
185
- saving.set(false)
130
+ onMount(loadSection)
131
+ useEventListener('stx:load', loadSection)
132
+ useEventListener('keydown', (event: KeyboardEvent) => {
133
+ if (!event.defaultPrevented && (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey && event.key.toLowerCase() === 's') {
134
+ event.preventDefault()
135
+ if (!confirming() && !pending())
136
+ void save()
186
137
  }
187
- }
188
-
189
- useEventListener('beforeunload', handleBeforeUnload)
190
- void loadFiles()
138
+ })
191
139
  </script>
192
140
 
193
141
  <template>
194
142
  <div class="dashboard-settings-stack">
195
- <div :if="files().length > 0">
196
- <SettingsGroup header="Project configuration">
197
- <details class="dashboard-settings-config-picker">
198
- <summary>
199
- <span>Configuration file</span>
200
- <span class="dashboard-settings-config-selection">
201
- <span :text="selectedFile()?.title"></span>
202
- <span class="i-f7-chevron-down" aria-hidden="true"></span>
203
- </span>
204
- </summary>
205
- <div class="pt-2 px-2">
206
- <SearchFilter v-model:searchValue="configQuery" placeholder="Search config" ariaLabel="Search configuration" />
207
- </div>
208
-
209
- <nav class="overflow-y-auto p-2 max-h-[68vh]" aria-label="Configuration files">
210
- <button :for="file in filteredFiles"
211
- type="button"
212
- :class="selected() === file.name ? 'flex items-center gap-3 px-3 py-2.5 w-full text-left text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-500/10 rounded-lg' : 'flex items-center gap-3 px-3 py-2.5 w-full text-left text-neutral-700 dark:text-neutral-300 hover:bg-neutral-100 dark:hover:bg-white/5 rounded-lg'"
213
- @click="requestSelectFile(file.name)"
214
- >
215
- <span class="flex-none h-4 w-4 i-hugeicons-settings-02"></span>
216
- <span class="flex-1 font-medium text-sm truncate">{{ file.title }}</span>
217
- <span class="text-[10px] text-neutral-500 dark:text-neutral-400">{{ file.size < 1024 ? file.size + ' B' : Math.round(file.size / 1024) + ' KB' }}</span>
218
- </button>
219
- </nav>
220
- </details>
143
+ <p class="dashboard-config-intro" :text="configSection?.description"></p>
144
+
145
+ <div :if="files().length > 1">
146
+ <SettingsGroup>
147
+ <SettingsRow label="Configuration file">
148
+ <SettingsPicker :options="fileOptions()" :value="selected()" ariaLabel="Configuration file"
149
+ :disabled="saving() || confirming()" @change="openFile($event)" />
150
+ </SettingsRow>
221
151
  </SettingsGroup>
222
152
  </div>
223
153
 
224
- <SettingsGroup>
225
- @if(loading())
226
- <div class="flex items-center justify-center min-h-80 text-neutral-500 dark:text-neutral-400">
227
- <span class="mr-2 h-5 w-5 animate-spin i-hugeicons-loading-03"></span>
228
- Loading configuration
229
- </div>
230
- @elseif(error() && !selectedFile())
231
- <div class="p-8 text-center">
232
- <span class="inline-block h-8 w-8 text-red-500 i-hugeicons-alert-02"></span>
233
- <p class="mt-3 font-medium text-neutral-900 dark:text-white">Configuration unavailable</p>
234
- <p class="mt-1 text-red-600 text-sm dark:text-red-400">{{ error() }}</p>
235
- </div>
236
- @elseif(files().length === 0)
237
- <div class="p-8 text-center">
238
- <span class="inline-block h-8 w-8 text-neutral-400 i-hugeicons-settings-02"></span>
239
- <p class="mt-3 font-medium text-neutral-900 dark:text-white">No configuration files</p>
240
- <p class="mt-1 text-neutral-500 text-sm dark:text-neutral-400">Add a TypeScript config file under config to manage it here.</p>
241
- </div>
242
- @elseif(selectedFile())
243
- <div class="flex flex-wrap gap-4 items-center justify-between px-4 py-3 border-b border-neutral-200/60 dark:border-white/5">
244
- <div>
245
- <h2 class="font-semibold text-lg text-neutral-900 dark:text-white">{{ selectedFile()?.title }}</h2>
246
- <p class="mt-1 font-mono text-neutral-500 text-xs dark:text-neutral-400">config/{{ selectedFile()?.name }}.ts</p>
154
+ <p :if="loading()" class="dashboard-config-intro" role="status">Loading configuration…</p>
155
+ <div :if="error()" class="text-red-700 text-sm dark:text-red-400" role="alert">
156
+ <p :text="error()"></p>
157
+ <Button :if="!current() && !loading()" variant="secondary" size="sm" @click="selected() ? openFile(selected(), true) : loadSection()">Retry</Button>
158
+ <Button :if="current() && isDirty()" variant="secondary" size="sm" @click="requestDiscard('reload')">Reopen file</Button>
159
+ </div>
160
+ <p :if="!loading() && !error() && files().length === 0" class="dashboard-config-intro">This project has no configuration files in this section.</p>
161
+ <p :if="message()" class="text-green-700 text-sm dark:text-green-400" role="status" :text="message()"></p>
162
+
163
+ <div :if="current()" class="min-w-0">
164
+ <SettingsGroup>
165
+ <form @submit.prevent="save()">
166
+ <div class="dashboard-config-header">
167
+ <div class="min-w-0">
168
+ <h2 :text="selectedFile()?.title"></h2>
169
+ <p class="dashboard-config-path" data-config-path :text="'config/' + selected() + '.ts'"></p>
247
170
  </div>
248
- <div class="flex gap-2 items-center">
249
- <Badge :if="isDirty()" variant="warning" size="sm">Unsaved changes</Badge>
250
- <Badge variant="default" size="sm">{{ editableCount() + ' editable' }}</Badge>
251
- <Button variant="primary" size="sm" :disabled="saving() || editableCount() === 0 || !isDirty()" @click="save()">
252
- {{ saving() ? 'Saving...' : 'Save changes' }}
253
- </Button>
171
+ <div class="flex flex-wrap gap-2 items-center">
172
+ <SegmentedControl v-model:value="visibleMode" :options="editorModes()" label="Configuration editor" variant="mac"
173
+ :disabled="saving() || confirming()" @change="requestMode($event)" />
174
+ <Button :if="!dnsFile() || mode() === 'source'" type="submit" size="sm" :loading="saving()" :disabled="saving() || !isDirty()">Save changes</Button>
254
175
  </div>
255
176
  </div>
256
177
 
257
- @if(message())
258
- <div class="mt-3 mx-4 px-4 py-3 text-green-700 text-sm dark:text-green-300 bg-green-50 dark:bg-green-500/10 border border-green-200 rounded-lg dark:border-green-500/20">
259
- {{ message() }}
260
- </div>
261
- @endif
262
- @if(error())
263
- <div class="mt-3 mx-4 px-4 py-3 text-red-700 text-sm dark:text-red-300 bg-red-50 dark:bg-red-500/10 border border-red-200 rounded-lg dark:border-red-500/20">
264
- {{ error() }}
265
- </div>
266
- @endif
178
+ <div :if="mode() === 'source'" class="flex flex-col gap-2 p-4 pt-0">
179
+ <p :if="current()?.diagnostic" class="text-amber-700 text-sm dark:text-amber-300" :text="current()?.diagnostic"></p>
180
+ <SettingsCodeEditor v-model:value="sourceDraft" language="typescript" :label="'config/' + selected() + '.ts'" :readonly="saving()" @save="save()" />
181
+ </div>
267
182
 
268
- <form class="divide-neutral-200/60 divide-y dark:divide-white/5" @submit.prevent="save()">
269
- <div :for="field in fields" class="grid gap-3 sm:grid-cols-[minmax(10rem,0.8fr)_minmax(0,1.2fr)] sm:items-start px-4 py-3">
270
- <div>
271
- <label :for="'config-' + field.key" class="font-medium text-neutral-900 text-sm dark:text-white">{{ field.key }}</label>
272
- <p class="mt-1 text-neutral-500 text-xs dark:text-neutral-400">{{ field.type }}</p>
183
+ <div :if="mode() === 'fields' && !dnsFile()" class="min-w-0">
184
+ <div class="dashboard-config-field-tools">
185
+ <p class="dashboard-config-intro">Use TypeScript for expressions, environment bindings, and new keys.</p>
186
+ <div :if="fields().length > 6">
187
+ <SearchFilter v-model:searchValue="fieldQuery" placeholder="Filter fields" ariaLabel="Filter configuration fields" />
273
188
  </div>
274
-
275
- <div>
276
- @if(field.type === 'boolean' && field.editable)
277
- <Toggle
278
- :id="'config-' + field.key"
279
- v-model:checked="drafts[field.key]"
280
- :label="drafts[field.key] ? 'Enabled' : 'Disabled'"
281
- :ariaLabel="field.key"
282
- />
283
- @elseif(field.editable && field.type === 'number')
284
- <input
285
- :id="'config-' + field.key"
286
- type="number"
287
- x-model.number="drafts[field.key]"
288
- class="block px-3 py-2 w-full text-neutral-900 text-sm dark:text-white bg-white dark:bg-white/5 border border-black/10 rounded-lg dark:border-white/15 focus:border-blue-500/50 focus:outline-none focus:ring-2 focus:ring-blue-500/40"
289
- >
290
- @elseif(field.editable)
291
- <input
292
- :id="'config-' + field.key"
293
- type="text"
294
- x-model="drafts[field.key]"
295
- class="block px-3 py-2 w-full text-neutral-900 text-sm dark:text-white bg-white dark:bg-white/5 border border-black/10 rounded-lg dark:border-white/15 focus:border-blue-500/50 focus:outline-none focus:ring-2 focus:ring-blue-500/40"
296
- >
189
+ </div>
190
+ <p :if="displayRows().length === 0" class="pb-4 px-4 text-neutral-500 text-sm dark:text-neutral-400"
191
+ :text="fieldQuery() ? 'No matching fields' : 'Open TypeScript to edit this file.'"></p>
192
+
193
+ <div :for="(field, index) in displayRows()" :key="field.key">
194
+ <h3 :if="field.sectionHeading" class="dashboard-config-subheading" :text="field.sectionHeading"></h3>
195
+ @if(field.type === 'boolean')
196
+ <SettingsRow :label="field.label" :description="field.description">
197
+ <Switch v-model:checked="drafts[field.key]" variant="mac" :disabled="saving()" />
198
+ </SettingsRow>
199
+ @else
200
+ <div class="dashboard-config-field" :data-config-type="field.type">
201
+ @if(field.type === 'null')
202
+ <span class="dashboard-config-field-label" :title="field.key" :text="field.label"></span>
203
+ <span class="dashboard-config-intro">Unset</span>
297
204
  @else
298
- <div class="px-3 py-2 break-all font-mono text-neutral-500 text-xs dark:text-neutral-400 bg-neutral-50 dark:bg-white/[0.03] border border-neutral-200 rounded-lg dark:border-white/10">
299
- {{ displayValue(field) }}
205
+ <div class="min-w-0">
206
+ <label :for="'dashboard-config-field-' + index" class="dashboard-config-field-label" :title="field.key" :text="field.label"></label>
207
+ <p :if="field.description" :id="'dashboard-config-help-' + index" class="dashboard-config-field-description" :text="field.description"></p>
300
208
  </div>
301
- <p class="mt-1.5 text-amber-700 text-xs dark:text-amber-300">{{ field.reason }}</p>
209
+ @if(field.type === 'number')
210
+ <input :id="'dashboard-config-field-' + index" data-dashboard-field type="number" step="any" required
211
+ :aria-describedby="field.description ? 'dashboard-config-help-' + index : null"
212
+ class="dashboard-config-input" x-model="drafts[field.key]" :disabled="saving()">
213
+ @else
214
+ <input :id="'dashboard-config-field-' + index" data-dashboard-field :type="fieldInputType(field)" autocomplete="off"
215
+ :aria-describedby="field.description ? 'dashboard-config-help-' + index : null"
216
+ class="dashboard-config-input" x-model="drafts[field.key]" :disabled="saving()">
217
+ @endif
302
218
  @endif
303
219
  </div>
220
+ @endif
221
+ </div>
222
+ <div :if="filteredFields().length > fieldLimit()" class="p-3">
223
+ <Button variant="secondary" size="sm" @click="fieldLimit.update(limit => limit + 40)">Show more fields</Button>
304
224
  </div>
305
- </form>
306
- @endif
307
- </SettingsGroup>
225
+ </div>
226
+ </form>
227
+ <div :if="dnsFile() && mode() === 'fields'">
228
+ <DnsRecordsSettings @saved="setDocument($event)" />
229
+ </div>
230
+ </SettingsGroup>
231
+ </div>
308
232
 
309
- <ConfirmDialog
310
- :isOpen="Boolean(pendingSelection())"
311
- title="Discard unsaved changes?"
312
- description="Switching configuration files will discard the edits in this file."
313
- confirmLabel="Discard changes"
314
- variant="warning"
315
- @close="cancelPendingSelection"
316
- @confirm="discardAndSelect"
317
- />
233
+ <ConfirmDialog :isOpen="Boolean(pending())" :title="discardTitle" :description="discardDescription"
234
+ confirmLabel="Discard Changes" variant="warning" @close="pending.set(null)" @confirm="discardAndContinue()" />
318
235
  </div>
319
236
  </template>
@@ -0,0 +1,87 @@
1
+ <script client>
2
+ import { contextMenu } from '@stacksjs/desktop/browser'
3
+
4
+ interface PickerOption {
5
+ value: string
6
+ label: string
7
+ disabled?: boolean
8
+ }
9
+
10
+ const value = useReactiveProp('value', '')
11
+ const options = useReactiveProp<PickerOption[]>('options', [])
12
+ const label = useReactiveProp('label', '')
13
+ const ariaLabel = useReactiveProp('ariaLabel', '')
14
+ const hint = useReactiveProp('hint', '')
15
+ const error = useReactiveProp('error', '')
16
+ const disabled = useReactiveProp('disabled', false)
17
+ const native = state(contextMenu.available())
18
+ const showingMenu = state(false)
19
+ const emit = defineEmits(['change'])
20
+ const hintId = useId('settings-picker-hint')
21
+ const selectedLabel = derived(() => options().find(option => option.value === value())?.label ?? '')
22
+ const accessibleLabel = derived(() => ariaLabel() || label())
23
+ const describedBy = derived(() => error() || hint() ? hintId : null)
24
+
25
+ useEventListener('craft:ready', () => native.set(contextMenu.available()))
26
+
27
+ async function showMenu(event: Event): Promise<void> {
28
+ if (disabled() || showingMenu())
29
+ return
30
+ const anchor = event.currentTarget as HTMLButtonElement
31
+ const { left, bottom } = anchor.getBoundingClientRect()
32
+ const current = options()
33
+ const selected = value()
34
+ showingMenu.set(true)
35
+ try {
36
+ const id = await contextMenu.pick({
37
+ x: Math.round(left),
38
+ y: Math.round(bottom),
39
+ items: current.map((option, index) => ({
40
+ id: String(index),
41
+ title: option.label,
42
+ disabled: option.disabled,
43
+ checked: option.value === selected,
44
+ })),
45
+ })
46
+ const choice = id == null ? undefined : current[Number(id)]
47
+ if (choice && !disabled() && options().some(option => option.value === choice.value && !option.disabled) && choice.value !== value())
48
+ emit('change', choice.value)
49
+ }
50
+ catch {
51
+ native.set(false)
52
+ }
53
+ finally {
54
+ showingMenu.set(false)
55
+ }
56
+ }
57
+
58
+ function change(event: Event): void {
59
+ const select = event.currentTarget as HTMLSelectElement
60
+ const next = select.value
61
+ select.value = value()
62
+ if (next !== value())
63
+ emit('change', next)
64
+ }
65
+ </script>
66
+
67
+ <label class="dashboard-settings-picker">
68
+ <span :if="label()" class="dashboard-settings-picker-label" :text="label()"></span>
69
+ <span class="dashboard-settings-picker-control">
70
+ <button :if="native()" class="dashboard-settings-picker-button" type="button" aria-haspopup="menu"
71
+ :aria-expanded="String(showingMenu())" :aria-label="accessibleLabel() + (selectedLabel() ? ', ' + selectedLabel() : '')"
72
+ :aria-describedby="describedBy()" :aria-invalid="error() ? 'true' : null"
73
+ :disabled="disabled() || options().length === 0"
74
+ @click="showMenu">
75
+ <span :text="selectedLabel()"></span>
76
+ </button>
77
+ <select :else class="dashboard-settings-picker-button" data-ui-select data-dashboard-field
78
+ :aria-label="accessibleLabel()" :aria-describedby="describedBy()" :aria-invalid="error() ? 'true' : null"
79
+ :disabled="disabled() || options().length === 0" @change="change">
80
+ <option :for="option in options()" :key="option.value" :value="option.value"
81
+ :selected="option.value === value()" :disabled="option.disabled" :text="option.label"></option>
82
+ </select>
83
+ <span class="dashboard-settings-picker-glyph i-f7-chevron-up-chevron-down" aria-hidden="true"></span>
84
+ </span>
85
+ <span :if="error() || hint()" :id="hintId" :data-invalid="String(Boolean(error()))"
86
+ class="dashboard-settings-picker-hint" :text="error() || hint()"></span>
87
+ </label>
@@ -0,0 +1,11 @@
1
+ export function serializeEnvironmentValue(value: string): string {
2
+ if (!value)
3
+ return ''
4
+ if (/^[A-Za-z0-9_./:@+-]+$/.test(value))
5
+ return value
6
+
7
+ return `"${value
8
+ .replace(/\\/g, '\\\\')
9
+ .replace(/"/g, '\\"')
10
+ .replace(/\n/g, '\\n')}"`
11
+ }
@@ -46,7 +46,7 @@ const sectionPages = {
46
46
  analytics: ['/analytics'],
47
47
  management: ['/management', '/cloud', '/servers', '/remote', '/serverless', '/dns', '/mailboxes', '/logs', '/health', '/insights', '/kanban'],
48
48
  // Settings is also opened by the native application menu and the browser account menu.
49
- utilities: ['/buddy', '/environment', '/access-tokens'],
49
+ utilities: ['/buddy', '/access-tokens'],
50
50
  ci: ['/ci'],
51
51
  } as const satisfies Partial<Record<keyof ResolvedDashboardToggles, readonly string[]>>
52
52