@btst/plugin-cms 0.0.0-stage → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +17 -0
- package/dist/api/getters.cjs +328 -0
- package/dist/api/getters.mjs +314 -0
- package/dist/api/index.cjs +29 -0
- package/dist/api/index.d.cts +209 -0
- package/dist/api/index.d.mts +209 -0
- package/dist/api/index.d.ts +209 -0
- package/dist/api/index.mjs +7 -0
- package/dist/api/lifecycle-migrations.cjs +13 -0
- package/dist/api/lifecycle-migrations.mjs +11 -0
- package/dist/api/mutations.cjs +59 -0
- package/dist/api/mutations.mjs +57 -0
- package/dist/api/operations.cjs +1769 -0
- package/dist/api/operations.mjs +1762 -0
- package/dist/api/plugin.cjs +337 -0
- package/dist/api/plugin.mjs +331 -0
- package/dist/api/query-key-defs.cjs +44 -0
- package/dist/api/query-key-defs.mjs +39 -0
- package/dist/api/relations.cjs +76 -0
- package/dist/api/relations.mjs +70 -0
- package/dist/client/components/forms/content-form.cjs +286 -0
- package/dist/client/components/forms/content-form.mjs +284 -0
- package/dist/client/components/forms/file-upload.cjs +160 -0
- package/dist/client/components/forms/file-upload.mjs +158 -0
- package/dist/client/components/forms/relation-field.cjs +237 -0
- package/dist/client/components/forms/relation-field.mjs +235 -0
- package/dist/client/components/index.cjs +14 -0
- package/dist/client/components/index.d.cts +20 -0
- package/dist/client/components/index.d.mts +20 -0
- package/dist/client/components/index.d.ts +20 -0
- package/dist/client/components/index.mjs +10 -0
- package/dist/client/components/inverse-relations-panel.cjs +272 -0
- package/dist/client/components/inverse-relations-panel.mjs +270 -0
- package/dist/client/components/loading/dashboard-skeleton.cjs +18 -0
- package/dist/client/components/loading/dashboard-skeleton.mjs +16 -0
- package/dist/client/components/loading/editor-skeleton.cjs +32 -0
- package/dist/client/components/loading/editor-skeleton.mjs +30 -0
- package/dist/client/components/loading/list-skeleton.cjs +32 -0
- package/dist/client/components/loading/list-skeleton.mjs +30 -0
- package/dist/client/components/pages/404-page.cjs +26 -0
- package/dist/client/components/pages/404-page.mjs +24 -0
- package/dist/client/components/pages/content-editor-page.cjs +84 -0
- package/dist/client/components/pages/content-editor-page.internal.cjs +170 -0
- package/dist/client/components/pages/content-editor-page.internal.mjs +168 -0
- package/dist/client/components/pages/content-editor-page.mjs +82 -0
- package/dist/client/components/pages/content-list-page.cjs +49 -0
- package/dist/client/components/pages/content-list-page.internal.cjs +334 -0
- package/dist/client/components/pages/content-list-page.internal.mjs +332 -0
- package/dist/client/components/pages/content-list-page.mjs +47 -0
- package/dist/client/components/pages/dashboard-page.cjs +42 -0
- package/dist/client/components/pages/dashboard-page.internal.cjs +102 -0
- package/dist/client/components/pages/dashboard-page.internal.mjs +100 -0
- package/dist/client/components/pages/dashboard-page.mjs +40 -0
- package/dist/client/components/shared/default-error.cjs +17 -0
- package/dist/client/components/shared/default-error.mjs +15 -0
- package/dist/client/components/shared/empty-state.cjs +16 -0
- package/dist/client/components/shared/empty-state.mjs +14 -0
- package/dist/client/components/shared/page-wrapper.cjs +29 -0
- package/dist/client/components/shared/page-wrapper.mjs +27 -0
- package/dist/client/constants.cjs +5 -0
- package/dist/client/constants.mjs +3 -0
- package/dist/client/hooks/cms-hooks.cjs +300 -0
- package/dist/client/hooks/cms-hooks.mjs +280 -0
- package/dist/client/hooks/cms-resource.cjs +13 -0
- package/dist/client/hooks/cms-resource.mjs +11 -0
- package/dist/client/hooks/index.cjs +25 -0
- package/dist/client/hooks/index.d.cts +693 -0
- package/dist/client/hooks/index.d.mts +693 -0
- package/dist/client/hooks/index.d.ts +693 -0
- package/dist/client/hooks/index.mjs +1 -0
- package/dist/client/index.cjs +15 -0
- package/dist/client/index.d.cts +654 -0
- package/dist/client/index.d.mts +654 -0
- package/dist/client/index.d.ts +654 -0
- package/dist/client/index.mjs +3 -0
- package/dist/client/overrides.cjs +26 -0
- package/dist/client/overrides.mjs +24 -0
- package/dist/client/plugin.cjs +316 -0
- package/dist/client/plugin.mjs +314 -0
- package/dist/client.css +3 -0
- package/dist/db.cjs +118 -0
- package/dist/db.mjs +116 -0
- package/dist/permissions.cjs +46 -0
- package/dist/permissions.d.cts +42 -0
- package/dist/permissions.d.mts +42 -0
- package/dist/permissions.d.ts +42 -0
- package/dist/permissions.mjs +44 -0
- package/dist/query-keys.cjs +229 -0
- package/dist/query-keys.d.cts +8 -0
- package/dist/query-keys.d.mts +8 -0
- package/dist/query-keys.d.ts +8 -0
- package/dist/query-keys.mjs +225 -0
- package/dist/schemas.cjs +81 -0
- package/dist/schemas.mjs +72 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.cts +6 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.mts +6 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.ts +6 -0
- package/dist/shared/plugin-cms.Bptwe33B.d.cts +1749 -0
- package/dist/shared/plugin-cms.Csx7tNDO.d.mts +1749 -0
- package/dist/shared/plugin-cms.eNW9_FO5.d.ts +1749 -0
- package/dist/style.css +6 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +406 -0
- package/dist/types.d.mts +406 -0
- package/dist/types.d.ts +406 -0
- package/dist/types.mjs +1 -0
- package/dist/ui/src/components/accordion.cjs +81 -0
- package/dist/ui/src/components/accordion.mjs +62 -0
- package/dist/ui/src/components/alert-dialog.cjs +157 -0
- package/dist/ui/src/components/alert-dialog.mjs +132 -0
- package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
- package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
- package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
- package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
- package/dist/ui/src/components/auto-form/config.cjs +40 -0
- package/dist/ui/src/components/auto-form/config.mjs +37 -0
- package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
- package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
- package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
- package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
- package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
- package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
- package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
- package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
- package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
- package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
- package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
- package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
- package/dist/ui/src/components/auto-form/index.cjs +92 -0
- package/dist/ui/src/components/auto-form/index.mjs +86 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
- package/dist/ui/src/components/auto-form/types.cjs +11 -0
- package/dist/ui/src/components/auto-form/types.mjs +9 -0
- package/dist/ui/src/components/badge.cjs +42 -0
- package/dist/ui/src/components/badge.mjs +39 -0
- package/dist/ui/src/components/button.cjs +56 -0
- package/dist/ui/src/components/button.mjs +53 -0
- package/dist/ui/src/components/calendar.cjs +207 -0
- package/dist/ui/src/components/calendar.mjs +190 -0
- package/dist/ui/src/components/card.cjs +56 -0
- package/dist/ui/src/components/card.mjs +51 -0
- package/dist/ui/src/components/checkbox.cjs +48 -0
- package/dist/ui/src/components/checkbox.mjs +32 -0
- package/dist/ui/src/components/command.cjs +78 -0
- package/dist/ui/src/components/command.mjs +73 -0
- package/dist/ui/src/components/date-picker.cjs +41 -0
- package/dist/ui/src/components/date-picker.mjs +39 -0
- package/dist/ui/src/components/dialog.cjs +119 -0
- package/dist/ui/src/components/dialog.mjs +97 -0
- package/dist/ui/src/components/form.cjs +120 -0
- package/dist/ui/src/components/form.mjs +98 -0
- package/dist/ui/src/components/input.cjs +23 -0
- package/dist/ui/src/components/input.mjs +21 -0
- package/dist/ui/src/components/label.cjs +39 -0
- package/dist/ui/src/components/label.mjs +23 -0
- package/dist/ui/src/components/multi-select.cjs +555 -0
- package/dist/ui/src/components/multi-select.mjs +540 -0
- package/dist/ui/src/components/page-layout.cjs +25 -0
- package/dist/ui/src/components/page-layout.mjs +23 -0
- package/dist/ui/src/components/page-wrapper.cjs +20 -0
- package/dist/ui/src/components/page-wrapper.mjs +18 -0
- package/dist/ui/src/components/popover.cjs +60 -0
- package/dist/ui/src/components/popover.mjs +42 -0
- package/dist/ui/src/components/radio-group.cjs +62 -0
- package/dist/ui/src/components/radio-group.mjs +45 -0
- package/dist/ui/src/components/select.cjs +161 -0
- package/dist/ui/src/components/select.mjs +139 -0
- package/dist/ui/src/components/separator.cjs +43 -0
- package/dist/ui/src/components/separator.mjs +27 -0
- package/dist/ui/src/components/skeleton.cjs +17 -0
- package/dist/ui/src/components/skeleton.mjs +15 -0
- package/dist/ui/src/components/stack-attribution.cjs +24 -0
- package/dist/ui/src/components/stack-attribution.mjs +22 -0
- package/dist/ui/src/components/switch.cjs +48 -0
- package/dist/ui/src/components/switch.mjs +32 -0
- package/dist/ui/src/components/table.cjs +89 -0
- package/dist/ui/src/components/table.mjs +82 -0
- package/dist/ui/src/components/textarea.cjs +20 -0
- package/dist/ui/src/components/textarea.mjs +18 -0
- package/dist/ui/src/hooks/use-debounce.cjs +16 -0
- package/dist/ui/src/hooks/use-debounce.mjs +14 -0
- package/dist/ui/src/hooks/use-route-lifecycle.cjs +31 -0
- package/dist/ui/src/hooks/use-route-lifecycle.mjs +29 -0
- package/dist/ui/src/lib/schema-converter.cjs +133 -0
- package/dist/ui/src/lib/schema-converter.mjs +127 -0
- package/dist/ui/src/lib/utils.cjs +10 -0
- package/dist/ui/src/lib/utils.mjs +8 -0
- package/dist/utils.cjs +19 -0
- package/dist/utils.mjs +12 -0
- package/package.json +170 -3
- package/README.md +0 -3
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { lazy } from 'react';
|
|
4
|
+
import { usePluginOverrides } from '@btst/stack/context';
|
|
5
|
+
import { CMS_PLUGIN_ID } from '../../constants.mjs';
|
|
6
|
+
import { ComposedRoute } from '@btst/stack/client/components';
|
|
7
|
+
import { DefaultError } from '../shared/default-error.mjs';
|
|
8
|
+
import { NotFoundPage } from './404-page.mjs';
|
|
9
|
+
import { cmsPermissions } from '../../../permissions.mjs';
|
|
10
|
+
import { ListSkeleton } from '../loading/list-skeleton.mjs';
|
|
11
|
+
|
|
12
|
+
const ContentListPageInternal = lazy(
|
|
13
|
+
() => import('./content-list-page.internal.mjs').then((m) => ({
|
|
14
|
+
default: m.ContentListPage
|
|
15
|
+
}))
|
|
16
|
+
);
|
|
17
|
+
function ContentListPageComponent({
|
|
18
|
+
typeSlug
|
|
19
|
+
}) {
|
|
20
|
+
const { onRouteError } = usePluginOverrides(CMS_PLUGIN_ID);
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
ComposedRoute,
|
|
23
|
+
{
|
|
24
|
+
path: `/cms/${typeSlug}`,
|
|
25
|
+
permission: cmsPermissions.record.read({
|
|
26
|
+
contentType: typeSlug,
|
|
27
|
+
scope: "collection"
|
|
28
|
+
}),
|
|
29
|
+
PageComponent: ContentListPageInternal,
|
|
30
|
+
ErrorComponent: DefaultError,
|
|
31
|
+
LoadingComponent: ListSkeleton,
|
|
32
|
+
NotFoundComponent: NotFoundPage,
|
|
33
|
+
props: { typeSlug },
|
|
34
|
+
onError: (error) => {
|
|
35
|
+
if (onRouteError) {
|
|
36
|
+
onRouteError("contentList", error, {
|
|
37
|
+
path: `/cms/${typeSlug}`,
|
|
38
|
+
params: { typeSlug },
|
|
39
|
+
isSSR: typeof window === "undefined"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { ContentListPageComponent };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const React = require('react');
|
|
6
|
+
const context = require('@btst/stack/context');
|
|
7
|
+
const constants = require('../../constants.cjs');
|
|
8
|
+
const components = require('@btst/stack/client/components');
|
|
9
|
+
const defaultError = require('../shared/default-error.cjs');
|
|
10
|
+
const _404Page = require('./404-page.cjs');
|
|
11
|
+
const permissions = require('../../../permissions.cjs');
|
|
12
|
+
const dashboardSkeleton = require('../loading/dashboard-skeleton.cjs');
|
|
13
|
+
|
|
14
|
+
const DashboardPageInternal = React.lazy(
|
|
15
|
+
() => import('./dashboard-page.internal.cjs').then((m) => ({
|
|
16
|
+
default: m.DashboardPage
|
|
17
|
+
}))
|
|
18
|
+
);
|
|
19
|
+
function DashboardPageComponent() {
|
|
20
|
+
const { onRouteError } = context.usePluginOverrides(constants.CMS_PLUGIN_ID);
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
22
|
+
components.ComposedRoute,
|
|
23
|
+
{
|
|
24
|
+
path: "/cms",
|
|
25
|
+
permission: permissions.cmsPermissions.contentType.read({}),
|
|
26
|
+
PageComponent: DashboardPageInternal,
|
|
27
|
+
ErrorComponent: defaultError.DefaultError,
|
|
28
|
+
LoadingComponent: dashboardSkeleton.DashboardSkeleton,
|
|
29
|
+
NotFoundComponent: _404Page.NotFoundPage,
|
|
30
|
+
onError: (error) => {
|
|
31
|
+
if (onRouteError) {
|
|
32
|
+
onRouteError("dashboard", error, {
|
|
33
|
+
path: "/cms",
|
|
34
|
+
isSSR: typeof window === "undefined"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.DashboardPageComponent = DashboardPageComponent;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const lucideReact = require('lucide-react');
|
|
6
|
+
const card = require('../../../ui/src/components/card.cjs');
|
|
7
|
+
const context = require('@btst/stack/context');
|
|
8
|
+
const overrides = require('../../overrides.cjs');
|
|
9
|
+
const constants = require('../../constants.cjs');
|
|
10
|
+
const emptyState = require('../shared/empty-state.cjs');
|
|
11
|
+
const pageWrapper = require('../shared/page-wrapper.cjs');
|
|
12
|
+
const useRouteLifecycle = require('../../../ui/src/hooks/use-route-lifecycle.cjs');
|
|
13
|
+
const utils = require('../../../utils.cjs');
|
|
14
|
+
const cmsHooks = require('../../hooks/cms-hooks.cjs');
|
|
15
|
+
|
|
16
|
+
function DashboardPage() {
|
|
17
|
+
const t = context.useTranslate();
|
|
18
|
+
const overrides$1 = context.usePluginOverrides(constants.CMS_PLUGIN_ID);
|
|
19
|
+
const { localization, classNames } = overrides$1;
|
|
20
|
+
const { router, plugins, basePath: stackBasePath } = context.useStack();
|
|
21
|
+
const navigate = router?.navigate;
|
|
22
|
+
const basePath = plugins?.[constants.CMS_PLUGIN_ID]?.site.basePath ?? stackBasePath;
|
|
23
|
+
useRouteLifecycle.useRouteLifecycle({
|
|
24
|
+
routeName: "dashboard",
|
|
25
|
+
context: {
|
|
26
|
+
path: "/cms",
|
|
27
|
+
isSSR: typeof window === "undefined"
|
|
28
|
+
},
|
|
29
|
+
overrides: overrides$1
|
|
30
|
+
});
|
|
31
|
+
const { contentTypes: serverContentTypes } = cmsHooks.useSuspenseContentTypes();
|
|
32
|
+
const contentTypes = overrides.orderCMSContentTypes(
|
|
33
|
+
serverContentTypes,
|
|
34
|
+
plugins?.[constants.CMS_PLUGIN_ID]?.config
|
|
35
|
+
);
|
|
36
|
+
const title = localization?.CMS_DASHBOARD_TITLE ?? t("cms.dashboard.title", "Content");
|
|
37
|
+
const subtitle = localization?.CMS_DASHBOARD_SUBTITLE ?? t("cms.dashboard.subtitle", "Manage your content types");
|
|
38
|
+
if (contentTypes.length === 0) {
|
|
39
|
+
return /* @__PURE__ */ jsxRuntime.jsx(pageWrapper.PageWrapper, { testId: "cms-dashboard-page", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full max-w-5xl space-y-6", children: [
|
|
40
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
41
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-2xl font-bold tracking-tight", children: title }),
|
|
42
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: subtitle })
|
|
43
|
+
] }),
|
|
44
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
45
|
+
emptyState.EmptyState,
|
|
46
|
+
{
|
|
47
|
+
title: localization?.CMS_DASHBOARD_NO_TYPES ?? t("cms.dashboard.noTypes", "No content types configured"),
|
|
48
|
+
description: localization?.CMS_DASHBOARD_NO_TYPES_DESCRIPTION ?? t(
|
|
49
|
+
"cms.dashboard.noTypesDescription",
|
|
50
|
+
"Add content types to your CMS configuration to get started."
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
] }) });
|
|
55
|
+
}
|
|
56
|
+
const formatItemCount = (count) => {
|
|
57
|
+
if (count === 0)
|
|
58
|
+
return localization?.CMS_DASHBOARD_ITEMS_COUNT_ZERO ?? t("cms.dashboard.itemsCountZero", "No items");
|
|
59
|
+
if (count === 1)
|
|
60
|
+
return localization?.CMS_DASHBOARD_ITEMS_COUNT_ONE ?? t("cms.dashboard.itemsCountOne", "1 item");
|
|
61
|
+
return (localization?.CMS_DASHBOARD_ITEMS_COUNT ?? t("cms.dashboard.itemsCount", "{count} items")).replace("{count}", String(count));
|
|
62
|
+
};
|
|
63
|
+
return /* @__PURE__ */ jsxRuntime.jsx(pageWrapper.PageWrapper, { testId: "cms-dashboard-page", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full max-w-5xl space-y-6", children: [
|
|
64
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-2xl font-bold tracking-tight", children: title }),
|
|
66
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: subtitle })
|
|
67
|
+
] }),
|
|
68
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3", children: contentTypes.map((ct) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
69
|
+
card.Card,
|
|
70
|
+
{
|
|
71
|
+
className: utils.cn(
|
|
72
|
+
"hover:border-primary/50 transition-colors cursor-pointer",
|
|
73
|
+
classNames?.contentTypeCard
|
|
74
|
+
),
|
|
75
|
+
onClick: () => void navigate?.(context.joinBasePath(basePath, `/cms/${ct.slug}`)),
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsxs(card.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
78
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
79
|
+
card.CardTitle,
|
|
80
|
+
{
|
|
81
|
+
className: utils.cn(
|
|
82
|
+
"text-lg font-medium",
|
|
83
|
+
classNames?.contentTypeTitle
|
|
84
|
+
),
|
|
85
|
+
children: ct.name
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "h-5 w-5 text-muted-foreground" })
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ jsxRuntime.jsxs(card.CardContent, { children: [
|
|
91
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-2xl font-bold", children: ct.itemCount }),
|
|
92
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: formatItemCount(ct.itemCount) }),
|
|
93
|
+
ct.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mt-2 line-clamp-2", children: ct.description })
|
|
94
|
+
] })
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
ct.id
|
|
98
|
+
)) })
|
|
99
|
+
] }) });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
exports.DashboardPage = DashboardPage;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { FileText } from 'lucide-react';
|
|
4
|
+
import { Card, CardHeader, CardTitle, CardContent } from '../../../ui/src/components/card.mjs';
|
|
5
|
+
import { useTranslate, usePluginOverrides, useStack, joinBasePath } from '@btst/stack/context';
|
|
6
|
+
import { orderCMSContentTypes } from '../../overrides.mjs';
|
|
7
|
+
import { CMS_PLUGIN_ID } from '../../constants.mjs';
|
|
8
|
+
import { EmptyState } from '../shared/empty-state.mjs';
|
|
9
|
+
import { PageWrapper } from '../shared/page-wrapper.mjs';
|
|
10
|
+
import { useRouteLifecycle } from '../../../ui/src/hooks/use-route-lifecycle.mjs';
|
|
11
|
+
import { cn } from '../../../utils.mjs';
|
|
12
|
+
import { useSuspenseContentTypes } from '../../hooks/cms-hooks.mjs';
|
|
13
|
+
|
|
14
|
+
function DashboardPage() {
|
|
15
|
+
const t = useTranslate();
|
|
16
|
+
const overrides = usePluginOverrides(CMS_PLUGIN_ID);
|
|
17
|
+
const { localization, classNames } = overrides;
|
|
18
|
+
const { router, plugins, basePath: stackBasePath } = useStack();
|
|
19
|
+
const navigate = router?.navigate;
|
|
20
|
+
const basePath = plugins?.[CMS_PLUGIN_ID]?.site.basePath ?? stackBasePath;
|
|
21
|
+
useRouteLifecycle({
|
|
22
|
+
routeName: "dashboard",
|
|
23
|
+
context: {
|
|
24
|
+
path: "/cms",
|
|
25
|
+
isSSR: typeof window === "undefined"
|
|
26
|
+
},
|
|
27
|
+
overrides
|
|
28
|
+
});
|
|
29
|
+
const { contentTypes: serverContentTypes } = useSuspenseContentTypes();
|
|
30
|
+
const contentTypes = orderCMSContentTypes(
|
|
31
|
+
serverContentTypes,
|
|
32
|
+
plugins?.[CMS_PLUGIN_ID]?.config
|
|
33
|
+
);
|
|
34
|
+
const title = localization?.CMS_DASHBOARD_TITLE ?? t("cms.dashboard.title", "Content");
|
|
35
|
+
const subtitle = localization?.CMS_DASHBOARD_SUBTITLE ?? t("cms.dashboard.subtitle", "Manage your content types");
|
|
36
|
+
if (contentTypes.length === 0) {
|
|
37
|
+
return /* @__PURE__ */ jsx(PageWrapper, { testId: "cms-dashboard-page", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-5xl space-y-6", children: [
|
|
38
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
39
|
+
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold tracking-tight", children: title }),
|
|
40
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: subtitle })
|
|
41
|
+
] }),
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
EmptyState,
|
|
44
|
+
{
|
|
45
|
+
title: localization?.CMS_DASHBOARD_NO_TYPES ?? t("cms.dashboard.noTypes", "No content types configured"),
|
|
46
|
+
description: localization?.CMS_DASHBOARD_NO_TYPES_DESCRIPTION ?? t(
|
|
47
|
+
"cms.dashboard.noTypesDescription",
|
|
48
|
+
"Add content types to your CMS configuration to get started."
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
] }) });
|
|
53
|
+
}
|
|
54
|
+
const formatItemCount = (count) => {
|
|
55
|
+
if (count === 0)
|
|
56
|
+
return localization?.CMS_DASHBOARD_ITEMS_COUNT_ZERO ?? t("cms.dashboard.itemsCountZero", "No items");
|
|
57
|
+
if (count === 1)
|
|
58
|
+
return localization?.CMS_DASHBOARD_ITEMS_COUNT_ONE ?? t("cms.dashboard.itemsCountOne", "1 item");
|
|
59
|
+
return (localization?.CMS_DASHBOARD_ITEMS_COUNT ?? t("cms.dashboard.itemsCount", "{count} items")).replace("{count}", String(count));
|
|
60
|
+
};
|
|
61
|
+
return /* @__PURE__ */ jsx(PageWrapper, { testId: "cms-dashboard-page", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-5xl space-y-6", children: [
|
|
62
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
63
|
+
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold tracking-tight", children: title }),
|
|
64
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: subtitle })
|
|
65
|
+
] }),
|
|
66
|
+
/* @__PURE__ */ jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3", children: contentTypes.map((ct) => /* @__PURE__ */ jsxs(
|
|
67
|
+
Card,
|
|
68
|
+
{
|
|
69
|
+
className: cn(
|
|
70
|
+
"hover:border-primary/50 transition-colors cursor-pointer",
|
|
71
|
+
classNames?.contentTypeCard
|
|
72
|
+
),
|
|
73
|
+
onClick: () => void navigate?.(joinBasePath(basePath, `/cms/${ct.slug}`)),
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsxs(CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
76
|
+
/* @__PURE__ */ jsx(
|
|
77
|
+
CardTitle,
|
|
78
|
+
{
|
|
79
|
+
className: cn(
|
|
80
|
+
"text-lg font-medium",
|
|
81
|
+
classNames?.contentTypeTitle
|
|
82
|
+
),
|
|
83
|
+
children: ct.name
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsx(FileText, { className: "h-5 w-5 text-muted-foreground" })
|
|
87
|
+
] }),
|
|
88
|
+
/* @__PURE__ */ jsxs(CardContent, { children: [
|
|
89
|
+
/* @__PURE__ */ jsx("div", { className: "text-2xl font-bold", children: ct.itemCount }),
|
|
90
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: formatItemCount(ct.itemCount) }),
|
|
91
|
+
ct.description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mt-2 line-clamp-2", children: ct.description })
|
|
92
|
+
] })
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
ct.id
|
|
96
|
+
)) })
|
|
97
|
+
] }) });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { DashboardPage };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { lazy } from 'react';
|
|
4
|
+
import { usePluginOverrides } from '@btst/stack/context';
|
|
5
|
+
import { CMS_PLUGIN_ID } from '../../constants.mjs';
|
|
6
|
+
import { ComposedRoute } from '@btst/stack/client/components';
|
|
7
|
+
import { DefaultError } from '../shared/default-error.mjs';
|
|
8
|
+
import { NotFoundPage } from './404-page.mjs';
|
|
9
|
+
import { cmsPermissions } from '../../../permissions.mjs';
|
|
10
|
+
import { DashboardSkeleton } from '../loading/dashboard-skeleton.mjs';
|
|
11
|
+
|
|
12
|
+
const DashboardPageInternal = lazy(
|
|
13
|
+
() => import('./dashboard-page.internal.mjs').then((m) => ({
|
|
14
|
+
default: m.DashboardPage
|
|
15
|
+
}))
|
|
16
|
+
);
|
|
17
|
+
function DashboardPageComponent() {
|
|
18
|
+
const { onRouteError } = usePluginOverrides(CMS_PLUGIN_ID);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
ComposedRoute,
|
|
21
|
+
{
|
|
22
|
+
path: "/cms",
|
|
23
|
+
permission: cmsPermissions.contentType.read({}),
|
|
24
|
+
PageComponent: DashboardPageInternal,
|
|
25
|
+
ErrorComponent: DefaultError,
|
|
26
|
+
LoadingComponent: DashboardSkeleton,
|
|
27
|
+
NotFoundComponent: NotFoundPage,
|
|
28
|
+
onError: (error) => {
|
|
29
|
+
if (onRouteError) {
|
|
30
|
+
onRouteError("dashboard", error, {
|
|
31
|
+
path: "/cms",
|
|
32
|
+
isSSR: typeof window === "undefined"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { DashboardPageComponent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const lucideReact = require('lucide-react');
|
|
6
|
+
const button = require('../../../ui/src/components/button.cjs');
|
|
7
|
+
|
|
8
|
+
function DefaultError({ error, resetErrorBoundary }) {
|
|
9
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center", children: [
|
|
10
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-full bg-destructive/10 p-4 mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-8 w-8 text-destructive" }) }),
|
|
11
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-medium text-foreground mb-2", children: "Something went wrong" }),
|
|
12
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mb-4 max-w-sm", children: (error instanceof Error ? error.message : void 0) || "An unexpected error occurred" }),
|
|
13
|
+
resetErrorBoundary && /* @__PURE__ */ jsxRuntime.jsx(button.Button, { variant: "outline", onClick: resetErrorBoundary, children: "Try again" })
|
|
14
|
+
] });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.DefaultError = DefaultError;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { AlertCircle } from 'lucide-react';
|
|
4
|
+
import { Button } from '../../../ui/src/components/button.mjs';
|
|
5
|
+
|
|
6
|
+
function DefaultError({ error, resetErrorBoundary }) {
|
|
7
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center", children: [
|
|
8
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-full bg-destructive/10 p-4 mb-4", children: /* @__PURE__ */ jsx(AlertCircle, { className: "h-8 w-8 text-destructive" }) }),
|
|
9
|
+
/* @__PURE__ */ jsx("h3", { className: "text-lg font-medium text-foreground mb-2", children: "Something went wrong" }),
|
|
10
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-4 max-w-sm", children: (error instanceof Error ? error.message : void 0) || "An unexpected error occurred" }),
|
|
11
|
+
resetErrorBoundary && /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: resetErrorBoundary, children: "Try again" })
|
|
12
|
+
] });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { DefaultError };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const lucideReact = require('lucide-react');
|
|
6
|
+
|
|
7
|
+
function EmptyState({ title, description, action }) {
|
|
8
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center", children: [
|
|
9
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-full bg-muted p-4 mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Inbox, { className: "h-8 w-8 text-muted-foreground" }) }),
|
|
10
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-medium text-foreground mb-2", children: title }),
|
|
11
|
+
description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mb-4 max-w-sm", children: description }),
|
|
12
|
+
action
|
|
13
|
+
] });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.EmptyState = EmptyState;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Inbox } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
function EmptyState({ title, description, action }) {
|
|
6
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center", children: [
|
|
7
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-full bg-muted p-4 mb-4", children: /* @__PURE__ */ jsx(Inbox, { className: "h-8 w-8 text-muted-foreground" }) }),
|
|
8
|
+
/* @__PURE__ */ jsx("h3", { className: "text-lg font-medium text-foreground mb-2", children: title }),
|
|
9
|
+
description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-4 max-w-sm", children: description }),
|
|
10
|
+
action
|
|
11
|
+
] });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { EmptyState };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const context = require('@btst/stack/context');
|
|
6
|
+
const pageWrapper = require('../../../ui/src/components/page-wrapper.cjs');
|
|
7
|
+
const constants = require('../../constants.cjs');
|
|
8
|
+
const utils = require('../../../utils.cjs');
|
|
9
|
+
|
|
10
|
+
function PageWrapper({
|
|
11
|
+
children,
|
|
12
|
+
className,
|
|
13
|
+
testId
|
|
14
|
+
}) {
|
|
15
|
+
const { showAttribution, classNames } = context.usePluginOverrides(constants.CMS_PLUGIN_ID, {
|
|
16
|
+
showAttribution: true
|
|
17
|
+
});
|
|
18
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
19
|
+
pageWrapper.PageWrapper,
|
|
20
|
+
{
|
|
21
|
+
className: utils.cn(className, classNames?.container),
|
|
22
|
+
testId,
|
|
23
|
+
showAttribution,
|
|
24
|
+
children
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.PageWrapper = PageWrapper;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { usePluginOverrides } from '@btst/stack/context';
|
|
4
|
+
import { PageWrapper as PageWrapper$1 } from '../../../ui/src/components/page-wrapper.mjs';
|
|
5
|
+
import { CMS_PLUGIN_ID } from '../../constants.mjs';
|
|
6
|
+
import { cn } from '../../../utils.mjs';
|
|
7
|
+
|
|
8
|
+
function PageWrapper({
|
|
9
|
+
children,
|
|
10
|
+
className,
|
|
11
|
+
testId
|
|
12
|
+
}) {
|
|
13
|
+
const { showAttribution, classNames } = usePluginOverrides(CMS_PLUGIN_ID, {
|
|
14
|
+
showAttribution: true
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
PageWrapper$1,
|
|
18
|
+
{
|
|
19
|
+
className: cn(className, classNames?.container),
|
|
20
|
+
testId,
|
|
21
|
+
showAttribution,
|
|
22
|
+
children
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { PageWrapper };
|