@elytracms/studio 0.0.37 → 0.0.39
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/cms.ts +8 -2
- package/dist/components/app-views/default-modules.d.ts +60 -5
- package/dist/components/app-views/default-modules.js +53 -15
- package/dist/components/app-views/default-modules.js.map +1 -1
- package/dist/components/app-views/module.d.ts +2 -0
- package/dist/components/app-views/module.js +8 -0
- package/dist/components/app-views/module.js.map +1 -1
- package/dist/components/assets/asset-detail.d.ts +24 -0
- package/dist/components/assets/asset-detail.js +163 -0
- package/dist/components/assets/asset-detail.js.map +1 -0
- package/dist/components/assets/asset-grid.d.ts +28 -0
- package/dist/components/assets/asset-grid.js +68 -0
- package/dist/components/assets/asset-grid.js.map +1 -0
- package/dist/components/assets/asset-metadata.d.ts +19 -0
- package/dist/components/assets/asset-metadata.js +44 -0
- package/dist/components/assets/asset-metadata.js.map +1 -1
- package/dist/components/assets/assets-collection-view-source.d.ts +54 -0
- package/dist/components/assets/assets-collection-view-source.js +186 -0
- package/dist/components/assets/assets-collection-view-source.js.map +1 -0
- package/dist/components/assets/assets-module.d.ts +18 -0
- package/dist/components/assets/assets-module.js +94 -0
- package/dist/components/assets/assets-module.js.map +1 -0
- package/dist/components/assets/assets-store.js +2 -7
- package/dist/components/assets/assets-store.js.map +1 -1
- package/dist/components/assets/assets-view-preference.d.ts +15 -0
- package/dist/components/assets/assets-view-preference.js +22 -0
- package/dist/components/assets/assets-view-preference.js.map +1 -0
- package/dist/components/builder/builder-store.d.ts +12 -0
- package/dist/components/builder/builder-store.js +18 -16
- package/dist/components/builder/builder-store.js.map +1 -1
- package/dist/components/builder/clipboard-actions.js +5 -14
- package/dist/components/builder/clipboard-actions.js.map +1 -1
- package/dist/components/builder/composition-field-editor-lazy.d.ts +19 -0
- package/dist/components/builder/composition-field-editor-lazy.js +29 -0
- package/dist/components/builder/composition-field-editor-lazy.js.map +1 -0
- package/dist/components/builder/composition-field-editor.js +1 -4
- package/dist/components/builder/composition-field-editor.js.map +1 -1
- package/dist/components/builder/insert-context.d.ts +8 -0
- package/dist/components/builder/insert-context.js +1 -3
- package/dist/components/builder/insert-context.js.map +1 -1
- package/dist/components/builder/page-tree.js +1 -3
- package/dist/components/builder/page-tree.js.map +1 -1
- package/dist/components/builder/property-inspector.js +7 -134
- package/dist/components/builder/property-inspector.js.map +1 -1
- package/dist/components/cms/cms-store.d.ts +15 -4
- package/dist/components/cms/cms-store.js +42 -24
- package/dist/components/cms/cms-store.js.map +1 -1
- package/dist/components/cms/collection-table.d.ts +8 -1
- package/dist/components/cms/collection-table.js +62 -10
- package/dist/components/cms/collection-table.js.map +1 -1
- package/dist/components/cms/column-width.d.ts +25 -0
- package/dist/components/cms/column-width.js +47 -0
- package/dist/components/cms/column-width.js.map +1 -0
- package/dist/components/cms/detail-editor.js +101 -68
- package/dist/components/cms/detail-editor.js.map +1 -1
- package/dist/components/cms/discard-draft.d.ts +32 -0
- package/dist/components/cms/discard-draft.js +13 -0
- package/dist/components/cms/discard-draft.js.map +1 -0
- package/dist/components/cms/document-staging.d.ts +7 -0
- package/dist/components/cms/document-staging.js +44 -0
- package/dist/components/cms/document-staging.js.map +1 -0
- package/dist/components/cms/field-connection.d.ts +22 -0
- package/dist/components/cms/field-connection.js +37 -0
- package/dist/components/cms/field-connection.js.map +1 -0
- package/dist/components/cms/field-control.js +158 -34
- package/dist/components/cms/field-control.js.map +1 -1
- package/dist/components/cms/prop-fields.d.ts +43 -0
- package/dist/components/cms/prop-fields.js +130 -0
- package/dist/components/cms/prop-fields.js.map +1 -0
- package/dist/components/cms/rich-text/component-embed.d.ts +17 -3
- package/dist/components/cms/rich-text/component-embed.js +29 -7
- package/dist/components/cms/rich-text/component-embed.js.map +1 -1
- package/dist/components/cms/rich-text/editor.d.ts +3 -0
- package/dist/components/cms/rich-text/editor.js +21 -3
- package/dist/components/cms/rich-text/editor.js.map +1 -1
- package/dist/components/cms/rich-text/embed-picker.d.ts +17 -0
- package/dist/components/cms/rich-text/embed-picker.js +34 -0
- package/dist/components/cms/rich-text/embed-picker.js.map +1 -0
- package/dist/components/cms/rich-text/embed-props.d.ts +49 -0
- package/dist/components/cms/rich-text/embed-props.js +106 -0
- package/dist/components/cms/rich-text/embed-props.js.map +1 -0
- package/dist/components/cms/rich-text/extensions.d.ts +7 -1
- package/dist/components/cms/rich-text/extensions.js +6 -1
- package/dist/components/cms/rich-text/extensions.js.map +1 -1
- package/dist/components/cms/rich-text/index.d.ts +6 -1
- package/dist/components/cms/rich-text/index.js +6 -1
- package/dist/components/cms/rich-text/index.js.map +1 -1
- package/dist/components/cms/rich-text/insert.d.ts +21 -0
- package/dist/components/cms/rich-text/insert.js +55 -0
- package/dist/components/cms/rich-text/insert.js.map +1 -0
- package/dist/components/cms/rich-text/lazy.d.ts +19 -0
- package/dist/components/cms/rich-text/lazy.js +26 -0
- package/dist/components/cms/rich-text/lazy.js.map +1 -0
- package/dist/components/cms/rich-text/slash-command.d.ts +27 -0
- package/dist/components/cms/rich-text/slash-command.js +158 -0
- package/dist/components/cms/rich-text/slash-command.js.map +1 -0
- package/dist/components/cms/rich-text/toolbar.d.ts +5 -6
- package/dist/components/cms/rich-text/toolbar.js +3 -5
- package/dist/components/cms/rich-text/toolbar.js.map +1 -1
- package/dist/components/cms/row-actions.d.ts +28 -0
- package/dist/components/cms/row-actions.js +20 -0
- package/dist/components/cms/row-actions.js.map +1 -0
- package/dist/components/cms/use-document-versions.d.ts +8 -1
- package/dist/components/cms/use-document-versions.js +31 -4
- package/dist/components/cms/use-document-versions.js.map +1 -1
- package/dist/components/cms/version-compare-lazy.d.ts +1 -0
- package/dist/components/cms/version-compare-lazy.js +23 -0
- package/dist/components/cms/version-compare-lazy.js.map +1 -0
- package/dist/components/cms/version-compare-text.d.ts +46 -0
- package/dist/components/cms/version-compare-text.js +78 -0
- package/dist/components/cms/version-compare-text.js.map +1 -1
- package/dist/components/cms/version-compare.d.ts +9 -5
- package/dist/components/cms/version-compare.js +184 -59
- package/dist/components/cms/version-compare.js.map +1 -1
- package/dist/components/cms/versions-pane.js +10 -4
- package/dist/components/cms/versions-pane.js.map +1 -1
- package/dist/components/components/component-detail.d.ts +5 -3
- package/dist/components/components/component-detail.js +41 -8
- package/dist/components/components/component-detail.js.map +1 -1
- package/dist/components/components/component-preview.d.ts +61 -0
- package/dist/components/components/component-preview.js +103 -0
- package/dist/components/components/component-preview.js.map +1 -0
- package/dist/components/components/components-index.d.ts +5 -3
- package/dist/components/components/components-index.js +19 -24
- package/dist/components/components/components-index.js.map +1 -1
- package/dist/components/components/registry-browser.d.ts +7 -0
- package/dist/components/components/registry-browser.js +20 -36
- package/dist/components/components/registry-browser.js.map +1 -1
- package/dist/components/components/taxonomy.d.ts +51 -0
- package/dist/components/components/taxonomy.js +73 -0
- package/dist/components/components/taxonomy.js.map +1 -0
- package/dist/components/components/transfer-dialog.d.ts +20 -0
- package/dist/components/components/transfer-dialog.js +64 -0
- package/dist/components/components/transfer-dialog.js.map +1 -0
- package/dist/components/components/transfer.d.ts +43 -0
- package/dist/components/components/transfer.js +31 -0
- package/dist/components/components/transfer.js.map +1 -0
- package/dist/components/project-list.js +3 -4
- package/dist/components/project-list.js.map +1 -1
- package/dist/components/project-switcher.js +3 -2
- package/dist/components/project-switcher.js.map +1 -1
- package/dist/components/rail-store-status.d.ts +21 -0
- package/dist/components/rail-store-status.js +21 -0
- package/dist/components/rail-store-status.js.map +1 -0
- package/dist/components/redirects/redirects-module.js +4 -8
- package/dist/components/redirects/redirects-module.js.map +1 -1
- package/dist/components/redirects/redirects-store.js +2 -7
- package/dist/components/redirects/redirects-store.js.map +1 -1
- package/dist/components/sign-in-needed-badge.d.ts +6 -0
- package/dist/components/sign-in-needed-badge.js +13 -0
- package/dist/components/sign-in-needed-badge.js.map +1 -0
- package/dist/components/studio-project-screen.js +1 -4
- package/dist/components/studio-project-screen.js.map +1 -1
- package/dist/components/studio-shell.js +1 -4
- package/dist/components/studio-shell.js.map +1 -1
- package/dist/components/users/users-module.js +5 -7
- package/dist/components/users/users-module.js.map +1 -1
- package/dist/components/users/users-store.js +2 -7
- package/dist/components/users/users-store.js.map +1 -1
- package/dist/lib/auth/index.js +1 -1
- package/dist/lib/auth/index.js.map +1 -1
- package/dist/lib/clipboard/paste-target.js +1 -3
- package/dist/lib/clipboard/paste-target.js.map +1 -1
- package/dist/lib/cms-views/view-model.d.ts +0 -2
- package/dist/lib/cms-views/view-model.js +0 -7
- package/dist/lib/cms-views/view-model.js.map +1 -1
- package/dist/lib/diff-view-preference.d.ts +7 -0
- package/dist/lib/diff-view-preference.js +21 -0
- package/dist/lib/diff-view-preference.js.map +1 -0
- package/dist/lib/i18n/messages.en.js +81 -30
- package/dist/lib/i18n/messages.en.js.map +1 -1
- package/dist/lib/local-preference.d.ts +11 -0
- package/dist/lib/local-preference.js +26 -0
- package/dist/lib/local-preference.js.map +1 -0
- package/dist/lib/locale/fallback.d.ts +45 -0
- package/dist/lib/locale/fallback.js +85 -0
- package/dist/lib/locale/fallback.js.map +1 -1
- package/dist/lib/persona/labels.d.ts +6 -0
- package/dist/lib/persona/labels.js +8 -0
- package/dist/lib/persona/labels.js.map +1 -1
- package/dist/lib/query/index.d.ts +1 -1
- package/dist/lib/query/index.js +1 -1
- package/dist/lib/query/index.js.map +1 -1
- package/dist/lib/query/operations-query.d.ts +14 -2
- package/dist/lib/query/operations-query.js +11 -6
- package/dist/lib/query/operations-query.js.map +1 -1
- package/dist/lib/rail.d.ts +0 -6
- package/dist/lib/rail.js +6 -25
- package/dist/lib/rail.js.map +1 -1
- package/dist/lib/theme.d.ts +0 -6
- package/dist/lib/theme.js +10 -13
- package/dist/lib/theme.js.map +1 -1
- package/dist/router/match.d.ts +1 -0
- package/dist/router/match.js +4 -0
- package/dist/router/match.js.map +1 -1
- package/dist/ui/button.d.ts +1 -1
- package/package.json +22 -24
- package/src/styles/studio.css +17 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { isPrimitive } from '@elytracms/core/component-registry';
|
|
2
|
+
function namespaceOfManifest(manifest) {
|
|
3
|
+
return isPrimitive(manifest.id) ? 'base' : 'project';
|
|
4
|
+
}
|
|
5
|
+
/** Case-insensitive match against a manifest's id, title, category, description. */
|
|
6
|
+
export function manifestMatchesQuery(manifest, query) {
|
|
7
|
+
const q = query.trim().toLowerCase();
|
|
8
|
+
if (q === '')
|
|
9
|
+
return true;
|
|
10
|
+
const haystack = [manifest.id, manifest.title, manifest.category, manifest.description]
|
|
11
|
+
.filter((v) => typeof v === 'string')
|
|
12
|
+
.join(' ')
|
|
13
|
+
.toLowerCase();
|
|
14
|
+
return haystack.includes(q);
|
|
15
|
+
}
|
|
16
|
+
/** Group category buckets: sorted alphabetically, the uncategorized bucket last. */
|
|
17
|
+
function groupCategories(manifests) {
|
|
18
|
+
const byCategory = new Map();
|
|
19
|
+
for (const manifest of manifests) {
|
|
20
|
+
const key = manifest.category ?? '';
|
|
21
|
+
const bucket = byCategory.get(key);
|
|
22
|
+
if (bucket)
|
|
23
|
+
bucket.push(manifest);
|
|
24
|
+
else
|
|
25
|
+
byCategory.set(key, [manifest]);
|
|
26
|
+
}
|
|
27
|
+
return [...byCategory.entries()]
|
|
28
|
+
.sort(([a], [b]) => {
|
|
29
|
+
// Uncategorized ('') always sorts last; otherwise alphabetical.
|
|
30
|
+
if (a === '')
|
|
31
|
+
return 1;
|
|
32
|
+
if (b === '')
|
|
33
|
+
return -1;
|
|
34
|
+
return a.localeCompare(b);
|
|
35
|
+
})
|
|
36
|
+
.map(([key, ms]) => ({
|
|
37
|
+
key,
|
|
38
|
+
manifests: [...ms].sort((x, y) => (x.title ?? x.id).localeCompare(y.title ?? y.id)),
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Derive the two-level taxonomy for the sidebar. `base` precedes `project` (rail
|
|
43
|
+
* order). An optional `query` filters manifests first; a namespace/category with
|
|
44
|
+
* no surviving manifest is omitted, so every rendered group yields results.
|
|
45
|
+
*/
|
|
46
|
+
export function deriveTaxonomy(manifests, query = '') {
|
|
47
|
+
const matched = manifests.filter((m) => manifestMatchesQuery(m, query));
|
|
48
|
+
const order = ['base', 'project'];
|
|
49
|
+
return order
|
|
50
|
+
.map((namespace) => {
|
|
51
|
+
const inNamespace = matched.filter((m) => namespaceOfManifest(m) === namespace);
|
|
52
|
+
return {
|
|
53
|
+
namespace,
|
|
54
|
+
count: inNamespace.length,
|
|
55
|
+
categories: groupCategories(inNamespace),
|
|
56
|
+
};
|
|
57
|
+
})
|
|
58
|
+
.filter((group) => group.count > 0);
|
|
59
|
+
}
|
|
60
|
+
export function deriveComponentStats(manifests) {
|
|
61
|
+
let base = 0;
|
|
62
|
+
for (const m of manifests)
|
|
63
|
+
if (namespaceOfManifest(m) === 'base')
|
|
64
|
+
base += 1;
|
|
65
|
+
const categories = groupCategories([...manifests]).map((c) => ({ key: c.key, count: c.manifests.length }));
|
|
66
|
+
return {
|
|
67
|
+
total: manifests.length,
|
|
68
|
+
base,
|
|
69
|
+
project: manifests.length - base,
|
|
70
|
+
categories,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=taxonomy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taxonomy.js","sourceRoot":"","sources":["../../../src/components/components/taxonomy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AA+BhE,SAAS,mBAAmB,CAAC,QAA2B;IACtD,OAAO,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;AACtD,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,oBAAoB,CAAC,QAA2B,EAAE,KAAa;IAC7E,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACpC,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,IAAI,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AAG,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAClE,CAAA;IACD,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,MAAM;QACvB,IAAI;QACJ,OAAO,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI;QAChC,UAAU;KACX,CAAA;AACH,CAAC","sourcesContent":["import { isPrimitive } from '@elytracms/core/component-registry'\nimport type { ComponentManifest } from '@elytracms/core/component-registry'\n\n/**\n * EC-320 — the component registry TAXONOMY, derived purely from the metadata a\n * manifest actually declares (no invented axes). Two levels of grouping:\n *\n * 1. **namespace** — `base` platform primitives vs `project` components\n * (`isPrimitive(id)`, i.e. `namespaceOf(id) === 'base'`).\n * 2. **category** — the manifest's optional `category` string, with an\n * \"uncategorized\" bucket (`key: ''`) collected last.\n *\n * Manifests carry no free-form `tags`, so category is the finest declared axis —\n * this makes the best of what's there rather than fabricating structure. Pure and\n * store-agnostic so the sidebar's grouping/search is unit-testable without React.\n */\n\nexport type ComponentNamespace = 'base' | 'project'\n\nexport interface TaxonomyCategory {\n /** The manifest category, or `''` for the uncategorized bucket. */\n key: string\n manifests: ComponentManifest[]\n}\n\nexport interface TaxonomyNamespace {\n namespace: ComponentNamespace\n count: number\n categories: TaxonomyCategory[]\n}\n\nfunction namespaceOfManifest(manifest: ComponentManifest): ComponentNamespace {\n return isPrimitive(manifest.id) ? 'base' : 'project'\n}\n\n/** Case-insensitive match against a manifest's id, title, category, description. */\nexport function manifestMatchesQuery(manifest: ComponentManifest, query: string): boolean {\n const q = query.trim().toLowerCase()\n if (q === '') return true\n const haystack = [manifest.id, manifest.title, manifest.category, manifest.description]\n .filter((v): v is string => typeof v === 'string')\n .join(' ')\n .toLowerCase()\n return haystack.includes(q)\n}\n\n/** Group category buckets: sorted alphabetically, the uncategorized bucket last. */\nfunction groupCategories(manifests: ComponentManifest[]): TaxonomyCategory[] {\n const byCategory = new Map<string, ComponentManifest[]>()\n for (const manifest of manifests) {\n const key = manifest.category ?? ''\n const bucket = byCategory.get(key)\n if (bucket) bucket.push(manifest)\n else byCategory.set(key, [manifest])\n }\n return [...byCategory.entries()]\n .sort(([a], [b]) => {\n // Uncategorized ('') always sorts last; otherwise alphabetical.\n if (a === '') return 1\n if (b === '') return -1\n return a.localeCompare(b)\n })\n .map(([key, ms]) => ({\n key,\n manifests: [...ms].sort((x, y) => (x.title ?? x.id).localeCompare(y.title ?? y.id)),\n }))\n}\n\n/**\n * Derive the two-level taxonomy for the sidebar. `base` precedes `project` (rail\n * order). An optional `query` filters manifests first; a namespace/category with\n * no surviving manifest is omitted, so every rendered group yields results.\n */\nexport function deriveTaxonomy(\n manifests: readonly ComponentManifest[],\n query = '',\n): TaxonomyNamespace[] {\n const matched = manifests.filter((m) => manifestMatchesQuery(m, query))\n const order: ComponentNamespace[] = ['base', 'project']\n return order\n .map((namespace) => {\n const inNamespace = matched.filter((m) => namespaceOfManifest(m) === namespace)\n return {\n namespace,\n count: inNamespace.length,\n categories: groupCategories(inNamespace),\n }\n })\n .filter((group) => group.count > 0)\n}\n\n// --- Stats (intro page) ---\n\nexport interface CategoryCount {\n /** The manifest category, or `''` for the uncategorized bucket. */\n key: string\n count: number\n}\n\n/**\n * Cheap registry stats for the intro page (EC-320): the total, the base/project\n * split, and a per-category breakdown (uncategorized last). Derived purely from\n * the manifest set — no health/implementation lookups here (those come from the\n * separate {@link import('@elytracms/studio/lib/registry').registryHealth}).\n */\nexport interface ComponentStats {\n total: number\n base: number\n project: number\n categories: CategoryCount[]\n}\n\nexport function deriveComponentStats(manifests: readonly ComponentManifest[]): ComponentStats {\n let base = 0\n for (const m of manifests) if (namespaceOfManifest(m) === 'base') base += 1\n const categories = groupCategories([...manifests]).map(\n (c): CategoryCount => ({ key: c.key, count: c.manifests.length }),\n )\n return {\n total: manifests.length,\n base,\n project: manifests.length - base,\n categories,\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ComponentManifest } from '@elytracms/core/component-registry';
|
|
2
|
+
import type { ComponentNode } from '@elytracms/core/project-graph';
|
|
3
|
+
/**
|
|
4
|
+
* EC-320 — "Use in document…". Transfers the current component combination (the
|
|
5
|
+
* live preview {@link ComponentNode}, edited props and all) into a NEW DRAFT
|
|
6
|
+
* document whose blocks field holds it, then opens that document.
|
|
7
|
+
*
|
|
8
|
+
* The dialog mounts a CMS session (so it reuses the store's create/save machinery,
|
|
9
|
+
* collision-free ids and persistence) only while open. On confirm it builds the
|
|
10
|
+
* draft (pure {@link buildBlockDocument}), persists it via `saveDocument`, STAGES
|
|
11
|
+
* it for the next CMS mount (the playground handoff, see document-staging), and
|
|
12
|
+
* navigates to the document — focused on its blocks field so it opens on the canvas.
|
|
13
|
+
*/
|
|
14
|
+
export declare function TransferToDocumentDialog({ projectId, manifest, node, open, onOpenChange, }: {
|
|
15
|
+
projectId: string;
|
|
16
|
+
manifest: ComponentManifest;
|
|
17
|
+
node: ComponentNode;
|
|
18
|
+
open: boolean;
|
|
19
|
+
onOpenChange: (open: boolean) => void;
|
|
20
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { FilePlus2 } from 'lucide-react';
|
|
4
|
+
import { STUDIO_PROJECT_ROUTE, studioPath, useNavigate } from '@elytracms/studio/router';
|
|
5
|
+
import { Button, Code, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Row, Stack, Text, } from '@elytracms/studio/ui';
|
|
6
|
+
import { localizedLabel, translate } from '@elytracms/studio/lib/i18n';
|
|
7
|
+
import { isPlaygroundMode } from '@elytracms/studio/lib/persistence';
|
|
8
|
+
import { resolveDeploymentCollections } from '@elytracms/studio/lib/workspace';
|
|
9
|
+
import { getInstantiatedKit } from '@elytracms/studio/lib/starters/kit-session';
|
|
10
|
+
import { CmsSessionGate } from '../project-session';
|
|
11
|
+
import { CmsProvider, useCms } from '../cms/cms-store';
|
|
12
|
+
import { stageDocument } from '../cms/document-staging';
|
|
13
|
+
import { buildBlockDocument, collectionsWithBlocks } from './transfer';
|
|
14
|
+
import { embedNodeFrom } from './component-preview';
|
|
15
|
+
/**
|
|
16
|
+
* EC-320 — "Use in document…". Transfers the current component combination (the
|
|
17
|
+
* live preview {@link ComponentNode}, edited props and all) into a NEW DRAFT
|
|
18
|
+
* document whose blocks field holds it, then opens that document.
|
|
19
|
+
*
|
|
20
|
+
* The dialog mounts a CMS session (so it reuses the store's create/save machinery,
|
|
21
|
+
* collision-free ids and persistence) only while open. On confirm it builds the
|
|
22
|
+
* draft (pure {@link buildBlockDocument}), persists it via `saveDocument`, STAGES
|
|
23
|
+
* it for the next CMS mount (the playground handoff, see document-staging), and
|
|
24
|
+
* navigates to the document — focused on its blocks field so it opens on the canvas.
|
|
25
|
+
*/
|
|
26
|
+
export function TransferToDocumentDialog({ projectId, manifest, node, open, onOpenChange, }) {
|
|
27
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "max-w-md", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: translate('components.transfer.title', { name: manifest.title ?? manifest.id }) }), _jsx(DialogDescription, { children: translate('components.transfer.description') })] }), open ? (_jsx(CmsSessionGate, { children: (cms) => {
|
|
28
|
+
const kit = getInstantiatedKit(projectId);
|
|
29
|
+
const collections = cms?.collections ??
|
|
30
|
+
kit?.collections ??
|
|
31
|
+
(isPlaygroundMode() ? resolveDeploymentCollections() : []);
|
|
32
|
+
return (_jsx(CmsProvider, { projectId: projectId, initialCollections: collections, initialDocuments: cms?.documents ?? kit?.documents, initialPublishedKeys: cms?.publishedKeys, children: _jsx(TransferPicker, { projectId: projectId, node: node, collections: collections, onClose: () => onOpenChange(false) }) }));
|
|
33
|
+
} })) : null] }) }));
|
|
34
|
+
}
|
|
35
|
+
function TransferPicker({ projectId, node, collections, onClose, }) {
|
|
36
|
+
const cms = useCms();
|
|
37
|
+
const navigate = useNavigate();
|
|
38
|
+
const targets = useMemo(() => collectionsWithBlocks(collections), [collections]);
|
|
39
|
+
function transfer(target) {
|
|
40
|
+
const existingIds = new Set(cms.documentsOf(target.collection.id).map((d) => d.id));
|
|
41
|
+
const doc = buildBlockDocument({
|
|
42
|
+
collection: target.collection,
|
|
43
|
+
blocksField: target.field,
|
|
44
|
+
node: embedNodeFrom(node, 'node-1'),
|
|
45
|
+
existingIds,
|
|
46
|
+
seq: { current: 0 },
|
|
47
|
+
});
|
|
48
|
+
// Persist through the store (upsert + reference index) and stage for the next
|
|
49
|
+
// CMS mount (playground handoff), then open the document on its canvas.
|
|
50
|
+
cms.saveDocument(doc);
|
|
51
|
+
stageDocument(projectId, doc);
|
|
52
|
+
onClose();
|
|
53
|
+
void navigate({
|
|
54
|
+
to: STUDIO_PROJECT_ROUTE,
|
|
55
|
+
params: { projectId, _splat: studioPath.cmsDocument(target.collection.id, doc.id) },
|
|
56
|
+
search: { field: `values/${target.field.name}` },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (targets.length === 0) {
|
|
60
|
+
return (_jsx(Text, { size: "sm", tone: "muted", "data-testid": "transfer-no-targets", children: translate('components.transfer.noTargets') }));
|
|
61
|
+
}
|
|
62
|
+
return (_jsxs(_Fragment, { children: [_jsx(Stack, { gap: "2", className: "max-h-[50vh] overflow-y-auto", children: targets.map((target) => (_jsxs("button", { type: "button", "data-testid": "transfer-target", onClick: () => transfer(target), className: "flex items-center gap-3 rounded-md border border-border p-3 text-left transition-colors hover:border-primary/40 hover:bg-muted", children: [_jsx("span", { className: "grid size-8 shrink-0 place-items-center rounded-md bg-muted text-muted-foreground", children: _jsx(FilePlus2, { className: "size-4" }) }), _jsxs(Stack, { gap: "px", className: "min-w-0 flex-1", children: [_jsx(Text, { size: "sm", weight: "medium", className: "truncate", children: localizedLabel(target.collection.form?.label, target.collection.id) }), _jsxs(Row, { gap: "1", align: "center", children: [_jsx(Text, { size: "xs", tone: "muted", children: translate('components.transfer.intoField') }), _jsx(Code, { tone: "muted", children: target.field.name })] })] })] }, target.collection.id))) }), _jsx(DialogFooter, { children: _jsx(Button, { type: "button", variant: "ghost", onClick: onClose, children: translate('common.cancel') }) })] }));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=transfer-dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer-dialog.js","sourceRoot":"","sources":["../../../src/components/components/transfer-dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAIxC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACxF,OAAO,EACL,MAAM,EACN,IAAI,EACJ,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,GAAG,EACH,KAAK,EACL,IAAI,GACL,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAA;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD;;;;;;;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AA;AACH,CAAC","sourcesContent":["import { useMemo } from 'react'\nimport { FilePlus2 } from 'lucide-react'\nimport type { ComponentManifest } from '@elytracms/core/component-registry'\nimport type { CollectionDef } from '@elytracms/core/cms-core'\nimport type { ComponentNode } from '@elytracms/core/project-graph'\nimport { STUDIO_PROJECT_ROUTE, studioPath, useNavigate } from '@elytracms/studio/router'\nimport {\n Button,\n Code,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Row,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { isPlaygroundMode } from '@elytracms/studio/lib/persistence'\nimport { resolveDeploymentCollections } from '@elytracms/studio/lib/workspace'\nimport { getInstantiatedKit } from '@elytracms/studio/lib/starters/kit-session'\nimport { CmsSessionGate } from '../project-session'\nimport { CmsProvider, useCms } from '../cms/cms-store'\nimport { stageDocument } from '../cms/document-staging'\nimport { buildBlockDocument, collectionsWithBlocks } from './transfer'\nimport type { CollectionBlocksTarget } from './transfer'\nimport { embedNodeFrom } from './component-preview'\n\n/**\n * EC-320 — \"Use in document…\". Transfers the current component combination (the\n * live preview {@link ComponentNode}, edited props and all) into a NEW DRAFT\n * document whose blocks field holds it, then opens that document.\n *\n * The dialog mounts a CMS session (so it reuses the store's create/save machinery,\n * collision-free ids and persistence) only while open. On confirm it builds the\n * draft (pure {@link buildBlockDocument}), persists it via `saveDocument`, STAGES\n * it for the next CMS mount (the playground handoff, see document-staging), and\n * navigates to the document — focused on its blocks field so it opens on the canvas.\n */\nexport function TransferToDocumentDialog({\n projectId,\n manifest,\n node,\n open,\n onOpenChange,\n}: {\n projectId: string\n manifest: ComponentManifest\n node: ComponentNode\n open: boolean\n onOpenChange: (open: boolean) => void\n}) {\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-w-md\">\n <DialogHeader>\n <DialogTitle>\n {translate('components.transfer.title', { name: manifest.title ?? manifest.id })}\n </DialogTitle>\n <DialogDescription>{translate('components.transfer.description')}</DialogDescription>\n </DialogHeader>\n {open ? (\n <CmsSessionGate>\n {(cms) => {\n const kit = getInstantiatedKit(projectId)\n const collections =\n cms?.collections ??\n kit?.collections ??\n (isPlaygroundMode() ? resolveDeploymentCollections() : [])\n return (\n <CmsProvider\n projectId={projectId}\n initialCollections={collections}\n initialDocuments={cms?.documents ?? kit?.documents}\n initialPublishedKeys={cms?.publishedKeys}\n >\n <TransferPicker\n projectId={projectId}\n node={node}\n collections={collections}\n onClose={() => onOpenChange(false)}\n />\n </CmsProvider>\n )\n }}\n </CmsSessionGate>\n ) : null}\n </DialogContent>\n </Dialog>\n )\n}\n\nfunction TransferPicker({\n projectId,\n node,\n collections,\n onClose,\n}: {\n projectId: string\n node: ComponentNode\n collections: readonly CollectionDef[]\n onClose: () => void\n}) {\n const cms = useCms()\n const navigate = useNavigate()\n const targets = useMemo(() => collectionsWithBlocks(collections), [collections])\n\n function transfer(target: CollectionBlocksTarget) {\n const existingIds = new Set(cms.documentsOf(target.collection.id).map((d) => d.id))\n const doc = buildBlockDocument({\n collection: target.collection,\n blocksField: target.field,\n node: embedNodeFrom(node, 'node-1'),\n existingIds,\n seq: { current: 0 },\n })\n // Persist through the store (upsert + reference index) and stage for the next\n // CMS mount (playground handoff), then open the document on its canvas.\n cms.saveDocument(doc)\n stageDocument(projectId, doc)\n onClose()\n void navigate({\n to: STUDIO_PROJECT_ROUTE,\n params: { projectId, _splat: studioPath.cmsDocument(target.collection.id, doc.id) },\n search: { field: `values/${target.field.name}` },\n })\n }\n\n if (targets.length === 0) {\n return (\n <Text size=\"sm\" tone=\"muted\" data-testid=\"transfer-no-targets\">\n {translate('components.transfer.noTargets')}\n </Text>\n )\n }\n\n return (\n <>\n <Stack gap=\"2\" className=\"max-h-[50vh] overflow-y-auto\">\n {targets.map((target) => (\n <button\n key={target.collection.id}\n type=\"button\"\n data-testid=\"transfer-target\"\n onClick={() => transfer(target)}\n className=\"flex items-center gap-3 rounded-md border border-border p-3 text-left transition-colors hover:border-primary/40 hover:bg-muted\"\n >\n <span className=\"grid size-8 shrink-0 place-items-center rounded-md bg-muted text-muted-foreground\">\n <FilePlus2 className=\"size-4\" />\n </span>\n <Stack gap=\"px\" className=\"min-w-0 flex-1\">\n <Text size=\"sm\" weight=\"medium\" className=\"truncate\">\n {localizedLabel(target.collection.form?.label, target.collection.id)}\n </Text>\n <Row gap=\"1\" align=\"center\">\n <Text size=\"xs\" tone=\"muted\">\n {translate('components.transfer.intoField')}\n </Text>\n <Code tone=\"muted\">{target.field.name}</Code>\n </Row>\n </Stack>\n </button>\n ))}\n </Stack>\n <DialogFooter>\n <Button type=\"button\" variant=\"ghost\" onClick={onClose}>\n {translate('common.cancel')}\n </Button>\n </DialogFooter>\n </>\n )\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CmsDocument, CollectionDef, FieldDef } from '@elytracms/core/cms-core';
|
|
2
|
+
import type { ComponentNode } from '@elytracms/core/project-graph';
|
|
3
|
+
/**
|
|
4
|
+
* EC-320 — the "design guide → real content" bridge. A component combination the
|
|
5
|
+
* user has arranged in the Components view (a manifest + edited prop values,
|
|
6
|
+
* captured as a {@link ComponentNode}) is transferred into a NEW DRAFT document
|
|
7
|
+
* whose blocks/composition field holds that node. Pure so the id-minting and
|
|
8
|
+
* embedding are unit-testable; the React dialog owns the picker, persistence, and
|
|
9
|
+
* navigation.
|
|
10
|
+
*/
|
|
11
|
+
export interface CollectionBlocksTarget {
|
|
12
|
+
collection: CollectionDef;
|
|
13
|
+
/** The (first) blocks field the node lands in. */
|
|
14
|
+
field: FieldDef;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Collections that can receive a transferred combination — those declaring a
|
|
18
|
+
* `blocks` (composition) field. The first blocks field wins (a collection with a
|
|
19
|
+
* single canvas is the norm; a second is an unusual edge we don't disambiguate).
|
|
20
|
+
*/
|
|
21
|
+
export declare function collectionsWithBlocks(collections: readonly CollectionDef[]): CollectionBlocksTarget[];
|
|
22
|
+
export interface BuildBlockDocumentInput {
|
|
23
|
+
collection: CollectionDef;
|
|
24
|
+
/** The blocks field the node lands in (from {@link collectionsWithBlocks}). */
|
|
25
|
+
blocksField: FieldDef;
|
|
26
|
+
/** The component node — a manifest id + the edited static props (+ slots). */
|
|
27
|
+
node: ComponentNode;
|
|
28
|
+
/** Every doc id already in the target collection (collision guard, EC-316). */
|
|
29
|
+
existingIds: ReadonlySet<string>;
|
|
30
|
+
/** The session id counter (mutated by {@link mintDocumentId}). */
|
|
31
|
+
seq: {
|
|
32
|
+
current: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build the draft document that embeds `node` in the collection's blocks field.
|
|
37
|
+
* Reuses the CMS create machinery: {@link mintDocumentId} for a collision-free id
|
|
38
|
+
* (EC-316) and {@link seedDefaults} so declared field defaults are present (as a
|
|
39
|
+
* normal `+ New` would be). A `multiple` blocks field stores an array; a single
|
|
40
|
+
* (`multiple: false`) blocks field stores the lone node — matching how the
|
|
41
|
+
* composition editor persists and `blockRootsOf` reads it back.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildBlockDocument({ collection, blocksField, node, existingIds, seq, }: BuildBlockDocumentInput): CmsDocument;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { isBlocksField, seedDefaults } from '@elytracms/core/cms-core';
|
|
2
|
+
import { mintDocumentId } from '../cms/cms-store';
|
|
3
|
+
/**
|
|
4
|
+
* Collections that can receive a transferred combination — those declaring a
|
|
5
|
+
* `blocks` (composition) field. The first blocks field wins (a collection with a
|
|
6
|
+
* single canvas is the norm; a second is an unusual edge we don't disambiguate).
|
|
7
|
+
*/
|
|
8
|
+
export function collectionsWithBlocks(collections) {
|
|
9
|
+
const targets = [];
|
|
10
|
+
for (const collection of collections) {
|
|
11
|
+
const field = collection.fields.find(isBlocksField);
|
|
12
|
+
if (field)
|
|
13
|
+
targets.push({ collection, field });
|
|
14
|
+
}
|
|
15
|
+
return targets;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Build the draft document that embeds `node` in the collection's blocks field.
|
|
19
|
+
* Reuses the CMS create machinery: {@link mintDocumentId} for a collision-free id
|
|
20
|
+
* (EC-316) and {@link seedDefaults} so declared field defaults are present (as a
|
|
21
|
+
* normal `+ New` would be). A `multiple` blocks field stores an array; a single
|
|
22
|
+
* (`multiple: false`) blocks field stores the lone node — matching how the
|
|
23
|
+
* composition editor persists and `blockRootsOf` reads it back.
|
|
24
|
+
*/
|
|
25
|
+
export function buildBlockDocument({ collection, blocksField, node, existingIds, seq, }) {
|
|
26
|
+
const id = mintDocumentId(collection.id, seq, existingIds);
|
|
27
|
+
const values = seedDefaults(collection);
|
|
28
|
+
values[blocksField.name] = isBlocksField(blocksField) && blocksField.multiple ? [node] : node;
|
|
29
|
+
return { collection: collection.id, id, values };
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=transfer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../../src/components/components/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAiBjD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,WAAqC;IAErC,MAAM,OAAO,GAA6B,EAAE,CAAA;IAC5C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QACnD,IAAI,KAAK;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAA;IAChD,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAcD;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,UAAU,EACV,WAAW,EACX,IAAI,EACJ,WAAW,EACX,GAAG,GACqB;IACxB,MAAM,EAAE,GAAG,cAAc,CAAC,UAAU,CAAC,EAAE,EAAE,GAAG,EAAE,WAAW,CAAC,CAAA;IAC1D,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,CAAA;IACvC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC7F,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAA;AAClD,CAAC","sourcesContent":["import { isBlocksField, seedDefaults } from '@elytracms/core/cms-core'\nimport type { CmsDocument, CollectionDef, FieldDef } from '@elytracms/core/cms-core'\nimport type { ComponentNode } from '@elytracms/core/project-graph'\nimport { mintDocumentId } from '../cms/cms-store'\n\n/**\n * EC-320 — the \"design guide → real content\" bridge. A component combination the\n * user has arranged in the Components view (a manifest + edited prop values,\n * captured as a {@link ComponentNode}) is transferred into a NEW DRAFT document\n * whose blocks/composition field holds that node. Pure so the id-minting and\n * embedding are unit-testable; the React dialog owns the picker, persistence, and\n * navigation.\n */\n\nexport interface CollectionBlocksTarget {\n collection: CollectionDef\n /** The (first) blocks field the node lands in. */\n field: FieldDef\n}\n\n/**\n * Collections that can receive a transferred combination — those declaring a\n * `blocks` (composition) field. The first blocks field wins (a collection with a\n * single canvas is the norm; a second is an unusual edge we don't disambiguate).\n */\nexport function collectionsWithBlocks(\n collections: readonly CollectionDef[],\n): CollectionBlocksTarget[] {\n const targets: CollectionBlocksTarget[] = []\n for (const collection of collections) {\n const field = collection.fields.find(isBlocksField)\n if (field) targets.push({ collection, field })\n }\n return targets\n}\n\nexport interface BuildBlockDocumentInput {\n collection: CollectionDef\n /** The blocks field the node lands in (from {@link collectionsWithBlocks}). */\n blocksField: FieldDef\n /** The component node — a manifest id + the edited static props (+ slots). */\n node: ComponentNode\n /** Every doc id already in the target collection (collision guard, EC-316). */\n existingIds: ReadonlySet<string>\n /** The session id counter (mutated by {@link mintDocumentId}). */\n seq: { current: number }\n}\n\n/**\n * Build the draft document that embeds `node` in the collection's blocks field.\n * Reuses the CMS create machinery: {@link mintDocumentId} for a collision-free id\n * (EC-316) and {@link seedDefaults} so declared field defaults are present (as a\n * normal `+ New` would be). A `multiple` blocks field stores an array; a single\n * (`multiple: false`) blocks field stores the lone node — matching how the\n * composition editor persists and `blockRootsOf` reads it back.\n */\nexport function buildBlockDocument({\n collection,\n blocksField,\n node,\n existingIds,\n seq,\n}: BuildBlockDocumentInput): CmsDocument {\n const id = mintDocumentId(collection.id, seq, existingIds)\n const values = seedDefaults(collection)\n values[blocksField.name] = isBlocksField(blocksField) && blocksField.multiple ? [node] : node\n return { collection: collection.id, id, values }\n}\n"]}
|
|
@@ -5,6 +5,7 @@ import { Badge, Button, Card, Code, Heading, Row, Spacer, Stack, Text } from '@e
|
|
|
5
5
|
import { hasProjectSession } from '@elytracms/studio/lib/auth';
|
|
6
6
|
import { translate } from '@elytracms/studio/lib/i18n';
|
|
7
7
|
import { PlaygroundBadge } from './playground-badge';
|
|
8
|
+
import { SignInNeededBadge } from './sign-in-needed-badge';
|
|
8
9
|
import { SectionStateView } from './section-state';
|
|
9
10
|
import { useStudio } from './studio-context';
|
|
10
11
|
import { useSwitcherEntries } from './workspace-projects';
|
|
@@ -28,9 +29,7 @@ export function ProjectLauncher({ forcedState }) {
|
|
|
28
29
|
.filter((p) => entries.some((e) => e.kind === 'project' && e.project.id === p.id))
|
|
29
30
|
.slice(0, 4);
|
|
30
31
|
const forced = forcedState && forcedState !== 'working' ? forcedState : null;
|
|
31
|
-
return (_jsxs("div", { className: "mx-auto w-full max-w-6xl px-6 py-8", children: [_jsxs(Row, { gap: "3", className: "mb-6", children: [_jsxs(Stack, { gap: "1", children: [_jsxs(Row, { gap: "2", children: [_jsx(Heading, { size: "display", children: translate('shell.projects') }), _jsx(PlaygroundBadge, {}), hasConfig ? (
|
|
32
|
-
// EC-154: this workspace is defined in code.
|
|
33
|
-
_jsxs(Badge, { variant: "outline", children: [_jsx(TerminalSquare, { className: "size-3" }), " ", workspace.source] })) : null] }), _jsx(Text, { tone: "muted", children: hasConfig
|
|
32
|
+
return (_jsxs("div", { className: "mx-auto w-full max-w-6xl px-6 py-8", children: [_jsxs(Row, { gap: "3", className: "mb-6", children: [_jsxs(Stack, { gap: "1", children: [_jsxs(Row, { gap: "2", children: [_jsx(Heading, { size: "display", children: translate('shell.projects') }), _jsx(PlaygroundBadge, {}), hasConfig ? (_jsxs(Badge, { variant: "outline", children: [_jsx(TerminalSquare, { className: "size-3" }), " ", workspace.source] })) : null] }), _jsx(Text, { tone: "muted", children: hasConfig
|
|
34
33
|
? 'Projects are defined in code. Add entries to elytra.config.ts and provision them with the CLI.'
|
|
35
34
|
: 'Open and manage your Elytra projects.' })] }), _jsx(Spacer, {})] }), recents.length > 0 && !forced ? (_jsxs(Stack, { gap: "2", className: "mb-6", children: [_jsx(Text, { size: "xs", tone: "muted", mono: true, className: "uppercase", children: translate('shell.projectList.recent') }), _jsx(Row, { gap: "2", wrap: true, children: recents.map((p) => (_jsxs(Link, { to: STUDIO_PROJECT_ROUTE, params: { projectId: p.id, _splat: studioPath.index() }, onClick: () => studio.activate(p.id), className: "inline-flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5 text-sm transition-colors hover:border-primary/40 hover:bg-muted", children: [_jsx("span", { className: "grid size-4 place-items-center rounded-[4px] bg-primary text-[0.6rem] font-bold text-primary-foreground", children: p.name.charAt(0).toUpperCase() }), p.name] }, p.id))) })] })) : null, forced ? (_jsx(SectionStateView, { state: forced, title: forced === 'empty' ? translate('shell.projectList.empty.title') : undefined })) : visible.length === 0 ? (_jsx(SectionStateView, { state: "empty", title: translate('shell.projectList.empty.title'), description: hasConfig
|
|
36
35
|
? 'The workspace config declares no visible projects. Add an entry to elytra.config.ts, or ask an admin to grant you access.'
|
|
@@ -41,7 +40,7 @@ function ProjectCard({ project }) {
|
|
|
41
40
|
// Per-backend sign-in state (EC-179): one project per backend, so a project on
|
|
42
41
|
// a deployment the user hasn't authenticated into shows "Sign in", not "Open".
|
|
43
42
|
const authed = hasProjectSession(project.slug);
|
|
44
|
-
return (_jsxs(Card, { className: "flex flex-col gap-3 p-4 transition-colors hover:border-primary/30", children: [_jsxs(Row, { gap: "2", children: [_jsx("span", { className: "grid size-8 shrink-0 place-items-center rounded-lg bg-primary text-sm font-bold text-primary-foreground", children: project.name.charAt(0).toUpperCase() }), _jsxs(Stack, { gap: "1", className: "min-w-0", children: [_jsx(Text, { weight: "semibold", className: "truncate", children: project.name }), _jsx(Code, { tone: "muted", className: "w-fit max-w-full truncate", children: project.slug })] }), _jsx(Spacer, {}), authed ? null :
|
|
43
|
+
return (_jsxs(Card, { className: "flex flex-col gap-3 p-4 transition-colors hover:border-primary/30", children: [_jsxs(Row, { gap: "2", children: [_jsx("span", { className: "grid size-8 shrink-0 place-items-center rounded-lg bg-primary text-sm font-bold text-primary-foreground", children: project.name.charAt(0).toUpperCase() }), _jsxs(Stack, { gap: "1", className: "min-w-0", children: [_jsx(Text, { weight: "semibold", className: "truncate", children: project.name }), _jsx(Code, { tone: "muted", className: "w-fit max-w-full truncate", children: project.slug })] }), _jsx(Spacer, {}), authed ? null : _jsx(SignInNeededBadge, {})] }), _jsxs(Row, { gap: "2", className: "text-muted-foreground", children: [_jsxs(Badge, { variant: "outline", children: [_jsx(Globe, { className: "size-3" }), " ", project.settings.locales.length] }), _jsx(Spacer, {})] }), _jsx(Button, { variant: authed ? 'secondary' : 'default', size: "sm", asChild: true, className: "mt-1", children: _jsx(Link, { to: STUDIO_PROJECT_ROUTE, params: { projectId: project.id, _splat: studioPath.index() }, onClick: () => studio.activate(project.id), children: authed ? translate('shell.projectCard.open') : (_jsxs(_Fragment, { children: [_jsx(LogIn, {}), " ", translate('auth.signIn')] })) }) })] }));
|
|
45
44
|
}
|
|
46
45
|
/**
|
|
47
46
|
* A configured project that has no backend project yet (EC-154): an explicit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-list.js","sourceRoot":"","sources":["../../src/components/project-list.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAOzD;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,EAAE,WAAW,EAAwB;IACnE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAEnD,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,KAAK,QAAQ,CAAA;IAC7C,MAAM,OAAO,GAAG,OAAO,CAAA;IACvB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB;SAC5C,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE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MAAM,CAAC,IAAI,GACP,EACP,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,2BAA2B,YACrD,MAAM,CAAC,IAAI,GACP,IACD,EACR,KAAC,MAAM,KAAG,EACV,KAAC,KAAK,IAAC,OAAO,EAAC,SAAS,YAAE,SAAS,CAAC,8BAA8B,CAAC,GAAS,IACxE,EAEN,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,kHAGrB,EACP,MAAC,IAAI,IAAC,SAAS,EAAC,yCAAyC,wCAC/B,MAAM,CAAC,IAAI,IAC9B,IACF,CACR,CAAA;AACH,CAAC","sourcesContent":["import { Link, STUDIO_PROJECT_ROUTE, studioPath } from '@elytracms/studio/router'\nimport { Globe, LogIn, TerminalSquare } from 'lucide-react'\nimport type { Project, ResolvedWorkspaceProject, SectionState } from '@elytracms/core/studio-core'\nimport { Badge, Button, Card, Code, Heading, Row, Spacer, Stack, Text } from '@elytracms/studio/ui'\nimport { hasProjectSession } from '@elytracms/studio/lib/auth'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { PlaygroundBadge } from './playground-badge'\nimport { SectionStateView } from './section-state'\nimport { useStudio } from './studio-context'\nimport { useSwitcherEntries } from './workspace-projects'\n\nexport interface ProjectLauncherProps {\n /** Force a deterministic list state for browser verification (?state=…). */\n forcedState?: SectionState | null\n}\n\n/**\n * Studio launcher / project list (brief §4.3, §8.1; reframed by EC-154). The\n * Studio's front door: lists the workspace's projects and routes into a\n * project's shell. With a workspace config the list is config-driven\n * (configured projects ∩ grants, plus explicit \"not provisioned\" states);\n * project *creation* is code-first — `elytra.config.ts` + `builder init\n * --project <slug>` — so there is no in-UI create flow. Without a config the\n * adapter-backed list (and the starter-kit gallery) behaves as before.\n */\nexport function ProjectLauncher({ forcedState }: ProjectLauncherProps) {\n const studio = useStudio()\n const { entries, workspace } = useSwitcherEntries()\n\n const hasConfig = workspace.kind === 'config'\n const visible = entries\n const recents = studio.context.recentProjectIds\n .map((id) => studio.getProject(id))\n .filter((p): p is Project => Boolean(p))\n .filter((p) => entries.some((e) => e.kind === 'project' && e.project.id === p.id))\n .slice(0, 4)\n\n const forced = forcedState && forcedState !== 'working' ? forcedState : null\n\n return (\n <div className=\"mx-auto w-full max-w-6xl px-6 py-8\">\n <Row gap=\"3\" className=\"mb-6\">\n <Stack gap=\"1\">\n <Row gap=\"2\">\n <Heading size=\"display\">{translate('shell.projects')}</Heading>\n {/* EC-153: explicit playground-mode marker (renders nothing on Convex). */}\n <PlaygroundBadge />\n {hasConfig ? (\n // EC-154: this workspace is defined in code.\n <Badge variant=\"outline\">\n <TerminalSquare className=\"size-3\" /> {workspace.source}\n </Badge>\n ) : null}\n </Row>\n <Text tone=\"muted\">\n {hasConfig\n ? 'Projects are defined in code. Add entries to elytra.config.ts and provision them with the CLI.'\n : 'Open and manage your Elytra projects.'}\n </Text>\n </Stack>\n <Spacer />\n </Row>\n\n {recents.length > 0 && !forced ? (\n <Stack gap=\"2\" className=\"mb-6\">\n <Text size=\"xs\" tone=\"muted\" mono className=\"uppercase\">\n {translate('shell.projectList.recent')}\n </Text>\n <Row gap=\"2\" wrap>\n {recents.map((p) => (\n <Link\n key={p.id}\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId: p.id, _splat: studioPath.index() }}\n onClick={() => studio.activate(p.id)}\n className=\"inline-flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5 text-sm transition-colors hover:border-primary/40 hover:bg-muted\"\n >\n <span className=\"grid size-4 place-items-center rounded-[4px] bg-primary text-[0.6rem] font-bold text-primary-foreground\">\n {p.name.charAt(0).toUpperCase()}\n </span>\n {p.name}\n </Link>\n ))}\n </Row>\n </Stack>\n ) : null}\n\n {forced ? (\n <SectionStateView\n state={forced}\n title={forced === 'empty' ? translate('shell.projectList.empty.title') : undefined}\n />\n ) : visible.length === 0 ? (\n <SectionStateView\n state=\"empty\"\n title={translate('shell.projectList.empty.title')}\n description={\n hasConfig\n ? 'The workspace config declares no visible projects. Add an entry to elytra.config.ts, or ask an admin to grant you access.'\n : 'No active projects. Create one from the CLI: run `builder init` in your repo to scaffold elytra.config.ts, then `builder init --project <slug>`.'\n }\n />\n ) : (\n <div className=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {visible.map((entry) =>\n entry.kind === 'project' ? (\n <ProjectCard key={entry.project.id} project={entry.project} />\n ) : (\n <UnprovisionedCard key={`config:${entry.config.slug}`} config={entry.config} />\n ),\n )}\n </div>\n )}\n </div>\n )\n}\n\nfunction ProjectCard({ project }: { project: Project }) {\n const studio = useStudio()\n // Per-backend sign-in state (EC-179): one project per backend, so a project on\n // a deployment the user hasn't authenticated into shows \"Sign in\", not \"Open\".\n const authed = hasProjectSession(project.slug)\n return (\n <Card className=\"flex flex-col gap-3 p-4 transition-colors hover:border-primary/30\">\n <Row gap=\"2\">\n <span className=\"grid size-8 shrink-0 place-items-center rounded-lg bg-primary text-sm font-bold text-primary-foreground\">\n {project.name.charAt(0).toUpperCase()}\n </span>\n <Stack gap=\"1\" className=\"min-w-0\">\n <Text weight=\"semibold\" className=\"truncate\">\n {project.name}\n </Text>\n <Code tone=\"muted\" className=\"w-fit max-w-full truncate\">\n {project.slug}\n </Code>\n </Stack>\n <Spacer />\n {authed ? null : (\n <Badge variant=\"warning\">\n <LogIn className=\"size-3\" /> {translate('auth.signIn')}\n </Badge>\n )}\n </Row>\n\n <Row gap=\"2\" className=\"text-muted-foreground\">\n <Badge variant=\"outline\">\n <Globe className=\"size-3\" /> {project.settings.locales.length}\n </Badge>\n <Spacer />\n </Row>\n\n <Button variant={authed ? 'secondary' : 'default'} size=\"sm\" asChild className=\"mt-1\">\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId: project.id, _splat: studioPath.index() }}\n onClick={() => studio.activate(project.id)}\n >\n {authed ? translate('shell.projectCard.open') : (\n <>\n <LogIn /> {translate('auth.signIn')}\n </>\n )}\n </Link>\n </Button>\n </Card>\n )\n}\n\n/**\n * A configured project that has no backend project yet (EC-154): an explicit,\n * deterministic state pointing at the CLI provisioning flow — never an error.\n */\nfunction UnprovisionedCard({ config }: { config: ResolvedWorkspaceProject }) {\n return (\n <Card className=\"flex flex-col gap-3 border-dashed p-4\">\n <Row gap=\"2\">\n <span className=\"grid size-8 shrink-0 place-items-center rounded-lg border border-border bg-muted text-sm font-bold text-muted-foreground\">\n {config.name.charAt(0).toUpperCase()}\n </span>\n <Stack gap=\"1\" className=\"min-w-0\">\n <Text weight=\"semibold\" className=\"truncate\">\n {config.name}\n </Text>\n <Code tone=\"muted\" className=\"w-fit max-w-full truncate\">\n {config.slug}\n </Code>\n </Stack>\n <Spacer />\n <Badge variant=\"outline\">{translate('shell.project.notProvisioned')}</Badge>\n </Row>\n\n <Text size=\"sm\" tone=\"muted\">\n Declared in the workspace config, but no backend project exists yet. Provision it from your\n repo:\n </Text>\n <Code className=\"block w-fit max-w-full truncate text-xs\">\n builder init --project {config.slug}\n </Code>\n </Card>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"project-list.js","sourceRoot":"","sources":["../../src/components/project-list.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,g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J,CACR,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,EAAE,MAAM,EAAwC;IACzE,OAAO,CACL,MAAC,IAAI,IAAC,SAAS,EAAC,uCAAuC,aACrD,MAAC,GAAG,IAAC,GAAG,EAAC,GAAG,aACV,eAAM,SAAS,EAAC,0HAA0H,YACvI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAC/B,EACP,MAAC,KAAK,IAAC,GAAG,EAAC,GAAG,EAAC,SAAS,EAAC,SAAS,aAChC,KAAC,IAAI,IAAC,MAAM,EAAC,UAAU,EAAC,SAAS,EAAC,UAAU,YACzC,MAAM,CAAC,IAAI,GACP,EACP,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,2BAA2B,YACrD,MAAM,CAAC,IAAI,GACP,IACD,EACR,KAAC,MAAM,KAAG,EACV,KAAC,KAAK,IAAC,OAAO,EAAC,SAAS,YAAE,SAAS,CAAC,8BAA8B,CAAC,GAAS,IACxE,EAEN,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,kHAGrB,EACP,MAAC,IAAI,IAAC,SAAS,EAAC,yCAAyC,wCAC/B,MAAM,CAAC,IAAI,IAC9B,IACF,CACR,CAAA;AACH,CAAC","sourcesContent":["import { Link, STUDIO_PROJECT_ROUTE, studioPath } from '@elytracms/studio/router'\nimport { Globe, LogIn, TerminalSquare } from 'lucide-react'\nimport type { Project, ResolvedWorkspaceProject, SectionState } from '@elytracms/core/studio-core'\nimport { Badge, Button, Card, Code, Heading, Row, Spacer, Stack, Text } from '@elytracms/studio/ui'\nimport { hasProjectSession } from '@elytracms/studio/lib/auth'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { PlaygroundBadge } from './playground-badge'\nimport { SignInNeededBadge } from './sign-in-needed-badge'\nimport { SectionStateView } from './section-state'\nimport { useStudio } from './studio-context'\nimport { useSwitcherEntries } from './workspace-projects'\n\nexport interface ProjectLauncherProps {\n /** Force a deterministic list state for browser verification (?state=…). */\n forcedState?: SectionState | null\n}\n\n/**\n * Studio launcher / project list (brief §4.3, §8.1; reframed by EC-154). The\n * Studio's front door: lists the workspace's projects and routes into a\n * project's shell. With a workspace config the list is config-driven\n * (configured projects ∩ grants, plus explicit \"not provisioned\" states);\n * project *creation* is code-first — `elytra.config.ts` + `builder init\n * --project <slug>` — so there is no in-UI create flow. Without a config the\n * adapter-backed list (and the starter-kit gallery) behaves as before.\n */\nexport function ProjectLauncher({ forcedState }: ProjectLauncherProps) {\n const studio = useStudio()\n const { entries, workspace } = useSwitcherEntries()\n\n const hasConfig = workspace.kind === 'config'\n const visible = entries\n const recents = studio.context.recentProjectIds\n .map((id) => studio.getProject(id))\n .filter((p): p is Project => Boolean(p))\n .filter((p) => entries.some((e) => e.kind === 'project' && e.project.id === p.id))\n .slice(0, 4)\n\n const forced = forcedState && forcedState !== 'working' ? forcedState : null\n\n return (\n <div className=\"mx-auto w-full max-w-6xl px-6 py-8\">\n <Row gap=\"3\" className=\"mb-6\">\n <Stack gap=\"1\">\n <Row gap=\"2\">\n <Heading size=\"display\">{translate('shell.projects')}</Heading>\n {/* EC-153: explicit playground-mode marker (renders nothing on Convex). */}\n <PlaygroundBadge />\n {hasConfig ? (\n // EC-154: this workspace is defined in code.\n <Badge variant=\"outline\">\n <TerminalSquare className=\"size-3\" /> {workspace.source}\n </Badge>\n ) : null}\n </Row>\n <Text tone=\"muted\">\n {hasConfig\n ? 'Projects are defined in code. Add entries to elytra.config.ts and provision them with the CLI.'\n : 'Open and manage your Elytra projects.'}\n </Text>\n </Stack>\n <Spacer />\n </Row>\n\n {recents.length > 0 && !forced ? (\n <Stack gap=\"2\" className=\"mb-6\">\n <Text size=\"xs\" tone=\"muted\" mono className=\"uppercase\">\n {translate('shell.projectList.recent')}\n </Text>\n <Row gap=\"2\" wrap>\n {recents.map((p) => (\n <Link\n key={p.id}\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId: p.id, _splat: studioPath.index() }}\n onClick={() => studio.activate(p.id)}\n className=\"inline-flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5 text-sm transition-colors hover:border-primary/40 hover:bg-muted\"\n >\n <span className=\"grid size-4 place-items-center rounded-[4px] bg-primary text-[0.6rem] font-bold text-primary-foreground\">\n {p.name.charAt(0).toUpperCase()}\n </span>\n {p.name}\n </Link>\n ))}\n </Row>\n </Stack>\n ) : null}\n\n {forced ? (\n <SectionStateView\n state={forced}\n title={forced === 'empty' ? translate('shell.projectList.empty.title') : undefined}\n />\n ) : visible.length === 0 ? (\n <SectionStateView\n state=\"empty\"\n title={translate('shell.projectList.empty.title')}\n description={\n hasConfig\n ? 'The workspace config declares no visible projects. Add an entry to elytra.config.ts, or ask an admin to grant you access.'\n : 'No active projects. Create one from the CLI: run `builder init` in your repo to scaffold elytra.config.ts, then `builder init --project <slug>`.'\n }\n />\n ) : (\n <div className=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {visible.map((entry) =>\n entry.kind === 'project' ? (\n <ProjectCard key={entry.project.id} project={entry.project} />\n ) : (\n <UnprovisionedCard key={`config:${entry.config.slug}`} config={entry.config} />\n ),\n )}\n </div>\n )}\n </div>\n )\n}\n\nfunction ProjectCard({ project }: { project: Project }) {\n const studio = useStudio()\n // Per-backend sign-in state (EC-179): one project per backend, so a project on\n // a deployment the user hasn't authenticated into shows \"Sign in\", not \"Open\".\n const authed = hasProjectSession(project.slug)\n return (\n <Card className=\"flex flex-col gap-3 p-4 transition-colors hover:border-primary/30\">\n <Row gap=\"2\">\n <span className=\"grid size-8 shrink-0 place-items-center rounded-lg bg-primary text-sm font-bold text-primary-foreground\">\n {project.name.charAt(0).toUpperCase()}\n </span>\n <Stack gap=\"1\" className=\"min-w-0\">\n <Text weight=\"semibold\" className=\"truncate\">\n {project.name}\n </Text>\n <Code tone=\"muted\" className=\"w-fit max-w-full truncate\">\n {project.slug}\n </Code>\n </Stack>\n <Spacer />\n {authed ? null : <SignInNeededBadge />}\n </Row>\n\n <Row gap=\"2\" className=\"text-muted-foreground\">\n <Badge variant=\"outline\">\n <Globe className=\"size-3\" /> {project.settings.locales.length}\n </Badge>\n <Spacer />\n </Row>\n\n <Button variant={authed ? 'secondary' : 'default'} size=\"sm\" asChild className=\"mt-1\">\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId: project.id, _splat: studioPath.index() }}\n onClick={() => studio.activate(project.id)}\n >\n {authed ? translate('shell.projectCard.open') : (\n <>\n <LogIn /> {translate('auth.signIn')}\n </>\n )}\n </Link>\n </Button>\n </Card>\n )\n}\n\n/**\n * A configured project that has no backend project yet (EC-154): an explicit,\n * deterministic state pointing at the CLI provisioning flow — never an error.\n */\nfunction UnprovisionedCard({ config }: { config: ResolvedWorkspaceProject }) {\n return (\n <Card className=\"flex flex-col gap-3 border-dashed p-4\">\n <Row gap=\"2\">\n <span className=\"grid size-8 shrink-0 place-items-center rounded-lg border border-border bg-muted text-sm font-bold text-muted-foreground\">\n {config.name.charAt(0).toUpperCase()}\n </span>\n <Stack gap=\"1\" className=\"min-w-0\">\n <Text weight=\"semibold\" className=\"truncate\">\n {config.name}\n </Text>\n <Code tone=\"muted\" className=\"w-fit max-w-full truncate\">\n {config.slug}\n </Code>\n </Stack>\n <Spacer />\n <Badge variant=\"outline\">{translate('shell.project.notProvisioned')}</Badge>\n </Row>\n\n <Text size=\"sm\" tone=\"muted\">\n Declared in the workspace config, but no backend project exists yet. Provision it from your\n repo:\n </Text>\n <Code className=\"block w-fit max-w-full truncate text-xs\">\n builder init --project {config.slug}\n </Code>\n </Card>\n )\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { STUDIO_PROJECT_ROUTE, studioPath, useNavigate } from '@elytracms/studio/router';
|
|
3
|
-
import { Check, ChevronsUpDown, FolderOpen
|
|
3
|
+
import { Check, ChevronsUpDown, FolderOpen } from 'lucide-react';
|
|
4
4
|
import { hasProjectSession } from '@elytracms/studio/lib/auth';
|
|
5
5
|
import { translate } from '@elytracms/studio/lib/i18n';
|
|
6
6
|
import { Badge, Button, Code, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, Row, Spacer, Stack, Text, } from '@elytracms/studio/ui';
|
|
7
7
|
import { useStudio } from './studio-context';
|
|
8
8
|
import { useSwitcherEntries } from './workspace-projects';
|
|
9
|
+
import { SignInNeededBadge } from './sign-in-needed-badge';
|
|
9
10
|
/**
|
|
10
11
|
* The project switcher (EC-033, reframed by EC-154): with a workspace config
|
|
11
12
|
* the list is config-driven — configured projects ∩ the user's grants, plus
|
|
@@ -33,7 +34,7 @@ function ProjectMenuItem({ project, active, onSelect, }) {
|
|
|
33
34
|
// Per-backend sign-in state (EC-179): the active project is signed-in by
|
|
34
35
|
// definition; others wear a "Sign in" badge when their backend has no session.
|
|
35
36
|
const needsSignIn = !active && !hasProjectSession(project.slug);
|
|
36
|
-
return (_jsx(DropdownMenuItem, { onSelect: onSelect, className: "gap-2", children: _jsxs(Row, { gap: "2", className: "min-w-0 flex-1", children: [_jsx(Text, { size: "sm", className: "truncate", children: project.name }), _jsx(Code, { tone: "muted", className: "shrink-0", children: project.slug }), _jsx(Spacer, {}), needsSignIn ?
|
|
37
|
+
return (_jsx(DropdownMenuItem, { onSelect: onSelect, className: "gap-2", children: _jsxs(Row, { gap: "2", className: "min-w-0 flex-1", children: [_jsx(Text, { size: "sm", className: "truncate", children: project.name }), _jsx(Code, { tone: "muted", className: "shrink-0", children: project.slug }), _jsx(Spacer, {}), needsSignIn ? _jsx(SignInNeededBadge, {}) : null, active ? _jsx(Check, { className: "size-4 text-primary" }) : null] }) }));
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* A configured project with no backend project yet (EC-154): a clear,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-switcher.js","sourceRoot":"","sources":["../../src/components/project-switcher.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACxF,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"project-switcher.js","sourceRoot":"","sources":["../../src/components/project-switcher.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACxF,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EACL,KAAK,EACL,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,GAAG,EACH,MAAM,EACN,KAAK,EACL,IAAI,GACL,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,EAAE,aAAa,EAA8B;IAC3E,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,MAAM,EAAE,OAAO,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAExC,MAAM,aAAa,GAAG,OAAO,CAAA;IAC7B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB;SAC5C,GAA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S,EAAC,yCAAyC,wCAC5C,MAAM,CAAC,IAAI,IAC9B,IACD,GACS,CACpB,CAAA;AACH,CAAC","sourcesContent":["import { STUDIO_PROJECT_ROUTE, studioPath, useNavigate } from '@elytracms/studio/router'\nimport { Check, ChevronsUpDown, FolderOpen } from 'lucide-react'\nimport type { Project, ResolvedWorkspaceProject } from '@elytracms/core/studio-core'\nimport { hasProjectSession } from '@elytracms/studio/lib/auth'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport {\n Badge,\n Button,\n Code,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n Row,\n Spacer,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { useStudio } from './studio-context'\nimport { useSwitcherEntries } from './workspace-projects'\nimport { SignInNeededBadge } from './sign-in-needed-badge'\n\n/**\n * The project switcher (EC-033, reframed by EC-154): with a workspace config\n * the list is config-driven — configured projects ∩ the user's grants, plus\n * explicit \"not provisioned\" states for config entries that have no backend\n * project yet. Without a config it lists the adapter-backed projects exactly\n * as before. Project *creation* lives in code + CLI (`builder init`), not here.\n */\nexport function ProjectSwitcher({ activeProject }: { activeProject: Project }) {\n const studio = useStudio()\n const navigate = useNavigate()\n const { entries } = useSwitcherEntries()\n\n const activeEntries = entries\n const recents = studio.context.recentProjectIds\n .map((id) => studio.getProject(id))\n .filter((p): p is Project => Boolean(p) && p!.id !== activeProject.id)\n .filter((p) =>\n activeEntries.some((entry) => entry.kind === 'project' && entry.project.id === p.id),\n )\n .slice(0, 4)\n\n function open(project: Project) {\n studio.activate(project.id)\n navigate({ to: STUDIO_PROJECT_ROUTE, params: { projectId: project.id, _splat: studioPath.index() } })\n }\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"outline\" size=\"sm\" className=\"h-8 gap-2 px-2.5\">\n <span className=\"grid size-4 place-items-center rounded-[4px] bg-primary text-[0.6rem] font-bold text-primary-foreground\">\n {activeProject.name.charAt(0).toUpperCase()}\n </span>\n <span className=\"max-w-[12rem] truncate font-medium\">{activeProject.name}</span>\n <ChevronsUpDown className=\"size-3.5 text-muted-foreground\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent className=\"w-80\" align=\"start\">\n {recents.length > 0 ? (\n <>\n <DropdownMenuLabel>{translate('shell.projectSwitcher.recent')}</DropdownMenuLabel>\n {recents.map((p) => (\n <ProjectMenuItem key={p.id} project={p} active={false} onSelect={() => open(p)} />\n ))}\n <DropdownMenuSeparator />\n </>\n ) : null}\n <DropdownMenuLabel>{translate('shell.projects')}</DropdownMenuLabel>\n {activeEntries.map((entry) =>\n entry.kind === 'project' ? (\n <ProjectMenuItem\n key={entry.project.id}\n project={entry.project}\n active={entry.project.id === activeProject.id}\n onSelect={() => open(entry.project)}\n />\n ) : (\n <UnprovisionedMenuItem key={`config:${entry.config.slug}`} config={entry.config} />\n ),\n )}\n <DropdownMenuSeparator />\n <DropdownMenuItem onSelect={() => navigate({ to: '/' })}>\n <FolderOpen /> {translate('shell.projectSwitcher.browseAll')}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n\nfunction ProjectMenuItem({\n project,\n active,\n onSelect,\n}: {\n project: Project\n active: boolean\n onSelect: () => void\n}) {\n // Per-backend sign-in state (EC-179): the active project is signed-in by\n // definition; others wear a \"Sign in\" badge when their backend has no session.\n const needsSignIn = !active && !hasProjectSession(project.slug)\n return (\n <DropdownMenuItem onSelect={onSelect} className=\"gap-2\">\n <Row gap=\"2\" className=\"min-w-0 flex-1\">\n <Text size=\"sm\" className=\"truncate\">\n {project.name}\n </Text>\n <Code tone=\"muted\" className=\"shrink-0\">\n {project.slug}\n </Code>\n <Spacer />\n {needsSignIn ? <SignInNeededBadge /> : null}\n {active ? <Check className=\"size-4 text-primary\" /> : null}\n </Row>\n </DropdownMenuItem>\n )\n}\n\n/**\n * A configured project with no backend project yet (EC-154): a clear,\n * non-navigating state pointing at the CLI provisioning flow — never an error.\n */\nfunction UnprovisionedMenuItem({ config }: { config: ResolvedWorkspaceProject }) {\n return (\n <DropdownMenuItem disabled className=\"gap-2 opacity-100\">\n <Stack gap=\"1\" className=\"min-w-0 flex-1 py-0.5\">\n <Row gap=\"2\" className=\"min-w-0\">\n <Text size=\"sm\" tone=\"muted\" className=\"truncate\">\n {config.name}\n </Text>\n <Spacer />\n <Badge variant=\"outline\">{translate('shell.project.notProvisioned')}</Badge>\n </Row>\n <Code tone=\"muted\" className=\"w-fit max-w-full truncate text-[0.7rem]\">\n builder init --project {config.slug}\n </Code>\n </Stack>\n </DropdownMenuItem>\n )\n}\n\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The shared error/loading status gate for a rail module (EC-319/EC-323). The
|
|
4
|
+
* assets, users, and redirects rails each read a list store with the same
|
|
5
|
+
* `{ status, errorMessage, refresh }` shape; this renders the identical error
|
|
6
|
+
* (heading + reason + retry) and loading states, so a module early-returns it
|
|
7
|
+
* instead of re-inlining the same ~28 lines. Returns `null` for a `ready` store.
|
|
8
|
+
*/
|
|
9
|
+
export declare function RailStoreStatus({ store, errorLabel, loadingLabel, errorTestId, }: {
|
|
10
|
+
store: {
|
|
11
|
+
status: 'loading' | 'ready' | 'error';
|
|
12
|
+
errorMessage?: string;
|
|
13
|
+
refresh: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
/** Localized "…failed to load" heading for this rail. */
|
|
16
|
+
errorLabel: string;
|
|
17
|
+
/** Localized "Loading …" text for this rail. */
|
|
18
|
+
loadingLabel: string;
|
|
19
|
+
/** data-testid on the error container (per-rail, for tests). */
|
|
20
|
+
errorTestId: string;
|
|
21
|
+
}): ReactElement | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AlertTriangle, RotateCcw } from 'lucide-react';
|
|
3
|
+
import { Button, Row, Stack, Text } from '@elytracms/studio/ui';
|
|
4
|
+
import { translate } from '@elytracms/studio/lib/i18n';
|
|
5
|
+
/**
|
|
6
|
+
* The shared error/loading status gate for a rail module (EC-319/EC-323). The
|
|
7
|
+
* assets, users, and redirects rails each read a list store with the same
|
|
8
|
+
* `{ status, errorMessage, refresh }` shape; this renders the identical error
|
|
9
|
+
* (heading + reason + retry) and loading states, so a module early-returns it
|
|
10
|
+
* instead of re-inlining the same ~28 lines. Returns `null` for a `ready` store.
|
|
11
|
+
*/
|
|
12
|
+
export function RailStoreStatus({ store, errorLabel, loadingLabel, errorTestId, }) {
|
|
13
|
+
if (store.status === 'error') {
|
|
14
|
+
return (_jsxs(Stack, { gap: "2", className: "p-6", "data-testid": errorTestId, children: [_jsxs(Row, { gap: "2", children: [_jsx(AlertTriangle, { className: "size-4 text-destructive" }), _jsx(Text, { weight: "semibold", children: errorLabel })] }), _jsx(Text, { size: "sm", tone: "muted", children: store.errorMessage ?? translate('common.backendUnreachable') }), _jsx(Row, { children: _jsxs(Button, { variant: "outline", size: "sm", onClick: () => void store.refresh(), children: [_jsx(RotateCcw, {}), " ", translate('common.retry')] }) })] }));
|
|
15
|
+
}
|
|
16
|
+
if (store.status === 'loading') {
|
|
17
|
+
return (_jsx(Stack, { className: "h-full place-items-center p-8", align: "center", justify: "center", children: _jsx(Text, { size: "sm", tone: "muted", children: loadingLabel }) }));
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=rail-store-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rail-store-status.js","sourceRoot":"","sources":["../../src/components/rail-store-status.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,KAAK,EACL,UAAU,EACV,YAAY,EACZ,WAAW,GAaZ;IACC,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAC7B,OAAO,CACL,MAAC,KAAK,IAAC,GAAG,EAAC,GAAG,EAAC,SAAS,EAAC,KAAK,iBAAc,WAAW,aACrD,MAAC,GAAG,IAAC,GAAG,EAAC,GAAG,aACV,KAAC,aAAa,IAAC,SAAS,EAAC,yBAAyB,GAAG,EACrD,KAAC,IAAI,IAAC,MAAM,EAAC,UAAU,YAAE,UAAU,GAAQ,IACvC,EACN,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,YACzB,KAAK,CAAC,YAAY,IAAI,SAAS,CAAC,2BAA2B,CAAC,GACxD,EACP,KAAC,GAAG,cACF,MAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,aACrE,KAAC,SAAS,KAAG,OAAE,SAAS,CAAC,cAAc,CAAC,IACjC,GACL,IACA,CACT,CAAA;IACH,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,CACL,KAAC,KAAK,IAAC,SAAS,EAAC,+BAA+B,EAAC,KAAK,EAAC,QAAQ,EAAC,OAAO,EAAC,QAAQ,YAC9E,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,YACzB,YAAY,GACR,GACD,CACT,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import type { ReactElement } from 'react'\nimport { AlertTriangle, RotateCcw } from 'lucide-react'\nimport { Button, Row, Stack, Text } from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\n\n/**\n * The shared error/loading status gate for a rail module (EC-319/EC-323). The\n * assets, users, and redirects rails each read a list store with the same\n * `{ status, errorMessage, refresh }` shape; this renders the identical error\n * (heading + reason + retry) and loading states, so a module early-returns it\n * instead of re-inlining the same ~28 lines. Returns `null` for a `ready` store.\n */\nexport function RailStoreStatus({\n store,\n errorLabel,\n loadingLabel,\n errorTestId,\n}: {\n store: {\n status: 'loading' | 'ready' | 'error'\n errorMessage?: string\n refresh: () => Promise<void>\n }\n /** Localized \"…failed to load\" heading for this rail. */\n errorLabel: string\n /** Localized \"Loading …\" text for this rail. */\n loadingLabel: string\n /** data-testid on the error container (per-rail, for tests). */\n errorTestId: string\n}): ReactElement | null {\n if (store.status === 'error') {\n return (\n <Stack gap=\"2\" className=\"p-6\" data-testid={errorTestId}>\n <Row gap=\"2\">\n <AlertTriangle className=\"size-4 text-destructive\" />\n <Text weight=\"semibold\">{errorLabel}</Text>\n </Row>\n <Text size=\"sm\" tone=\"muted\">\n {store.errorMessage ?? translate('common.backendUnreachable')}\n </Text>\n <Row>\n <Button variant=\"outline\" size=\"sm\" onClick={() => void store.refresh()}>\n <RotateCcw /> {translate('common.retry')}\n </Button>\n </Row>\n </Stack>\n )\n }\n if (store.status === 'loading') {\n return (\n <Stack className=\"h-full place-items-center p-8\" align=\"center\" justify=\"center\">\n <Text size=\"sm\" tone=\"muted\">\n {loadingLabel}\n </Text>\n </Stack>\n )\n }\n return null\n}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import { AlertTriangle, RotateCcw } from 'lucide-react';
|
|
3
|
-
import { Button, Row, Stack, Text } from '@elytracms/studio/ui';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
2
|
import { translate } from '@elytracms/studio/lib/i18n';
|
|
5
3
|
import { RedirectsProvider, useRedirects } from './redirects-store';
|
|
6
4
|
import { useRedirectsCollectionViewSource } from './redirects-collection-view-source';
|
|
7
5
|
import { CollectionViewProvider } from '../collection-view/collection-view-context';
|
|
6
|
+
import { RailStoreStatus } from '../rail-store-status';
|
|
8
7
|
import { LoadedCollectionTable } from '../cms/collection-table';
|
|
9
8
|
import { PortableDetailEditor } from '../cms/detail-editor';
|
|
10
9
|
/**
|
|
@@ -28,11 +27,8 @@ export function RedirectsModule({ projectId, redirectId = null, schema, }) {
|
|
|
28
27
|
function RedirectsSurface({ projectId, redirectId, schema, }) {
|
|
29
28
|
const store = useRedirects();
|
|
30
29
|
const source = useRedirectsCollectionViewSource(projectId, schema);
|
|
31
|
-
if (store.status
|
|
32
|
-
return (
|
|
33
|
-
}
|
|
34
|
-
if (store.status === 'loading') {
|
|
35
|
-
return (_jsx(Stack, { className: "h-full place-items-center p-8", align: "center", justify: "center", children: _jsx(Text, { size: "sm", tone: "muted", children: translate('redirects.loading') }) }));
|
|
30
|
+
if (store.status !== 'ready') {
|
|
31
|
+
return (_jsx(RailStoreStatus, { store: store, errorLabel: translate('redirects.loadFailed'), loadingLabel: translate('redirects.loading'), errorTestId: "redirects-error" }));
|
|
36
32
|
}
|
|
37
33
|
// One redirect's detail opens in the portable edit shell (AD-19); the list otherwise.
|
|
38
34
|
// The shell mounts its own CollectionViewProvider, so only the list wraps here.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirects-module.js","sourceRoot":"","sources":["../../../src/components/redirects/redirects-module.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"redirects-module.js","sourceRoot":"","sources":["../../../src/components/redirects/redirects-module.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAA;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AACnF,OAAO,EAAE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ytracms/core/cms-core'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { RedirectsProvider, useRedirects } from './redirects-store'\nimport { useRedirectsCollectionViewSource } from './redirects-collection-view-source'\nimport { CollectionViewProvider } from '../collection-view/collection-view-context'\nimport { RailStoreStatus } from '../rail-store-status'\nimport { LoadedCollectionTable } from '../cms/collection-table'\nimport { PortableDetailEditor } from '../cms/detail-editor'\n\n/**\n * The studio Redirects module (EC-303). Editorial redirects as data — the reuse\n * proof (with the users rail) that the portable interaction surfaces serve any\n * rail: it renders the SAME `LoadedCollectionTable` for the list and the SAME\n * `DetailEditor` body (via {@link PortableDetailEditor}) for one redirect, over a\n * redirects {@link useRedirectsCollectionViewSource}. The redirects capability\n * profile (content-gated, create + remove, no publish/versions/locales) drives\n * which regions appear; the edit shell's explicit-save path (no publish) makes a\n * saved+enabled redirect live.\n *\n * `redirectId === null` is the list; a `redirectId` opens that redirect's detail\n * (routed via `studioPath.redirect`). No admin gate — redirects are content, so\n * viewers read and editors write (enforced at the chokepoint + Convex boundary).\n */\nexport function RedirectsModule({\n projectId,\n redirectId = null,\n schema,\n}: {\n projectId: string\n redirectId?: string | null\n /** EC-311: a mount-customized redirects def (built-in fields overridden by name). */\n schema?: CollectionDef\n}) {\n return (\n <RedirectsProvider projectId={projectId}>\n <RedirectsSurface projectId={projectId} redirectId={redirectId} schema={schema} />\n </RedirectsProvider>\n )\n}\n\n/** The loaded surface: the portable list (or one redirect's detail) over the source. */\nfunction RedirectsSurface({\n projectId,\n redirectId,\n schema,\n}: {\n projectId: string\n redirectId: string | null\n schema?: CollectionDef\n}) {\n const store = useRedirects()\n const source = useRedirectsCollectionViewSource(projectId, schema)\n\n if (store.status !== 'ready') {\n return (\n <RailStoreStatus\n store={store}\n errorLabel={translate('redirects.loadFailed')}\n loadingLabel={translate('redirects.loading')}\n errorTestId=\"redirects-error\"\n />\n )\n }\n\n // One redirect's detail opens in the portable edit shell (AD-19); the list otherwise.\n // The shell mounts its own CollectionViewProvider, so only the list wraps here.\n if (redirectId !== null) {\n return <PortableDetailEditor source={source} projectId={projectId} documentId={redirectId} />\n }\n\n return (\n <CollectionViewProvider source={source}>\n <LoadedCollectionTable projectId={projectId} />\n </CollectionViewProvider>\n )\n}\n"]}
|