@elytracms/studio 0.0.26 → 0.0.28
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/convex/assets.ts +19 -10
- package/convex/authority.ts +60 -0
- package/convex/cliTokens.ts +4 -4
- package/convex/cms.ts +12 -12
- package/convex/content.ts +10 -3
- package/convex/delivery.ts +22 -4
- package/convex/guard.ts +28 -11
- package/convex/members.ts +40 -7
- package/convex/redirects.ts +67 -0
- package/convex/references.ts +11 -11
- package/convex/schema.ts +30 -1
- package/convex/sync.ts +17 -10
- package/convex/users.ts +63 -0
- package/dist/components/app-views/default-modules.d.ts +33 -14
- package/dist/components/app-views/default-modules.js +59 -20
- package/dist/components/app-views/default-modules.js.map +1 -1
- package/dist/components/app-views/module.d.ts +32 -0
- package/dist/components/app-views/module.js +16 -0
- package/dist/components/app-views/module.js.map +1 -1
- package/dist/components/app-views/sidebar.d.ts +15 -1
- package/dist/components/app-views/sidebar.js +10 -0
- package/dist/components/app-views/sidebar.js.map +1 -1
- package/dist/components/cms/asset-picker.js +4 -4
- package/dist/components/cms/asset-picker.js.map +1 -1
- package/dist/components/cms/cell.js +16 -13
- package/dist/components/cms/cell.js.map +1 -1
- package/dist/components/cms/cms-store.d.ts +11 -26
- package/dist/components/cms/cms-store.js +25 -160
- package/dist/components/cms/cms-store.js.map +1 -1
- package/dist/components/cms/collection-table.d.ts +10 -0
- package/dist/components/cms/collection-table.js +72 -72
- package/dist/components/cms/collection-table.js.map +1 -1
- package/dist/components/cms/detail-editor.d.ts +14 -0
- package/dist/components/cms/detail-editor.js +224 -72
- package/dist/components/cms/detail-editor.js.map +1 -1
- package/dist/components/cms/document-editor-context.d.ts +26 -0
- package/dist/components/cms/document-editor-context.js.map +1 -1
- package/dist/components/cms/editable-cell.js +12 -7
- package/dist/components/cms/editable-cell.js.map +1 -1
- package/dist/components/cms/field-control.d.ts +2 -0
- package/dist/components/cms/field-control.js +40 -30
- package/dist/components/cms/field-control.js.map +1 -1
- package/dist/components/cms/filter-builder.d.ts +18 -0
- package/dist/components/cms/filter-builder.js +47 -6
- package/dist/components/cms/filter-builder.js.map +1 -1
- package/dist/components/cms/import-export.js +5 -3
- package/dist/components/cms/import-export.js.map +1 -1
- package/dist/components/cms/reference-confirm.js +8 -9
- package/dist/components/cms/reference-confirm.js.map +1 -1
- package/dist/components/cms/relation-picker.js +13 -10
- package/dist/components/cms/relation-picker.js.map +1 -1
- package/dist/components/cms/use-cell-edit.js +13 -7
- package/dist/components/cms/use-cell-edit.js.map +1 -1
- package/dist/components/cms/use-document-versions.d.ts +16 -0
- package/dist/components/cms/use-document-versions.js +31 -0
- package/dist/components/cms/use-document-versions.js.map +1 -0
- package/dist/components/cms/version-compare-text.d.ts +30 -0
- package/dist/components/cms/version-compare-text.js +113 -0
- package/dist/components/cms/version-compare-text.js.map +1 -0
- package/dist/components/cms/version-compare.d.ts +12 -0
- package/dist/components/cms/version-compare.js +271 -0
- package/dist/components/cms/version-compare.js.map +1 -0
- package/dist/components/cms/versions-pane.d.ts +3 -0
- package/dist/components/cms/versions-pane.js +47 -38
- package/dist/components/cms/versions-pane.js.map +1 -1
- package/dist/components/cms/view-bar.d.ts +21 -6
- package/dist/components/cms/view-bar.js +42 -57
- package/dist/components/cms/view-bar.js.map +1 -1
- package/dist/components/collection-view/cms-collection-view-source.d.ts +15 -0
- package/dist/components/collection-view/cms-collection-view-source.js +158 -0
- package/dist/components/collection-view/cms-collection-view-source.js.map +1 -0
- package/dist/components/collection-view/collection-view-context.d.ts +10 -0
- package/dist/components/collection-view/collection-view-context.js +26 -0
- package/dist/components/collection-view/collection-view-context.js.map +1 -0
- package/dist/components/current-user-menu.js +8 -1
- package/dist/components/current-user-menu.js.map +1 -1
- package/dist/components/redirects/redirects-collection-view-source.d.ts +18 -0
- package/dist/components/redirects/redirects-collection-view-source.js +114 -0
- package/dist/components/redirects/redirects-collection-view-source.js.map +1 -0
- package/dist/components/redirects/redirects-module.d.ts +18 -0
- package/dist/components/redirects/redirects-module.js +43 -0
- package/dist/components/redirects/redirects-module.js.map +1 -0
- package/dist/components/redirects/redirects-schema.d.ts +10 -0
- package/dist/components/redirects/redirects-schema.js +42 -0
- package/dist/components/redirects/redirects-schema.js.map +1 -0
- package/dist/components/redirects/redirects-store.d.ts +46 -0
- package/dist/components/redirects/redirects-store.js +124 -0
- package/dist/components/redirects/redirects-store.js.map +1 -0
- package/dist/components/references/references-panel.js +2 -2
- package/dist/components/references/references-panel.js.map +1 -1
- package/dist/components/section-nav.js +14 -5
- package/dist/components/section-nav.js.map +1 -1
- package/dist/components/users/user-search.d.ts +8 -0
- package/dist/components/users/user-search.js +13 -0
- package/dist/components/users/user-search.js.map +1 -0
- package/dist/components/users/users-collection-view-source.d.ts +28 -0
- package/dist/components/users/users-collection-view-source.js +157 -0
- package/dist/components/users/users-collection-view-source.js.map +1 -0
- package/dist/components/users/users-module.d.ts +23 -0
- package/dist/components/users/users-module.js +61 -0
- package/dist/components/users/users-module.js.map +1 -0
- package/dist/components/users/users-schema.d.ts +19 -0
- package/dist/components/users/users-schema.js +38 -0
- package/dist/components/users/users-schema.js.map +1 -0
- package/dist/components/users/users-store.d.ts +40 -0
- package/dist/components/users/users-store.js +87 -0
- package/dist/components/users/users-store.js.map +1 -0
- package/dist/lib/cms-views/index.d.ts +4 -5
- package/dist/lib/cms-views/index.js +4 -5
- package/dist/lib/cms-views/index.js.map +1 -1
- package/dist/lib/cms-views/view-model.d.ts +48 -1
- package/dist/lib/cms-views/view-model.js +77 -1
- package/dist/lib/cms-views/view-model.js.map +1 -1
- package/dist/lib/collection-view/collection-view-source.d.ts +251 -0
- package/dist/lib/collection-view/collection-view-source.js +10 -0
- package/dist/lib/collection-view/collection-view-source.js.map +1 -0
- package/dist/lib/operations/session-hydration.d.ts +7 -0
- package/dist/lib/operations/session-hydration.js +7 -1
- package/dist/lib/operations/session-hydration.js.map +1 -1
- package/dist/lib/persistence/convex-adapter.d.ts +5 -1
- package/dist/lib/persistence/convex-adapter.js +148 -1
- package/dist/lib/persistence/convex-adapter.js.map +1 -1
- package/dist/lib/workspace/index.d.ts +1 -8
- package/dist/lib/workspace/index.js +3 -9
- package/dist/lib/workspace/index.js.map +1 -1
- package/dist/router/match.d.ts +4 -0
- package/dist/router/match.js +8 -0
- package/dist/router/match.js.map +1 -1
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +2 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/popover.d.ts +13 -0
- package/dist/ui/popover.js +17 -0
- package/dist/ui/popover.js.map +1 -0
- package/dist/ui/row-item.d.ts +16 -0
- package/dist/ui/row-item.js +18 -0
- package/dist/ui/row-item.js.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { RedirectEntry, SaveRedirectInput } from '@elytracms/core/persistence';
|
|
3
|
+
/**
|
|
4
|
+
* Editorial redirects store (EC-303). The redirects rail — data-backed 301/302
|
|
5
|
+
* forwards — read + written through the shared operations client (`redirects.*`),
|
|
6
|
+
* the same seam the users/assets stores use. Content-gated (a viewer reads, an
|
|
7
|
+
* editor writes); no draft/published split — a saved+enabled redirect is live.
|
|
8
|
+
*
|
|
9
|
+
* The "New" flow keeps an unsaved redirect as a LOCAL draft (memory only) until
|
|
10
|
+
* the first explicit save persists it — so an abandoned "New" never writes a stub
|
|
11
|
+
* to the backend and never shows in the list. Drafts are reachable via {@link
|
|
12
|
+
* RedirectsStore.get} (the detail editor loads one), never listed.
|
|
13
|
+
*/
|
|
14
|
+
export interface RedirectsStore {
|
|
15
|
+
projectId: string;
|
|
16
|
+
status: 'loading' | 'ready' | 'error';
|
|
17
|
+
errorMessage?: string;
|
|
18
|
+
/** The persisted redirects, ordered by source path. Unsaved drafts are excluded. */
|
|
19
|
+
redirects: readonly RedirectEntry[];
|
|
20
|
+
/** One redirect: a local unsaved draft if present, else a persisted record. */
|
|
21
|
+
get(id: string): RedirectEntry | undefined;
|
|
22
|
+
/** Mint a blank in-memory draft and return its id (the "New" navigation target). */
|
|
23
|
+
createDraft(): string;
|
|
24
|
+
/** Persist a create/modify; drops the matching draft on success. */
|
|
25
|
+
save(input: SaveRedirectInput): Promise<{
|
|
26
|
+
ok: true;
|
|
27
|
+
redirect: RedirectEntry;
|
|
28
|
+
} | {
|
|
29
|
+
ok: false;
|
|
30
|
+
message: string;
|
|
31
|
+
}>;
|
|
32
|
+
/** Delete a persisted redirect, or silently discard an unsaved draft. */
|
|
33
|
+
remove(id: string): Promise<{
|
|
34
|
+
ok: true;
|
|
35
|
+
} | {
|
|
36
|
+
ok: false;
|
|
37
|
+
message: string;
|
|
38
|
+
}>;
|
|
39
|
+
/** Re-list from the backend. */
|
|
40
|
+
refresh(): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export declare function RedirectsProvider({ projectId, children, }: {
|
|
43
|
+
projectId: string;
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
}): import("react").JSX.Element;
|
|
46
|
+
export declare function useRedirects(): RedirectsStore;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
3
|
+
import { getStudioOperations } from '@elytracms/studio/lib/operations';
|
|
4
|
+
import { useOperationCache, useOperationQuery } from '@elytracms/studio/lib/query';
|
|
5
|
+
const RedirectsContext = createContext(null);
|
|
6
|
+
const EMPTY_REDIRECTS = [];
|
|
7
|
+
let draftCounter = 0;
|
|
8
|
+
/** A collision-resistant client id for a new redirect (used as its real id on save). */
|
|
9
|
+
function newDraftId() {
|
|
10
|
+
draftCounter += 1;
|
|
11
|
+
return `redirect_${Date.now().toString(36)}_${draftCounter}`;
|
|
12
|
+
}
|
|
13
|
+
function redirectsQueryKey(projectId) {
|
|
14
|
+
return ['redirects', projectId];
|
|
15
|
+
}
|
|
16
|
+
async function loadRedirects(operations, projectId) {
|
|
17
|
+
const result = await operations.redirects.list({ projectId });
|
|
18
|
+
if (!result.ok)
|
|
19
|
+
throw new Error(result.error.message);
|
|
20
|
+
return [...result.value];
|
|
21
|
+
}
|
|
22
|
+
function byFrom(a, b) {
|
|
23
|
+
return a.from < b.from ? -1 : a.from > b.from ? 1 : 0;
|
|
24
|
+
}
|
|
25
|
+
export function RedirectsProvider({ projectId, children, }) {
|
|
26
|
+
const query = useOperationQuery({
|
|
27
|
+
queryKey: redirectsQueryKey(projectId),
|
|
28
|
+
loader: (operations) => loadRedirects(operations, projectId),
|
|
29
|
+
});
|
|
30
|
+
const cache = useOperationCache();
|
|
31
|
+
const refetch = query.refetch;
|
|
32
|
+
const persisted = query.data ?? EMPTY_REDIRECTS;
|
|
33
|
+
const status = query.isPending
|
|
34
|
+
? 'loading'
|
|
35
|
+
: query.isError
|
|
36
|
+
? 'error'
|
|
37
|
+
: 'ready';
|
|
38
|
+
const errorMessage = query.isError && query.error instanceof Error ? query.error.message : undefined;
|
|
39
|
+
// In-memory unsaved "New" drafts, keyed by id. Not listed; only get()-able.
|
|
40
|
+
const [drafts, setDrafts] = useState({});
|
|
41
|
+
const refresh = useCallback(async () => {
|
|
42
|
+
await refetch();
|
|
43
|
+
}, [refetch]);
|
|
44
|
+
const get = useCallback((id) => drafts[id] ?? persisted.find((r) => r.id === id), [drafts, persisted]);
|
|
45
|
+
const createDraft = useCallback(() => {
|
|
46
|
+
const id = newDraftId();
|
|
47
|
+
const now = new Date().toISOString();
|
|
48
|
+
const draft = {
|
|
49
|
+
id,
|
|
50
|
+
projectId,
|
|
51
|
+
from: '',
|
|
52
|
+
to: '',
|
|
53
|
+
permanent: true,
|
|
54
|
+
enabled: false,
|
|
55
|
+
createdAt: now,
|
|
56
|
+
updatedAt: now,
|
|
57
|
+
};
|
|
58
|
+
setDrafts((prev) => ({ ...prev, [id]: draft }));
|
|
59
|
+
return id;
|
|
60
|
+
}, [projectId]);
|
|
61
|
+
const save = useCallback(async (input) => {
|
|
62
|
+
const { operations } = await getStudioOperations();
|
|
63
|
+
const result = await operations.redirects.save({
|
|
64
|
+
projectId,
|
|
65
|
+
...(input.id !== undefined ? { id: input.id } : {}),
|
|
66
|
+
from: input.from,
|
|
67
|
+
to: input.to,
|
|
68
|
+
...(input.permanent !== undefined ? { permanent: input.permanent } : {}),
|
|
69
|
+
...(input.enabled !== undefined ? { enabled: input.enabled } : {}),
|
|
70
|
+
});
|
|
71
|
+
if (!result.ok)
|
|
72
|
+
return { ok: false, message: result.error.message };
|
|
73
|
+
const saved = result.value;
|
|
74
|
+
cache.patch(redirectsQueryKey(projectId), (prev) => {
|
|
75
|
+
const rest = (prev ?? []).filter((r) => r.id !== saved.id);
|
|
76
|
+
return [...rest, saved].sort(byFrom);
|
|
77
|
+
});
|
|
78
|
+
// The record is now persisted — drop any matching draft.
|
|
79
|
+
setDrafts((prev) => {
|
|
80
|
+
if (!(saved.id in prev))
|
|
81
|
+
return prev;
|
|
82
|
+
const next = { ...prev };
|
|
83
|
+
delete next[saved.id];
|
|
84
|
+
return next;
|
|
85
|
+
});
|
|
86
|
+
return { ok: true, redirect: saved };
|
|
87
|
+
}, [projectId, cache]);
|
|
88
|
+
const remove = useCallback(async (id) => {
|
|
89
|
+
// An unsaved draft was never persisted — discard it locally, no backend call.
|
|
90
|
+
if (drafts[id]) {
|
|
91
|
+
setDrafts((prev) => {
|
|
92
|
+
const next = { ...prev };
|
|
93
|
+
delete next[id];
|
|
94
|
+
return next;
|
|
95
|
+
});
|
|
96
|
+
return { ok: true };
|
|
97
|
+
}
|
|
98
|
+
const { operations } = await getStudioOperations();
|
|
99
|
+
const result = await operations.redirects.remove({ projectId, id });
|
|
100
|
+
if (!result.ok)
|
|
101
|
+
return { ok: false, message: result.error.message };
|
|
102
|
+
cache.patch(redirectsQueryKey(projectId), (prev) => (prev ?? []).filter((r) => r.id !== id));
|
|
103
|
+
return { ok: true };
|
|
104
|
+
}, [projectId, cache, drafts]);
|
|
105
|
+
const store = useMemo(() => ({
|
|
106
|
+
projectId,
|
|
107
|
+
status,
|
|
108
|
+
...(errorMessage !== undefined ? { errorMessage } : {}),
|
|
109
|
+
redirects: persisted,
|
|
110
|
+
get,
|
|
111
|
+
createDraft,
|
|
112
|
+
save,
|
|
113
|
+
remove,
|
|
114
|
+
refresh,
|
|
115
|
+
}), [projectId, status, errorMessage, persisted, get, createDraft, save, remove, refresh]);
|
|
116
|
+
return _jsx(RedirectsContext.Provider, { value: store, children: children });
|
|
117
|
+
}
|
|
118
|
+
export function useRedirects() {
|
|
119
|
+
const store = useContext(RedirectsContext);
|
|
120
|
+
if (!store)
|
|
121
|
+
throw new Error('useRedirects must be used within a <RedirectsProvider>.');
|
|
122
|
+
return store;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=redirects-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirects-store.js","sourceRoot":"","sources":["../../../src/components/redirects/redirects-store.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAEtE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAkClF,MAAM,gBAAgB,GAAG,aAAa,CAAwB,IAAI,CAAC,CAAA;AAEnE,MAAM,eAAe,GAA6B,EAAE,CAAA;AAEpD,IAAI,YAAY,GAAG,CAAC,CAAA;AACpB,wFAAwF;AACxF,SAAS,UAAU;IACjB,YAAY,IAAI,CAAC,CAAA;IACjB,OAAO,YAAY,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,YAAY,EAAE,CAAA;AAC9D,CAAC;AAED,SAAS,iBAAiB,CAAC,SAAiB;IAC1C,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;AACjC,CAAC;AAED,KAAK,UAAU,a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,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAC3B,CAAA;IAED,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,SAAS;QACT,MAAM;QACN,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,SAAS,EAAE,SAAS;QACpB,GAAG;QACH,WAAW;QACX,IAAI;QACJ,MAAM;QACN,OAAO;KACR,CAAC,EACF,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CACtF,CAAA;IAED,OAAO,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAA6B,CAAA;AACxF,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,KAAK,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAC1C,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAA;IACtF,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import { createContext, useCallback, useContext, useMemo, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport type { RedirectEntry, SaveRedirectInput } from '@elytracms/core/persistence'\nimport { getStudioOperations } from '@elytracms/studio/lib/operations'\nimport type { OperationsClient } from '@elytracms/studio/lib/operations'\nimport { useOperationCache, useOperationQuery } from '@elytracms/studio/lib/query'\n\n/**\n * Editorial redirects store (EC-303). The redirects rail — data-backed 301/302\n * forwards — read + written through the shared operations client (`redirects.*`),\n * the same seam the users/assets stores use. Content-gated (a viewer reads, an\n * editor writes); no draft/published split — a saved+enabled redirect is live.\n *\n * The \"New\" flow keeps an unsaved redirect as a LOCAL draft (memory only) until\n * the first explicit save persists it — so an abandoned \"New\" never writes a stub\n * to the backend and never shows in the list. Drafts are reachable via {@link\n * RedirectsStore.get} (the detail editor loads one), never listed.\n */\n\nexport interface RedirectsStore {\n projectId: string\n status: 'loading' | 'ready' | 'error'\n errorMessage?: string\n /** The persisted redirects, ordered by source path. Unsaved drafts are excluded. */\n redirects: readonly RedirectEntry[]\n /** One redirect: a local unsaved draft if present, else a persisted record. */\n get(id: string): RedirectEntry | undefined\n /** Mint a blank in-memory draft and return its id (the \"New\" navigation target). */\n createDraft(): string\n /** Persist a create/modify; drops the matching draft on success. */\n save(\n input: SaveRedirectInput,\n ): Promise<{ ok: true; redirect: RedirectEntry } | { ok: false; message: string }>\n /** Delete a persisted redirect, or silently discard an unsaved draft. */\n remove(id: string): Promise<{ ok: true } | { ok: false; message: string }>\n /** Re-list from the backend. */\n refresh(): Promise<void>\n}\n\nconst RedirectsContext = createContext<RedirectsStore | null>(null)\n\nconst EMPTY_REDIRECTS: readonly RedirectEntry[] = []\n\nlet draftCounter = 0\n/** A collision-resistant client id for a new redirect (used as its real id on save). */\nfunction newDraftId(): string {\n draftCounter += 1\n return `redirect_${Date.now().toString(36)}_${draftCounter}`\n}\n\nfunction redirectsQueryKey(projectId: string): readonly [string, string] {\n return ['redirects', projectId]\n}\n\nasync function loadRedirects(\n operations: OperationsClient,\n projectId: string,\n): Promise<RedirectEntry[]> {\n const result = await operations.redirects.list({ projectId })\n if (!result.ok) throw new Error(result.error.message)\n return [...result.value]\n}\n\nfunction byFrom(a: RedirectEntry, b: RedirectEntry): number {\n return a.from < b.from ? -1 : a.from > b.from ? 1 : 0\n}\n\nexport function RedirectsProvider({\n projectId,\n children,\n}: {\n projectId: string\n children: ReactNode\n}) {\n const query = useOperationQuery<RedirectEntry[]>({\n queryKey: redirectsQueryKey(projectId),\n loader: (operations) => loadRedirects(operations, projectId),\n })\n const cache = useOperationCache()\n const refetch = query.refetch\n const persisted = query.data ?? EMPTY_REDIRECTS\n const status: RedirectsStore['status'] = query.isPending\n ? 'loading'\n : query.isError\n ? 'error'\n : 'ready'\n const errorMessage =\n query.isError && query.error instanceof Error ? query.error.message : undefined\n\n // In-memory unsaved \"New\" drafts, keyed by id. Not listed; only get()-able.\n const [drafts, setDrafts] = useState<Record<string, RedirectEntry>>({})\n\n const refresh = useCallback(async () => {\n await refetch()\n }, [refetch])\n\n const get = useCallback<RedirectsStore['get']>(\n (id) => drafts[id] ?? persisted.find((r) => r.id === id),\n [drafts, persisted],\n )\n\n const createDraft = useCallback<RedirectsStore['createDraft']>(() => {\n const id = newDraftId()\n const now = new Date().toISOString()\n const draft: RedirectEntry = {\n id,\n projectId,\n from: '',\n to: '',\n permanent: true,\n enabled: false,\n createdAt: now,\n updatedAt: now,\n }\n setDrafts((prev) => ({ ...prev, [id]: draft }))\n return id\n }, [projectId])\n\n const save = useCallback<RedirectsStore['save']>(\n async (input) => {\n const { operations } = await getStudioOperations()\n const result = await operations.redirects.save({\n projectId,\n ...(input.id !== undefined ? { id: input.id } : {}),\n from: input.from,\n to: input.to,\n ...(input.permanent !== undefined ? { permanent: input.permanent } : {}),\n ...(input.enabled !== undefined ? { enabled: input.enabled } : {}),\n })\n if (!result.ok) return { ok: false, message: result.error.message }\n const saved = result.value\n cache.patch<RedirectEntry[]>(redirectsQueryKey(projectId), (prev) => {\n const rest = (prev ?? []).filter((r) => r.id !== saved.id)\n return [...rest, saved].sort(byFrom)\n })\n // The record is now persisted — drop any matching draft.\n setDrafts((prev) => {\n if (!(saved.id in prev)) return prev\n const next = { ...prev }\n delete next[saved.id]\n return next\n })\n return { ok: true, redirect: saved }\n },\n [projectId, cache],\n )\n\n const remove = useCallback<RedirectsStore['remove']>(\n async (id) => {\n // An unsaved draft was never persisted — discard it locally, no backend call.\n if (drafts[id]) {\n setDrafts((prev) => {\n const next = { ...prev }\n delete next[id]\n return next\n })\n return { ok: true }\n }\n const { operations } = await getStudioOperations()\n const result = await operations.redirects.remove({ projectId, id })\n if (!result.ok) return { ok: false, message: result.error.message }\n cache.patch<RedirectEntry[]>(redirectsQueryKey(projectId), (prev) =>\n (prev ?? []).filter((r) => r.id !== id),\n )\n return { ok: true }\n },\n [projectId, cache, drafts],\n )\n\n const store = useMemo<RedirectsStore>(\n () => ({\n projectId,\n status,\n ...(errorMessage !== undefined ? { errorMessage } : {}),\n redirects: persisted,\n get,\n createDraft,\n save,\n remove,\n refresh,\n }),\n [projectId, status, errorMessage, persisted, get, createDraft, save, remove, refresh],\n )\n\n return <RedirectsContext.Provider value={store}>{children}</RedirectsContext.Provider>\n}\n\nexport function useRedirects(): RedirectsStore {\n const store = useContext(RedirectsContext)\n if (!store) throw new Error('useRedirects must be used within a <RedirectsProvider>.')\n return store\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { Link, STUDIO_PROJECT_ROUTE, studioPath } from '@elytracms/studio/router';
|
|
3
3
|
import { AlertTriangle, ArrowDownLeft, ArrowUpRight, Link2, RotateCcw } from 'lucide-react';
|
|
4
4
|
import { useReferencePanel } from '@elytracms/studio/lib/references';
|
|
5
|
-
import { Badge, Button, Panel, PanelHeader, Row, Spacer, Stack, Text } from '@elytracms/studio/ui';
|
|
5
|
+
import { Badge, Button, Panel, PanelHeader, Row, RowItem, Spacer, Stack, Text } from '@elytracms/studio/ui';
|
|
6
6
|
/**
|
|
7
7
|
* The shared "References / Used by" panel (EC-172) — one generic component,
|
|
8
8
|
* three hosts (CMS document detail, asset library, component detail). Entries
|
|
@@ -36,7 +36,7 @@ function ReferenceEntryRow({ entry, direction, projectId, }) {
|
|
|
36
36
|
const primary = direction === 'inbound'
|
|
37
37
|
? { label: entry.sourceLabel, link: entry.sourceLink }
|
|
38
38
|
: { label: entry.targetLabel, link: entry.targetLink };
|
|
39
|
-
return (
|
|
39
|
+
return (_jsx(RowItem, { "data-testid": "reference-entry", actions: _jsxs(_Fragment, { children: [_jsx(Badge, { variant: "outline", children: entry.kindLabel }), _jsx(VariantBadges, { draft: entry.draft, published: entry.published })] }), children: _jsxs(Stack, { gap: "1", className: "min-w-0", children: [_jsx(Row, { gap: "2", className: "min-w-0", children: _jsx(DeepLinkText, { projectId: projectId, link: primary.link, label: primary.label, primary: true }) }), _jsxs(Row, { gap: "1", className: "min-w-0", children: [_jsx(Text, { size: "xs", tone: "muted", className: "shrink-0", children: "at" }), _jsx(DeepLinkText, { projectId: projectId, link: entry.sourceLink, label: entry.locationLabel })] })] }) }));
|
|
40
40
|
}
|
|
41
41
|
/** Draft/published visibility (the Sanity hidden-draft-reference case, AD-6). */
|
|
42
42
|
function VariantBadges({ draft, published }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references-panel.js","sourceRoot":"","sources":["../../../src/components/references/references-panel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAEpE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAElG;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,SAAS,EACT,MAAM,EACN,MAAM,EACN,SAAS,GAQV;IACC,MAAM,KAAK,GAAG,iBAAiB,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAC9D,MAAM,KAAK,GACT,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;IAErF,OAAO,CACL,MAA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S,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,EAAE,EACnD,MAAM,EAAE,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAC9D,SAAS,EAAE,SAAS,iBACR,wBAAwB,YAEnC,KAAK,GACD,CACR,CAAA;QACH,KAAK,WAAW;YACd,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAE,oBAAoB,EACxB,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EACrE,SAAS,EAAE,SAAS,iBACR,0BAA0B,YAErC,KAAK,GACD,CACR,CAAA;QACH,KAAK,OAAO;YACV,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAE,oBAAoB,EACxB,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,EAAE,EAClD,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,EAC/B,SAAS,EAAE,SAAS,iBACR,sBAAsB,YAEjC,KAAK,GACD,CACR,CAAA;IACL,CAAC;AACH,CAAC","sourcesContent":["import { Link, STUDIO_PROJECT_ROUTE, studioPath } from '@elytracms/studio/router'\nimport { AlertTriangle, ArrowDownLeft, ArrowUpRight, Link2, RotateCcw } from 'lucide-react'\nimport type { ReactNode } from 'react'\nimport type { ReferenceSource, ReferenceTarget } from '@elytracms/core/persistence'\nimport { useReferencePanel } from '@elytracms/studio/lib/references'\nimport type { ReferenceDeepLink, ReferenceEntryView } from '@elytracms/studio/lib/references'\nimport { Badge, Button, Panel, PanelHeader, Row, Spacer, Stack, Text } from '@elytracms/studio/ui'\n\n/**\n * The shared \"References / Used by\" panel (EC-172) — one generic component,\n * three hosts (CMS document detail, asset library, component detail). Entries\n * are served entirely by `@elytracms/core/operations` reference queries over the\n * EC-155 index; every entry deep-links to the exact field control or graph\n * node its index path identifies, and draft-only entries are visibly\n * distinguished from published (live) ones.\n */\nexport function ReferencesPanel({\n projectId,\n source,\n target,\n className,\n}: {\n projectId: string\n /** The holding entity — enables the outbound \"References\" section. */\n source?: ReferenceSource\n /** The referenced entity — enables the inbound \"Used by\" section. */\n target?: ReferenceTarget\n className?: string\n}) {\n const panel = useReferencePanel({ projectId, source, target })\n const total =\n panel.data === null ? null : panel.data.outbound.length + panel.data.inbound.length\n\n return (\n <Panel className={className} data-testid=\"references-panel\">\n <PanelHeader>\n <Link2 className=\"size-4 text-primary\" />\n <Text size=\"sm\" weight=\"semibold\">\n References\n </Text>\n {total !== null ? <Badge variant=\"outline\">{total}</Badge> : null}\n <Spacer />\n </PanelHeader>\n <Stack gap=\"4\" className=\"p-4\">\n {panel.status === 'loading' ? (\n <ReferencesLoading />\n ) : panel.status === 'error' ? (\n <ReferencesError message={panel.errorMessage} onRetry={panel.refresh} />\n ) : (\n <>\n {source ? (\n <ReferenceSection\n title=\"References\"\n icon={<ArrowUpRight className=\"size-3.5\" />}\n hint=\"What this entry points at — click to jump to the target, or to the exact field.\"\n direction=\"outbound\"\n projectId={projectId}\n entries={panel.data?.outbound ?? []}\n error={panel.data?.outboundError ?? null}\n emptyLabel=\"No outbound references.\"\n />\n ) : null}\n {target ? (\n <ReferenceSection\n title=\"Used by\"\n icon={<ArrowDownLeft className=\"size-3.5\" />}\n hint=\"Everything referencing this entry — click to jump to the exact field or node.\"\n direction=\"inbound\"\n projectId={projectId}\n entries={panel.data?.inbound ?? []}\n error={panel.data?.inboundError ?? null}\n emptyLabel=\"Not referenced anywhere.\"\n />\n ) : null}\n </>\n )}\n </Stack>\n </Panel>\n )\n}\n\n/** Named loading state, consistent with existing studio panels. */\nfunction ReferencesLoading() {\n return (\n <Text size=\"sm\" tone=\"muted\" data-testid=\"references-loading\">\n Loading references…\n </Text>\n )\n}\n\n/** Named error state with retry — never a silent failure. */\nfunction ReferencesError({\n message,\n onRetry,\n}: {\n message: string | null\n onRetry: () => void\n}) {\n return (\n <Stack gap=\"2\" data-testid=\"references-error\">\n <Row gap=\"2\">\n <AlertTriangle className=\"size-4 text-destructive\" />\n <Text size=\"sm\" weight=\"semibold\">\n References failed to load\n </Text>\n </Row>\n <Text size=\"xs\" tone=\"muted\">\n {message ?? 'The reference index is unreachable.'}\n </Text>\n <Row>\n <Button variant=\"outline\" size=\"sm\" onClick={onRetry}>\n <RotateCcw /> Retry\n </Button>\n </Row>\n </Stack>\n )\n}\n\nfunction ReferenceSection({\n title,\n icon,\n hint,\n direction,\n projectId,\n entries,\n error,\n emptyLabel,\n}: {\n title: string\n icon: ReactNode\n hint: string\n direction: 'outbound' | 'inbound'\n projectId: string\n entries: readonly ReferenceEntryView[]\n /** EC-205: this direction's read failed — shown inline, the panel stays usable. */\n error?: string | null\n emptyLabel: string\n}) {\n return (\n <Stack gap=\"2\" data-testid={`references-${direction}`}>\n <Row gap=\"2\">\n <span className=\"text-muted-foreground\">{icon}</span>\n <Text size=\"xs\" weight=\"semibold\" tone=\"muted\" className=\"uppercase tracking-wide\">\n {title}\n </Text>\n <Badge variant=\"outline\">{entries.length}</Badge>\n </Row>\n {error ? (\n <Row gap=\"2\" data-testid={`references-${direction}-error`}>\n <AlertTriangle className=\"size-3.5 shrink-0 text-destructive\" />\n <Text size=\"xs\" tone=\"muted\">\n Couldn’t load this section: {error}\n </Text>\n </Row>\n ) : entries.length === 0 ? (\n <Text size=\"sm\" tone=\"muted\" data-testid={`references-${direction}-empty`}>\n {emptyLabel}\n </Text>\n ) : (\n <Stack gap=\"2\" title={hint}>\n {entries.map((entry) => (\n <ReferenceEntryRow\n key={entry.key}\n entry={entry}\n direction={direction}\n projectId={projectId}\n />\n ))}\n </Stack>\n )}\n </Stack>\n )\n}\n\n/**\n * One entry row. Inbound rows lead with the *source* (where it is used) and\n * deep-link to the exact location; outbound rows lead with the *target* and\n * keep the exact-field link on the location line.\n */\nfunction ReferenceEntryRow({\n entry,\n direction,\n projectId,\n}: {\n entry: ReferenceEntryView\n direction: 'outbound' | 'inbound'\n projectId: string\n}) {\n const primary =\n direction === 'inbound'\n ? { label: entry.sourceLabel, link: entry.sourceLink }\n : { label: entry.targetLabel, link: entry.targetLink }\n return (\n <Row\n gap=\"2\"\n className=\"rounded-md border border-border/70 bg-background/40 px-2.5 py-2\"\n data-testid=\"reference-entry\"\n >\n <Stack gap=\"1\" className=\"min-w-0 flex-1\">\n <Row gap=\"2\" className=\"min-w-0\">\n <DeepLinkText projectId={projectId} link={primary.link} label={primary.label} primary />\n </Row>\n <Row gap=\"1\" className=\"min-w-0\">\n <Text size=\"xs\" tone=\"muted\" className=\"shrink-0\">\n at\n </Text>\n <DeepLinkText\n projectId={projectId}\n link={entry.sourceLink}\n label={entry.locationLabel}\n />\n </Row>\n </Stack>\n <Badge variant=\"outline\" className=\"shrink-0\">\n {entry.kindLabel}\n </Badge>\n <VariantBadges draft={entry.draft} published={entry.published} />\n </Row>\n )\n}\n\n/** Draft/published visibility (the Sanity hidden-draft-reference case, AD-6). */\nfunction VariantBadges({ draft, published }: { draft: boolean; published: boolean }) {\n return (\n <Row gap=\"1\" className=\"shrink-0\" data-testid=\"reference-variants\">\n {draft ? <Badge variant=\"warning\">draft</Badge> : null}\n {published ? <Badge variant=\"success\">published</Badge> : null}\n </Row>\n )\n}\n\n/** Render a deep-link descriptor as a router link (plain text when unresolvable). */\nfunction DeepLinkText({\n projectId,\n link,\n label,\n primary = false,\n}: {\n projectId: string\n link: ReferenceDeepLink | null\n label: string\n primary?: boolean\n}) {\n const className = primary\n ? 'min-w-0 truncate text-sm font-medium text-foreground hover:text-primary hover:underline'\n : 'min-w-0 truncate text-xs text-muted-foreground hover:text-primary hover:underline'\n if (link === null) {\n return primary ? (\n <Text size=\"sm\" weight=\"medium\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n ) : (\n <Text size=\"xs\" tone=\"muted\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n )\n }\n switch (link.kind) {\n case 'cms-field':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.cmsDocument(link.collectionId, link.documentId) }}\n search={link.fieldPath !== undefined ? { field: link.fieldPath } : {}}\n className={className}\n data-testid=\"reference-link-cms\"\n >\n {label}\n </Link>\n )\n case 'builder-node':\n // The builder redirect (EC-187) only reads `?page=`; the page-graph-only\n // `node` has no home in the document editor and is dropped.\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.builder() }}\n search={link.pageId !== undefined ? { page: link.pageId } : {}}\n className={className}\n data-testid=\"reference-link-builder\"\n >\n {label}\n </Link>\n )\n case 'component':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.component(link.componentId) }}\n className={className}\n data-testid=\"reference-link-component\"\n >\n {label}\n </Link>\n )\n case 'asset':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.assets() }}\n search={{ asset: link.assetId }}\n className={className}\n data-testid=\"reference-link-asset\"\n >\n {label}\n </Link>\n )\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"references-panel.js","sourceRoot":"","sources":["../../../src/components/references/references-panel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAEpE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAE3G;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,SAA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KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,EACrE,SAAS,EAAE,SAAS,iBACR,oBAAoB,YAE/B,KAAK,GACD,CACR,CAAA;QACH,KAAK,cAAc;YACjB,yEAAyE;YACzE,4DAA4D;YAC5D,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAE,oBAAoB,EACxB,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,EAAE,EACnD,MAAM,EAAE,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAC9D,SAAS,EAAE,SAAS,iBACR,wBAAwB,YAEnC,KAAK,GACD,CACR,CAAA;QACH,KAAK,WAAW;YACd,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAE,oBAAoB,EACxB,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EACrE,SAAS,EAAE,SAAS,iBACR,0BAA0B,YAErC,KAAK,GACD,CACR,CAAA;QACH,KAAK,OAAO;YACV,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAE,oBAAoB,EACxB,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,EAAE,EAClD,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,EAC/B,SAAS,EAAE,SAAS,iBACR,sBAAsB,YAEjC,KAAK,GACD,CACR,CAAA;IACL,CAAC;AACH,CAAC","sourcesContent":["import { Link, STUDIO_PROJECT_ROUTE, studioPath } from '@elytracms/studio/router'\nimport { AlertTriangle, ArrowDownLeft, ArrowUpRight, Link2, RotateCcw } from 'lucide-react'\nimport type { ReactNode } from 'react'\nimport type { ReferenceSource, ReferenceTarget } from '@elytracms/core/persistence'\nimport { useReferencePanel } from '@elytracms/studio/lib/references'\nimport type { ReferenceDeepLink, ReferenceEntryView } from '@elytracms/studio/lib/references'\nimport { Badge, Button, Panel, PanelHeader, Row, RowItem, Spacer, Stack, Text } from '@elytracms/studio/ui'\n\n/**\n * The shared \"References / Used by\" panel (EC-172) — one generic component,\n * three hosts (CMS document detail, asset library, component detail). Entries\n * are served entirely by `@elytracms/core/operations` reference queries over the\n * EC-155 index; every entry deep-links to the exact field control or graph\n * node its index path identifies, and draft-only entries are visibly\n * distinguished from published (live) ones.\n */\nexport function ReferencesPanel({\n projectId,\n source,\n target,\n className,\n}: {\n projectId: string\n /** The holding entity — enables the outbound \"References\" section. */\n source?: ReferenceSource\n /** The referenced entity — enables the inbound \"Used by\" section. */\n target?: ReferenceTarget\n className?: string\n}) {\n const panel = useReferencePanel({ projectId, source, target })\n const total =\n panel.data === null ? null : panel.data.outbound.length + panel.data.inbound.length\n\n return (\n <Panel className={className} data-testid=\"references-panel\">\n <PanelHeader>\n <Link2 className=\"size-4 text-primary\" />\n <Text size=\"sm\" weight=\"semibold\">\n References\n </Text>\n {total !== null ? <Badge variant=\"outline\">{total}</Badge> : null}\n <Spacer />\n </PanelHeader>\n <Stack gap=\"4\" className=\"p-4\">\n {panel.status === 'loading' ? (\n <ReferencesLoading />\n ) : panel.status === 'error' ? (\n <ReferencesError message={panel.errorMessage} onRetry={panel.refresh} />\n ) : (\n <>\n {source ? (\n <ReferenceSection\n title=\"References\"\n icon={<ArrowUpRight className=\"size-3.5\" />}\n hint=\"What this entry points at — click to jump to the target, or to the exact field.\"\n direction=\"outbound\"\n projectId={projectId}\n entries={panel.data?.outbound ?? []}\n error={panel.data?.outboundError ?? null}\n emptyLabel=\"No outbound references.\"\n />\n ) : null}\n {target ? (\n <ReferenceSection\n title=\"Used by\"\n icon={<ArrowDownLeft className=\"size-3.5\" />}\n hint=\"Everything referencing this entry — click to jump to the exact field or node.\"\n direction=\"inbound\"\n projectId={projectId}\n entries={panel.data?.inbound ?? []}\n error={panel.data?.inboundError ?? null}\n emptyLabel=\"Not referenced anywhere.\"\n />\n ) : null}\n </>\n )}\n </Stack>\n </Panel>\n )\n}\n\n/** Named loading state, consistent with existing studio panels. */\nfunction ReferencesLoading() {\n return (\n <Text size=\"sm\" tone=\"muted\" data-testid=\"references-loading\">\n Loading references…\n </Text>\n )\n}\n\n/** Named error state with retry — never a silent failure. */\nfunction ReferencesError({\n message,\n onRetry,\n}: {\n message: string | null\n onRetry: () => void\n}) {\n return (\n <Stack gap=\"2\" data-testid=\"references-error\">\n <Row gap=\"2\">\n <AlertTriangle className=\"size-4 text-destructive\" />\n <Text size=\"sm\" weight=\"semibold\">\n References failed to load\n </Text>\n </Row>\n <Text size=\"xs\" tone=\"muted\">\n {message ?? 'The reference index is unreachable.'}\n </Text>\n <Row>\n <Button variant=\"outline\" size=\"sm\" onClick={onRetry}>\n <RotateCcw /> Retry\n </Button>\n </Row>\n </Stack>\n )\n}\n\nfunction ReferenceSection({\n title,\n icon,\n hint,\n direction,\n projectId,\n entries,\n error,\n emptyLabel,\n}: {\n title: string\n icon: ReactNode\n hint: string\n direction: 'outbound' | 'inbound'\n projectId: string\n entries: readonly ReferenceEntryView[]\n /** EC-205: this direction's read failed — shown inline, the panel stays usable. */\n error?: string | null\n emptyLabel: string\n}) {\n return (\n <Stack gap=\"2\" data-testid={`references-${direction}`}>\n <Row gap=\"2\">\n <span className=\"text-muted-foreground\">{icon}</span>\n <Text size=\"xs\" weight=\"semibold\" tone=\"muted\" className=\"uppercase tracking-wide\">\n {title}\n </Text>\n <Badge variant=\"outline\">{entries.length}</Badge>\n </Row>\n {error ? (\n <Row gap=\"2\" data-testid={`references-${direction}-error`}>\n <AlertTriangle className=\"size-3.5 shrink-0 text-destructive\" />\n <Text size=\"xs\" tone=\"muted\">\n Couldn’t load this section: {error}\n </Text>\n </Row>\n ) : entries.length === 0 ? (\n <Text size=\"sm\" tone=\"muted\" data-testid={`references-${direction}-empty`}>\n {emptyLabel}\n </Text>\n ) : (\n <Stack gap=\"2\" title={hint}>\n {entries.map((entry) => (\n <ReferenceEntryRow\n key={entry.key}\n entry={entry}\n direction={direction}\n projectId={projectId}\n />\n ))}\n </Stack>\n )}\n </Stack>\n )\n}\n\n/**\n * One entry row. Inbound rows lead with the *source* (where it is used) and\n * deep-link to the exact location; outbound rows lead with the *target* and\n * keep the exact-field link on the location line.\n */\nfunction ReferenceEntryRow({\n entry,\n direction,\n projectId,\n}: {\n entry: ReferenceEntryView\n direction: 'outbound' | 'inbound'\n projectId: string\n}) {\n const primary =\n direction === 'inbound'\n ? { label: entry.sourceLabel, link: entry.sourceLink }\n : { label: entry.targetLabel, link: entry.targetLink }\n return (\n <RowItem\n data-testid=\"reference-entry\"\n actions={\n <>\n <Badge variant=\"outline\">{entry.kindLabel}</Badge>\n <VariantBadges draft={entry.draft} published={entry.published} />\n </>\n }\n >\n <Stack gap=\"1\" className=\"min-w-0\">\n <Row gap=\"2\" className=\"min-w-0\">\n <DeepLinkText projectId={projectId} link={primary.link} label={primary.label} primary />\n </Row>\n <Row gap=\"1\" className=\"min-w-0\">\n <Text size=\"xs\" tone=\"muted\" className=\"shrink-0\">\n at\n </Text>\n <DeepLinkText\n projectId={projectId}\n link={entry.sourceLink}\n label={entry.locationLabel}\n />\n </Row>\n </Stack>\n </RowItem>\n )\n}\n\n/** Draft/published visibility (the Sanity hidden-draft-reference case, AD-6). */\nfunction VariantBadges({ draft, published }: { draft: boolean; published: boolean }) {\n return (\n <Row gap=\"1\" className=\"shrink-0\" data-testid=\"reference-variants\">\n {draft ? <Badge variant=\"warning\">draft</Badge> : null}\n {published ? <Badge variant=\"success\">published</Badge> : null}\n </Row>\n )\n}\n\n/** Render a deep-link descriptor as a router link (plain text when unresolvable). */\nfunction DeepLinkText({\n projectId,\n link,\n label,\n primary = false,\n}: {\n projectId: string\n link: ReferenceDeepLink | null\n label: string\n primary?: boolean\n}) {\n const className = primary\n ? 'min-w-0 truncate text-sm font-medium text-foreground hover:text-primary hover:underline'\n : 'min-w-0 truncate text-xs text-muted-foreground hover:text-primary hover:underline'\n if (link === null) {\n return primary ? (\n <Text size=\"sm\" weight=\"medium\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n ) : (\n <Text size=\"xs\" tone=\"muted\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n )\n }\n switch (link.kind) {\n case 'cms-field':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.cmsDocument(link.collectionId, link.documentId) }}\n search={link.fieldPath !== undefined ? { field: link.fieldPath } : {}}\n className={className}\n data-testid=\"reference-link-cms\"\n >\n {label}\n </Link>\n )\n case 'builder-node':\n // The builder redirect (EC-187) only reads `?page=`; the page-graph-only\n // `node` has no home in the document editor and is dropped.\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.builder() }}\n search={link.pageId !== undefined ? { page: link.pageId } : {}}\n className={className}\n data-testid=\"reference-link-builder\"\n >\n {label}\n </Link>\n )\n case 'component':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.component(link.componentId) }}\n className={className}\n data-testid=\"reference-link-component\"\n >\n {label}\n </Link>\n )\n case 'asset':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.assets() }}\n search={{ asset: link.assetId }}\n className={className}\n data-testid=\"reference-link-asset\"\n >\n {label}\n </Link>\n )\n }\n}\n"]}
|
|
@@ -5,8 +5,9 @@ import { AlertTriangle, ChevronDown, PanelLeftClose, PanelLeftOpen } from 'lucid
|
|
|
5
5
|
import { cn } from '@elytracms/studio/lib/utils';
|
|
6
6
|
import { readCollapsedViews, storeCollapsedViews } from '@elytracms/studio/lib/rail';
|
|
7
7
|
import { Text } from '@elytracms/studio/ui';
|
|
8
|
-
import { activeViewIdFromPath, useStudioNav } from './app-views/sidebar';
|
|
8
|
+
import { activeViewIdFromPath, isNavViewVisible, useStudioNav } from './app-views/sidebar';
|
|
9
9
|
import { useFieldRenderers } from './cms/field-renderer';
|
|
10
|
+
import { useProjectRole } from './auth-context';
|
|
10
11
|
/**
|
|
11
12
|
* Vertical section rail (brief §8.1), driven by the configurable sidebar (EC-237):
|
|
12
13
|
* a consumer-extendable tree of views / groups / separators resolved over the
|
|
@@ -24,6 +25,13 @@ export function SectionNav({ project, collapsed, onToggleCollapsed }) {
|
|
|
24
25
|
const { issues: rendererIssues } = useFieldRenderers();
|
|
25
26
|
const issues = [...navIssues, ...rendererIssues];
|
|
26
27
|
const projectId = project.id;
|
|
28
|
+
// EC-240 (AD-18): per-nav-item, default-open permission gating. The signed-in
|
|
29
|
+
// user's role drives an OPTIONAL `visible` predicate on any view; absent →
|
|
30
|
+
// visible. UI reflection only — the server chokepoint stays the real boundary,
|
|
31
|
+
// and a permission-hidden view is still reachable by URL (EC-221).
|
|
32
|
+
const role = useProjectRole(projectId);
|
|
33
|
+
const navCtx = { project, role };
|
|
34
|
+
const isVisible = (view) => isNavViewVisible(view, navCtx);
|
|
27
35
|
// EC-293: per-parent collapse of nested sub-views, persisted (read after mount,
|
|
28
36
|
// like the rail-collapse pref — no flash script needed). A collapsed parent hides
|
|
29
37
|
// its children but stays a navigable link.
|
|
@@ -47,14 +55,15 @@ export function SectionNav({ project, collapsed, onToggleCollapsed }) {
|
|
|
47
55
|
return _jsx("div", { className: "my-1.5 border-t border-border/60", "aria-hidden": true }, `sep-${index}`);
|
|
48
56
|
}
|
|
49
57
|
if (node.kind === 'group') {
|
|
50
|
-
const views = node.views.filter((view) => view.availability !== 'unavailable');
|
|
58
|
+
const views = node.views.filter((view) => view.availability !== 'unavailable' && isVisible(view));
|
|
51
59
|
if (views.length === 0)
|
|
52
60
|
return null;
|
|
53
61
|
return (_jsxs("div", { className: "mt-2 first:mt-0", children: [collapsed ? (_jsx("div", { className: "my-1 border-t border-border/60", "aria-hidden": true })) : (_jsx(Text, { size: "xs", tone: "subtle", className: "px-3 pb-1 pt-1 font-medium uppercase tracking-wide", children: node.label })), views.map((view) => (_jsx(NavViewLink, { projectId: projectId, view: view, activeViewId: activeViewId, collapsed: collapsed }, view.id)))] }, `group-${node.label}-${index}`));
|
|
54
62
|
}
|
|
55
63
|
// EC-221: an unavailable view is absent from the rail (not greyed) — it
|
|
56
|
-
// stays reachable by URL, the rail simply doesn't advertise it.
|
|
57
|
-
|
|
64
|
+
// stays reachable by URL, the rail simply doesn't advertise it. EC-240: a
|
|
65
|
+
// permission-hidden view is likewise absent-but-addressable.
|
|
66
|
+
if (node.availability === 'unavailable' || !isVisible(node))
|
|
58
67
|
return null;
|
|
59
68
|
// EC-293: a view may nest its sub-views (CMS collections). The parent renders
|
|
60
69
|
// as a link with a disclosure chevron; its children render indented below,
|
|
@@ -65,7 +74,7 @@ export function SectionNav({ project, collapsed, onToggleCollapsed }) {
|
|
|
65
74
|
const viewCollapsed = collapsedViews.has(node.id);
|
|
66
75
|
return (_jsxs(Fragment, { children: [_jsx(NavViewLink, { projectId: projectId, view: node, activeViewId: activeViewId, collapsed: collapsed, hasActiveChild: hasActiveChild, collapsible: hasChildren && !collapsed, expanded: !viewCollapsed, onToggleExpanded: () => toggleViewCollapsed(node.id) }), collapsed || viewCollapsed
|
|
67
76
|
? null
|
|
68
|
-
: node.children?.map((child) => (_jsx(NavViewLink, { projectId: projectId, view: child, activeViewId: activeViewId, collapsed: collapsed, nested: true }, child.id)))] }, node.id));
|
|
77
|
+
: node.children?.filter(isVisible).map((child) => (_jsx(NavViewLink, { projectId: projectId, view: child, activeViewId: activeViewId, collapsed: collapsed, nested: true }, child.id)))] }, node.id));
|
|
69
78
|
}), _jsxs("div", { className: "mt-auto flex flex-col gap-0.5", children: [issues.length > 0 ? _jsx(NavIssues, { issues: issues, collapsed: collapsed }) : null, _jsx("button", { type: "button", onClick: onToggleCollapsed, "aria-label": collapsed ? 'Expand sidebar' : 'Collapse sidebar', "aria-pressed": collapsed, title: collapsed ? 'Expand sidebar' : 'Collapse sidebar', className: cn('flex h-9 items-center gap-2.5 rounded-md text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground', collapsed ? 'justify-center px-0' : 'px-3'), children: collapsed ? (_jsx(PanelLeftOpen, { className: "size-4 shrink-0" })) : (_jsxs(_Fragment, { children: [_jsx(PanelLeftClose, { className: "size-4 shrink-0" }), _jsx("span", { className: "min-w-0 flex-1 truncate text-left", children: "Collapse" })] })) })] })] }));
|
|
70
79
|
}
|
|
71
80
|
/** One rail view (top-level or nested) — a Link to its home route, active by view id. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section-nav.js","sourceRoot":"","sources":["../../src/components/section-nav.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClE,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAClF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGxF,OAAO,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACpF,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AASxD;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAmB;IACnF,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAA;IAClC,MAAM,YAAY,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IACnD,MAAM,EAAE,KAAK,EAAE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KAAC,aAAa,IAAC,SAAS,EAAC,QAAQ,gBAAa,GAAG,MAAM,CAAC,MAAM,iBAAiB,GAAI,GAC/E,CACP,CAAA;IACH,CAAC;IACD,OAAO,CACL,cAAK,SAAS,EAAC,mFAAmF,YAC/F,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAC5B,eAEE,SAAS,EAAC,6DAA6D,EACvE,KAAK,EAAE,KAAK,CAAC,OAAO,aAEpB,KAAC,aAAa,IAAC,SAAS,EAAC,0BAA0B,wBAAe,EAClE,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,sBAAsB,YAC7C,KAAK,CAAC,OAAO,GACT,KAPF,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,EAAE,CAQtC,CACP,CAAC,GACE,CACP,CAAA;AACH,CAAC","sourcesContent":["import { Fragment, useCallback, useEffect, useState } from 'react'\nimport { Link, STUDIO_PROJECT_ROUTE, useLocation } from '@elytracms/studio/router'\nimport { AlertTriangle, ChevronDown, PanelLeftClose, PanelLeftOpen } from 'lucide-react'\nimport type { Project } from '@elytracms/core/studio-core'\nimport type { CustomizationIssue } from '@elytracms/core/studio-core'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { readCollapsedViews, storeCollapsedViews } from '@elytracms/studio/lib/rail'\nimport { Text } from '@elytracms/studio/ui'\nimport { activeViewIdFromPath, useStudioNav } from './app-views/sidebar'\nimport type { ResolvedRailView } from './app-views/sidebar'\nimport { useFieldRenderers } from './cms/field-renderer'\n\nexport interface SectionNavProps {\n project: Project\n /** User-toggled collapse (EC-214) — icons only when collapsed, persisted by the shell. */\n collapsed: boolean\n onToggleCollapsed: () => void\n}\n\n/**\n * Vertical section rail (brief §8.1), driven by the configurable sidebar (EC-237):\n * a consumer-extendable tree of views / groups / separators resolved over the\n * built-in views (EC-239). Availability-aware (`unavailable` items are absent per\n * EC-221); the active item is matched by the VIEW ID in the URL, so two views\n * backed by the same surface (Content vs. a focused Categories) highlight\n * independently. The preference-persisted collapse and the strong active marker\n * (EC-214) are preserved. Customization issues (duplicate view id, invalid view,\n * non-component renderers) render at the rail foot — visible, never silent.\n */\nexport function SectionNav({ project, collapsed, onToggleCollapsed }: SectionNavProps) {\n const { pathname } = useLocation()\n const activeViewId = activeViewIdFromPath(pathname)\n const { nodes, issues: navIssues } = useStudioNav(project)\n const { issues: rendererIssues } = useFieldRenderers()\n const issues = [...navIssues, ...rendererIssues]\n const projectId = project.id\n\n // EC-293: per-parent collapse of nested sub-views, persisted (read after mount,\n // like the rail-collapse pref — no flash script needed). A collapsed parent hides\n // its children but stays a navigable link.\n const [collapsedViews, setCollapsedViews] = useState<Set<string>>(() => new Set())\n useEffect(() => {\n setCollapsedViews(readCollapsedViews())\n }, [])\n const toggleViewCollapsed = useCallback((id: string) => {\n setCollapsedViews((prev) => {\n const next = new Set(prev)\n if (next.has(id)) next.delete(id)\n else next.add(id)\n storeCollapsedViews(next)\n return next\n })\n }, [])\n\n return (\n <nav\n aria-label=\"Sections\"\n className={cn(\n 'flex shrink-0 flex-col gap-0.5 border-r border-border bg-card/40 p-2 transition-[width] duration-150',\n collapsed ? 'w-[3.5rem]' : 'w-56',\n )}\n >\n {nodes.map((node, index) => {\n if (node.kind === 'separator') {\n return <div key={`sep-${index}`} className=\"my-1.5 border-t border-border/60\" aria-hidden />\n }\n if (node.kind === 'group') {\n const views = node.views.filter((view) => view.availability !== 'unavailable')\n if (views.length === 0) return null\n return (\n <div key={`group-${node.label}-${index}`} className=\"mt-2 first:mt-0\">\n {collapsed ? (\n <div className=\"my-1 border-t border-border/60\" aria-hidden />\n ) : (\n <Text\n size=\"xs\"\n tone=\"subtle\"\n className=\"px-3 pb-1 pt-1 font-medium uppercase tracking-wide\"\n >\n {node.label}\n </Text>\n )}\n {views.map((view) => (\n <NavViewLink\n key={view.id}\n projectId={projectId}\n view={view}\n activeViewId={activeViewId}\n collapsed={collapsed}\n />\n ))}\n </div>\n )\n }\n // EC-221: an unavailable view is absent from the rail (not greyed) — it\n // stays reachable by URL, the rail simply doesn't advertise it.\n if (node.availability === 'unavailable') return null\n // EC-293: a view may nest its sub-views (CMS collections). The parent renders\n // as a link with a disclosure chevron; its children render indented below,\n // hidden when the rail is collapsed OR this parent is collapsed. The parent\n // gets a subtle active hint when one of its children is the active view.\n const hasChildren = (node.children?.length ?? 0) > 0\n const hasActiveChild = node.children?.some((child) => child.id === activeViewId) ?? false\n const viewCollapsed = collapsedViews.has(node.id)\n return (\n <Fragment key={node.id}>\n <NavViewLink\n projectId={projectId}\n view={node}\n activeViewId={activeViewId}\n collapsed={collapsed}\n hasActiveChild={hasActiveChild}\n collapsible={hasChildren && !collapsed}\n expanded={!viewCollapsed}\n onToggleExpanded={() => toggleViewCollapsed(node.id)}\n />\n {collapsed || viewCollapsed\n ? null\n : node.children?.map((child) => (\n <NavViewLink\n key={child.id}\n projectId={projectId}\n view={child}\n activeViewId={activeViewId}\n collapsed={collapsed}\n nested\n />\n ))}\n </Fragment>\n )\n })}\n\n <div className=\"mt-auto flex flex-col gap-0.5\">\n {issues.length > 0 ? <NavIssues issues={issues} collapsed={collapsed} /> : null}\n\n {/* Collapse toggle pinned to the rail foot (EC-214). */}\n <button\n type=\"button\"\n onClick={onToggleCollapsed}\n aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}\n aria-pressed={collapsed}\n title={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}\n className={cn(\n 'flex h-9 items-center gap-2.5 rounded-md text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground',\n collapsed ? 'justify-center px-0' : 'px-3',\n )}\n >\n {collapsed ? (\n <PanelLeftOpen className=\"size-4 shrink-0\" />\n ) : (\n <>\n <PanelLeftClose className=\"size-4 shrink-0\" />\n <span className=\"min-w-0 flex-1 truncate text-left\">Collapse</span>\n </>\n )}\n </button>\n </div>\n </nav>\n )\n}\n\n/** One rail view (top-level or nested) — a Link to its home route, active by view id. */\nfunction NavViewLink({\n projectId,\n view,\n activeViewId,\n collapsed,\n nested = false,\n hasActiveChild = false,\n collapsible = false,\n expanded = true,\n onToggleExpanded,\n}: {\n projectId: string\n view: ResolvedRailView\n activeViewId: string | null\n collapsed: boolean\n nested?: boolean\n /** EC-293: this parent's a child is the active view → a subtle (non-accent) hint. */\n hasActiveChild?: boolean\n /** EC-293: this parent has nested children → render a disclosure chevron. */\n collapsible?: boolean\n /** Whether the nested children are shown (chevron points down) or hidden. */\n expanded?: boolean\n /** Toggle this parent's collapse (the chevron click — does not navigate). */\n onToggleExpanded?: () => void\n}) {\n const isActive = view.id === activeViewId\n const Icon = view.icon\n const link = (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: view.path }}\n title={view.label}\n aria-current={isActive ? 'page' : undefined}\n className={cn(\n 'group relative flex h-9 items-center gap-2.5 rounded-md text-sm transition-colors',\n // Collapsible parents reserve room on the right for the chevron toggle.\n collapsed ? 'justify-center px-0' : nested ? 'pl-7 pr-3' : collapsible ? 'pl-3 pr-9' : 'px-3',\n isActive\n ? 'bg-accent font-medium text-accent-foreground'\n : hasActiveChild\n ? 'text-foreground hover:bg-muted'\n : 'text-muted-foreground hover:bg-muted hover:text-foreground',\n )}\n >\n {/* Strong active marker: a leading accent bar (EC-214). */}\n {isActive ? (\n <span className=\"absolute inset-y-1.5 left-0 w-0.5 rounded-full bg-primary\" aria-hidden />\n ) : null}\n <Icon className=\"size-4 shrink-0\" />\n {collapsed ? null : <span className=\"min-w-0 flex-1 truncate\">{view.label}</span>}\n {view.availability === 'planned' && !collapsed ? (\n <span className=\"size-1.5 shrink-0 rounded-full bg-warning\" aria-hidden title=\"Planned\" />\n ) : null}\n </Link>\n )\n // A leaf (or the collapsed icons-only rail) is just the link.\n if (!collapsible) return link\n // A parent pairs the link with a sibling chevron toggle (so the chevron collapses\n // without navigating, and the link still navigates to the parent surface).\n return (\n <div className=\"relative\">\n {link}\n <button\n type=\"button\"\n onClick={onToggleExpanded}\n aria-label={`${expanded ? 'Collapse' : 'Expand'} ${view.label}`}\n aria-expanded={expanded}\n className=\"absolute right-1 top-1/2 grid size-6 -translate-y-1/2 place-items-center rounded text-muted-foreground/70 transition-colors hover:bg-background hover:text-foreground\"\n >\n <ChevronDown\n className={cn('size-3.5 transition-transform', expanded ? '' : '-rotate-90')}\n aria-hidden\n />\n </button>\n </div>\n )\n}\n\n/** Visible customization issues at the rail foot — the seam's \"never silent\" (EC-236). */\nfunction NavIssues({ issues, collapsed }: { issues: CustomizationIssue[]; collapsed: boolean }) {\n if (collapsed) {\n return (\n <div\n className=\"grid h-9 place-items-center text-amber-600 dark:text-amber-400\"\n title={issues.map((issue) => issue.message).join('\\n')}\n >\n <AlertTriangle className=\"size-4\" aria-label={`${issues.length} sidebar issues`} />\n </div>\n )\n }\n return (\n <div className=\"mb-1 flex flex-col gap-1 rounded-md border border-amber-500/30 bg-amber-500/5 p-2\">\n {issues.map((issue, index) => (\n <div\n key={`${issue.point}:${issue.id ?? index}`}\n className=\"flex items-start gap-1.5 text-amber-600 dark:text-amber-400\"\n title={issue.message}\n >\n <AlertTriangle className=\"mt-0.5 size-3.5 shrink-0\" aria-hidden />\n <Text size=\"xs\" className=\"min-w-0 leading-snug\">\n {issue.message}\n </Text>\n </div>\n ))}\n </div>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"section-nav.js","sourceRoot":"","sources":["../../src/components/section-nav.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClE,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAClF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGxF,OAAO,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAA;AAChD,OAAO,E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Aa,IAAC,SAAS,EAAC,0BAA0B,wBAAe,EAClE,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,sBAAsB,YAC7C,KAAK,CAAC,OAAO,GACT,KAPF,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,EAAE,CAQtC,CACP,CAAC,GACE,CACP,CAAA;AACH,CAAC","sourcesContent":["import { Fragment, useCallback, useEffect, useState } from 'react'\nimport { Link, STUDIO_PROJECT_ROUTE, useLocation } from '@elytracms/studio/router'\nimport { AlertTriangle, ChevronDown, PanelLeftClose, PanelLeftOpen } from 'lucide-react'\nimport type { Project } from '@elytracms/core/studio-core'\nimport type { CustomizationIssue } from '@elytracms/core/studio-core'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { readCollapsedViews, storeCollapsedViews } from '@elytracms/studio/lib/rail'\nimport { Text } from '@elytracms/studio/ui'\nimport { activeViewIdFromPath, isNavViewVisible, useStudioNav } from './app-views/sidebar'\nimport type { ResolvedRailView } from './app-views/sidebar'\nimport { useFieldRenderers } from './cms/field-renderer'\nimport { useProjectRole } from './auth-context'\nimport type { NavPermissionContext } from './app-views/module'\n\nexport interface SectionNavProps {\n project: Project\n /** User-toggled collapse (EC-214) — icons only when collapsed, persisted by the shell. */\n collapsed: boolean\n onToggleCollapsed: () => void\n}\n\n/**\n * Vertical section rail (brief §8.1), driven by the configurable sidebar (EC-237):\n * a consumer-extendable tree of views / groups / separators resolved over the\n * built-in views (EC-239). Availability-aware (`unavailable` items are absent per\n * EC-221); the active item is matched by the VIEW ID in the URL, so two views\n * backed by the same surface (Content vs. a focused Categories) highlight\n * independently. The preference-persisted collapse and the strong active marker\n * (EC-214) are preserved. Customization issues (duplicate view id, invalid view,\n * non-component renderers) render at the rail foot — visible, never silent.\n */\nexport function SectionNav({ project, collapsed, onToggleCollapsed }: SectionNavProps) {\n const { pathname } = useLocation()\n const activeViewId = activeViewIdFromPath(pathname)\n const { nodes, issues: navIssues } = useStudioNav(project)\n const { issues: rendererIssues } = useFieldRenderers()\n const issues = [...navIssues, ...rendererIssues]\n const projectId = project.id\n\n // EC-240 (AD-18): per-nav-item, default-open permission gating. The signed-in\n // user's role drives an OPTIONAL `visible` predicate on any view; absent →\n // visible. UI reflection only — the server chokepoint stays the real boundary,\n // and a permission-hidden view is still reachable by URL (EC-221).\n const role = useProjectRole(projectId)\n const navCtx: NavPermissionContext = { project, role }\n const isVisible = (view: ResolvedRailView) => isNavViewVisible(view, navCtx)\n\n // EC-293: per-parent collapse of nested sub-views, persisted (read after mount,\n // like the rail-collapse pref — no flash script needed). A collapsed parent hides\n // its children but stays a navigable link.\n const [collapsedViews, setCollapsedViews] = useState<Set<string>>(() => new Set())\n useEffect(() => {\n setCollapsedViews(readCollapsedViews())\n }, [])\n const toggleViewCollapsed = useCallback((id: string) => {\n setCollapsedViews((prev) => {\n const next = new Set(prev)\n if (next.has(id)) next.delete(id)\n else next.add(id)\n storeCollapsedViews(next)\n return next\n })\n }, [])\n\n return (\n <nav\n aria-label=\"Sections\"\n className={cn(\n 'flex shrink-0 flex-col gap-0.5 border-r border-border bg-card/40 p-2 transition-[width] duration-150',\n collapsed ? 'w-[3.5rem]' : 'w-56',\n )}\n >\n {nodes.map((node, index) => {\n if (node.kind === 'separator') {\n return <div key={`sep-${index}`} className=\"my-1.5 border-t border-border/60\" aria-hidden />\n }\n if (node.kind === 'group') {\n const views = node.views.filter(\n (view) => view.availability !== 'unavailable' && isVisible(view),\n )\n if (views.length === 0) return null\n return (\n <div key={`group-${node.label}-${index}`} className=\"mt-2 first:mt-0\">\n {collapsed ? (\n <div className=\"my-1 border-t border-border/60\" aria-hidden />\n ) : (\n <Text\n size=\"xs\"\n tone=\"subtle\"\n className=\"px-3 pb-1 pt-1 font-medium uppercase tracking-wide\"\n >\n {node.label}\n </Text>\n )}\n {views.map((view) => (\n <NavViewLink\n key={view.id}\n projectId={projectId}\n view={view}\n activeViewId={activeViewId}\n collapsed={collapsed}\n />\n ))}\n </div>\n )\n }\n // EC-221: an unavailable view is absent from the rail (not greyed) — it\n // stays reachable by URL, the rail simply doesn't advertise it. EC-240: a\n // permission-hidden view is likewise absent-but-addressable.\n if (node.availability === 'unavailable' || !isVisible(node)) return null\n // EC-293: a view may nest its sub-views (CMS collections). The parent renders\n // as a link with a disclosure chevron; its children render indented below,\n // hidden when the rail is collapsed OR this parent is collapsed. The parent\n // gets a subtle active hint when one of its children is the active view.\n const hasChildren = (node.children?.length ?? 0) > 0\n const hasActiveChild = node.children?.some((child) => child.id === activeViewId) ?? false\n const viewCollapsed = collapsedViews.has(node.id)\n return (\n <Fragment key={node.id}>\n <NavViewLink\n projectId={projectId}\n view={node}\n activeViewId={activeViewId}\n collapsed={collapsed}\n hasActiveChild={hasActiveChild}\n collapsible={hasChildren && !collapsed}\n expanded={!viewCollapsed}\n onToggleExpanded={() => toggleViewCollapsed(node.id)}\n />\n {collapsed || viewCollapsed\n ? null\n : node.children?.filter(isVisible).map((child) => (\n <NavViewLink\n key={child.id}\n projectId={projectId}\n view={child}\n activeViewId={activeViewId}\n collapsed={collapsed}\n nested\n />\n ))}\n </Fragment>\n )\n })}\n\n <div className=\"mt-auto flex flex-col gap-0.5\">\n {issues.length > 0 ? <NavIssues issues={issues} collapsed={collapsed} /> : null}\n\n {/* Collapse toggle pinned to the rail foot (EC-214). */}\n <button\n type=\"button\"\n onClick={onToggleCollapsed}\n aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}\n aria-pressed={collapsed}\n title={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}\n className={cn(\n 'flex h-9 items-center gap-2.5 rounded-md text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground',\n collapsed ? 'justify-center px-0' : 'px-3',\n )}\n >\n {collapsed ? (\n <PanelLeftOpen className=\"size-4 shrink-0\" />\n ) : (\n <>\n <PanelLeftClose className=\"size-4 shrink-0\" />\n <span className=\"min-w-0 flex-1 truncate text-left\">Collapse</span>\n </>\n )}\n </button>\n </div>\n </nav>\n )\n}\n\n/** One rail view (top-level or nested) — a Link to its home route, active by view id. */\nfunction NavViewLink({\n projectId,\n view,\n activeViewId,\n collapsed,\n nested = false,\n hasActiveChild = false,\n collapsible = false,\n expanded = true,\n onToggleExpanded,\n}: {\n projectId: string\n view: ResolvedRailView\n activeViewId: string | null\n collapsed: boolean\n nested?: boolean\n /** EC-293: this parent's a child is the active view → a subtle (non-accent) hint. */\n hasActiveChild?: boolean\n /** EC-293: this parent has nested children → render a disclosure chevron. */\n collapsible?: boolean\n /** Whether the nested children are shown (chevron points down) or hidden. */\n expanded?: boolean\n /** Toggle this parent's collapse (the chevron click — does not navigate). */\n onToggleExpanded?: () => void\n}) {\n const isActive = view.id === activeViewId\n const Icon = view.icon\n const link = (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: view.path }}\n title={view.label}\n aria-current={isActive ? 'page' : undefined}\n className={cn(\n 'group relative flex h-9 items-center gap-2.5 rounded-md text-sm transition-colors',\n // Collapsible parents reserve room on the right for the chevron toggle.\n collapsed ? 'justify-center px-0' : nested ? 'pl-7 pr-3' : collapsible ? 'pl-3 pr-9' : 'px-3',\n isActive\n ? 'bg-accent font-medium text-accent-foreground'\n : hasActiveChild\n ? 'text-foreground hover:bg-muted'\n : 'text-muted-foreground hover:bg-muted hover:text-foreground',\n )}\n >\n {/* Strong active marker: a leading accent bar (EC-214). */}\n {isActive ? (\n <span className=\"absolute inset-y-1.5 left-0 w-0.5 rounded-full bg-primary\" aria-hidden />\n ) : null}\n <Icon className=\"size-4 shrink-0\" />\n {collapsed ? null : <span className=\"min-w-0 flex-1 truncate\">{view.label}</span>}\n {view.availability === 'planned' && !collapsed ? (\n <span className=\"size-1.5 shrink-0 rounded-full bg-warning\" aria-hidden title=\"Planned\" />\n ) : null}\n </Link>\n )\n // A leaf (or the collapsed icons-only rail) is just the link.\n if (!collapsible) return link\n // A parent pairs the link with a sibling chevron toggle (so the chevron collapses\n // without navigating, and the link still navigates to the parent surface).\n return (\n <div className=\"relative\">\n {link}\n <button\n type=\"button\"\n onClick={onToggleExpanded}\n aria-label={`${expanded ? 'Collapse' : 'Expand'} ${view.label}`}\n aria-expanded={expanded}\n className=\"absolute right-1 top-1/2 grid size-6 -translate-y-1/2 place-items-center rounded text-muted-foreground/70 transition-colors hover:bg-background hover:text-foreground\"\n >\n <ChevronDown\n className={cn('size-3.5 transition-transform', expanded ? '' : '-rotate-90')}\n aria-hidden\n />\n </button>\n </div>\n )\n}\n\n/** Visible customization issues at the rail foot — the seam's \"never silent\" (EC-236). */\nfunction NavIssues({ issues, collapsed }: { issues: CustomizationIssue[]; collapsed: boolean }) {\n if (collapsed) {\n return (\n <div\n className=\"grid h-9 place-items-center text-amber-600 dark:text-amber-400\"\n title={issues.map((issue) => issue.message).join('\\n')}\n >\n <AlertTriangle className=\"size-4\" aria-label={`${issues.length} sidebar issues`} />\n </div>\n )\n }\n return (\n <div className=\"mb-1 flex flex-col gap-1 rounded-md border border-amber-500/30 bg-amber-500/5 p-2\">\n {issues.map((issue, index) => (\n <div\n key={`${issue.point}:${issue.id ?? index}`}\n className=\"flex items-start gap-1.5 text-amber-600 dark:text-amber-400\"\n title={issue.message}\n >\n <AlertTriangle className=\"mt-0.5 size-3.5 shrink-0\" aria-hidden />\n <Text size=\"xs\" className=\"min-w-0 leading-snug\">\n {issue.message}\n </Text>\n </div>\n ))}\n </div>\n )\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { UserRecord } from '@elytracms/core/persistence';
|
|
2
|
+
/**
|
|
3
|
+
* Free-text filter over the studio users roster (EC-240, 240b) — matches a query
|
|
4
|
+
* against a user's name, email, id, or any of their roles, case-insensitively.
|
|
5
|
+
* Pure + deterministic (mirrors `asset-search.ts`), so the roster's search state
|
|
6
|
+
* is reproducible from fixtures.
|
|
7
|
+
*/
|
|
8
|
+
export declare function filterUsers(users: readonly UserRecord[], query: string): readonly UserRecord[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Free-text filter over the studio users roster (EC-240, 240b) — matches a query
|
|
3
|
+
* against a user's name, email, id, or any of their roles, case-insensitively.
|
|
4
|
+
* Pure + deterministic (mirrors `asset-search.ts`), so the roster's search state
|
|
5
|
+
* is reproducible from fixtures.
|
|
6
|
+
*/
|
|
7
|
+
export function filterUsers(users, query) {
|
|
8
|
+
const q = query.trim().toLowerCase();
|
|
9
|
+
if (!q)
|
|
10
|
+
return users;
|
|
11
|
+
return users.filter((user) => [user.name ?? '', user.email, user.id, ...user.roles].some((field) => field.toLowerCase().includes(q)));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=user-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-search.js","sourceRoot":"","sources":["../../../src/components/users/user-search.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAA4B,EAAE,KAAa;IACrE,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACpC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IACpB,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAC3B,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CACnE,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAChC,CACF,CAAA;AACH,CAAC","sourcesContent":["import type { UserRecord } from '@elytracms/core/persistence'\n\n/**\n * Free-text filter over the studio users roster (EC-240, 240b) — matches a query\n * against a user's name, email, id, or any of their roles, case-insensitively.\n * Pure + deterministic (mirrors `asset-search.ts`), so the roster's search state\n * is reproducible from fixtures.\n */\nexport function filterUsers(users: readonly UserRecord[], query: string): readonly UserRecord[] {\n const q = query.trim().toLowerCase()\n if (!q) return users\n return users.filter((user) =>\n [user.name ?? '', user.email, user.id, ...user.roles].some((field) =>\n field.toLowerCase().includes(q),\n ),\n )\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CmsDocument, FieldDef } from '@elytracms/core/cms-core';
|
|
2
|
+
import type { SaveUserInput, UserRecord } from '@elytracms/core/persistence';
|
|
3
|
+
import type { CollectionViewSource, FieldAccess } from '@elytracms/studio/lib/collection-view/collection-view-source';
|
|
4
|
+
/** Project the auth-identity + membership join into the lens's `values` shape. */
|
|
5
|
+
export declare function userToDocument(record: UserRecord): CmsDocument;
|
|
6
|
+
/**
|
|
7
|
+
* Principal-based field access for the users rail (EC-240, AD-18). `role` is
|
|
8
|
+
* authority: **read-only when you are editing YOURSELF** — you don't change your
|
|
9
|
+
* own role (the server integrity floor also guards it) — and **editable otherwise**
|
|
10
|
+
* (the rail is admin-only, so a non-self editor is an admin acting on someone else).
|
|
11
|
+
* Identity fields (name/email) follow their schema `form.readOnly`; everything else
|
|
12
|
+
* is editable. Pure, so the self/other rule is unit-testable without the auth hook.
|
|
13
|
+
*/
|
|
14
|
+
export declare function userFieldAccess(field: FieldDef, record: CmsDocument | undefined, currentUserId: string | undefined): FieldAccess;
|
|
15
|
+
/** Map an edited lens document back to the write contract (role + custom `meta`). */
|
|
16
|
+
export declare function documentToSaveInput(doc: CmsDocument): SaveUserInput;
|
|
17
|
+
/**
|
|
18
|
+
* Assemble a {@link CollectionViewSource} for the **users rail** (EC-240, AD-19) —
|
|
19
|
+
* the reuse proof that the portable list/edit surfaces serve a non-`cmsDocuments`
|
|
20
|
+
* rail. Mirrors {@link useCmsCollectionViewSource}, over the users store instead of
|
|
21
|
+
* the CMS store, with the users capability profile: admin-only, no
|
|
22
|
+
* publish/versions/create/import (identities are minted by sign-up and their bytes
|
|
23
|
+
* are auth-owned), remove allowed (revoke membership). Identity fields are
|
|
24
|
+
* read-only; an admin edits a member's role (and future custom `meta` fields).
|
|
25
|
+
*
|
|
26
|
+
* Must be mounted under a `UsersProvider` (for {@link useUsers}).
|
|
27
|
+
*/
|
|
28
|
+
export declare function useUsersCollectionViewSource(projectId: string): CollectionViewSource;
|