@stacksjs/defaults 0.75.674 → 0.75.685

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 (57) hide show
  1. package/ai/skills/stacks-ai/SKILL.md +7 -2
  2. package/ai/skills/stacks-api/SKILL.md +1 -1
  3. package/ai/skills/stacks-dashboard/SKILL.md +9 -2
  4. package/ai/skills/stacks-deploy/SKILL.md +8 -0
  5. package/ai/skills/stacks-desktop/SKILL.md +31 -0
  6. package/ai/skills/stacks-development/SKILL.md +5 -7
  7. package/ai/skills/stacks-health/SKILL.md +19 -9
  8. package/ai/skills/stacks-native/CATALOG.md +24 -24
  9. package/ai/skills/stacks-newsletter/SKILL.md +10 -4
  10. package/ai/skills/stacks-router/SKILL.md +2 -2
  11. package/ai/skills/stacks-routes/SKILL.md +2 -2
  12. package/ai/skills/stacks-scheduler/SKILL.md +16 -2
  13. package/ai/skills/stacks-security/SKILL.md +24 -0
  14. package/ai/skills/stacks-socials/SKILL.md +17 -1
  15. package/ai/skills/stacks-storage/SKILL.md +34 -15
  16. package/app/Actions/SubscriberEmailAction.ts +26 -10
  17. package/app/Jobs/Inspire.ts +33 -0
  18. package/functions/dashboard-sidebar-order.ts +3 -0
  19. package/ide/vscode/package.json +1 -1
  20. package/package.json +8 -7
  21. package/project/storage/framework/types/request-context.d.ts +3 -0
  22. package/resources/components/Dashboard/Billing/BillingPaymentMethodsPanel.stx +3 -10
  23. package/resources/components/Dashboard/Billing/BillingPlanSummary.stx +3 -10
  24. package/resources/components/Dashboard/Billing/BillingSettings.stx +13 -15
  25. package/resources/components/Dashboard/Billing/BillingTransactionHistory.stx +2 -9
  26. package/resources/components/Dashboard/DashboardSectionLanding.stx +72 -0
  27. package/resources/components/Dashboard/DashboardSectionSidebar.stx +78 -0
  28. package/resources/components/Dashboard/GlobalSearch.stx +3 -1
  29. package/resources/components/Dashboard/Home/DashboardHome.stx +14 -1
  30. package/resources/components/Dashboard/Settings/AppearanceSettingsDashboard.stx +21 -92
  31. package/resources/components/Dashboard/Settings/DashboardSettingsFrame.stx +98 -0
  32. package/resources/components/Dashboard/Settings/DashboardThemePicker.stx +4 -9
  33. package/resources/components/Dashboard/Settings/MailSettingsDashboard.stx +162 -167
  34. package/resources/components/Dashboard/Settings/SettingsDashboard.stx +34 -30
  35. package/resources/components/Dashboard/Settings/SoftwareUpdateDashboard.stx +229 -0
  36. package/resources/components/Dashboard/UI/DashboardNavigationCards.stx +44 -0
  37. package/resources/components/Dashboard/UI/Input.stx +1 -0
  38. package/resources/components/Dashboard/UI/Select.stx +1 -0
  39. package/resources/components/Dashboard/UI/Table.stx +1 -0
  40. package/resources/components/Dashboard/UI/Textarea.stx +1 -0
  41. package/resources/components/Marketing/SubscribeForm.stx +29 -8
  42. package/resources/functions/dashboard/section-landing.ts +201 -0
  43. package/resources/functions/dashboard/section-navigation.ts +95 -0
  44. package/styles/dashboard-theme.css +778 -9
  45. package/views/dashboard/composables/dashboard-themes.ts +5 -5
  46. package/views/dashboard/composables/settings-window.ts +116 -0
  47. package/views/dashboard/composables/useAppearance.ts +13 -4
  48. package/views/dashboard/composables/useDashboardThemes.ts +2 -1
  49. package/views/dashboard/composables/useSettingsWindow.ts +23 -0
  50. package/views/dashboard/layouts/default.stx +32 -20
  51. package/views/dashboard/layouts/settings.stx +48 -0
  52. package/views/dashboard/sections/[section].stx +19 -0
  53. package/views/dashboard/settings/appearance.stx +4 -2
  54. package/views/dashboard/settings/billing.stx +3 -4
  55. package/views/dashboard/settings/index.stx +4 -2
  56. package/views/dashboard/settings/mail.stx +3 -3
  57. package/views/dashboard/settings/software-update.stx +9 -0
