@contember/create 2.1.0-alpha.8 → 2.1.0-alpha.9
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/dist/development/src/commands/WorkspaceCreateCommand.cjs +36 -23
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js +36 -23
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +4 -6
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js +4 -6
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/development/src/lib/packageManagerDetector.cjs +22 -0
- package/dist/development/src/lib/packageManagerDetector.cjs.map +1 -0
- package/dist/development/src/lib/packageManagerDetector.js +22 -0
- package/dist/development/src/lib/packageManagerDetector.js.map +1 -0
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs +36 -23
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js +36 -23
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +4 -6
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js +4 -6
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/src/lib/packageManagerDetector.cjs +22 -0
- package/dist/production/src/lib/packageManagerDetector.cjs.map +1 -0
- package/dist/production/src/lib/packageManagerDetector.js +22 -0
- package/dist/production/src/lib/packageManagerDetector.js.map +1 -0
- package/dist/types/commands/WorkspaceCreateCommand.d.ts +4 -2
- package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/lib/packageManagerDetector.d.ts +3 -0
- package/dist/types/lib/packageManagerDetector.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/resources/templates/default/.gitignore.dist +154 -0
- package/resources/templates/default/README.md +98 -0
- package/resources/templates/{template-workspace → default}/admin/.env.development +1 -0
- package/resources/templates/{template-workspace → default}/admin/app/components/layout.tsx +7 -3
- package/resources/templates/default/admin/app/components/navigation.tsx +85 -0
- package/resources/templates/{template-workspace → default}/admin/app/index.tsx +4 -4
- package/resources/templates/default/admin/app/pages/tenant.tsx +160 -0
- package/resources/templates/default/admin/entrypoint/components/layout.tsx +14 -0
- package/resources/templates/default/admin/entrypoint/components/logged-in.tsx +47 -0
- package/resources/templates/default/admin/entrypoint/components/login.tsx +103 -0
- package/resources/templates/default/admin/entrypoint/config.ts +35 -0
- package/resources/templates/default/admin/entrypoint/contexts/login.tsx +18 -0
- package/resources/templates/default/admin/entrypoint/index.tsx +12 -0
- package/resources/templates/default/admin/entrypoint/login-entrypoint.tsx +24 -0
- package/resources/templates/default/admin/entrypoint/pages/index.tsx +48 -0
- package/resources/templates/default/admin/entrypoint/pages/magicLink.tsx +56 -0
- package/resources/templates/default/admin/entrypoint/pages/magicLintSent.tsx +63 -0
- package/resources/templates/default/admin/entrypoint/pages/passwordReset.tsx +44 -0
- package/resources/templates/default/admin/entrypoint/pages/resetRequest.tsx +35 -0
- package/resources/templates/default/admin/entrypoint/pages/resetRequestSuccess.tsx +34 -0
- package/resources/templates/default/admin/index.css +94 -0
- package/resources/templates/{template-workspace → default}/admin/index.html +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/block-repeater/block-repeater.tsx +4 -4
- package/resources/templates/{template-workspace → default}/admin/lib/board/board.tsx +3 -3
- package/resources/templates/{template-workspace → default}/admin/lib/datagrid/column-header.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/datagrid/columns.tsx +8 -8
- package/resources/templates/{template-workspace → default}/admin/lib/datagrid/elements.tsx +2 -2
- package/resources/templates/{template-workspace → default}/admin/lib/datagrid/empty.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/date.tsx +4 -4
- package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/relation.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/datagrid/pagination.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/datagrid/table.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/datagrid/ui.tsx +4 -4
- package/resources/templates/{template-workspace → default}/admin/lib/dimensions/dimensions.tsx +2 -2
- package/resources/templates/{template-workspace → default}/admin/lib/editor/common/editor-block-toolbar.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/editor/common/editor-canvas.tsx +2 -2
- package/resources/templates/{template-workspace → default}/admin/lib/editor/common/editor-inline-toolbar.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/BlockElement.tsx +2 -2
- package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/TableCellElementRenderer.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/editor/editor-block.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/editor/sortable-block.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/layout/layout-boxed.tsx +4 -4
- package/resources/templates/{template-workspace → default}/admin/lib/repeater/repeater.tsx +3 -3
- package/resources/templates/{template-workspace → default}/admin/lib/select/ui.tsx +5 -5
- package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/common.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/memberships-control.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/tenant/otp/otp-setup.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/toast/toast.tsx +4 -5
- package/resources/templates/{template-workspace → default}/admin/lib/ui/button.tsx +6 -6
- package/resources/templates/{template-workspace → default}/admin/lib/ui/card.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/ui/dialog.tsx +2 -2
- package/resources/templates/{template-workspace → default}/admin/lib/ui/dropdown.tsx +6 -6
- package/resources/templates/{template-workspace → default}/admin/lib/ui/input.tsx +11 -11
- package/resources/templates/{template-workspace → default}/admin/lib/ui/overlay.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/ui/popover.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/ui/property-list.tsx +3 -3
- package/resources/templates/{template-workspace → default}/admin/lib/ui/select.tsx +3 -3
- package/resources/templates/{template-workspace → default}/admin/lib/ui/sheet.tsx +4 -4
- package/resources/templates/{template-workspace → default}/admin/lib/ui/sidebar.tsx +14 -14
- package/resources/templates/{template-workspace → default}/admin/lib/ui/sortable.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/ui/switch.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/ui/table.tsx +3 -3
- package/resources/templates/{template-workspace → default}/admin/lib/ui/textarea.tsx +3 -3
- package/resources/templates/{template-workspace → default}/admin/lib/ui/toggle.tsx +2 -3
- package/resources/templates/{template-workspace → default}/admin/lib/ui/tooltip.tsx +2 -2
- package/resources/templates/{template-workspace → default}/admin/lib/upload/ui.tsx +4 -4
- package/resources/templates/{template-workspace → default}/admin/lib/upload/upload-progress.tsx +1 -1
- package/resources/templates/{template-workspace → default}/admin/lib/upload/view.tsx +3 -3
- package/resources/templates/{template-workspace → default}/admin/package.json +5 -2
- package/resources/templates/default/admin/postcss.config.js +5 -0
- package/resources/templates/default/admin/sentry.ts +26 -0
- package/resources/templates/{template-workspace → default}/admin/tsconfig.json +1 -9
- package/resources/templates/default/admin/vite-env.d.ts +12 -0
- package/resources/templates/default/admin/vite.config.ts +11 -0
- package/resources/templates/default/api/README.md +87 -0
- package/resources/templates/{template-workspace → default}/biome.json +1 -1
- package/resources/templates/default/client/README.md +285 -0
- package/resources/templates/{template-workspace → default}/contember.template.yaml +5 -0
- package/resources/templates/{template-workspace → default}/package.json +1 -1
- package/resources/templates/default/scripts/generate-client.sh +7 -0
- package/resources/templates/default/scripts/update-ui-lib.sh +344 -0
- package/src/commands/WorkspaceCreateCommand.ts +40 -24
- package/src/lib/TemplateInstaller.ts +6 -4
- package/src/lib/packageManagerDetector.ts +24 -0
- package/resources/templates/template-workspace/.gitignore.dist +0 -3
- package/resources/templates/template-workspace/admin/app/components/navigation.tsx +0 -1
- package/resources/templates/template-workspace/admin/index.css +0 -53
- package/resources/templates/template-workspace/admin/index.tsx +0 -268
- package/resources/templates/template-workspace/admin/postcss.config.js +0 -6
- package/resources/templates/template-workspace/admin/tailwind.config.js +0 -73
- package/resources/templates/template-workspace/admin/vite-env.d.ts +0 -7
- package/resources/templates/template-workspace/scripts/generate-client.sh +0 -8
- /package/resources/templates/{template-workspace → default}/.github/scripts/setup-actions-variables.sh +0 -0
- /package/resources/templates/{template-workspace → default}/.github/workflows/deploy.yaml +0 -0
- /package/resources/templates/{template-workspace → default}/admin/app/components/logo.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/app/config.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/app/index.html +0 -0
- /package/resources/templates/{template-workspace → default}/admin/app/pages/index.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/binding/binding.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/binding/delete.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/binding/hooks.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/binding/identity.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/binding/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/binding/navigation-guard-dialog.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/binding/persist.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/block-repeater/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/board/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/buttons/back-button.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/buttons/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/buttons/link-back-button.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/cells.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/column-leaf.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/export.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/boolean.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/common.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/defined.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/enum.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/mobile.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/number.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/text.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/grid.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/labels.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/layout-switcher.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/loader.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/tiles.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/toolbar.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/dev/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/dev/login-panel.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/dev/todo.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/dict.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/dimensions/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/block-editor.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/baseEditorPlugins.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/buttons.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/editor-editable-canvas.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/AnchorRenderer.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/HeadingRenderer.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/ListItemRenderer.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/OrderedListRenderer.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/ParagraphRenderer.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/ScrollTargetRenderer.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/TableElementRenderer.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/TableRowElementRenderer.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/plugins.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/rich-text-view.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/editor/rich-text.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/errors/error-boundary.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/errors/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/errors/use-error-formatter.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/field/formatted-field.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/field/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/form/container.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/form/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/form/inputs.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/form/labels.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/form/select.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/form/ui.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/form/upload-repeaters.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/form/upload.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/formatting/formatting.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/formatting/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/images/formatImageResizeUrl.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/images/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/labels/enum-labels.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/labels/field-labels.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/labels/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/layout/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/layout/layout.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/layout/slots.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/outdated-application-dialog/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/repeater/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/select/create-new.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/select/filter.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/select/highlight.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/select/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/select/list.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/select/multi-select.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/select/select.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/select/sortable-select.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/change-my-password.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/create-api-key.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/invite.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/login.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/password-reset-request.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/password-reset.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/passwordless-signin-init.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/passwordless-signin.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/update-project-member.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/hooks/useInvite.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/hooks/useInviteUser.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/listing/api-key-list.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/listing/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/listing/member-delete-dialog.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/listing/member-list.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/listing/person-list.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/tenant/otp/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/toast/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/toast/toaster.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/alert-dialog.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/avatar.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/collapsible.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/divider.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/label.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/loader.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/menu.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/progress.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/scroll-area.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/separator.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/skeleton.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/ui/toggle-group.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/upload/dropzone.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/upload/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/upload/repeater.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/utils/cn.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/utils/createComponentOpenHooks.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/utils/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/utils/uic.tsx +0 -0
- /package/resources/templates/{template-workspace → default}/admin/lib/utils/use-mobile.ts +0 -0
- /package/resources/templates/{template-workspace → default}/admin/public/favicon.png +0 -0
- /package/resources/templates/{template-workspace → default}/api/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/api/migrations/.gitkeep +0 -0
- /package/resources/templates/{template-workspace → default}/api/model/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/api/package.json +0 -0
- /package/resources/templates/{template-workspace → default}/api/tsconfig.json +0 -0
- /package/resources/templates/{template-workspace → default}/client/package.json +0 -0
- /package/resources/templates/{template-workspace → default}/client/src/index.ts +0 -0
- /package/resources/templates/{template-workspace → default}/client/tsconfig.json +0 -0
- /package/resources/templates/{template-workspace → default}/docker-compose.yaml +0 -0
- /package/resources/templates/{template-workspace → default}/tsconfig.json +0 -0
- /package/resources/templates/{template-workspace → default}/tsconfig.settings.json +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# My awesome multilingual CMS
|
|
2
|
+
|
|
3
|
+
Welcome to your new project created with [Contember AI Studio](https://www.contember.com/studio)! If you need
|
|
4
|
+
assistance, feel free to join the conversation in
|
|
5
|
+
our [GitHub Discussions](https://github.com/orgs/contember/discussions/categories/support).
|
|
6
|
+
|
|
7
|
+
## Getting Started
|
|
8
|
+
|
|
9
|
+
Before you begin, ensure you have:
|
|
10
|
+
|
|
11
|
+
- [Yarn](https://yarnpkg.com/getting-started/install) installed
|
|
12
|
+
- [Docker](https://docs.docker.com/get-docker/) installed and running
|
|
13
|
+
|
|
14
|
+
### Project Overview
|
|
15
|
+
|
|
16
|
+
Your project consists of the following packages:
|
|
17
|
+
|
|
18
|
+
#### [@app/admin](./admin)
|
|
19
|
+
|
|
20
|
+
- **Location:** `./admin`
|
|
21
|
+
- **Description:** A React SPA that serves as the administration UI, built with Contember DataBinding for seamless integration with the Contember API.
|
|
22
|
+
- **Sentry:** [Sentry](https://sentry.io) is integrated into the project. To enable Sentry, set the `VITE_SENTRY_DSN` environment variable in the `.env.production` file.
|
|
23
|
+
|
|
24
|
+
#### [@app/api](./api)
|
|
25
|
+
|
|
26
|
+
- **Location:** `./api`
|
|
27
|
+
- **Description:** Defines the data model and permissions for the Contember API.
|
|
28
|
+
|
|
29
|
+
#### [@app/client](./client)
|
|
30
|
+
|
|
31
|
+
- **Location:** `./client`
|
|
32
|
+
- **Description:** A type-safe GraphQL client for interacting with the Contember API, complete with generated types.
|
|
33
|
+
- **Documentation:** [Client Documentation](./client/README.md)
|
|
34
|
+
|
|
35
|
+
#### [@app/worker](./worker)
|
|
36
|
+
|
|
37
|
+
- **Location:** `./worker`
|
|
38
|
+
- **Description:** A serverless function deployed to Cloudflare Workers for executing server-side operations.
|
|
39
|
+
- **Documentation:** [Worker Documentation](./worker/README.md)
|
|
40
|
+
|
|
41
|
+
- - -
|
|
42
|
+
|
|
43
|
+
## Running the Project Locally
|
|
44
|
+
|
|
45
|
+
Follow these steps to set up and run your project locally:
|
|
46
|
+
|
|
47
|
+
1. **Install Dependencies**
|
|
48
|
+
|
|
49
|
+
Run the following command to install all required dependencies:
|
|
50
|
+
```bash
|
|
51
|
+
{packageManager} install
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
2. **Start the Project**
|
|
55
|
+
|
|
56
|
+
Start the admin application and all necessary services with:
|
|
57
|
+
```bash
|
|
58
|
+
{packageManager} run start
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This will launch the following components:
|
|
62
|
+
|
|
63
|
+
| Container | Port | Url |
|
|
64
|
+
|------------------|------|------------------------------------------------|
|
|
65
|
+
| Contember Engine | 1481 | [http://localhost:1481](http://localhost:1481) |
|
|
66
|
+
| Postgres | 1482 | [http://localhost:1482](http://localhost:1482) |
|
|
67
|
+
| S3 | 1483 | [http://localhost:1483](http://localhost:1483) |
|
|
68
|
+
| MailPit | 1484 | [http://localhost:1484](http://localhost:1484) |
|
|
69
|
+
| Adminer | 1485 | [http://localhost:1485](http://localhost:1485) |
|
|
70
|
+
| S3 Dashboard | 1486 | [http://localhost:1486](http://localhost:1486) |
|
|
71
|
+
|
|
72
|
+
When you're done, stop the Docker containers with:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
docker compose down
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- - -
|
|
79
|
+
|
|
80
|
+
## Next Steps
|
|
81
|
+
|
|
82
|
+
Congratulations, your project is now running locally! Access the administration UI
|
|
83
|
+
at [http://localhost:1480](http://localhost:1480/).
|
|
84
|
+
|
|
85
|
+
Enjoy building with Contember!
|
|
86
|
+
|
|
87
|
+
- - -
|
|
88
|
+
|
|
89
|
+
## Update headless UI components
|
|
90
|
+
|
|
91
|
+
To update the headless UI components, run the following command:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
sh ./scripts/update-ui-lib.sh
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
This will update `lib` folder in the `@app/admin` package with the latest headless UI components. If you have made any
|
|
98
|
+
changes to the components, make sure to commit them before running this command.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { memo, PropsWithChildren } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
import { LayoutComponent, Slots } from '@app/lib/layout'
|
|
4
|
-
import { Navigation } from './navigation'
|
|
2
|
+
import { Navigation, UserNavigation } from './navigation'
|
|
5
3
|
import { Link } from '@contember/interface'
|
|
6
4
|
import { Logo } from './logo'
|
|
5
|
+
import { IdentityLoader } from '~/lib/binding'
|
|
6
|
+
import { LayoutComponent, Slots } from '~/lib/layout'
|
|
7
7
|
|
|
8
8
|
export const Layout = memo(({ children }: PropsWithChildren) => {
|
|
9
9
|
return (
|
|
@@ -20,6 +20,10 @@ export const Layout = memo(({ children }: PropsWithChildren) => {
|
|
|
20
20
|
<Navigation />
|
|
21
21
|
</Slots.Navigation>
|
|
22
22
|
|
|
23
|
+
<Slots.UserNavigation>
|
|
24
|
+
<UserNavigation />
|
|
25
|
+
</Slots.UserNavigation>
|
|
26
|
+
|
|
23
27
|
<Slots.Footer>
|
|
24
28
|
<p><small>Created with <a className="content-link" href="https://www.contember.com/">Contember</a></small></p>
|
|
25
29
|
</Slots.Footer>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Link, LogoutTrigger, useIdentity } from '@contember/interface'
|
|
2
|
+
import { BadgeCheckIcon, BellIcon, ChevronsUpDown, LogOutIcon } from 'lucide-react'
|
|
3
|
+
import { dict } from '~/lib/dict'
|
|
4
|
+
import { Avatar, AvatarFallback } from '~/lib/ui/avatar'
|
|
5
|
+
import { AnchorButton, Button } from '~/lib/ui/button'
|
|
6
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from '~/lib/ui/dropdown'
|
|
7
|
+
import { SidebarMenuButton } from '~/lib/ui/sidebar'
|
|
8
|
+
import { useIsMobile } from '~/lib/utils/use-mobile'
|
|
9
|
+
|
|
10
|
+
export const Navigation = () => (<div>Navigation</div>)
|
|
11
|
+
|
|
12
|
+
export const UserNavigation = () => {
|
|
13
|
+
const isMobile = useIsMobile()
|
|
14
|
+
const identity = useIdentity()
|
|
15
|
+
|
|
16
|
+
const userEmail = identity?.person?.email
|
|
17
|
+
const userInitial = userEmail?.substring(0, 1).toLocaleUpperCase()
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<DropdownMenu>
|
|
21
|
+
<DropdownMenuTrigger asChild>
|
|
22
|
+
<SidebarMenuButton
|
|
23
|
+
size="lg"
|
|
24
|
+
className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
|
|
25
|
+
>
|
|
26
|
+
<Avatar className="icon h-6 w-6 rounded-lg">
|
|
27
|
+
<AvatarFallback avatarFallbackColorString={userEmail} className="rounded-lg">
|
|
28
|
+
{userInitial}
|
|
29
|
+
</AvatarFallback>
|
|
30
|
+
</Avatar>
|
|
31
|
+
<div className="grid flex-1 text-left text-sm leading-tight">
|
|
32
|
+
<span className="truncate font-semibold">{userEmail}</span>
|
|
33
|
+
</div>
|
|
34
|
+
<ChevronsUpDown className="ml-auto size-4" />
|
|
35
|
+
</SidebarMenuButton>
|
|
36
|
+
</DropdownMenuTrigger>
|
|
37
|
+
<DropdownMenuContent
|
|
38
|
+
className="w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg"
|
|
39
|
+
side={isMobile ? 'bottom' : 'right'}
|
|
40
|
+
align="end"
|
|
41
|
+
sideOffset={4}
|
|
42
|
+
>
|
|
43
|
+
<DropdownMenuLabel className="p-0 font-normal">
|
|
44
|
+
<div className="flex items-center gap-2 pl-3 pr-1 py-1.5 text-left text-sm">
|
|
45
|
+
<Avatar className="h-8 w-8 rounded-lg">
|
|
46
|
+
<AvatarFallback avatarFallbackColorString={userEmail} className="rounded-lg">
|
|
47
|
+
{userInitial}
|
|
48
|
+
</AvatarFallback>
|
|
49
|
+
</Avatar>
|
|
50
|
+
<div className="grid flex-1 text-left text-sm leading-tight">
|
|
51
|
+
<span className="truncate font-semibold">{userEmail}</span>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</DropdownMenuLabel>
|
|
55
|
+
<DropdownMenuSeparator />
|
|
56
|
+
<DropdownMenuGroup>
|
|
57
|
+
<DropdownMenuItem>
|
|
58
|
+
<Link to="tenant/security">
|
|
59
|
+
<AnchorButton variant="ghost" size="xs" className="flex gap-2">
|
|
60
|
+
<BadgeCheckIcon size={16} />
|
|
61
|
+
Security
|
|
62
|
+
</AnchorButton>
|
|
63
|
+
</Link>
|
|
64
|
+
</DropdownMenuItem>
|
|
65
|
+
<DropdownMenuItem>
|
|
66
|
+
<Link to="tenant/apiKeys">
|
|
67
|
+
<AnchorButton variant="ghost" size="xs" className="flex gap-2">
|
|
68
|
+
<BellIcon size={16} />
|
|
69
|
+
API keys
|
|
70
|
+
</AnchorButton>
|
|
71
|
+
</Link>
|
|
72
|
+
</DropdownMenuItem>
|
|
73
|
+
</DropdownMenuGroup>
|
|
74
|
+
<DropdownMenuSeparator />
|
|
75
|
+
<DropdownMenuItem>
|
|
76
|
+
<LogoutTrigger>
|
|
77
|
+
<Button variant="ghost" size="xs" className="flex gap-2">
|
|
78
|
+
<LogOutIcon size={16} /> {dict.logout}
|
|
79
|
+
</Button>
|
|
80
|
+
</LogoutTrigger>
|
|
81
|
+
</DropdownMenuItem>
|
|
82
|
+
</DropdownMenuContent>
|
|
83
|
+
</DropdownMenu>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { LoginWithEmail } from '../lib/dev'
|
|
2
|
-
import { OutdatedApplicationDialog } from '@app/lib/outdated-application-dialog'
|
|
3
|
-
import { Toaster } from '@app/lib/toast'
|
|
4
1
|
import { ApplicationEntrypoint, PageModule, Pages } from '@contember/interface'
|
|
5
2
|
import { createErrorHandler, DevBar, DevPanel } from '@contember/react-devbar'
|
|
6
3
|
import { SlotsProvider } from '@contember/react-slots'
|
|
7
4
|
import { LogInIcon } from 'lucide-react'
|
|
8
5
|
import { createRoot } from 'react-dom/client'
|
|
9
|
-
import {
|
|
6
|
+
import { OutdatedApplicationDialog } from '~/lib/outdated-application-dialog'
|
|
7
|
+
import { Toaster } from '~/lib/toast'
|
|
10
8
|
import '../index.css'
|
|
9
|
+
import { LoginWithEmail } from '../lib/dev'
|
|
10
|
+
import { Layout } from './components/layout'
|
|
11
11
|
import { getConfig } from './config'
|
|
12
12
|
|
|
13
13
|
const errorHandler = createErrorHandler((dom, react, onRecoverableError) => createRoot(dom, { onRecoverableError }).render(react))
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { useProjectSlug } from '@contember/react-client'
|
|
2
|
+
import { ChangeMyPasswordForm, CreateApiKeyForm, InviteForm } from '@contember/react-identity'
|
|
3
|
+
import { KeyRoundIcon, LockKeyholeIcon, UsersIcon } from 'lucide-react'
|
|
4
|
+
import { ReactNode, useRef } from 'react'
|
|
5
|
+
import { Slots } from '~/lib/layout'
|
|
6
|
+
import {
|
|
7
|
+
ApiKeyList,
|
|
8
|
+
ChangeMyPasswordFormFields,
|
|
9
|
+
CreateApiKeyFormFields,
|
|
10
|
+
InviteFormFields,
|
|
11
|
+
MemberListController,
|
|
12
|
+
OtpSetup,
|
|
13
|
+
PersonList,
|
|
14
|
+
} from '~/lib/tenant'
|
|
15
|
+
import { ToastContent, useShowToast } from '~/lib/toast'
|
|
16
|
+
import { Card, CardContent, CardHeader, CardTitle } from '~/lib/ui/card'
|
|
17
|
+
import { Input } from '~/lib/ui/input'
|
|
18
|
+
|
|
19
|
+
const Title = ({ icon, children }: { icon?: ReactNode; children: ReactNode }) => {
|
|
20
|
+
return (
|
|
21
|
+
<div className="flex items-center">
|
|
22
|
+
{icon && <div className="mr-2">{icon}</div>}
|
|
23
|
+
<h1>{children}</h1>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const Security = () => {
|
|
29
|
+
const showToast = useShowToast()
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<Slots.Title>
|
|
34
|
+
<Title icon={<LockKeyholeIcon />}>Security</Title>
|
|
35
|
+
</Slots.Title>
|
|
36
|
+
|
|
37
|
+
<div className="flex flex-col gap-4">
|
|
38
|
+
<Card className="w-[40rem] max-w-full">
|
|
39
|
+
<CardHeader>
|
|
40
|
+
<CardTitle className="text-2xl">Change Password</CardTitle>
|
|
41
|
+
</CardHeader>
|
|
42
|
+
<CardContent>
|
|
43
|
+
<ChangeMyPasswordForm onSuccess={() => showToast(
|
|
44
|
+
<ToastContent>Password changed</ToastContent>, { type: 'success' })}>
|
|
45
|
+
<form className="grid gap-4">
|
|
46
|
+
<ChangeMyPasswordFormFields />
|
|
47
|
+
</form>
|
|
48
|
+
</ChangeMyPasswordForm>
|
|
49
|
+
</CardContent>
|
|
50
|
+
</Card>
|
|
51
|
+
<Card className="w-[40rem] max-w-full">
|
|
52
|
+
<CardHeader>
|
|
53
|
+
<CardTitle className="text-2xl">Two-factor setup</CardTitle>
|
|
54
|
+
</CardHeader>
|
|
55
|
+
<CardContent>
|
|
56
|
+
<OtpSetup />
|
|
57
|
+
</CardContent>
|
|
58
|
+
</Card>
|
|
59
|
+
</div>
|
|
60
|
+
</>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const Members = () => {
|
|
65
|
+
const projectSlug = useProjectSlug()!
|
|
66
|
+
const showToast = useShowToast()
|
|
67
|
+
const memberListController = useRef<MemberListController>()
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<>
|
|
71
|
+
<Slots.Title>
|
|
72
|
+
<Title icon={<UsersIcon />}>Members</Title>
|
|
73
|
+
</Slots.Title>
|
|
74
|
+
|
|
75
|
+
<div className="flex flex-col gap-4">
|
|
76
|
+
<Card className="w-[40rem] max-w-full">
|
|
77
|
+
<CardHeader>
|
|
78
|
+
<CardTitle className="text-2xl">Invite</CardTitle>
|
|
79
|
+
</CardHeader>
|
|
80
|
+
<CardContent>
|
|
81
|
+
<InviteForm
|
|
82
|
+
projectSlug={projectSlug}
|
|
83
|
+
initialMemberships={[{ role: 'admin', variables: [] }]}
|
|
84
|
+
onSuccess={args => {
|
|
85
|
+
showToast(
|
|
86
|
+
<ToastContent>Invitation sent to {args.result.person?.email}</ToastContent>, { type: 'success' })
|
|
87
|
+
memberListController.current?.refresh()
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<form>
|
|
91
|
+
<InviteFormFields projectSlug={projectSlug} />
|
|
92
|
+
</form>
|
|
93
|
+
</InviteForm>
|
|
94
|
+
</CardContent>
|
|
95
|
+
</Card>
|
|
96
|
+
<Card className="w-[40rem] max-w-full">
|
|
97
|
+
<CardHeader>
|
|
98
|
+
<CardTitle className="text-2xl">Members</CardTitle>
|
|
99
|
+
</CardHeader>
|
|
100
|
+
<CardContent>
|
|
101
|
+
<PersonList controller={memberListController} />
|
|
102
|
+
</CardContent>
|
|
103
|
+
</Card>
|
|
104
|
+
|
|
105
|
+
</div>
|
|
106
|
+
</>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const ApiKeys = () => {
|
|
111
|
+
const projectSlug = useProjectSlug()!
|
|
112
|
+
const showToast = useShowToast()
|
|
113
|
+
const memberListController = useRef<MemberListController>()
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<>
|
|
117
|
+
<Slots.Title>
|
|
118
|
+
<Title icon={<KeyRoundIcon />}>API keys</Title>
|
|
119
|
+
</Slots.Title>
|
|
120
|
+
|
|
121
|
+
<div className="flex flex-col gap-4">
|
|
122
|
+
<div>
|
|
123
|
+
<Card className="w-[40rem] max-w-full">
|
|
124
|
+
<CardHeader>
|
|
125
|
+
<CardTitle className="text-2xl">Create API key</CardTitle>
|
|
126
|
+
</CardHeader>
|
|
127
|
+
<CardContent>
|
|
128
|
+
<CreateApiKeyForm
|
|
129
|
+
projectSlug={projectSlug}
|
|
130
|
+
initialMemberships={[{ role: 'admin', variables: [] }]}
|
|
131
|
+
onSuccess={args => {
|
|
132
|
+
showToast((
|
|
133
|
+
<ToastContent title="API key created">
|
|
134
|
+
<Input value={args.result.apiKey.token} type="text" />
|
|
135
|
+
</ToastContent>
|
|
136
|
+
), { type: 'success' })
|
|
137
|
+
memberListController.current?.refresh()
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
<form className="grid gap-4">
|
|
141
|
+
<CreateApiKeyFormFields projectSlug={projectSlug} />
|
|
142
|
+
</form>
|
|
143
|
+
</CreateApiKeyForm>
|
|
144
|
+
</CardContent>
|
|
145
|
+
</Card>
|
|
146
|
+
</div>
|
|
147
|
+
<div>
|
|
148
|
+
<Card className="w-[40rem] max-w-full">
|
|
149
|
+
<CardHeader>
|
|
150
|
+
<CardTitle className="text-2xl">API keys</CardTitle>
|
|
151
|
+
</CardHeader>
|
|
152
|
+
<CardContent>
|
|
153
|
+
<ApiKeyList controller={memberListController} />
|
|
154
|
+
</CardContent>
|
|
155
|
+
</Card>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
</>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const Layout = ({ children }: { children?: React.ReactNode }) => (
|
|
2
|
+
<div className="grid md:grid-cols-2 min-h-screen ">
|
|
3
|
+
<div className="bg-gray-100 p-4 flex items-center justify-center">
|
|
4
|
+
{children}
|
|
5
|
+
</div>
|
|
6
|
+
<div className="bg-gray-700 text-white p-4 flex items-center justify-center">
|
|
7
|
+
<div className="w-full max-w-md">
|
|
8
|
+
<div className="text-center text-2xl">Welcome to your app</div>
|
|
9
|
+
<p className="mt-8 text-center text-gray-300">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec auctor, sem
|
|
10
|
+
eget ultricies ultricies, sapien urna tristique eros, ac tincidunt felis lacus nec nunc.</p>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useIdentity } from '@contember/react-identity'
|
|
2
|
+
import { useEffect } from 'react'
|
|
3
|
+
import { Card, CardDescription, CardHeader, CardTitle } from '~/lib/ui/card'
|
|
4
|
+
import { Loader } from '~/lib/ui/loader'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props for {@link LoggedIn} component
|
|
8
|
+
*/
|
|
9
|
+
export type LoggedInProps = {
|
|
10
|
+
/**
|
|
11
|
+
* The URL to redirect to after successful login.
|
|
12
|
+
*/
|
|
13
|
+
appUrl: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Props {@link LoggedInProps}
|
|
18
|
+
*
|
|
19
|
+
* `LoggedIn` displays a confirmation UI upon successful login and redirects the user to the specified app URL.
|
|
20
|
+
* Must be used in a context where `useIdentity` is available (e.g., inside a Contember admin interface).
|
|
21
|
+
*
|
|
22
|
+
* #### Example: login redirect screen
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <LoggedIn appUrl="https://admin.example.com/dashboard" />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export const LoggedIn = ({ appUrl }: LoggedInProps) => {
|
|
28
|
+
const identity = useIdentity()
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
window.location.href = appUrl
|
|
33
|
+
}, 500)
|
|
34
|
+
}, [appUrl])
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Card className="w-96 relative">
|
|
38
|
+
<CardHeader>
|
|
39
|
+
<CardTitle className="text-2xl">Logged in</CardTitle>
|
|
40
|
+
<CardDescription>
|
|
41
|
+
as {identity?.person?.email ?? 'unknown'}
|
|
42
|
+
</CardDescription>
|
|
43
|
+
</CardHeader>
|
|
44
|
+
<Loader position="static" />
|
|
45
|
+
</Card>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ToastContent, useShowToast } from '~/lib/toast'
|
|
2
|
+
import { dict } from '~/lib/dict'
|
|
3
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '~/lib/ui/card'
|
|
4
|
+
import { AnchorButton, Button } from '~/lib/ui/button'
|
|
5
|
+
import { LoginFormFields } from '~/lib/tenant'
|
|
6
|
+
import { PasswordlessSignInInitFormFields } from '~/lib/tenant/forms/passwordless-signin-init'
|
|
7
|
+
import { Loader } from '~/lib/ui/loader'
|
|
8
|
+
import { useRedirect } from '@contember/react-routing'
|
|
9
|
+
import { IDP, IDPInitTrigger, IDPState, LoginForm, PasswordlessSignInInitForm } from '@contember/react-identity'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Props for {@link Login} component
|
|
13
|
+
*/
|
|
14
|
+
export type LoginProps = {
|
|
15
|
+
/**
|
|
16
|
+
* IDPs to be displayed in the login form
|
|
17
|
+
*/
|
|
18
|
+
idps: Record<string, string>
|
|
19
|
+
/**
|
|
20
|
+
* Whether the login form should display a token from environment
|
|
21
|
+
*/
|
|
22
|
+
hasTokenFromEnv: boolean
|
|
23
|
+
/**
|
|
24
|
+
* The URL of the application
|
|
25
|
+
*/
|
|
26
|
+
appUrl: string
|
|
27
|
+
/**
|
|
28
|
+
* Whether the login form should display a magic link
|
|
29
|
+
*/
|
|
30
|
+
magicLink: boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Props {@link LoginProps}
|
|
35
|
+
*
|
|
36
|
+
* `Login` renders a flexible authentication UI supporting multiple identity providers (IDPs), magic link login, and fallback login options.
|
|
37
|
+
* Must be used within a Contember environment where `useShowToast` and `useRedirect` are available.
|
|
38
|
+
*
|
|
39
|
+
* - Supports IDP login (OAuth, SAML, etc.) with customizable labels
|
|
40
|
+
* - Displays errors via toast notifications
|
|
41
|
+
* - Supports magic link (passwordless) login
|
|
42
|
+
* - Optional login as a default user using token from environment
|
|
43
|
+
*
|
|
44
|
+
* #### Example: full-featured login page
|
|
45
|
+
* ```tsx
|
|
46
|
+
* <Login
|
|
47
|
+
* idps={{ github: 'GitHub', google: 'Google' }}
|
|
48
|
+
* hasTokenFromEnv={true}
|
|
49
|
+
* appUrl="https://admin.example.com/dashboard"
|
|
50
|
+
* magicLink={true}
|
|
51
|
+
* />
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export const Login = ({ idps, hasTokenFromEnv, appUrl, magicLink }: LoginProps) => {
|
|
55
|
+
const showToast = useShowToast()
|
|
56
|
+
const redirect = useRedirect()
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<IDP
|
|
60
|
+
onInitError={error => showToast(<ToastContent>{dict.tenant.login.idpInitError} {error}</ToastContent>, { type: 'error' })}
|
|
61
|
+
onResponseError={error => showToast(
|
|
62
|
+
<ToastContent>{dict.tenant.login.idpResponseError} {error}</ToastContent>, { type: 'error' })}
|
|
63
|
+
>
|
|
64
|
+
<Card className="w-96 relative">
|
|
65
|
+
<CardHeader>
|
|
66
|
+
<CardTitle className="text-2xl">{dict.tenant.login.title}</CardTitle>
|
|
67
|
+
<CardDescription>
|
|
68
|
+
{dict.tenant.login.description}
|
|
69
|
+
</CardDescription>
|
|
70
|
+
</CardHeader>
|
|
71
|
+
<CardContent>
|
|
72
|
+
{hasTokenFromEnv && <AnchorButton href={appUrl} size="lg" className="w-full" variant="destructive">
|
|
73
|
+
Continue as default user
|
|
74
|
+
</AnchorButton>}
|
|
75
|
+
<LoginForm>
|
|
76
|
+
<form className="grid gap-4">
|
|
77
|
+
<LoginFormFields />
|
|
78
|
+
</form>
|
|
79
|
+
</LoginForm>
|
|
80
|
+
|
|
81
|
+
{Object.entries(idps).map(([idp, label]) => (
|
|
82
|
+
<IDPInitTrigger key={idp} identityProvider={idp}>
|
|
83
|
+
<Button variant="outline" className="w-full">
|
|
84
|
+
{label}
|
|
85
|
+
</Button>
|
|
86
|
+
</IDPInitTrigger>
|
|
87
|
+
))}
|
|
88
|
+
|
|
89
|
+
{magicLink && <PasswordlessSignInInitForm onSuccess={({ result }) => {
|
|
90
|
+
redirect('magicLinkSent(request_id: $requestId)', { requestId: result.requestId })
|
|
91
|
+
}}>
|
|
92
|
+
<form>
|
|
93
|
+
<PasswordlessSignInInitFormFields />
|
|
94
|
+
</form>
|
|
95
|
+
</PasswordlessSignInInitForm>}
|
|
96
|
+
</CardContent>
|
|
97
|
+
<IDPState state={['processing_init', 'processing_response', 'success']}>
|
|
98
|
+
<Loader />
|
|
99
|
+
</IDPState>
|
|
100
|
+
</Card>
|
|
101
|
+
</IDP>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ContemberClientProps } from '@contember/react-client'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the login entrypoint.
|
|
5
|
+
* Loads environment variables and prepares configuration for the Contember client.
|
|
6
|
+
*/
|
|
7
|
+
export const loginEntrypointConfig = (() => {
|
|
8
|
+
const apiBaseUrl = import.meta.env.VITE_CONTEMBER_ADMIN_API_BASE_URL
|
|
9
|
+
const loginToken = import.meta.env.VITE_CONTEMBER_ADMIN_LOGIN_TOKEN
|
|
10
|
+
|
|
11
|
+
if (!apiBaseUrl) {
|
|
12
|
+
throw new Error('VITE_CONTEMBER_ADMIN_API_BASE_URL is not set')
|
|
13
|
+
}
|
|
14
|
+
if (!loginToken) {
|
|
15
|
+
throw new Error('VITE_CONTEMBER_ADMIN_LOGIN_TOKEN is not set')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const clientConfig = {
|
|
19
|
+
apiBaseUrl,
|
|
20
|
+
loginToken,
|
|
21
|
+
} satisfies ContemberClientProps
|
|
22
|
+
|
|
23
|
+
// You can add more IDPs here
|
|
24
|
+
const identityProviders = {
|
|
25
|
+
// google: 'Login with Google',
|
|
26
|
+
} satisfies Record<string, string>
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
...clientConfig,
|
|
30
|
+
idps: identityProviders,
|
|
31
|
+
appUrl: '/app',
|
|
32
|
+
hasTokenFromEnv: import.meta.env.VITE_CONTEMBER_ADMIN_SESSION_TOKEN !== '__SESSION_TOKEN__',
|
|
33
|
+
magicLink: true,
|
|
34
|
+
}
|
|
35
|
+
})()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRequiredContext } from '@contember/react-utils'
|
|
2
|
+
import { PropsWithChildren } from 'react'
|
|
3
|
+
|
|
4
|
+
export type LoginConfig = {
|
|
5
|
+
appUrl: string
|
|
6
|
+
hasTokenFromEnv: boolean
|
|
7
|
+
idps: Record<string, string>
|
|
8
|
+
magicLink: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const [LoginConfigContext, useLoginConfig] = createRequiredContext<LoginConfig>('LoginConfigContext')
|
|
12
|
+
export { LoginConfigContext, useLoginConfig }
|
|
13
|
+
|
|
14
|
+
export const LoginConfigProvider = ({ children, ...config }: PropsWithChildren<LoginConfig>) => (
|
|
15
|
+
<LoginConfigContext.Provider value={config}>
|
|
16
|
+
{children}
|
|
17
|
+
</LoginConfigContext.Provider>
|
|
18
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createErrorHandler } from '@contember/react-devbar'
|
|
2
|
+
import { LoginEntrypoint } from './login-entrypoint'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import '../index.css'
|
|
5
|
+
import '../sentry'
|
|
6
|
+
import { loginEntrypointConfig } from './config'
|
|
7
|
+
|
|
8
|
+
const errorHandler = createErrorHandler((dom, react, onRecoverableError) => createRoot(dom, { onRecoverableError }).render(react))
|
|
9
|
+
|
|
10
|
+
const rootEl = document.body.appendChild(document.createElement('div'))
|
|
11
|
+
|
|
12
|
+
errorHandler(onRecoverableError => createRoot(rootEl, { onRecoverableError }).render(<LoginEntrypoint {...loginEntrypointConfig} />))
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ContemberClient, ContemberClientProps } from '@contember/react-client'
|
|
2
|
+
import { type PageModule, Pages, RoutingProvider } from '@contember/react-routing'
|
|
3
|
+
import { Toaster } from '~/lib/toast/toast'
|
|
4
|
+
import { Layout } from './components/layout'
|
|
5
|
+
import { type LoginConfig, LoginConfigProvider } from './contexts/login'
|
|
6
|
+
|
|
7
|
+
export type LoginEntrypointProps = ContemberClientProps & LoginConfig
|
|
8
|
+
|
|
9
|
+
export const LoginEntrypoint = ({ appUrl, hasTokenFromEnv, idps, magicLink, apiBaseUrl, sessionToken, loginToken, project, stage }: LoginEntrypointProps) => (
|
|
10
|
+
<ContemberClient apiBaseUrl={apiBaseUrl} sessionToken={sessionToken} loginToken={loginToken} project={project} stage={stage}>
|
|
11
|
+
<LoginConfigProvider appUrl={appUrl} hasTokenFromEnv={hasTokenFromEnv} idps={idps} magicLink={magicLink}>
|
|
12
|
+
<RoutingProvider pageInQuery>
|
|
13
|
+
<Toaster>
|
|
14
|
+
<Pages
|
|
15
|
+
layout={Layout}
|
|
16
|
+
children={import.meta.glob<PageModule>(
|
|
17
|
+
'./pages/**/*.tsx',
|
|
18
|
+
{ eager: true }
|
|
19
|
+
)} />
|
|
20
|
+
</Toaster>
|
|
21
|
+
</RoutingProvider>
|
|
22
|
+
</LoginConfigProvider>
|
|
23
|
+
</ContemberClient>
|
|
24
|
+
)
|