sandcms 0.6.1 → 0.6.3
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/README.md +1 -1
- package/dist/admin/Account.svelte +284 -83
- package/dist/admin/ApiKeys.svelte +146 -79
- package/dist/admin/AssetAttachment.svelte +9 -9
- package/dist/admin/BlueprintFields.svelte +20 -2
- package/dist/admin/BlueprintFields.svelte.d.ts +2 -0
- package/dist/admin/Collection.svelte +111 -54
- package/dist/admin/Dashboard.svelte +3 -37
- package/dist/admin/DateField.svelte +75 -0
- package/dist/admin/DateField.svelte.d.ts +11 -0
- package/dist/admin/Editor.svelte +71 -65
- package/dist/admin/Fields.svelte +24 -16
- package/dist/admin/FocusPicker.svelte +1 -2
- package/dist/admin/Gallery.svelte +0 -1
- package/dist/admin/GlobalSearch.svelte +54 -26
- package/dist/admin/HoverHint.svelte +37 -0
- package/dist/admin/HoverHint.svelte.d.ts +8 -0
- package/dist/admin/Inbox.svelte +6 -11
- package/dist/admin/LinkField.svelte +129 -64
- package/dist/admin/Login.svelte +0 -1
- package/dist/admin/MediaLibrary.svelte +61 -50
- package/dist/admin/MediaPicker.svelte +57 -42
- package/dist/admin/NotificationSettings.svelte +35 -27
- package/dist/admin/RichText.svelte +2 -2
- package/dist/admin/RowMenu.svelte +28 -0
- package/dist/admin/RowMenu.svelte.d.ts +10 -0
- package/dist/admin/SearchList.svelte +51 -14
- package/dist/admin/Shell.svelte +64 -29
- package/dist/admin/Users.svelte +106 -50
- package/dist/admin/client.d.ts +2 -0
- package/dist/admin/client.js +18 -0
- package/dist/admin/components/ui/calendar/calendar-caption.svelte +76 -0
- package/dist/admin/components/ui/calendar/calendar-caption.svelte.d.ts +19 -0
- package/dist/admin/components/ui/calendar/calendar-cell.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-cell.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-day.svelte +33 -0
- package/dist/admin/components/ui/calendar/calendar-day.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid-body.svelte +12 -0
- package/dist/admin/components/ui/calendar/calendar-grid-body.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid-head.svelte +12 -0
- package/dist/admin/components/ui/calendar/calendar-grid-head.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid-row.svelte +12 -0
- package/dist/admin/components/ui/calendar/calendar-grid-row.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid.svelte +16 -0
- package/dist/admin/components/ui/calendar/calendar-grid.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-head-cell.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-head-cell.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-header.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-header.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-heading.svelte +16 -0
- package/dist/admin/components/ui/calendar/calendar-heading.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-month-select.svelte +48 -0
- package/dist/admin/components/ui/calendar/calendar-month-select.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-month.svelte +15 -0
- package/dist/admin/components/ui/calendar/calendar-month.svelte.d.ts +5 -0
- package/dist/admin/components/ui/calendar/calendar-months.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-months.svelte.d.ts +5 -0
- package/dist/admin/components/ui/calendar/calendar-nav.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-nav.svelte.d.ts +5 -0
- package/dist/admin/components/ui/calendar/calendar-next-button.svelte +37 -0
- package/dist/admin/components/ui/calendar/calendar-next-button.svelte.d.ts +8 -0
- package/dist/admin/components/ui/calendar/calendar-prev-button.svelte +37 -0
- package/dist/admin/components/ui/calendar/calendar-prev-button.svelte.d.ts +8 -0
- package/dist/admin/components/ui/calendar/calendar-year-select.svelte +47 -0
- package/dist/admin/components/ui/calendar/calendar-year-select.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar.svelte +115 -0
- package/dist/admin/components/ui/calendar/calendar.svelte.d.ts +21 -0
- package/dist/admin/components/ui/calendar/index.d.ts +19 -0
- package/dist/admin/components/ui/calendar/index.js +21 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-group.svelte +16 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-group.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +46 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte.d.ts +9 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-content.svelte +31 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-content.svelte.d.ts +10 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte +22 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte.d.ts +8 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-item.svelte +27 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +8 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-label.svelte +24 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-label.svelte.d.ts +8 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-portal.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-portal.svelte.d.ts +3 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte +16 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +36 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-separator.svelte +17 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-separator.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte +23 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte.d.ts +5 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +31 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte.d.ts +10 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +29 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte.d.ts +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub.svelte.d.ts +3 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-trigger.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-trigger.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu.svelte.d.ts +3 -0
- package/dist/admin/components/ui/dropdown-menu/index.d.ts +18 -0
- package/dist/admin/components/ui/dropdown-menu/index.js +18 -0
- package/dist/admin/components/ui/input-otp/index.d.ts +5 -0
- package/dist/admin/components/ui/input-otp/index.js +5 -0
- package/dist/admin/components/ui/input-otp/input-otp-group.svelte +23 -0
- package/dist/admin/components/ui/input-otp/input-otp-group.svelte.d.ts +5 -0
- package/dist/admin/components/ui/input-otp/input-otp-separator.svelte +27 -0
- package/dist/admin/components/ui/input-otp/input-otp-separator.svelte.d.ts +5 -0
- package/dist/admin/components/ui/input-otp/input-otp-slot.svelte +29 -0
- package/dist/admin/components/ui/input-otp/input-otp-slot.svelte.d.ts +4 -0
- package/dist/admin/components/ui/input-otp/input-otp.svelte +24 -0
- package/dist/admin/components/ui/input-otp/input-otp.svelte.d.ts +4 -0
- package/dist/admin/components/ui/popover/index.d.ts +9 -0
- package/dist/admin/components/ui/popover/index.js +11 -0
- package/dist/admin/components/ui/popover/popover-close.svelte +7 -0
- package/dist/admin/components/ui/popover/popover-close.svelte.d.ts +4 -0
- package/dist/admin/components/ui/popover/popover-content.svelte +31 -0
- package/dist/admin/components/ui/popover/popover-content.svelte.d.ts +10 -0
- package/dist/admin/components/ui/popover/popover-description.svelte +20 -0
- package/dist/admin/components/ui/popover/popover-description.svelte.d.ts +5 -0
- package/dist/admin/components/ui/popover/popover-header.svelte +20 -0
- package/dist/admin/components/ui/popover/popover-header.svelte.d.ts +5 -0
- package/dist/admin/components/ui/popover/popover-portal.svelte +7 -0
- package/dist/admin/components/ui/popover/popover-portal.svelte.d.ts +3 -0
- package/dist/admin/components/ui/popover/popover-title.svelte +20 -0
- package/dist/admin/components/ui/popover/popover-title.svelte.d.ts +5 -0
- package/dist/admin/components/ui/popover/popover-trigger.svelte +17 -0
- package/dist/admin/components/ui/popover/popover-trigger.svelte.d.ts +4 -0
- package/dist/admin/components/ui/popover/popover.svelte +7 -0
- package/dist/admin/components/ui/popover/popover.svelte.d.ts +3 -0
- package/dist/admin/components/ui/switch/switch.svelte +2 -2
- package/dist/admin/components/ui/tooltip/index.d.ts +6 -0
- package/dist/admin/components/ui/tooltip/index.js +8 -0
- package/dist/admin/components/ui/tooltip/tooltip-content.svelte +48 -0
- package/dist/admin/components/ui/tooltip/tooltip-content.svelte.d.ts +11 -0
- package/dist/admin/components/ui/tooltip/tooltip-portal.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip-portal.svelte.d.ts +4 -0
- package/dist/admin/components/ui/tooltip/tooltip-provider.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip-provider.svelte.d.ts +4 -0
- package/dist/admin/components/ui/tooltip/tooltip-trigger.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip-trigger.svelte.d.ts +25 -0
- package/dist/admin/components/ui/tooltip/tooltip.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip.svelte.d.ts +25 -0
- package/dist/admin/generated/admin.css +774 -138
- package/dist/admin/slug.d.ts +1 -0
- package/dist/admin/slug.js +6 -0
- package/dist/cli/doctor.js +2 -2
- package/dist/cli/files.js +11 -6
- package/dist/cli/index.js +1 -1
- package/dist/cli/upgrade.js +2 -1
- package/dist/env.d.ts +80 -0
- package/dist/env.js +103 -0
- package/dist/server/admin-load.d.ts +46 -76
- package/dist/server/admin-load.js +98 -24
- package/dist/server/api-pagination.d.ts +2 -0
- package/dist/server/api-pagination.js +51 -7
- package/dist/server/api.js +6 -1
- package/dist/server/auth.d.ts +1 -0
- package/dist/server/auth.js +23 -0
- package/dist/server/cms.d.ts +17 -2
- package/dist/server/cms.js +3 -1
- package/dist/server/content.d.ts +15 -2
- package/dist/server/content.js +72 -30
- package/dist/server/db/migration-data.js +8 -0
- package/dist/server/db/migrations/0007_content_and_job_indexes.sql +2 -0
- package/dist/server/db/migrations/0008_search_text_cache.sql +45 -0
- package/dist/server/db/migrations/meta/0007_snapshot.json +1643 -0
- package/dist/server/db/migrations/meta/0008_snapshot.json +1711 -0
- package/dist/server/db/migrations/meta/_journal.json +14 -0
- package/dist/server/db/schema.d.ts +83 -0
- package/dist/server/db/schema.js +23 -5
- package/dist/server/email/index.d.ts +5 -1
- package/dist/server/email/index.js +12 -11
- package/dist/server/media/runner.js +217 -191
- package/dist/server/media/service.d.ts +6 -0
- package/dist/server/media/service.js +36 -3
- package/dist/server/search.d.ts +2 -0
- package/dist/server/search.js +7 -0
- package/dist/worker/index.js +129 -76
- package/docs/api.md +1 -1
- package/docs/cloudflare.md +1 -1
- package/docs/deployment.md +15 -1
- package/docs/email.md +5 -5
- package/docs/media.md +2 -2
- package/docs/package.md +4 -4
- package/docs/releases.md +20 -0
- package/docs/upgrades.md +40 -1
- package/package.json +9 -3
- package/templates/env.ts +8 -0
- package/templates/integration.ts +5 -5
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount } from 'svelte';
|
|
3
|
-
import { api, message } from './client.js';
|
|
3
|
+
import { api, copyText, message } from './client.js';
|
|
4
4
|
import Notice from './Notice.svelte';
|
|
5
5
|
import * as Card from './components/ui/card/index.js';
|
|
6
6
|
import { Button } from './components/ui/button/index.js';
|
|
7
7
|
import { Input } from './components/ui/input/index.js';
|
|
8
8
|
import { Label } from './components/ui/label/index.js';
|
|
9
9
|
import SelectField from './SelectField.svelte';
|
|
10
|
+
import * as Dialog from './components/ui/dialog/index.js';
|
|
11
|
+
import * as Table from './components/ui/table/index.js';
|
|
12
|
+
import { Badge } from './components/ui/badge/index.js';
|
|
13
|
+
import Plus from '@lucide/svelte/icons/plus';
|
|
14
|
+
import KeyRound from '@lucide/svelte/icons/key-round';
|
|
10
15
|
type Key = {
|
|
11
16
|
id: string;
|
|
12
17
|
name: string;
|
|
@@ -20,7 +25,9 @@
|
|
|
20
25
|
let keys = $state<Key[]>([]),
|
|
21
26
|
name = $state(''),
|
|
22
27
|
scope = $state('read'),
|
|
23
|
-
days = $state(30)
|
|
28
|
+
days = $state('30'),
|
|
29
|
+
creating = $state(false),
|
|
30
|
+
copied = $state(false);
|
|
24
31
|
let secret = $state(''),
|
|
25
32
|
error = $state(''),
|
|
26
33
|
notice = $state(''),
|
|
@@ -49,10 +56,13 @@
|
|
|
49
56
|
const result = await api<{ key: string }>('keys/create', {
|
|
50
57
|
name,
|
|
51
58
|
scope,
|
|
52
|
-
expiresIn: days * 86400
|
|
59
|
+
expiresIn: Number(days) * 86400
|
|
53
60
|
});
|
|
54
61
|
secret = result.key;
|
|
62
|
+
copied = false;
|
|
55
63
|
name = '';
|
|
64
|
+
scope = 'read';
|
|
65
|
+
days = '30';
|
|
56
66
|
await refresh();
|
|
57
67
|
} catch (e) {
|
|
58
68
|
error = message(e);
|
|
@@ -60,6 +70,15 @@
|
|
|
60
70
|
busy = false;
|
|
61
71
|
}
|
|
62
72
|
}
|
|
73
|
+
async function copy() {
|
|
74
|
+
error = '';
|
|
75
|
+
try {
|
|
76
|
+
await copyText(secret);
|
|
77
|
+
copied = true;
|
|
78
|
+
} catch (e) {
|
|
79
|
+
error = message(e);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
63
82
|
async function revoke(id: string) {
|
|
64
83
|
busy = true;
|
|
65
84
|
error = '';
|
|
@@ -77,83 +96,131 @@
|
|
|
77
96
|
}
|
|
78
97
|
</script>
|
|
79
98
|
|
|
80
|
-
<Card.Root class="cms-detail-card">
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
99
|
+
<Card.Root class="cms-detail-card cms-settings-card">
|
|
100
|
+
<div class="cms-settings-header">
|
|
101
|
+
<div>
|
|
102
|
+
<h2>API keys</h2>
|
|
103
|
+
<p class="cms-muted">Keys can read or edit content and media, not users or submissions.</p>
|
|
104
|
+
</div>
|
|
105
|
+
<Button
|
|
106
|
+
variant="outline"
|
|
107
|
+
onclick={() => {
|
|
108
|
+
error = '';
|
|
109
|
+
secret = '';
|
|
110
|
+
creating = true;
|
|
111
|
+
}}><Plus size={15} />Create API key</Button
|
|
112
|
+
>
|
|
113
|
+
</div>
|
|
114
|
+
{#if error && !creating}<Notice error>{error}</Notice>{/if}
|
|
87
115
|
{#if notice}<Notice>{notice}</Notice>{/if}
|
|
88
|
-
{#if
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
116
|
+
{#if keys.length}
|
|
117
|
+
<Table.Root>
|
|
118
|
+
<Table.Header
|
|
119
|
+
><Table.Row
|
|
120
|
+
><Table.Head>Name</Table.Head><Table.Head>Access</Table.Head><Table.Head>Owner</Table.Head
|
|
121
|
+
><Table.Head>Expires</Table.Head><Table.Head>Last used</Table.Head><Table.Head
|
|
122
|
+
><span class="sr-only">Actions</span></Table.Head
|
|
123
|
+
></Table.Row
|
|
124
|
+
></Table.Header
|
|
125
|
+
><Table.Body
|
|
126
|
+
>{#each keys as key (key.id)}<Table.Row
|
|
127
|
+
><Table.Cell class="font-medium">{key.name}</Table.Cell><Table.Cell
|
|
128
|
+
><Badge variant="outline"
|
|
129
|
+
>{key.permissions?.cms?.includes('write') ? 'Read & write' : 'Read'}</Badge
|
|
130
|
+
></Table.Cell
|
|
131
|
+
><Table.Cell>{key.owner}</Table.Cell><Table.Cell
|
|
132
|
+
>{new Date(key.expiresAt).toLocaleDateString()}</Table.Cell
|
|
133
|
+
><Table.Cell class="cms-muted"
|
|
134
|
+
>{key.lastRequest ? new Date(key.lastRequest).toLocaleString() : 'Never'}</Table.Cell
|
|
135
|
+
><Table.Cell class="text-right"
|
|
136
|
+
><Button
|
|
137
|
+
variant="ghost"
|
|
138
|
+
size="sm"
|
|
139
|
+
disabled={busy}
|
|
140
|
+
aria-label={'Revoke ' + key.name}
|
|
141
|
+
onclick={() => revoke(key.id)}>Revoke</Button
|
|
142
|
+
></Table.Cell
|
|
143
|
+
></Table.Row
|
|
144
|
+
>{/each}</Table.Body
|
|
98
145
|
>
|
|
99
|
-
</
|
|
100
|
-
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
146
|
+
</Table.Root>
|
|
147
|
+
{:else if !busy}<div class="cms-empty cms-empty-compact">
|
|
148
|
+
<KeyRound size={28} />
|
|
149
|
+
<h3>No API keys</h3>
|
|
150
|
+
</div>{/if}
|
|
151
|
+
</Card.Root>
|
|
152
|
+
<Dialog.Root
|
|
153
|
+
bind:open={creating}
|
|
154
|
+
onOpenChange={(open) => {
|
|
155
|
+
if (!open) secret = '';
|
|
156
|
+
}}
|
|
157
|
+
><Dialog.Content portalProps={{ disabled: true }}
|
|
158
|
+
><Dialog.Header
|
|
159
|
+
><Dialog.Title>{secret ? 'Copy your API key' : 'Create API key'}</Dialog.Title
|
|
160
|
+
>{#if secret}<Dialog.Description>It won’t be shown again.</Dialog.Description
|
|
161
|
+
>{/if}</Dialog.Header
|
|
162
|
+
>
|
|
163
|
+
{#if secret}
|
|
164
|
+
<div class="cms-field">
|
|
165
|
+
<Label for="api-key-secret">New API key</Label>
|
|
166
|
+
<div class="cms-input-row">
|
|
167
|
+
<Input id="api-key-secret" value={secret} readonly />
|
|
168
|
+
<Button variant="outline" onclick={copy}>{copied ? 'Copied' : 'Copy'}</Button>
|
|
169
|
+
</div>
|
|
170
|
+
{#if error}<p class="cms-error" role="alert">{error}</p>{/if}
|
|
171
|
+
</div>
|
|
172
|
+
<Dialog.Footer
|
|
173
|
+
><Button
|
|
174
|
+
onclick={() => {
|
|
175
|
+
secret = '';
|
|
176
|
+
creating = false;
|
|
177
|
+
}}>Done</Button
|
|
178
|
+
></Dialog.Footer
|
|
179
|
+
>
|
|
180
|
+
{:else}
|
|
181
|
+
<form
|
|
182
|
+
class="cms-stack"
|
|
183
|
+
onsubmit={(event) => {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
create();
|
|
120
186
|
}}
|
|
121
|
-
options={[
|
|
122
|
-
{ value: 'read', label: 'Read' },
|
|
123
|
-
{ value: 'write', label: 'Write' }
|
|
124
|
-
]}
|
|
125
|
-
/>
|
|
126
|
-
<p class="cms-muted">
|
|
127
|
-
Write access includes reading, editing, publishing, and deleting content and media.
|
|
128
|
-
</p>
|
|
129
|
-
</div>
|
|
130
|
-
<div class="cms-field">
|
|
131
|
-
<Label for="api-key-days">Expires in days</Label>
|
|
132
|
-
<Input
|
|
133
|
-
id="api-key-days"
|
|
134
|
-
type="number"
|
|
135
|
-
bind:value={days}
|
|
136
|
-
min={1}
|
|
137
|
-
max={365}
|
|
138
|
-
step={1}
|
|
139
|
-
required
|
|
140
|
-
/>
|
|
141
|
-
</div>
|
|
142
|
-
<Button type="submit" disabled={busy}>Create API key</Button>
|
|
143
|
-
</form>
|
|
144
|
-
{#each keys as key (key.id)}
|
|
145
|
-
<div class="cms-stack">
|
|
146
|
-
<p>
|
|
147
|
-
<strong>{key.name}</strong> · {key.permissions?.cms?.includes('write') ? 'Write' : 'Read'} · expires
|
|
148
|
-
{new Date(key.expiresAt).toLocaleDateString()}
|
|
149
|
-
</p>
|
|
150
|
-
<p class="cms-muted">
|
|
151
|
-
Owner: {key.owner} · Prefix: {key.prefix ?? ''} · Starts with: {key.start ?? ''} · Last used:
|
|
152
|
-
{key.lastRequest ? new Date(key.lastRequest).toLocaleString() : 'Never'}
|
|
153
|
-
</p>
|
|
154
|
-
<Button variant="outline" disabled={busy} onclick={() => revoke(key.id)}
|
|
155
|
-
>Revoke {key.name}</Button
|
|
156
187
|
>
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
188
|
+
<div class="cms-field">
|
|
189
|
+
<Label for="api-key-name">Key name</Label>
|
|
190
|
+
<Input id="api-key-name" bind:value={name} required maxlength={100} />
|
|
191
|
+
</div>
|
|
192
|
+
<div class="cms-field">
|
|
193
|
+
<Label for="api-key-scope">Access</Label>
|
|
194
|
+
<SelectField
|
|
195
|
+
id="api-key-scope"
|
|
196
|
+
bind:value={scope}
|
|
197
|
+
clearable={false}
|
|
198
|
+
onchange={(value) => {
|
|
199
|
+
days = value === 'write' ? '7' : '30';
|
|
200
|
+
}}
|
|
201
|
+
options={[
|
|
202
|
+
{ value: 'read', label: 'Read' },
|
|
203
|
+
{ value: 'write', label: 'Read & write' }
|
|
204
|
+
]}
|
|
205
|
+
/>
|
|
206
|
+
</div>
|
|
207
|
+
<div class="cms-field">
|
|
208
|
+
<Label for="api-key-days">Expires</Label>
|
|
209
|
+
<SelectField
|
|
210
|
+
id="api-key-days"
|
|
211
|
+
bind:value={days}
|
|
212
|
+
clearable={false}
|
|
213
|
+
options={[
|
|
214
|
+
{ value: '7', label: 'In 7 days' },
|
|
215
|
+
{ value: '30', label: 'In 30 days' },
|
|
216
|
+
{ value: '90', label: 'In 90 days' },
|
|
217
|
+
{ value: '365', label: 'In 1 year' }
|
|
218
|
+
]}
|
|
219
|
+
/>
|
|
220
|
+
</div>
|
|
221
|
+
{#if error}<p class="cms-error" role="alert">{error}</p>{/if}
|
|
222
|
+
<Dialog.Footer><Button type="submit" disabled={busy}>Create API key</Button></Dialog.Footer>
|
|
223
|
+
</form>
|
|
224
|
+
{/if}
|
|
225
|
+
</Dialog.Content></Dialog.Root
|
|
226
|
+
>
|
|
@@ -52,15 +52,15 @@
|
|
|
52
52
|
asset.bytes / 1000
|
|
53
53
|
).toFixed(0)} KB{visibility ? ` · ${visibility}` : ''}
|
|
54
54
|
</Attachment.Description>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
? '
|
|
60
|
-
: asset.status === '
|
|
61
|
-
? '
|
|
62
|
-
: '
|
|
63
|
-
|
|
55
|
+
{#if asset.status !== 'ready'}<Attachment.Description
|
|
56
|
+
class={asset.status === 'failed' ? 'whitespace-normal' : undefined}
|
|
57
|
+
>
|
|
58
|
+
{asset.status === 'failed'
|
|
59
|
+
? asset.error || 'Image processing failed.'
|
|
60
|
+
: asset.status === 'deleting'
|
|
61
|
+
? 'Deleting image'
|
|
62
|
+
: 'Processing image'}
|
|
63
|
+
</Attachment.Description>{/if}
|
|
64
64
|
</Attachment.Content>
|
|
65
65
|
{#if onremove}
|
|
66
66
|
<Attachment.Actions>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import type { Asset, Relations } from './types.js';
|
|
6
6
|
import { tabErrorCount, widthSpan } from '../blueprints/layout.js';
|
|
7
7
|
import Fields from './Fields.svelte';
|
|
8
|
+
import { slugify } from './slug.js';
|
|
8
9
|
let {
|
|
9
10
|
blueprint,
|
|
10
11
|
value,
|
|
@@ -13,7 +14,8 @@
|
|
|
13
14
|
relations,
|
|
14
15
|
workerUrl,
|
|
15
16
|
fileBlueprints,
|
|
16
|
-
errors = {}
|
|
17
|
+
errors = {},
|
|
18
|
+
autoSlug = false
|
|
17
19
|
}: {
|
|
18
20
|
blueprint: Blueprint;
|
|
19
21
|
value: Payload;
|
|
@@ -23,7 +25,23 @@
|
|
|
23
25
|
workerUrl: string;
|
|
24
26
|
fileBlueprints?: FileBlueprint[];
|
|
25
27
|
errors?: Record<string, string>;
|
|
28
|
+
/** Keep slugs derived from their source field until the editor changes them by hand. */
|
|
29
|
+
autoSlug?: boolean;
|
|
26
30
|
} = $props();
|
|
31
|
+
function change(next: Payload) {
|
|
32
|
+
if (autoSlug)
|
|
33
|
+
for (const [key, field] of Object.entries(blueprint.fields)) {
|
|
34
|
+
const from = field.type === 'slug' ? field.from : undefined;
|
|
35
|
+
if (
|
|
36
|
+
from &&
|
|
37
|
+
next[from] !== value[from] &&
|
|
38
|
+
next[key] === value[key] &&
|
|
39
|
+
(!value[key] || value[key] === slugify(value[from]))
|
|
40
|
+
)
|
|
41
|
+
next = { ...next, [key]: slugify(next[from]) };
|
|
42
|
+
}
|
|
43
|
+
onchange(next);
|
|
44
|
+
}
|
|
27
45
|
let active = $state(untrack(() => Object.keys(blueprint.tabs ?? {})[0] ?? ''));
|
|
28
46
|
const tabs = $derived(Object.entries(blueprint.tabs ?? {}));
|
|
29
47
|
$effect(() => {
|
|
@@ -39,7 +57,7 @@
|
|
|
39
57
|
<Fields
|
|
40
58
|
fields={Object.fromEntries(keys.map((key) => [key, blueprint.fields[key]]))}
|
|
41
59
|
{value}
|
|
42
|
-
{
|
|
60
|
+
onchange={change}
|
|
43
61
|
{assets}
|
|
44
62
|
{relations}
|
|
45
63
|
{workerUrl}
|
|
@@ -9,6 +9,8 @@ type $$ComponentProps = {
|
|
|
9
9
|
workerUrl: string;
|
|
10
10
|
fileBlueprints?: FileBlueprint[];
|
|
11
11
|
errors?: Record<string, string>;
|
|
12
|
+
/** Keep slugs derived from their source field until the editor changes them by hand. */
|
|
13
|
+
autoSlug?: boolean;
|
|
12
14
|
};
|
|
13
15
|
declare const BlueprintFields: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
14
16
|
type BlueprintFields = ReturnType<typeof BlueprintFields>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import * as Table from './components/ui/table/index.js';
|
|
3
3
|
import * as Card from './components/ui/card/index.js';
|
|
4
|
-
import { goto } from '$app/navigation';
|
|
4
|
+
import { goto, refreshAll } from '$app/navigation';
|
|
5
5
|
import type { AdminData, Entry } from './types.js';
|
|
6
6
|
import { api, date, message } from './client.js';
|
|
7
7
|
import Notice from './Notice.svelte';
|
|
@@ -10,76 +10,133 @@
|
|
|
10
10
|
import Plus from '@lucide/svelte/icons/plus';
|
|
11
11
|
import Folder from '@lucide/svelte/icons/folder';
|
|
12
12
|
import SearchList from './SearchList.svelte';
|
|
13
|
+
import RowMenu from './RowMenu.svelte';
|
|
14
|
+
import * as DropdownMenu from './components/ui/dropdown-menu/index.js';
|
|
15
|
+
import * as Dialog from './components/ui/dialog/index.js';
|
|
16
|
+
import Copy from '@lucide/svelte/icons/copy';
|
|
17
|
+
import Upload from '@lucide/svelte/icons/upload';
|
|
18
|
+
import EyeOff from '@lucide/svelte/icons/eye-off';
|
|
19
|
+
import Trash2 from '@lucide/svelte/icons/trash-2';
|
|
13
20
|
let { data }: { data: AdminData } = $props();
|
|
14
|
-
let
|
|
21
|
+
let busy = $state(false),
|
|
22
|
+
deleting = $state<Entry | null>(null),
|
|
15
23
|
error = $state('');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
const changed = (entry: Entry) =>
|
|
25
|
+
!!entry.published && JSON.stringify(entry.draft) !== JSON.stringify(entry.published);
|
|
26
|
+
async function run(task: () => Promise<unknown>) {
|
|
27
|
+
if (busy) return;
|
|
28
|
+
busy = true;
|
|
19
29
|
error = '';
|
|
20
30
|
try {
|
|
21
|
-
|
|
22
|
-
await goto('/admin/content/' + copy.blueprint + '/' + copy.id);
|
|
31
|
+
await task();
|
|
23
32
|
} catch (e) {
|
|
24
33
|
error = message(e);
|
|
25
34
|
} finally {
|
|
26
|
-
|
|
35
|
+
busy = false;
|
|
27
36
|
}
|
|
28
37
|
}
|
|
38
|
+
const duplicate = (entry: Entry) =>
|
|
39
|
+
run(async () => {
|
|
40
|
+
const copy = await api<Entry>('content/duplicate', { id: entry.id, version: entry.version });
|
|
41
|
+
await goto('/admin/content/' + copy.blueprint + '/' + copy.id);
|
|
42
|
+
});
|
|
43
|
+
const act = (path: string, entry: Entry) =>
|
|
44
|
+
run(async () => {
|
|
45
|
+
await api(path, { id: entry.id, version: entry.version });
|
|
46
|
+
await refreshAll();
|
|
47
|
+
});
|
|
48
|
+
const remove = (entry: Entry) =>
|
|
49
|
+
run(async () => {
|
|
50
|
+
await api('content/delete', { id: entry.id });
|
|
51
|
+
deleting = null;
|
|
52
|
+
await refreshAll();
|
|
53
|
+
});
|
|
29
54
|
</script>
|
|
30
55
|
|
|
31
56
|
<div class="cms-page-heading">
|
|
32
57
|
<div>
|
|
33
|
-
<div class="cms-eyebrow">COLLECTION</div>
|
|
34
58
|
<h1>{data.blueprint?.label}</h1>
|
|
35
|
-
<p class="cms-muted">
|
|
36
|
-
{data.blueprint?.description ?? 'Create, edit, and publish your content.'}
|
|
37
|
-
</p>
|
|
59
|
+
{#if data.blueprint?.description}<p class="cms-muted">{data.blueprint.description}</p>{/if}
|
|
38
60
|
</div>
|
|
39
61
|
<Button href={'/admin/content/' + data.blueprint?.id + '/new'}><Plus size={16} />New entry</Button
|
|
40
62
|
>
|
|
41
63
|
</div>
|
|
42
64
|
{#if error}<Notice error>{error}</Notice>{/if}
|
|
43
|
-
<SearchList
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
><
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
>{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
</
|
|
83
|
-
|
|
84
|
-
|
|
65
|
+
<SearchList
|
|
66
|
+
path={'content/list?blueprint=' + encodeURIComponent(data.blueprint!.id)}
|
|
67
|
+
initial={data.entries ?? []}
|
|
68
|
+
label="Search this collection"
|
|
69
|
+
refreshKey={JSON.stringify(data.entries)}
|
|
70
|
+
>
|
|
71
|
+
{#snippet children(entries)}
|
|
72
|
+
<Card.Root class="gap-0 py-0">
|
|
73
|
+
{#if entries.length}
|
|
74
|
+
<Table.Root>
|
|
75
|
+
<Table.Header
|
|
76
|
+
><Table.Row
|
|
77
|
+
><Table.Head>Title</Table.Head><Table.Head>Status</Table.Head><Table.Head
|
|
78
|
+
>Last updated</Table.Head
|
|
79
|
+
><Table.Head><span class="sr-only">Actions</span></Table.Head></Table.Row
|
|
80
|
+
></Table.Header
|
|
81
|
+
><Table.Body
|
|
82
|
+
>{#each entries as entry}<Table.Row
|
|
83
|
+
><Table.Cell
|
|
84
|
+
><a
|
|
85
|
+
class="cms-entry-link"
|
|
86
|
+
href={'/admin/content/' + entry.blueprint + '/' + entry.id}
|
|
87
|
+
>{String(entry.draft.title ?? 'Untitled')}</a
|
|
88
|
+
></Table.Cell
|
|
89
|
+
><Table.Cell
|
|
90
|
+
><Badge variant="outline">{entry.published ? 'Published' : 'Draft'}</Badge
|
|
91
|
+
>{#if changed(entry)}
|
|
92
|
+
<span class="cms-muted">Unpublished changes</span>{/if}</Table.Cell
|
|
93
|
+
><Table.Cell class="cms-muted">{date(entry.updatedAt)}</Table.Cell><Table.Cell
|
|
94
|
+
class="text-right"
|
|
95
|
+
><RowMenu label={'Actions for ' + String(entry.draft.title ?? 'Untitled')}
|
|
96
|
+
>{#if entry.published}<DropdownMenu.Item
|
|
97
|
+
disabled={busy}
|
|
98
|
+
onSelect={() => act('content/unpublish', entry)}
|
|
99
|
+
><EyeOff /> Unpublish</DropdownMenu.Item
|
|
100
|
+
>{/if}{#if !entry.published || changed(entry)}<DropdownMenu.Item
|
|
101
|
+
disabled={busy}
|
|
102
|
+
onSelect={() => act('content/publish', entry)}
|
|
103
|
+
><Upload />
|
|
104
|
+
{entry.published ? 'Publish changes' : 'Publish'}</DropdownMenu.Item
|
|
105
|
+
>{/if}<DropdownMenu.Item disabled={busy} onSelect={() => duplicate(entry)}
|
|
106
|
+
><Copy /> Duplicate</DropdownMenu.Item
|
|
107
|
+
><DropdownMenu.Separator /><DropdownMenu.Item
|
|
108
|
+
variant="destructive"
|
|
109
|
+
onSelect={() => (deleting = entry)}><Trash2 /> Delete</DropdownMenu.Item
|
|
110
|
+
></RowMenu
|
|
111
|
+
></Table.Cell
|
|
112
|
+
></Table.Row
|
|
113
|
+
>{/each}</Table.Body
|
|
114
|
+
>
|
|
115
|
+
</Table.Root>{:else if !data.entries?.length}<div class="cms-empty">
|
|
116
|
+
<Folder size={32} />
|
|
117
|
+
<h2>No entries yet</h2>
|
|
118
|
+
<Button href={'/admin/content/' + data.blueprint?.id + '/new'}>Create an entry</Button>
|
|
119
|
+
</div>{/if}
|
|
120
|
+
</Card.Root>
|
|
121
|
+
{/snippet}
|
|
85
122
|
</SearchList>
|
|
123
|
+
<Dialog.Root
|
|
124
|
+
open={!!deleting}
|
|
125
|
+
onOpenChange={(value) => {
|
|
126
|
+
if (!value) deleting = null;
|
|
127
|
+
}}
|
|
128
|
+
><Dialog.Content portalProps={{ disabled: true }}
|
|
129
|
+
><Dialog.Header
|
|
130
|
+
><Dialog.Title>Delete “{String(deleting?.draft.title ?? 'Untitled')}”?</Dialog.Title
|
|
131
|
+
><Dialog.Description
|
|
132
|
+
>It will be removed from the website, and links to it will be cleared.</Dialog.Description
|
|
133
|
+
></Dialog.Header
|
|
134
|
+
><Dialog.Footer
|
|
135
|
+
><Button variant="outline" onclick={() => (deleting = null)}>Cancel</Button><Button
|
|
136
|
+
variant="destructive"
|
|
137
|
+
disabled={busy}
|
|
138
|
+
onclick={() => deleting && remove(deleting)}>Delete entry</Button
|
|
139
|
+
></Dialog.Footer
|
|
140
|
+
></Dialog.Content
|
|
141
|
+
></Dialog.Root
|
|
142
|
+
>
|
|
@@ -13,11 +13,7 @@
|
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<div class="cms-page-heading">
|
|
16
|
-
<
|
|
17
|
-
<div class="cms-eyebrow">YOUR WORKSPACE</div>
|
|
18
|
-
<h1>Good to see you, {data.user?.name.split(' ')[0]}.</h1>
|
|
19
|
-
<p class="cms-muted">A little care for your content goes a long way.</p>
|
|
20
|
-
</div>
|
|
16
|
+
<h1>Good to see you, {data.user?.name.split(' ')[0]}.</h1>
|
|
21
17
|
{#if collection}<Button href={'/admin/content/' + collection.id + '/new'}
|
|
22
18
|
><Plus size={15} />New entry</Button
|
|
23
19
|
>{/if}
|
|
@@ -31,11 +27,7 @@
|
|
|
31
27
|
</div>
|
|
32
28
|
<Card.Root class="gap-0 py-0">
|
|
33
29
|
<div class="cms-section-heading">
|
|
34
|
-
<
|
|
35
|
-
<h2>Recently updated</h2>
|
|
36
|
-
<p class="cms-muted">Pick up where you left off.</p>
|
|
37
|
-
</div>
|
|
38
|
-
<span class="cms-muted">Latest content</span>
|
|
30
|
+
<h2>Recently updated</h2>
|
|
39
31
|
</div>
|
|
40
32
|
{#if data.entries?.length}
|
|
41
33
|
<Table.Root>
|
|
@@ -71,35 +63,9 @@
|
|
|
71
63
|
</Table.Root>
|
|
72
64
|
{:else}<div class="cms-empty">
|
|
73
65
|
<FileText size={32} />
|
|
74
|
-
<h3>
|
|
75
|
-
<p>Create your first entry or open a page in the sidebar.</p>
|
|
66
|
+
<h3>No content yet</h3>
|
|
76
67
|
{#if collection}<Button href={'/admin/content/' + collection.id + '/new'}
|
|
77
68
|
>Create an entry</Button
|
|
78
69
|
>{/if}
|
|
79
70
|
</div>{/if}
|
|
80
71
|
</Card.Root>
|
|
81
|
-
<div class="cms-quick-grid">
|
|
82
|
-
<Card.Root>
|
|
83
|
-
<Card.Header
|
|
84
|
-
><span class="cms-eyebrow">MEDIA LIBRARY</span><Card.Title>One image, everywhere.</Card.Title>
|
|
85
|
-
<Card.Description>Upload, organize, and reuse your website’s images.</Card.Description
|
|
86
|
-
></Card.Header
|
|
87
|
-
>
|
|
88
|
-
<Card.Footer
|
|
89
|
-
><Button variant="outline" href="/admin/media">Open library <ArrowRight size={16} /></Button
|
|
90
|
-
></Card.Footer
|
|
91
|
-
>
|
|
92
|
-
</Card.Root>
|
|
93
|
-
<Card.Root>
|
|
94
|
-
<Card.Header
|
|
95
|
-
><span class="cms-eyebrow">A LITTLE REMINDER</span><Card.Title
|
|
96
|
-
>Room to get it right.</Card.Title
|
|
97
|
-
>
|
|
98
|
-
<Card.Description
|
|
99
|
-
>Save a draft, preview it on your website, then publish when you’re ready.</Card.Description
|
|
100
|
-
></Card.Header
|
|
101
|
-
>
|
|
102
|
-
<Card.Footer><span class="cms-muted">Your live content stays as you left it.</span></Card.Footer
|
|
103
|
-
>
|
|
104
|
-
</Card.Root>
|
|
105
|
-
</div>
|