@@ -0,0 +1,229 @@
1
+ <script server>
2
+ import { dashboardProjectIdentity } from '@stacksjs/defaults/resources/functions/dashboard/project-switcher'
3
+
4
+ export const localUpdates = dashboardProjectIdentity().enabled
5
+ defineClientPayload({ localUpdates })
6
+ </script>
7
+
8
+ <script client>
9
+ import { dashboardApi, DashboardApiError } from '@stacksjs/defaults/functions/dashboard-api'
10
+
11
+ interface UpdateProject {
12
+ id: string
13
+ name: string
14
+ current: boolean
15
+ installed: string | null
16
+ latest: string | null
17
+ available: boolean
18
+ supported: boolean
19
+ }
20
+
21
+ type RestartStatus = 'queued' | 'restarting' | 'complete' | 'failed' | 'interrupted'
22
+
23
+ interface UpdateReport {
24
+ id: string
25
+ running: boolean
26
+ restarting?: boolean
27
+ restartAvailable?: boolean
28
+ projects: Array<{ id: string, name: string, version: string, restartStatus?: RestartStatus, restartMessage?: string, status: 'queued' | 'updating' | 'complete' | 'failed' | 'interrupted', message?: string }>
29
+ logFile: string
30
+ }
31
+
32
+ interface UpdateStatus {
33
+ checked: boolean
34
+ projects: UpdateProject[]
35
+ update: UpdateReport | null
36
+ }
37
+
38
+ const endpoint = '/__buddy/software-update'
39
+ const enabled = {{ localUpdates }}
40
+ const snapshot = state<UpdateStatus | null>(null)
41
+ const selection = state<string[]>([])
42
+ const checking = state(false)
43
+ const starting = state(false)
44
+ const requestingRestart = state(false)
45
+ const failure = state('')
46
+ const report = derived(() => snapshot()?.update ?? null)
47
+ const running = derived(() => Boolean(report()?.running))
48
+ const restarting = derived(() => Boolean(report()?.restarting))
49
+ const busy = derived(() => checking() || starting() || requestingRestart() || running())
50
+ const projects = derived(() => snapshot()?.projects ?? [])
51
+ const current = derived(() => projects().find(project => project.current))
52
+ const selectedProjects = derived(() => projects().filter(project => project.available && selection().includes(project.id)))
53
+ const availableCount = derived(() => projects().filter(project => project.available).length)
54
+
55
+ const restartAvailable = derived(() => report()?.restartAvailable === true)
56
+ const updatesInstalled = derived(() => report()?.projects.some(project => project.status === 'complete') === true)
57
+ const projectsRestarted = derived(() => report()?.projects.some(project => project.restartStatus === 'complete') === true)
58
+ const restartFailed = derived(() => report()?.projects.some(project => project.restartStatus === 'failed' || project.restartStatus === 'interrupted') === true)
59
+ const reportHasErrors = derived(() => report()?.projects.some(project => project.status === 'failed' || project.status === 'interrupted') === true)
60
+ const reportProjects = derived(() => report()?.projects ?? [])
61
+ const statuses = { queued: 'Waiting', updating: 'Updating…', complete: 'Updated', failed: 'Failed', interrupted: 'Interrupted' }
62
+ const restartStatuses = { queued: 'Waiting', restarting: 'Restarting…', complete: 'Restarted', failed: 'Restart failed', interrupted: 'Restart interrupted' }
63
+
64
+ function statusLabel(project: UpdateReport['projects'][number]): string {
65
+ return project.restartStatus ? restartStatuses[project.restartStatus] : statuses[project.status]
66
+ }
67
+
68
+ let initialized = false
69
+
70
+ async function refresh(check = false): Promise<void> {
71
+ const next = await dashboardApi<UpdateStatus>(endpoint + (check ? '?check=1' : ''))
72
+ snapshot.set(next)
73
+ if (!initialized) {
74
+ selection.set(next.projects.filter(project => project.current && project.available).map(project => project.id))
75
+ initialized = true
76
+ }
77
+ }
78
+
79
+ async function checkUpdates(): Promise<void> {
80
+ checking.set(true)
81
+ failure.set('')
82
+ try {
83
+ await refresh(true)
84
+ }
85
+ catch (error) {
86
+ failure.set(error instanceof Error ? error.message : 'Could not check for updates.')
87
+ }
88
+ finally {
89
+ checking.set(false)
90
+ }
91
+ }
92
+
93
+ async function pollUpdate(): Promise<void> {
94
+ if (!running() || checking() || starting() || requestingRestart())
95
+ return
96
+ try {
97
+ await refresh()
98
+ }
99
+ catch {
100
+ // The Buddy worker continues while a dashboard restarts or reconnects.
101
+ }
102
+ }
103
+
104
+ function selectProject(id: string, checked: boolean): void {
105
+ const next = selection().filter(project => project !== id)
106
+ selection.set(checked ? [...next, id] : next)
107
+ }
108
+
109
+ async function installUpdates(): Promise<void> {
110
+ const ids = selectedProjects().map(project => project.id)
111
+ if (!ids.length || busy())
112
+ return
113
+ starting.set(true)
114
+ failure.set('')
115
+ try {
116
+ const result = await dashboardApi<{ update: UpdateReport }>(endpoint + '/install', { method: 'POST', body: { projects: ids } })
117
+ const previous = snapshot()
118
+ if (previous)
119
+ snapshot.set({ ...previous, update: result.update })
120
+ }
121
+ catch (error) {
122
+ failure.set(error instanceof Error ? error.message : 'Buddy could not start the update.')
123
+ }
124
+ finally {
125
+ starting.set(false)
126
+ }
127
+ }
128
+
129
+ async function restartProjects(): Promise<void> {
130
+ const previous = snapshot()
131
+ const update = previous?.update
132
+ if (!update || !restartAvailable() || busy())
133
+ return
134
+ requestingRestart.set(true)
135
+ failure.set('')
136
+ try {
137
+ const result = await dashboardApi<{ update: UpdateReport }>(endpoint + '/restart', { method: 'POST', body: { updateId: update.id } })
138
+ snapshot.set({ ...previous, update: result.update })
139
+ }
140
+ catch (error) {
141
+ if (error instanceof DashboardApiError) {
142
+ failure.set(error.message)
143
+ }
144
+ else {
145
+ // Buddy can accept the restart just before this connection goes down.
146
+ // Keep polling until the dashboard can report what happened.
147
+ snapshot.set({ ...previous, update: { ...update, running: true, restarting: true } })
148
+ }
149
+ }
150
+ finally {
151
+ requestingRestart.set(false)
152
+ }
153
+ }
154
+
155
+ function projectDescription(project: UpdateProject): string {
156
+ const installed = project.installed ? `Stacks ${project.installed}` : 'Installed version unavailable'
157
+ if (project.available)
158
+ return project.installed === project.latest ? `${installed} · Retry available` : `${installed} → ${project.latest}`
159
+ if (!project.supported)
160
+ return `${installed} · Buddy could not identify a Stacks installation`
161
+ if (!project.latest)
162
+ return `${installed} · Release check unavailable`
163
+ return project.installed === project.latest
164
+ ? `${installed} · Up to date`
165
+ : `${installed} · Latest stable is ${project.latest}`
166
+ }
167
+
168
+ useInterval(() => { void pollUpdate() }, 1800)
169
+ onMount(() => {
170
+ if (enabled)
171
+ void checkUpdates()
172
+ })
173
+ </script>
174
+
175
+ <div class="dashboard-settings-stack">
176
+ @if(!localUpdates)
177
+ <SettingsGroup>
178
+ <SettingsRow label="Software Update is available in your local dashboard" description="Open this project through Buddy to check for and install updates." multiline />
179
+ </SettingsGroup>
180
+ @else
181
+ <SettingsGroup header="Stacks Framework">
182
+ <SettingsRow label="Latest stable release" description="Buddy updates Stacks, installs the project’s framework dependencies, and runs its upgrade hooks." setting="check-for-updates" multiline>
183
+ <Button variant="secondary" size="sm" :loading="checking()" :disabled="busy()" @click="checkUpdates()">Check for Updates</Button>
184
+ </SettingsRow>
185
+ <SettingsRow label="Installed version" setting="installed-framework">
186
+ <span :text="current()?.installed || 'Unavailable'"></span>
187
+ </SettingsRow>
188
+ <SettingsRow label="Available version" setting="available-framework">
189
+ <span :text="checking() ? 'Checking…' : current()?.latest || 'Unavailable'"></span>
190
+ </SettingsRow>
191
+ </SettingsGroup>
192
+
193
+ <p :if="failure()" class="px-3 text-red-700 text-sm dark:text-red-300" role="alert" :text="failure()"></p>
194
+
195
+ <div :if="projects().length > 0">
196
+ <SettingsGroup header="Projects" footer="Your current project runs first when selected. Select any other registered projects to update their Stacks installations too.">
197
+ <div :for="project in projects()" :key="project.id" class="dashboard-settings-section-toggle">
198
+ <SettingsRow :label="project.current ? project.name + ' (Current project)' : project.name" :description="projectDescription(project)" multiline>
199
+ <Switch :if="project.available" :checked="selection().includes(project.id)" :disabled="busy()" :label="'Update ' + project.name" variant="mac" @change="selectProject(project.id, $event)" />
200
+ </SettingsRow>
201
+ </div>
202
+ <SettingsRow :if="availableCount() > 0" label="Install updates" setting="install-updates">
203
+ <Button size="sm" :loading="starting()" :disabled="busy() || selectedProjects().length === 0" @click="installUpdates()">Update Now</Button>
204
+ </SettingsRow>
205
+ </SettingsGroup>
206
+ </div>
207
+
208
+ <div :if="report()">
209
+ <SettingsGroup header="Update progress">
210
+ <div :for="project in reportProjects()" :key="project.id" class="dashboard-settings-section-toggle">
211
+ <SettingsRow :label="project.name" :description="project.restartMessage || project.message || 'Stacks ' + project.version" multiline>
212
+ <span :text="statusLabel(project)"></span>
213
+ </SettingsRow>
214
+ </div>
215
+ <p :if="running() && !restarting()" class="p-3 text-neutral-600 text-xs dark:text-neutral-300" role="status">Buddy is installing updates. You can close this window.</p>
216
+ <div :if="restartAvailable() || restarting()" class="dashboard-settings-section-toggle">
217
+ <SettingsRow label="Restart required" description="Restart the running app services and dashboards to load the new framework." setting="restart-updated-projects">
218
+ <Button size="sm" class="whitespace-nowrap" :loading="requestingRestart() || restarting()" :disabled="busy()" @click="restartProjects()">
219
+ {{ restarting() ? 'Restarting…' : 'Restart Now' }}
220
+ </Button>
221
+ </SettingsRow>
222
+ </div>
223
+ <p :if="!running() && !restartAvailable() && updatesInstalled() && !projectsRestarted() && !restartFailed()" class="p-3 text-neutral-600 text-xs dark:text-neutral-300" role="status">The updated framework will load the next time these projects start.</p>
224
+ <p :if="!running() && projectsRestarted() && !restartFailed()" class="p-3 text-neutral-600 text-xs dark:text-neutral-300" role="status">The updated projects restarted.</p>
225
+ <p :if="reportHasErrors() || restartFailed()" class="p-3 break-all text-red-700 text-xs dark:text-red-300" role="alert">Buddy log <code :text="report()?.logFile"></code></p>
226
+ </SettingsGroup>
227
+ </div>
228
+ @endif
229
+ </div>
@@ -0,0 +1,44 @@
1
+ <script server>
2
+ import type { DashboardNavigationCard } from '@stacksjs/defaults/resources/functions/dashboard/section-navigation'
3
+
4
+ const { navigationCards = [], emptyLabel = '' } = defineProps<{
5
+ navigationCards: DashboardNavigationCard[]
6
+ emptyLabel?: string
7
+ }>()
8
+ defineClientPayload({ navigationCards, emptyLabel })
9
+ </script>
10
+
11
+ <script client>
12
+ import { canSeeDashboardCard } from '@stacksjs/defaults/resources/functions/dashboard/section-navigation'
13
+ import { authStore } from '@stacksjs/defaults/views/dashboard/stores/auth'
14
+
15
+ const cards = {{ navigationCards }}
16
+ const emptyMessage = {{ emptyLabel }}
17
+ const visibleCards = derived(() => {
18
+ const roles = authStore.roles()
19
+ const localViewer = authStore.unauthenticated()
20
+ return cards.filter(card => canSeeDashboardCard(card, roles, localViewer))
21
+ })
22
+ </script>
23
+
24
+ <div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3" data-dashboard-navigation-cards>
25
+ <a
26
+ data-stx-link
27
+ :for="card in visibleCards()"
28
+ :href="card.href"
29
+ :data-section-id="card.section"
30
+ data-dashboard-card="default"
31
+ data-dashboard-navigation-card
32
+ class="flex overflow-hidden relative gap-3 items-start p-4 min-w-0 no-underline bg-white dark:bg-neutral-900 border border-neutral-200 rounded-xl dark:border-neutral-800"
33
+ >
34
+ <span class="dashboard-section-icon" aria-hidden="true">
35
+ <span :class="card.icon"></span>
36
+ </span>
37
+ <span class="flex flex-1 flex-col gap-1 min-w-0">
38
+ <span data-dashboard-ink class="font-semibold text-neutral-900 text-sm dark:text-white" :text="card.label"></span>
39
+ <span data-dashboard-muted :if="card.description" class="text-neutral-600 text-xs dark:text-neutral-400" :text="card.description"></span>
40
+ </span>
41
+ <span aria-hidden="true" class="shrink-0 h-4 w-4 i-f7-chevron-right" data-dashboard-muted></span>
42
+ </a>
43
+ </div>
44
+ <p :if="emptyMessage && !authStore.loading() && visibleCards().length === 0" class="text-neutral-600 text-sm dark:text-neutral-400" :text="emptyMessage"></p>
@@ -115,6 +115,7 @@ function handleKeydown(event: KeyboardEvent): void {
115
115
  </div>
116
116
  @endif
117
117
  <input
118
+ data-dashboard-field
118
119
  :id="inputId()"
119
120
  :type="liveType()"
120
121
  x-model="liveValue"
@@ -83,6 +83,7 @@ function handleChange(event: Event): void {
83
83
  <div class="relative">
84
84
  <select
85
85
  data-ui-select
86
+ data-dashboard-field
86
87
  :id="selectId()"
87
88
  :name="liveName() || null"
88
89
  :aria-label="liveAriaLabel() || liveLabel() || null"
@@ -792,6 +792,7 @@ function cellClass(column: DashboardTableColumn, index: number): string {
792
792
  <div :if="searchable()" class="relative">
793
793
  <span aria-hidden="true" class="absolute left-2.5 top-1/2 h-4 w-4 text-neutral-400 -translate-y-1/2 i-hugeicons-search-01"></span>
794
794
  <input
795
+ data-dashboard-field
795
796
  type="search"
796
797
  :placeholder="searchPlaceholder()"
797
798
  :aria-label="searchPlaceholder()"
@@ -102,6 +102,7 @@ function handleKeydown(event: KeyboardEvent): void {
102
102
 
103
103
  <div class="relative">
104
104
  <textarea
105
+ data-dashboard-field
105
106
  :id="textareaId()"
106
107
  :name="liveName() || null"
107
108
  :rows="liveRows()"
@@ -1,3 +1,21 @@
1
+ <script server>
2
+ // What the form shows before its client script has run. Rendered here, so an
3
+ // island (`client="interaction"`) or a page whose script has not loaded yet
4
+ // still has a labelled field and a button that says what it does, and a plain
5
+ // form post carries its source and return address.
6
+ const props = defineProps()
7
+ const initial = {
8
+ label: props.label || 'Subscribe',
9
+ placeholder: props.placeholder || 'you@example.com',
10
+ intro: props.intro || '',
11
+ fine: props.fine || '',
12
+ source: props.source || 'website',
13
+ list: props.list || '',
14
+ returnTo: props.returnTo || '',
15
+ buttonClass: `${props.tone === 'outline' ? 'subscribe-form__button--outline ' : ''}${props.buttonClass || ''}`.trim(),
16
+ }
17
+ </script>
18
+
1
19
  <script client>
2
20
  /*
3
21
  * A newsletter signup, answered in place. Drop it on any page:
@@ -62,6 +80,8 @@ const messages = {
62
80
  const outcomes = ['subscribed', 'pending', 'already', 'invalid', 'busy', 'error']
63
81
 
64
82
  const email = state('')
83
+ // The honeypot. People never see the field; a bot that fills it is answered as if it worked.
84
+ const website = state('')
65
85
  const sending = state(false)
66
86
  const outcome = state<Outcome | ''>(outcomes.includes(loadedWith()) ? loadedWith() as Outcome : '')
67
87
  const tonePositive = derived(() => outcome() === 'subscribed' || outcome() === 'pending' || outcome() === 'already')
@@ -102,7 +122,7 @@ async function send(): Promise<Outcome> {
102
122
  const response = await fetch('/api/email/subscribe', {
103
123
  method: 'POST',
104
124
  headers: { 'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' },
105
- body: new URLSearchParams({ email: email(), source: source(), list: list(), return: returnTo() }).toString(),
125
+ body: new URLSearchParams({ email: email(), source: source(), list: list(), return: returnTo(), website: website() }).toString(),
106
126
  })
107
127
  let body: { success?: unknown, pending?: unknown, message?: unknown } | null = null
108
128
  try {
@@ -140,15 +160,16 @@ async function submit(): Promise<void> {
140
160
  :aria-busy="sending() ? 'true' : 'false'"
141
161
  @submit.prevent="submit()"
142
162
  >
143
- <input type="hidden" name="source" :value="source()">
144
- <input type="hidden" name="list" :value="list()">
145
- <input type="hidden" name="return" :value="returnTo()">
146
- <label class="subscribe-form__intro" :class="intro() ? '' : 'subscribe-form__sr'" for="subscribe-email">{{ intro() || 'Email address' }}</label>
163
+ <input type="hidden" name="source" value="{{ initial.source }}" :value="source()">
164
+ <input type="hidden" name="list" value="{{ initial.list }}" :value="list()">
165
+ <input type="hidden" name="return" value="{{ initial.returnTo }}" :value="returnTo()">
166
+ <input class="subscribe-form__sr" type="text" name="website" value="" tabindex="-1" autocomplete="off" aria-hidden="true" x-model="website">
167
+ <label class="subscribe-form__intro {{ initial.intro ? '' : 'subscribe-form__sr' }}" :class="intro() ? '' : 'subscribe-form__sr'" for="subscribe-email" :text="intro() || 'Email address'">{{ initial.intro || 'Email address' }}</label>
147
168
  <div class="subscribe-form__row">
148
- <input id="subscribe-email" ref="emailInput" class="subscribe-form__field" type="email" name="email" :placeholder="placeholder()" autocomplete="email" required x-model.trim="email">
149
- <button type="submit" class="subscribe-form__button" :class="(tone() === 'outline' ? 'subscribe-form__button--outline ' : '') + buttonClass()" :disabled="sending()">
169
+ <input id="subscribe-email" ref="emailInput" class="subscribe-form__field" type="email" name="email" placeholder="{{ initial.placeholder }}" :placeholder="placeholder()" autocomplete="email" required x-model.trim="email">
170
+ <button type="submit" class="subscribe-form__button {{ initial.buttonClass }}" :class="(tone() === 'outline' ? 'subscribe-form__button--outline ' : '') + buttonClass()" :disabled="sending()">
150
171
  <span class="subscribe-form__spinner" aria-hidden="true"></span>
151
- <span>{{ label() }}</span>
172
+ <span :text="label()">{{ initial.label }}</span>
152
173
  </button>
153
174
  </div>
154
175
  <p class="subscribe-form__notice" :class="noticeClass()" role="status" aria-live="polite">
@@ -0,0 +1,201 @@
1
+ import type { DashboardNavigationCard, DashboardNavigationHub } from './section-navigation'
2
+ import { canSeeDashboardCard, dashboardNavigationPath } from './section-navigation'
3
+
4
+ interface LandingDefinition {
5
+ introduction: string
6
+ primary: string
7
+ featured: Record<string, string>
8
+ groups?: Record<string, string[]>
9
+ }
10
+
11
+ const landings: Record<string, LandingDefinition> = {
12
+ library: {
13
+ introduction: 'Browse the pieces of your project, from interface components to functions and installed packages.',
14
+ primary: '/library/components',
15
+ featured: {
16
+ '/functions': 'Find the shared functions available in your application.',
17
+ '/packages': 'See the packages your project installs and depends on.',
18
+ '/releases': 'Look through released versions of the project.',
19
+ },
20
+ },
21
+ content: {
22
+ introduction: 'Find what you’re working on, make changes, and keep published content organized.',
23
+ primary: '/content/posts',
24
+ featured: {
25
+ '/content/pages': 'Edit the pages visitors find on your site.',
26
+ '/content/files': 'Browse and organize the files on your storage disks.',
27
+ '/content/blog': 'Review blog activity and publishing.',
28
+ '/content/comments': 'Read and moderate responses to your posts.',
29
+ },
30
+ groups: {
31
+ 'Publishing': ['/content/dashboard', '/content/authors', '/content/categories', '/content/tags'],
32
+ 'Discoverability': ['/content/seo'],
33
+ },
34
+ },
35
+ app: {
36
+ introduction: 'Ship changes, follow background work, and see how the application is behaving.',
37
+ primary: '/deployments',
38
+ featured: {
39
+ '/operations/scheduler': 'Review scheduled tasks and their recent runs.',
40
+ '/requests': 'Inspect HTTP requests and response times.',
41
+ '/jobs': 'Follow work as it runs in the background.',
42
+ '/errors': 'Find captured exceptions and their context.',
43
+ },
44
+ groups: {
45
+ 'Background work': ['/actions', '/commands', '/queue', '/jobs'],
46
+ 'Diagnostics': ['/queries', '/realtime', '/search-engine'],
47
+ 'Messages': ['/inbox', '/notifications'],
48
+ },
49
+ },
50
+ data: {
51
+ introduction: 'Work with the people and records in your application, and see what’s changed recently.',
52
+ primary: '/models',
53
+ featured: {
54
+ '/data/users': 'Review accounts and manage individual users.',
55
+ '/data/teams': 'Browse teams and their members.',
56
+ '/data/activity': 'See recent changes made in the application.',
57
+ '/data/subscribers': 'Review the people on your subscriber list.',
58
+ },
59
+ groups: {
60
+ 'Data overview': ['/data/dashboard'],
61
+ },
62
+ },
63
+ commerce: {
64
+ introduction: 'Run the store from one place, from the products you sell to the orders customers place.',
65
+ primary: '/commerce/orders',
66
+ featured: {
67
+ '/commerce/products': 'Manage products, prices, and availability.',
68
+ '/commerce/customers': 'Find customers and review their order history.',
69
+ '/commerce/payments': 'Inspect recorded payments and their status.',
70
+ '/commerce/pos': 'Open the point of sale for in-person orders.',
71
+ },
72
+ groups: {
73
+ 'Catalog': ['/commerce/categories', '/commerce/manufacturers', '/commerce/units', '/commerce/variants', '/commerce/reviews'],
74
+ 'Promotions': ['/commerce/coupons', '/commerce/discounts', '/commerce/upsells', '/commerce/gift-cards', '/commerce/waitlist'],
75
+ 'Store operations': ['/commerce/dashboard', '/commerce/taxes', '/commerce/printers'],
76
+ },
77
+ },
78
+ delivery: {
79
+ introduction: 'Set up how orders reach customers and manage access to digital purchases.',
80
+ primary: '/commerce/delivery',
81
+ featured: {
82
+ '/commerce/delivery/shipping-methods': 'Manage the ways customers can receive an order.',
83
+ '/commerce/delivery/couriers': 'Review the couriers handling delivery.',
84
+ '/commerce/delivery/delivery-routes': 'Organize delivery routes.',
85
+ '/commerce/delivery/digital-delivery': 'Review digital items and their delivery.',
86
+ },
87
+ groups: {
88
+ 'Rates and regions': ['/commerce/delivery/shipping-rates', '/commerce/delivery/shipping-zones'],
89
+ 'Digital access': ['/commerce/delivery/license-keys'],
90
+ },
91
+ },
92
+ marketing: {
93
+ introduction: 'Plan outreach, keep track of your audiences, and see where customers are engaging.',
94
+ primary: '/marketing/campaigns',
95
+ featured: {
96
+ '/marketing/lists': 'Organize the audiences you want to reach.',
97
+ '/marketing/social-posts': 'Review and manage social posts.',
98
+ '/marketing/abandoned-carts': 'See storefront carts left before checkout.',
99
+ '/marketing/reviews': 'Review customer feedback on products.',
100
+ },
101
+ },
102
+ analytics: {
103
+ introduction: 'Understand how people find your application and what they do once they arrive.',
104
+ primary: '/analytics',
105
+ featured: {
106
+ '/analytics/web': 'Review traffic, visits, and engagement.',
107
+ '/analytics/pages': 'Find the pages people visit most.',
108
+ '/analytics/referrers': 'See which sources send people to your site.',
109
+ '/analytics/events': 'Explore events captured by the application.',
110
+ },
111
+ groups: {
112
+ 'Audience': ['/analytics/countries', '/analytics/browsers', '/analytics/devices'],
113
+ 'Channels': ['/analytics/blog', '/analytics/commerce', '/analytics/marketing'],
114
+ },
115
+ },
116
+ management: {
117
+ introduction: 'Check the services your application relies on and manage access to its infrastructure.',
118
+ primary: '/health',
119
+ featured: {
120
+ '/cloud': 'Review the cloud resources connected to this project.',
121
+ '/servers': 'Find the servers running your application.',
122
+ '/logs': 'Read application logs and trace recent activity.',
123
+ '/management/permissions': 'Review the roles and permissions used by the dashboard.',
124
+ },
125
+ groups: {
126
+ 'Infrastructure': ['/serverless', '/dns', '/remote', '/mailboxes'],
127
+ 'Team operations': ['/insights', '/kanban', '/ci'],
128
+ },
129
+ },
130
+ utilities: {
131
+ introduction: 'Configure your project and find the tools it uses to run.',
132
+ primary: '/settings',
133
+ featured: {
134
+ '/settings/appearance': 'Choose a dashboard theme and color mode.',
135
+ '/environment': 'Review the environment your application runs in.',
136
+ '/access-tokens': 'Manage tokens used to connect to the application.',
137
+ '/buddy': 'Browse commands for building and operating the project.',
138
+ },
139
+ groups: {
140
+ 'Email': ['/settings/mail'],
141
+ },
142
+ },
143
+ }
144
+
145
+ interface LandingGroup {
146
+ title: string
147
+ first: DashboardNavigationCard[]
148
+ more: DashboardNavigationCard[]
149
+ }
150
+
151
+ export function getDashboardSectionLanding(hub: DashboardNavigationHub, roles: readonly string[], localViewer: boolean): {
152
+ introduction: string
153
+ primary: DashboardNavigationCard | undefined
154
+ featured: DashboardNavigationCard[]
155
+ groups: LandingGroup[]
156
+ } {
157
+ const design = landings[hub.id]
158
+ const destinations = hub.destinations.filter(item => canSeeDashboardCard(item, roles, localViewer))
159
+ const featuredByPath = design?.featured
160
+ const primary = destinations.find(item => item.href === design?.primary)
161
+ ?? destinations.find(item => featuredByPath?.[item.href])
162
+ ?? destinations[0]
163
+ const used = new Set(primary ? [primary.id] : [])
164
+ const featured: DashboardNavigationCard[] = []
165
+ for (const [href, description] of Object.entries(featuredByPath ?? {})) {
166
+ const card = destinations.find(item => item.href === href && !used.has(item.id))
167
+ if (card) {
168
+ featured.push({ ...card, description })
169
+ used.add(card.id)
170
+ }
171
+ }
172
+ if (!design) {
173
+ for (const card of destinations.filter(item => !used.has(item.id)).slice(0, 4)) {
174
+ featured.push(card)
175
+ used.add(card.id)
176
+ }
177
+ }
178
+
179
+ const groups: LandingGroup[] = []
180
+ function addGroup(title: string, matches: (card: DashboardNavigationCard) => boolean): void {
181
+ const items = destinations.filter(card => !used.has(card.id) && matches(card))
182
+ if (!items.length)
183
+ return
184
+ for (const item of items)
185
+ used.add(item.id)
186
+ groups.push({ title, first: items.slice(0, 4), more: items.slice(4) })
187
+ }
188
+
189
+ for (const [title, paths] of Object.entries(design?.groups ?? {})) {
190
+ addGroup(title, ({ href }) => {
191
+ if (!href.startsWith('/') || href.startsWith('//'))
192
+ return false
193
+ const path = dashboardNavigationPath(href)
194
+ return paths.some(prefix => path === prefix || path.startsWith(`${prefix}/`))
195
+ })
196
+ }
197
+ addGroup('Model records', item => item.href.startsWith('/models/'))
198
+ addGroup('More pages', () => true)
199
+
200
+ return { introduction: design?.introduction ?? hub.description ?? '', primary, featured, groups }
201
+ }