uncial-cms 5.1.0 → 5.2.0
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 +61 -16
- package/dist/astro/index.d.ts +2 -1
- package/dist/astro/index.js +7 -2
- package/dist/content-sources.d.ts +10 -0
- package/dist/content-sources.js +25 -1
- package/dist/dashboard/ConfirmDialog.svelte +76 -0
- package/dist/dashboard/ConfirmDialog.svelte.d.ts +10 -0
- package/dist/dashboard/Dashboard.svelte +639 -0
- package/dist/dashboard/Dashboard.svelte.d.ts +4 -0
- package/dist/dashboard/FallbackEditor.svelte +42 -0
- package/dist/dashboard/FallbackEditor.svelte.d.ts +14 -0
- package/dist/dashboard/GlobalForm.svelte +405 -0
- package/dist/dashboard/GlobalForm.svelte.d.ts +17 -0
- package/dist/dashboard/GlobalsList.svelte +62 -0
- package/dist/dashboard/GlobalsList.svelte.d.ts +7 -0
- package/dist/dashboard/MediaSection.svelte +221 -0
- package/dist/dashboard/MediaSection.svelte.d.ts +16 -0
- package/dist/dashboard/PagesSection.svelte +477 -0
- package/dist/dashboard/PagesSection.svelte.d.ts +23 -0
- package/dist/dashboard/element.d.ts +39 -0
- package/dist/dashboard/element.js +107 -0
- package/dist/dashboard/pages-list.d.ts +18 -0
- package/dist/dashboard/pages-list.js +29 -0
- package/dist/dashboard/routes.d.ts +25 -0
- package/dist/dashboard/routes.js +81 -0
- package/dist/dashboard/types.d.ts +32 -0
- package/dist/dashboard/types.js +1 -0
- package/dist/define-site.d.ts +11 -6
- package/dist/define-site.js +4 -7
- package/dist/editor-controller.d.ts +1 -0
- package/dist/editor-controller.js +1 -0
- package/dist/editor-session.d.ts +5 -0
- package/dist/editor-session.js +1 -1
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +14 -0
- package/dist/globals.d.ts +12 -0
- package/dist/globals.js +29 -0
- package/dist/image-source.d.ts +0 -10
- package/dist/image-source.js +15 -44
- package/dist/index-actions.d.ts +29 -2
- package/dist/index-actions.js +36 -4
- package/dist/index-page.d.ts +2 -0
- package/dist/index-page.js +6 -256
- package/dist/index.d.ts +5 -2
- package/dist/index.js +3 -2
- package/dist/media-source.d.ts +45 -0
- package/dist/media-source.js +113 -0
- package/dist/mount.d.ts +1 -0
- package/dist/mount.js +2 -0
- package/dist/server/handlers.d.ts +1 -1
- package/dist/server/handlers.js +32 -5
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +2 -1
- package/dist/server/media.d.ts +1 -10
- package/dist/server/media.js +7 -11
- package/dist/server/postgres-store.d.ts +5 -0
- package/dist/server/postgres-store.js +50 -5
- package/dist/server-forge/adapter.d.ts +1 -0
- package/dist/server-forge/adapter.js +7 -4
- package/dist/server-forge/protocol.d.ts +3 -1
- package/dist/server-forge/protocol.js +2 -1
- package/dist/svelte/MediaLibrary.svelte +109 -53
- package/dist/svelte/MediaLibrary.svelte.d.ts +10 -2
- package/dist/svelte/index.d.ts +1 -4
- package/dist/svelte/index.js +1 -4
- package/dist/sveltekit/index.d.ts +2 -1
- package/dist/sveltekit/index.js +7 -2
- package/package.json +12 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ForgeAdapter, ForgeSession, UncialCmsSiteConfig } from '../types.js';
|
|
2
|
+
import type { DashboardAction } from './types.js';
|
|
3
|
+
interface Props {
|
|
4
|
+
config: UncialCmsSiteConfig;
|
|
5
|
+
adapter: ForgeAdapter;
|
|
6
|
+
session: ForgeSession;
|
|
7
|
+
staticDir?: string;
|
|
8
|
+
basePath: string;
|
|
9
|
+
mapSourceToPath?: (source: string) => string;
|
|
10
|
+
branchLabel: string;
|
|
11
|
+
can: (action: DashboardAction, subject?: unknown) => boolean;
|
|
12
|
+
onsignedout: (reason: string) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const MediaSection: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type MediaSection = ReturnType<typeof MediaSection>;
|
|
16
|
+
export default MediaSection;
|
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
<svelte:options css="injected" />
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { onMount } from 'svelte';
|
|
5
|
+
import { SignedOutError } from '../errors.js';
|
|
6
|
+
import { createPage, deletePage, listPages } from '../index-actions.js';
|
|
7
|
+
import { validatePagePath } from '../paths/index.js';
|
|
8
|
+
import type { ServerForgeAdapter } from '../server-forge/adapter.js';
|
|
9
|
+
import { describeContentStatus } from '../server-forge/protocol.js';
|
|
10
|
+
import type { ForgeAdapter, ForgeSession, UncialCmsSiteConfig } from '../types.js';
|
|
11
|
+
import ConfirmDialog from './ConfirmDialog.svelte';
|
|
12
|
+
import {
|
|
13
|
+
filterPages,
|
|
14
|
+
folderOptions,
|
|
15
|
+
kindOptions,
|
|
16
|
+
pageWindow,
|
|
17
|
+
type ListedPage
|
|
18
|
+
} from './pages-list.js';
|
|
19
|
+
import { hashForRoute, type PagesQuery } from './routes.js';
|
|
20
|
+
import type { DashboardAction } from './types.js';
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
config: UncialCmsSiteConfig;
|
|
24
|
+
adapter: ForgeAdapter;
|
|
25
|
+
session: ForgeSession;
|
|
26
|
+
blocks: unknown;
|
|
27
|
+
schemaFor: (pagePath: string) => unknown;
|
|
28
|
+
sourceFor: (pagePath: string) => string;
|
|
29
|
+
mapSourceToPath?: (source: string) => string;
|
|
30
|
+
basePath: string;
|
|
31
|
+
editorHref?: (pagePath: string) => string;
|
|
32
|
+
branchLabel: string;
|
|
33
|
+
can: (action: DashboardAction, subject?: unknown) => boolean;
|
|
34
|
+
query: PagesQuery;
|
|
35
|
+
onquery: (query: PagesQuery) => void;
|
|
36
|
+
onfocusheading: () => void;
|
|
37
|
+
onsignedout: (reason: string) => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let {
|
|
41
|
+
config,
|
|
42
|
+
adapter,
|
|
43
|
+
session,
|
|
44
|
+
blocks,
|
|
45
|
+
schemaFor,
|
|
46
|
+
sourceFor,
|
|
47
|
+
mapSourceToPath,
|
|
48
|
+
basePath,
|
|
49
|
+
editorHref,
|
|
50
|
+
branchLabel,
|
|
51
|
+
can,
|
|
52
|
+
query,
|
|
53
|
+
onquery,
|
|
54
|
+
onfocusheading,
|
|
55
|
+
onsignedout
|
|
56
|
+
}: Props = $props();
|
|
57
|
+
|
|
58
|
+
const uid = $props.id();
|
|
59
|
+
|
|
60
|
+
let pages = $state<ListedPage[]>();
|
|
61
|
+
let listError = $state('');
|
|
62
|
+
let path = $state('');
|
|
63
|
+
let createError = $state('');
|
|
64
|
+
let creating = $state(false);
|
|
65
|
+
let pendingDelete = $state<ListedPage>();
|
|
66
|
+
|
|
67
|
+
const server = $derived(config.forge === 'server');
|
|
68
|
+
const kinds = $derived(server ? kindOptions(pages ?? []) : []);
|
|
69
|
+
const folders = $derived(server ? [] : folderOptions(pages ?? []));
|
|
70
|
+
const known = (value: string | undefined, options: string[]) =>
|
|
71
|
+
value && options.includes(value) ? value : undefined;
|
|
72
|
+
const filters = $derived<PagesQuery>({
|
|
73
|
+
q: query.q,
|
|
74
|
+
kind: known(query.kind, kinds),
|
|
75
|
+
folder: known(query.folder, folders),
|
|
76
|
+
status: server ? query.status : undefined
|
|
77
|
+
});
|
|
78
|
+
const matches = $derived(filterPages(pages ?? [], filters));
|
|
79
|
+
const view = $derived(pageWindow(matches.length, query.page));
|
|
80
|
+
|
|
81
|
+
const filter = (next: PagesQuery) => onquery({ ...filters, ...next, page: undefined });
|
|
82
|
+
const turnTo = (page: number) => {
|
|
83
|
+
if (page >= 1 && page <= view.pageCount) onquery({ ...filters, page });
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
function message(error: unknown, fallback: string): string {
|
|
87
|
+
if (error instanceof SignedOutError) onsignedout(error.message);
|
|
88
|
+
return error instanceof Error ? error.message : fallback;
|
|
89
|
+
}
|
|
90
|
+
const labelFor = (page: ListedPage) =>
|
|
91
|
+
page.pagePath === '' ? '(site root)' : `/${page.pagePath}/`;
|
|
92
|
+
const liveUrl = (pagePath: string) => `${basePath}/${pagePath === '' ? '' : `${pagePath}/`}`;
|
|
93
|
+
const editUrl = (pagePath: string) =>
|
|
94
|
+
editorHref?.(pagePath) || hashForRoute({ section: 'edit', pagePath });
|
|
95
|
+
|
|
96
|
+
async function refresh() {
|
|
97
|
+
try {
|
|
98
|
+
pages =
|
|
99
|
+
config.forge === 'server'
|
|
100
|
+
? (await (adapter as ServerForgeAdapter).list()).map((record) => ({
|
|
101
|
+
pagePath: mapSourceToPath?.(record.path) ?? record.path.replace(/^\/+|\/+$/g, ''),
|
|
102
|
+
sourcePath: record.path,
|
|
103
|
+
title: record.title,
|
|
104
|
+
kind: record.kind,
|
|
105
|
+
status: record.status
|
|
106
|
+
}))
|
|
107
|
+
: await Promise.all(
|
|
108
|
+
(await listPages(adapter, config.contentDir, mapSourceToPath)).map(async (page) => {
|
|
109
|
+
const { content } = await adapter.readFile(page.sourcePath);
|
|
110
|
+
const { meta } = JSON.parse(content) as { meta?: { title?: unknown } };
|
|
111
|
+
return { ...page, title: typeof meta?.title === 'string' ? meta.title : undefined };
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
listError = '';
|
|
115
|
+
} catch (error) {
|
|
116
|
+
listError = message(error, 'Failed to list pages.');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function create(event: SubmitEvent) {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
const result = validatePagePath(path);
|
|
123
|
+
if (!result.ok) {
|
|
124
|
+
createError = result.message;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (!can('create', result.path)) {
|
|
128
|
+
createError = `You don’t have permission to create /${result.path}/.`;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
createError = '';
|
|
132
|
+
creating = true;
|
|
133
|
+
try {
|
|
134
|
+
await createPage(
|
|
135
|
+
{ adapter, blocks, schema: schemaFor(result.path), author: session.user },
|
|
136
|
+
{ pagePath: result.path, sourcePath: sourceFor(result.path) }
|
|
137
|
+
);
|
|
138
|
+
location.hash = hashForRoute({ section: 'edit', pagePath: result.path });
|
|
139
|
+
} catch (error) {
|
|
140
|
+
createError = message(error, 'Create failed.');
|
|
141
|
+
} finally {
|
|
142
|
+
creating = false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function finishDelete(confirmed: boolean) {
|
|
147
|
+
const page = pendingDelete;
|
|
148
|
+
pendingDelete = undefined;
|
|
149
|
+
if (!confirmed || !page) return;
|
|
150
|
+
try {
|
|
151
|
+
await deletePage(adapter, page);
|
|
152
|
+
await refresh();
|
|
153
|
+
onfocusheading();
|
|
154
|
+
} catch (error) {
|
|
155
|
+
listError = message(error, 'Delete failed.');
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
onMount(() => {
|
|
160
|
+
void refresh();
|
|
161
|
+
});
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
{#if can('create')}
|
|
165
|
+
<form class="create" onsubmit={create} novalidate>
|
|
166
|
+
<label for="{uid}-path">New page path</label>
|
|
167
|
+
<div class="create-row">
|
|
168
|
+
<input
|
|
169
|
+
id="{uid}-path"
|
|
170
|
+
name="path"
|
|
171
|
+
placeholder="team/new-page"
|
|
172
|
+
autocomplete="off"
|
|
173
|
+
spellcheck="false"
|
|
174
|
+
bind:value={path}
|
|
175
|
+
aria-invalid={createError ? 'true' : undefined}
|
|
176
|
+
aria-describedby={createError ? `${uid}-error` : undefined}
|
|
177
|
+
/>
|
|
178
|
+
<button type="submit" class="btn btn-primary" disabled={creating}>Create page</button>
|
|
179
|
+
</div>
|
|
180
|
+
{#if createError}
|
|
181
|
+
<p id="{uid}-error" class="error" role="alert">{createError}</p>
|
|
182
|
+
{/if}
|
|
183
|
+
</form>
|
|
184
|
+
{/if}
|
|
185
|
+
|
|
186
|
+
{#if listError}
|
|
187
|
+
<p class="error" role="alert">{listError}</p>
|
|
188
|
+
{/if}
|
|
189
|
+
|
|
190
|
+
{#if pages === undefined}
|
|
191
|
+
{#if !listError}<p class="note">Loading pages…</p>{/if}
|
|
192
|
+
{:else if pages.length === 0}
|
|
193
|
+
<p class="note">No pages yet.</p>
|
|
194
|
+
{:else}
|
|
195
|
+
<div class="filters" role="search" aria-label="Filter pages">
|
|
196
|
+
<div class="field search">
|
|
197
|
+
<label for="{uid}-q">Search</label>
|
|
198
|
+
<input
|
|
199
|
+
id="{uid}-q"
|
|
200
|
+
type="search"
|
|
201
|
+
placeholder="Title or path"
|
|
202
|
+
autocomplete="off"
|
|
203
|
+
spellcheck="false"
|
|
204
|
+
value={query.q ?? ''}
|
|
205
|
+
oninput={(event) => filter({ q: event.currentTarget.value })}
|
|
206
|
+
/>
|
|
207
|
+
</div>
|
|
208
|
+
{#if kinds.length > 0}
|
|
209
|
+
<div class="field">
|
|
210
|
+
<label for="{uid}-kind">Type</label>
|
|
211
|
+
<select
|
|
212
|
+
id="{uid}-kind"
|
|
213
|
+
value={filters.kind ?? ''}
|
|
214
|
+
onchange={(event) => filter({ kind: event.currentTarget.value || undefined })}
|
|
215
|
+
>
|
|
216
|
+
<option value="">All types</option>
|
|
217
|
+
{#each kinds as kind (kind)}<option value={kind}>{kind}</option>{/each}
|
|
218
|
+
</select>
|
|
219
|
+
</div>
|
|
220
|
+
{/if}
|
|
221
|
+
{#if folders.length > 0}
|
|
222
|
+
<div class="field">
|
|
223
|
+
<label for="{uid}-folder">Folder</label>
|
|
224
|
+
<select
|
|
225
|
+
id="{uid}-folder"
|
|
226
|
+
value={filters.folder ?? ''}
|
|
227
|
+
onchange={(event) => filter({ folder: event.currentTarget.value || undefined })}
|
|
228
|
+
>
|
|
229
|
+
<option value="">All folders</option>
|
|
230
|
+
{#each folders as folder (folder)}<option value={folder}>/{folder}/</option>{/each}
|
|
231
|
+
</select>
|
|
232
|
+
</div>
|
|
233
|
+
{/if}
|
|
234
|
+
{#if server}
|
|
235
|
+
<div class="field">
|
|
236
|
+
<label for="{uid}-status">Status</label>
|
|
237
|
+
<select
|
|
238
|
+
id="{uid}-status"
|
|
239
|
+
value={filters.status ?? ''}
|
|
240
|
+
onchange={(event) =>
|
|
241
|
+
filter({ status: (event.currentTarget.value || undefined) as PagesQuery['status'] })}
|
|
242
|
+
>
|
|
243
|
+
<option value="">Any status</option>
|
|
244
|
+
<option value="draft">Draft</option>
|
|
245
|
+
<option value="published">Published</option>
|
|
246
|
+
</select>
|
|
247
|
+
</div>
|
|
248
|
+
{/if}
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<p class="note" aria-live="polite">
|
|
252
|
+
{#if matches.length === 0}
|
|
253
|
+
No pages match.
|
|
254
|
+
{:else}
|
|
255
|
+
Showing {view.start + 1}–{view.end} of {matches.length}
|
|
256
|
+
{matches.length === 1 ? 'page' : 'pages'}
|
|
257
|
+
{/if}
|
|
258
|
+
</p>
|
|
259
|
+
|
|
260
|
+
{#if matches.length > 0}
|
|
261
|
+
<ul class="pages">
|
|
262
|
+
{#each matches.slice(view.start, view.end) as page (page.sourcePath)}
|
|
263
|
+
{@const label = labelFor(page)}
|
|
264
|
+
<li class="page">
|
|
265
|
+
<div class="page-main">
|
|
266
|
+
<span class="page-path">{label}</span>
|
|
267
|
+
{#if page.status}<span class="badge">{describeContentStatus(page.status)}</span>{/if}
|
|
268
|
+
{#if page.title}<span class="page-title">{page.title}</span>{/if}
|
|
269
|
+
<span class="page-source">{page.sourcePath}</span>
|
|
270
|
+
</div>
|
|
271
|
+
<div class="page-actions">
|
|
272
|
+
<a class="btn btn-primary" href={editUrl(page.pagePath)}>
|
|
273
|
+
Edit<span class="visually-hidden"> {label}</span>
|
|
274
|
+
</a>
|
|
275
|
+
<a class="btn" href={liveUrl(page.pagePath)}>
|
|
276
|
+
View<span class="visually-hidden"> {label}</span>
|
|
277
|
+
</a>
|
|
278
|
+
{#if can('delete', page.pagePath)}
|
|
279
|
+
<button type="button" class="btn btn-danger" onclick={() => (pendingDelete = page)}>
|
|
280
|
+
Delete<span class="visually-hidden"> {label}</span>
|
|
281
|
+
</button>
|
|
282
|
+
{/if}
|
|
283
|
+
</div>
|
|
284
|
+
</li>
|
|
285
|
+
{/each}
|
|
286
|
+
</ul>
|
|
287
|
+
{/if}
|
|
288
|
+
|
|
289
|
+
{#if view.pageCount > 1}
|
|
290
|
+
<nav class="pager" aria-label="Pagination">
|
|
291
|
+
<button
|
|
292
|
+
type="button"
|
|
293
|
+
class="btn"
|
|
294
|
+
aria-disabled={view.page === 1}
|
|
295
|
+
onclick={() => turnTo(view.page - 1)}>Previous page</button
|
|
296
|
+
>
|
|
297
|
+
<span>Page {view.page} of {view.pageCount}</span>
|
|
298
|
+
<button
|
|
299
|
+
type="button"
|
|
300
|
+
class="btn"
|
|
301
|
+
aria-disabled={view.page === view.pageCount}
|
|
302
|
+
onclick={() => turnTo(view.page + 1)}>Next page</button
|
|
303
|
+
>
|
|
304
|
+
</nav>
|
|
305
|
+
{/if}
|
|
306
|
+
{/if}
|
|
307
|
+
|
|
308
|
+
{#if pendingDelete}
|
|
309
|
+
<ConfirmDialog title="Delete this page?" confirmLabel="Delete" onclose={finishDelete}>
|
|
310
|
+
Delete <code>{pendingDelete.sourcePath}</code> from {branchLabel}?
|
|
311
|
+
{config.forge === 'server'
|
|
312
|
+
? 'This cannot be undone.'
|
|
313
|
+
: 'This commits the deletion immediately.'}
|
|
314
|
+
</ConfirmDialog>
|
|
315
|
+
{/if}
|
|
316
|
+
|
|
317
|
+
<style>
|
|
318
|
+
.create {
|
|
319
|
+
display: grid;
|
|
320
|
+
gap: var(--uncial-space-2);
|
|
321
|
+
margin-bottom: var(--uncial-space-6);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
label {
|
|
325
|
+
font-weight: 600;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.create-row {
|
|
329
|
+
display: flex;
|
|
330
|
+
flex-wrap: wrap;
|
|
331
|
+
gap: var(--uncial-space-2);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
input,
|
|
335
|
+
select {
|
|
336
|
+
flex: 1 1 14rem;
|
|
337
|
+
min-width: 0;
|
|
338
|
+
min-height: 2.5rem;
|
|
339
|
+
padding: 0 var(--uncial-space-3);
|
|
340
|
+
border: 1px solid var(--uncial-color-border-strong);
|
|
341
|
+
border-radius: var(--uncial-radius-md);
|
|
342
|
+
background: var(--uncial-color-surface);
|
|
343
|
+
color: var(--uncial-color-text);
|
|
344
|
+
font: inherit;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
select {
|
|
348
|
+
padding-right: var(--uncial-space-2);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
input[aria-invalid='true'] {
|
|
352
|
+
border-color: var(--uncial-color-danger);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.error {
|
|
356
|
+
margin: 0;
|
|
357
|
+
color: var(--uncial-color-danger);
|
|
358
|
+
font-weight: 600;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.note {
|
|
362
|
+
color: var(--uncial-dashboard-muted);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.filters {
|
|
366
|
+
display: flex;
|
|
367
|
+
flex-wrap: wrap;
|
|
368
|
+
gap: var(--uncial-space-3);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.field {
|
|
372
|
+
display: grid;
|
|
373
|
+
flex: 1 1 10rem;
|
|
374
|
+
gap: var(--uncial-space-1);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.field.search {
|
|
378
|
+
flex: 3 1 16rem;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.pager {
|
|
382
|
+
display: flex;
|
|
383
|
+
flex-wrap: wrap;
|
|
384
|
+
align-items: center;
|
|
385
|
+
justify-content: center;
|
|
386
|
+
gap: var(--uncial-space-3);
|
|
387
|
+
margin-top: var(--uncial-space-4);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.pager .btn[aria-disabled='true'] {
|
|
391
|
+
cursor: not-allowed;
|
|
392
|
+
opacity: 0.6;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.pages {
|
|
396
|
+
margin: 0;
|
|
397
|
+
padding: 0;
|
|
398
|
+
list-style: none;
|
|
399
|
+
border: 1px solid var(--uncial-color-border);
|
|
400
|
+
border-radius: var(--uncial-radius-lg);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.page {
|
|
404
|
+
display: flex;
|
|
405
|
+
align-items: center;
|
|
406
|
+
gap: var(--uncial-space-3);
|
|
407
|
+
padding: var(--uncial-space-3) var(--uncial-space-4);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.page + .page {
|
|
411
|
+
border-top: 1px solid var(--uncial-color-border);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.page-main {
|
|
415
|
+
display: flex;
|
|
416
|
+
flex: 1;
|
|
417
|
+
flex-wrap: wrap;
|
|
418
|
+
align-items: baseline;
|
|
419
|
+
gap: var(--uncial-space-1) var(--uncial-space-2);
|
|
420
|
+
min-width: 0;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.page-path {
|
|
424
|
+
font-weight: 600;
|
|
425
|
+
overflow-wrap: anywhere;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.page-title {
|
|
429
|
+
flex-basis: 100%;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.page-source {
|
|
433
|
+
flex-basis: 100%;
|
|
434
|
+
color: var(--uncial-dashboard-muted);
|
|
435
|
+
font-family: var(--uncial-font-mono);
|
|
436
|
+
font-size: 0.75rem;
|
|
437
|
+
overflow-wrap: anywhere;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.badge {
|
|
441
|
+
padding: 0 var(--uncial-space-2);
|
|
442
|
+
border: 1px solid var(--uncial-color-border-strong);
|
|
443
|
+
border-radius: 999px;
|
|
444
|
+
font-size: 0.75rem;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
.page-actions {
|
|
448
|
+
display: flex;
|
|
449
|
+
flex-shrink: 0;
|
|
450
|
+
gap: var(--uncial-space-2);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
@media (max-width: 40rem) {
|
|
454
|
+
.pages {
|
|
455
|
+
display: grid;
|
|
456
|
+
gap: var(--uncial-space-3);
|
|
457
|
+
border: 0;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.page {
|
|
461
|
+
flex-direction: column;
|
|
462
|
+
align-items: stretch;
|
|
463
|
+
border: 1px solid var(--uncial-color-border);
|
|
464
|
+
border-radius: var(--uncial-radius-lg);
|
|
465
|
+
background: var(--uncial-color-surface-elevated);
|
|
466
|
+
box-shadow: var(--uncial-shadow-sm);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.page + .page {
|
|
470
|
+
border-top: 1px solid var(--uncial-color-border);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
.page-actions .btn {
|
|
474
|
+
flex: 1;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ForgeAdapter, ForgeSession, UncialCmsSiteConfig } from '../types.js';
|
|
2
|
+
import { type PagesQuery } from './routes.js';
|
|
3
|
+
import type { DashboardAction } from './types.js';
|
|
4
|
+
interface Props {
|
|
5
|
+
config: UncialCmsSiteConfig;
|
|
6
|
+
adapter: ForgeAdapter;
|
|
7
|
+
session: ForgeSession;
|
|
8
|
+
blocks: unknown;
|
|
9
|
+
schemaFor: (pagePath: string) => unknown;
|
|
10
|
+
sourceFor: (pagePath: string) => string;
|
|
11
|
+
mapSourceToPath?: (source: string) => string;
|
|
12
|
+
basePath: string;
|
|
13
|
+
editorHref?: (pagePath: string) => string;
|
|
14
|
+
branchLabel: string;
|
|
15
|
+
can: (action: DashboardAction, subject?: unknown) => boolean;
|
|
16
|
+
query: PagesQuery;
|
|
17
|
+
onquery: (query: PagesQuery) => void;
|
|
18
|
+
onfocusheading: () => void;
|
|
19
|
+
onsignedout: (reason: string) => void;
|
|
20
|
+
}
|
|
21
|
+
declare const PagesSection: import("svelte").Component<Props, {}, "">;
|
|
22
|
+
type PagesSection = ReturnType<typeof PagesSection>;
|
|
23
|
+
export default PagesSection;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { UncialElement } from 'uncial/web-components';
|
|
2
|
+
import type { DashboardOptions, DashboardProps } from './types.js';
|
|
3
|
+
type Props = Partial<DashboardProps>;
|
|
4
|
+
export declare class UncialDashboardElement extends UncialElement<Props> {
|
|
5
|
+
get config(): Props['config'];
|
|
6
|
+
set config(value: Props['config']);
|
|
7
|
+
get blocks(): unknown;
|
|
8
|
+
set blocks(value: unknown);
|
|
9
|
+
get schema(): unknown;
|
|
10
|
+
set schema(value: unknown);
|
|
11
|
+
get globals(): DashboardOptions['globals'];
|
|
12
|
+
set globals(value: DashboardOptions['globals']);
|
|
13
|
+
get editorHref(): DashboardOptions['editorHref'];
|
|
14
|
+
set editorHref(value: DashboardOptions['editorHref']);
|
|
15
|
+
get can(): DashboardOptions['can'];
|
|
16
|
+
set can(value: DashboardOptions['can']);
|
|
17
|
+
get appSections(): DashboardOptions['appSections'];
|
|
18
|
+
set appSections(value: DashboardOptions['appSections']);
|
|
19
|
+
get signOutHref(): DashboardOptions['signOutHref'];
|
|
20
|
+
set signOutHref(value: DashboardOptions['signOutHref']);
|
|
21
|
+
get basePath(): DashboardOptions['basePath'];
|
|
22
|
+
set basePath(value: DashboardOptions['basePath']);
|
|
23
|
+
get theme(): DashboardOptions['theme'];
|
|
24
|
+
set theme(value: DashboardOptions['theme']);
|
|
25
|
+
get sessionProvider(): DashboardOptions['sessionProvider'];
|
|
26
|
+
set sessionProvider(value: DashboardOptions['sessionProvider']);
|
|
27
|
+
get mapPathToSource(): DashboardOptions['mapPathToSource'];
|
|
28
|
+
set mapPathToSource(value: DashboardOptions['mapPathToSource']);
|
|
29
|
+
get mapSourceToPath(): DashboardOptions['mapSourceToPath'];
|
|
30
|
+
set mapSourceToPath(value: DashboardOptions['mapSourceToPath']);
|
|
31
|
+
get editorStylesheets(): DashboardOptions['editorStylesheets'];
|
|
32
|
+
set editorStylesheets(value: DashboardOptions['editorStylesheets']);
|
|
33
|
+
get staticDir(): DashboardOptions['staticDir'];
|
|
34
|
+
set staticDir(value: DashboardOptions['staticDir']);
|
|
35
|
+
get sections(): DashboardProps['sections'];
|
|
36
|
+
set sections(value: DashboardProps['sections']);
|
|
37
|
+
protected mountComponent(target: ShadowRoot): Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { mount } from 'svelte';
|
|
2
|
+
import { UncialElement } from 'uncial/web-components';
|
|
3
|
+
import Dashboard from './Dashboard.svelte';
|
|
4
|
+
export class UncialDashboardElement extends UncialElement {
|
|
5
|
+
get config() {
|
|
6
|
+
return this.props.config;
|
|
7
|
+
}
|
|
8
|
+
set config(value) {
|
|
9
|
+
this.setProp('config', value);
|
|
10
|
+
}
|
|
11
|
+
get blocks() {
|
|
12
|
+
return this.props.blocks;
|
|
13
|
+
}
|
|
14
|
+
set blocks(value) {
|
|
15
|
+
this.setProp('blocks', value);
|
|
16
|
+
}
|
|
17
|
+
get schema() {
|
|
18
|
+
return this.props.schema;
|
|
19
|
+
}
|
|
20
|
+
set schema(value) {
|
|
21
|
+
this.setProp('schema', value);
|
|
22
|
+
}
|
|
23
|
+
get globals() {
|
|
24
|
+
return this.props.globals;
|
|
25
|
+
}
|
|
26
|
+
set globals(value) {
|
|
27
|
+
this.setProp('globals', value);
|
|
28
|
+
}
|
|
29
|
+
get editorHref() {
|
|
30
|
+
return this.props.editorHref;
|
|
31
|
+
}
|
|
32
|
+
set editorHref(value) {
|
|
33
|
+
this.setProp('editorHref', value);
|
|
34
|
+
}
|
|
35
|
+
get can() {
|
|
36
|
+
return this.props.can;
|
|
37
|
+
}
|
|
38
|
+
set can(value) {
|
|
39
|
+
this.setProp('can', value);
|
|
40
|
+
}
|
|
41
|
+
get appSections() {
|
|
42
|
+
return this.props.appSections;
|
|
43
|
+
}
|
|
44
|
+
set appSections(value) {
|
|
45
|
+
this.setProp('appSections', value);
|
|
46
|
+
}
|
|
47
|
+
get signOutHref() {
|
|
48
|
+
return this.props.signOutHref;
|
|
49
|
+
}
|
|
50
|
+
set signOutHref(value) {
|
|
51
|
+
this.setProp('signOutHref', value);
|
|
52
|
+
}
|
|
53
|
+
get basePath() {
|
|
54
|
+
return this.props.basePath;
|
|
55
|
+
}
|
|
56
|
+
set basePath(value) {
|
|
57
|
+
this.setProp('basePath', value);
|
|
58
|
+
}
|
|
59
|
+
get theme() {
|
|
60
|
+
return this.props.theme;
|
|
61
|
+
}
|
|
62
|
+
set theme(value) {
|
|
63
|
+
this.setProp('theme', value);
|
|
64
|
+
}
|
|
65
|
+
get sessionProvider() {
|
|
66
|
+
return this.props.sessionProvider;
|
|
67
|
+
}
|
|
68
|
+
set sessionProvider(value) {
|
|
69
|
+
this.setProp('sessionProvider', value);
|
|
70
|
+
}
|
|
71
|
+
get mapPathToSource() {
|
|
72
|
+
return this.props.mapPathToSource;
|
|
73
|
+
}
|
|
74
|
+
set mapPathToSource(value) {
|
|
75
|
+
this.setProp('mapPathToSource', value);
|
|
76
|
+
}
|
|
77
|
+
get mapSourceToPath() {
|
|
78
|
+
return this.props.mapSourceToPath;
|
|
79
|
+
}
|
|
80
|
+
set mapSourceToPath(value) {
|
|
81
|
+
this.setProp('mapSourceToPath', value);
|
|
82
|
+
}
|
|
83
|
+
get editorStylesheets() {
|
|
84
|
+
return this.props.editorStylesheets;
|
|
85
|
+
}
|
|
86
|
+
set editorStylesheets(value) {
|
|
87
|
+
this.setProp('editorStylesheets', value);
|
|
88
|
+
}
|
|
89
|
+
get staticDir() {
|
|
90
|
+
return this.props.staticDir;
|
|
91
|
+
}
|
|
92
|
+
set staticDir(value) {
|
|
93
|
+
this.setProp('staticDir', value);
|
|
94
|
+
}
|
|
95
|
+
get sections() {
|
|
96
|
+
return this.props.sections;
|
|
97
|
+
}
|
|
98
|
+
set sections(value) {
|
|
99
|
+
this.setProp('sections', value);
|
|
100
|
+
}
|
|
101
|
+
mountComponent(target) {
|
|
102
|
+
return mount(Dashboard, { target, props: this.props });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (typeof customElements !== 'undefined' && !customElements.get('uncial-dashboard')) {
|
|
106
|
+
customElements.define('uncial-dashboard', UncialDashboardElement);
|
|
107
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PageRef } from '../index-actions.js';
|
|
2
|
+
import type { ContentStatus } from '../server-forge/protocol.js';
|
|
3
|
+
import type { PagesQuery } from './routes.js';
|
|
4
|
+
export declare const PAGE_SIZE = 50;
|
|
5
|
+
export type ListedPage = PageRef & {
|
|
6
|
+
title?: string;
|
|
7
|
+
kind?: string;
|
|
8
|
+
status?: ContentStatus;
|
|
9
|
+
};
|
|
10
|
+
export declare function kindOptions(pages: ListedPage[]): string[];
|
|
11
|
+
export declare function folderOptions(pages: ListedPage[]): string[];
|
|
12
|
+
export declare function filterPages(pages: ListedPage[], query: PagesQuery): ListedPage[];
|
|
13
|
+
export declare function pageWindow(total: number, page?: number): {
|
|
14
|
+
page: number;
|
|
15
|
+
pageCount: number;
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
};
|