@contember/create 1.4.0-rc.3 → 1.4.0-rc.5
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/src/commands/WorkspaceCreateCommand.d.ts +4 -3
- package/dist/src/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/src/commands/WorkspaceCreateCommand.js +10 -4
- package/dist/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/src/lib/FileSystem.d.ts +14 -0
- package/dist/src/lib/FileSystem.d.ts.map +1 -0
- package/dist/src/lib/FileSystem.js +54 -0
- package/dist/src/lib/FileSystem.js.map +1 -0
- package/dist/src/lib/PackageDownloader.d.ts +7 -0
- package/dist/src/lib/PackageDownloader.d.ts.map +1 -0
- package/dist/src/lib/PackageDownloader.js +32 -0
- package/dist/src/lib/PackageDownloader.js.map +1 -0
- package/dist/src/lib/TemplateInstaller.d.ts +13 -0
- package/dist/src/lib/TemplateInstaller.d.ts.map +1 -0
- package/dist/src/lib/TemplateInstaller.js +75 -0
- package/dist/src/lib/TemplateInstaller.js.map +1 -0
- package/dist/src/lib/pathUtils.d.ts +3 -0
- package/dist/src/lib/pathUtils.d.ts.map +1 -0
- package/dist/src/lib/pathUtils.js +7 -0
- package/dist/src/lib/pathUtils.js.map +1 -0
- package/dist/src/run.js +7 -3
- package/dist/src/run.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -3
- package/resources/templates/template-workspace/.gitignore.dist +3 -0
- package/resources/templates/template-workspace/admin/.env.development +3 -0
- package/resources/templates/template-workspace/admin/.env.production +3 -0
- package/resources/templates/template-workspace/admin/app/components/layout.tsx +32 -0
- package/resources/templates/template-workspace/admin/app/components/logo.tsx +16 -0
- package/resources/templates/template-workspace/admin/app/components/navigation.tsx +1 -0
- package/resources/templates/template-workspace/admin/app/config.ts +27 -0
- package/resources/templates/template-workspace/admin/app/index.html +15 -0
- package/resources/templates/template-workspace/admin/app/index.tsx +40 -0
- package/resources/templates/template-workspace/admin/app/pages/index.tsx +5 -0
- package/resources/templates/template-workspace/admin/index.css +53 -0
- package/resources/templates/template-workspace/admin/index.html +13 -0
- package/resources/templates/template-workspace/admin/index.tsx +268 -0
- package/resources/templates/template-workspace/admin/lib/binding/binding.tsx +45 -0
- package/resources/templates/template-workspace/admin/lib/binding/delete.tsx +43 -0
- package/resources/templates/template-workspace/admin/lib/binding/hooks.tsx +71 -0
- package/resources/templates/template-workspace/admin/lib/binding/identity.tsx +19 -0
- package/resources/templates/template-workspace/admin/lib/binding/index.ts +5 -0
- package/resources/templates/template-workspace/admin/lib/binding/persist.tsx +70 -0
- package/resources/templates/template-workspace/admin/lib/block-repeater/block-repeater.tsx +224 -0
- package/resources/templates/template-workspace/admin/lib/block-repeater/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/board/board.tsx +240 -0
- package/resources/templates/template-workspace/admin/lib/board/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/buttons/back-button.tsx +20 -0
- package/resources/templates/template-workspace/admin/lib/buttons/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/buttons/link-back-button.tsx +21 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/cells.tsx +64 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/column-header.tsx +65 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +166 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/elements.tsx +42 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/empty.tsx +8 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/export.tsx +17 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/boolean.tsx +76 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/common.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/date.tsx +153 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/enum.tsx +115 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/index.ts +7 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/mobile.tsx +19 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/number.tsx +100 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/relation.tsx +180 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/text.tsx +121 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +61 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/index.ts +16 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/layout-switcher.tsx +32 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/loader.tsx +10 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/pagination.tsx +103 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/table.tsx +69 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/tiles.tsx +24 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/toolbar.tsx +66 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/ui.tsx +153 -0
- package/resources/templates/template-workspace/admin/lib/dev/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/dev/login-panel.tsx +56 -0
- package/resources/templates/template-workspace/admin/lib/dev/todo.tsx +14 -0
- package/resources/templates/template-workspace/admin/lib/dict.ts +324 -0
- package/resources/templates/template-workspace/admin/lib/dimensions/dimensions.tsx +135 -0
- package/resources/templates/template-workspace/admin/lib/dimensions/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/editor/block-editor.tsx +111 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/baseEditorPlugins.tsx +66 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/buttons.tsx +83 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-block-toolbar.tsx +17 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-canvas.tsx +30 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-editable-canvas.tsx +50 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-inline-toolbar.tsx +63 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/AnchorRenderer.tsx +36 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/BlockElement.tsx +48 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/HeadingRenderer.tsx +48 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +28 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/ListItemRenderer.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/OrderedListRenderer.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/ParagraphRenderer.tsx +15 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/ScrollTargetRenderer.tsx +30 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableCellElementRenderer.tsx +20 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableElementRenderer.tsx +96 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableRowElementRenderer.tsx +15 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/index.ts +6 -0
- package/resources/templates/template-workspace/admin/lib/editor/editor-block.tsx +96 -0
- package/resources/templates/template-workspace/admin/lib/editor/index.ts +5 -0
- package/resources/templates/template-workspace/admin/lib/editor/plugins.tsx +36 -0
- package/resources/templates/template-workspace/admin/lib/editor/rich-text.tsx +54 -0
- package/resources/templates/template-workspace/admin/lib/editor/sortable-block.tsx +51 -0
- package/resources/templates/template-workspace/admin/lib/errors/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/errors/use-error-formatter.ts +26 -0
- package/resources/templates/template-workspace/admin/lib/form/container.tsx +63 -0
- package/resources/templates/template-workspace/admin/lib/form/index.ts +5 -0
- package/resources/templates/template-workspace/admin/lib/form/inputs.tsx +99 -0
- package/resources/templates/template-workspace/admin/lib/form/select.tsx +123 -0
- package/resources/templates/template-workspace/admin/lib/form/ui.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/form/upload.tsx +243 -0
- package/resources/templates/template-workspace/admin/lib/formatting/formatting.ts +62 -0
- package/resources/templates/template-workspace/admin/lib/formatting/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/images/formatImageResizeUrl.ts +23 -0
- package/resources/templates/template-workspace/admin/lib/images/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/layout/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/layout/layout.tsx +167 -0
- package/resources/templates/template-workspace/admin/lib/layout/slots.tsx +24 -0
- package/resources/templates/template-workspace/admin/lib/outdated-application-dialog/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +41 -0
- package/resources/templates/template-workspace/admin/lib/repeater/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/repeater/repeater.tsx +142 -0
- package/resources/templates/template-workspace/admin/lib/select/create-new.tsx +34 -0
- package/resources/templates/template-workspace/admin/lib/select/filter.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/select/highlight.tsx +16 -0
- package/resources/templates/template-workspace/admin/lib/select/index.ts +7 -0
- package/resources/templates/template-workspace/admin/lib/select/list.tsx +49 -0
- package/resources/templates/template-workspace/admin/lib/select/multi-select.tsx +95 -0
- package/resources/templates/template-workspace/admin/lib/select/pagination.tsx +48 -0
- package/resources/templates/template-workspace/admin/lib/select/select.tsx +87 -0
- package/resources/templates/template-workspace/admin/lib/select/sortable-select.tsx +129 -0
- package/resources/templates/template-workspace/admin/lib/select/ui.tsx +80 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/change-my-password.tsx +40 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/common.tsx +94 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/create-api-key.tsx +39 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/index.ts +8 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/invite.tsx +46 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/login.tsx +52 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/memberships-control.tsx +128 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset-request.tsx +31 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset.tsx +44 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/update-project-member.tsx +32 -0
- package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInvite.ts +28 -0
- package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInviteUser.tsx +45 -0
- package/resources/templates/template-workspace/admin/lib/tenant/index.ts +3 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/api-key-list.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/index.ts +4 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/member-delete-dialog.tsx +38 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/member-list.tsx +147 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/person-list.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/tenant/otp/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/tenant/otp/otp-setup.tsx +146 -0
- package/resources/templates/template-workspace/admin/lib/toast/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/toast/toast.tsx +112 -0
- package/resources/templates/template-workspace/admin/lib/toast/toaster.tsx +104 -0
- package/resources/templates/template-workspace/admin/lib/ui/alert-dialog.tsx +59 -0
- package/resources/templates/template-workspace/admin/lib/ui/button.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/ui/card.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/ui/dialog.tsx +51 -0
- package/resources/templates/template-workspace/admin/lib/ui/divider.tsx +11 -0
- package/resources/templates/template-workspace/admin/lib/ui/dropdown.tsx +108 -0
- package/resources/templates/template-workspace/admin/lib/ui/input.tsx +62 -0
- package/resources/templates/template-workspace/admin/lib/ui/label.tsx +7 -0
- package/resources/templates/template-workspace/admin/lib/ui/loader.tsx +30 -0
- package/resources/templates/template-workspace/admin/lib/ui/menu.tsx +103 -0
- package/resources/templates/template-workspace/admin/lib/ui/overlay.tsx +33 -0
- package/resources/templates/template-workspace/admin/lib/ui/popover.tsx +31 -0
- package/resources/templates/template-workspace/admin/lib/ui/progress.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/ui/scroll-area.tsx +45 -0
- package/resources/templates/template-workspace/admin/lib/ui/sheet.tsx +67 -0
- package/resources/templates/template-workspace/admin/lib/ui/sortable.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/ui/switch.tsx +10 -0
- package/resources/templates/template-workspace/admin/lib/ui/table.tsx +46 -0
- package/resources/templates/template-workspace/admin/lib/ui/textarea.tsx +18 -0
- package/resources/templates/template-workspace/admin/lib/ui/toggle-group.tsx +44 -0
- package/resources/templates/template-workspace/admin/lib/ui/toggle.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/ui/tooltip.tsx +24 -0
- package/resources/templates/template-workspace/admin/lib/upload/dropzone.tsx +21 -0
- package/resources/templates/template-workspace/admin/lib/upload/index.ts +3 -0
- package/resources/templates/template-workspace/admin/lib/upload/repeater.tsx +12 -0
- package/resources/templates/template-workspace/admin/lib/upload/ui.tsx +57 -0
- package/resources/templates/template-workspace/admin/lib/upload/upload-progress.tsx +130 -0
- package/resources/templates/template-workspace/admin/lib/upload/view.tsx +219 -0
- package/resources/templates/template-workspace/admin/lib/utils/cn.ts +4 -0
- package/resources/templates/template-workspace/admin/lib/utils/dict-format.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/utils/format-image-resize-url.ts +17 -0
- package/resources/templates/template-workspace/admin/lib/utils/formatting.ts +60 -0
- package/resources/templates/template-workspace/admin/lib/utils/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/utils/uic.tsx +79 -0
- package/resources/templates/template-workspace/admin/package.json +63 -0
- package/resources/templates/template-workspace/admin/postcss.config.js +6 -0
- package/resources/templates/template-workspace/admin/public/favicon.png +0 -0
- package/resources/templates/template-workspace/admin/tailwind.config.js +73 -0
- package/resources/templates/template-workspace/admin/tsconfig.json +23 -0
- package/resources/templates/template-workspace/admin/vite-env.d.ts +7 -0
- package/resources/templates/template-workspace/admin/vite.config.ts +39 -0
- package/resources/templates/template-workspace/api/index.ts +7 -0
- package/resources/templates/template-workspace/api/migrations/.gitkeep +1 -0
- package/resources/templates/template-workspace/api/model/index.ts +1 -0
- package/resources/templates/template-workspace/api/package.json +16 -0
- package/resources/templates/template-workspace/api/tsconfig.json +10 -0
- package/resources/templates/template-workspace/biome.json +45 -0
- package/resources/templates/template-workspace/client/package.json +16 -0
- package/resources/templates/template-workspace/client/src/index.ts +1 -0
- package/resources/templates/template-workspace/client/tsconfig.json +9 -0
- package/resources/templates/template-workspace/contember.template.yaml +7 -0
- package/resources/templates/template-workspace/docker-compose.yaml +124 -0
- package/resources/templates/template-workspace/package.json +32 -0
- package/resources/templates/template-workspace/scripts/generate-client.sh +8 -0
- package/resources/templates/template-workspace/tsconfig.json +9 -0
- package/resources/templates/template-workspace/tsconfig.settings.json +15 -0
- package/src/commands/WorkspaceCreateCommand.ts +15 -6
- package/src/lib/FileSystem.ts +24 -0
- package/src/lib/PackageDownloader.ts +33 -0
- package/src/lib/TemplateInstaller.ts +102 -0
- package/src/lib/pathUtils.ts +4 -0
- package/src/run.ts +14 -5
- package/tsconfig.settings.json +5 -1
- package/types/download-tarball/index.d.ts +7 -0
- package/types/get-package-json-from-registry/index.d.ts +3 -0
- package/types/registry-info/index.d.ts +7 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { uic } from '../utils'
|
|
2
|
+
import { Button } from '../ui/button'
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { forwardRef } from 'react'
|
|
5
|
+
import { CheckIcon, PlusIcon, XIcon } from 'lucide-react'
|
|
6
|
+
import { PopoverContent } from '../ui/popover'
|
|
7
|
+
import { dict } from '../dict'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export const SelectInputWrapperUI = uic('div', {
|
|
11
|
+
baseClass: `
|
|
12
|
+
w-full max-w-md
|
|
13
|
+
relative
|
|
14
|
+
`,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export const SelectInputUI = uic('button', {
|
|
18
|
+
baseClass: `
|
|
19
|
+
flex gap-2 flex-wrap items-center
|
|
20
|
+
w-full min-h-10
|
|
21
|
+
p-2 py-1 pr-6
|
|
22
|
+
bg-background
|
|
23
|
+
rounded-md border border-input ring-offset-background
|
|
24
|
+
text-sm
|
|
25
|
+
cursor-pointer
|
|
26
|
+
hover:border-gray-400
|
|
27
|
+
placeholder:text-muted-foreground
|
|
28
|
+
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
|
|
29
|
+
disabled:cursor-not-allowed disabled:opacity-50
|
|
30
|
+
`,
|
|
31
|
+
})
|
|
32
|
+
export const SelectInputActionsUI = uic('span', {
|
|
33
|
+
baseClass: 'absolute right-2 top-1/2 -translate-y-1/2 flex gap-1 items-center',
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export const SelectListItemUI = uic(Button, {
|
|
37
|
+
baseClass: 'w-full text-left justify-start gap-1 data-[highlighted]:bg-gray-200 data-[selected]:bg-gray-100 group relative',
|
|
38
|
+
defaultProps: {
|
|
39
|
+
variant: 'ghost',
|
|
40
|
+
size: 'sm',
|
|
41
|
+
},
|
|
42
|
+
afterChildren: <CheckIcon className="h-3 w-3 opacity-0 group-data-[selected]:opacity-100 ml-auto"/>,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
export const SelectDefaultPlaceholderUI = () => <span className={'text-gray-400'}>{dict.select.placeholder}</span>
|
|
46
|
+
|
|
47
|
+
export const MultiSelectItemUI = uic('span', {
|
|
48
|
+
baseClass: 'flex items-stretch border rounded hover:shadow transition-all',
|
|
49
|
+
})
|
|
50
|
+
export const MultiSelectItemContentUI = uic('span', {
|
|
51
|
+
baseClass: 'rounded-l px-2 py-1 bg-white ',
|
|
52
|
+
})
|
|
53
|
+
export const MultiSelectSortableItemContentUI = uic('span', {
|
|
54
|
+
baseClass: 'rounded-l px-2 py-1 bg-white hover:bg-gray-50 cursor-move transition-all',
|
|
55
|
+
})
|
|
56
|
+
export const MultiSelectItemDragOverlayUI = uic('span', {
|
|
57
|
+
baseClass: 'rounded px-2 py-1 bg-gray-100 inline-flex gap-2 items-center bg-opacity-20 backdrop-blur text-sm border shadow',
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
export const MultiSelectItemRemoveButtonUI = uic('span', {
|
|
61
|
+
baseClass: 'bg-gray-100 border-l py-1 px-2 rounded-r text-black inline-flex items-center justify-center hover:bg-gray-300',
|
|
62
|
+
afterChildren: <XIcon className={'w-3 h-3'}/>,
|
|
63
|
+
defaultProps: {
|
|
64
|
+
tabIndex: 0,
|
|
65
|
+
role: 'button',
|
|
66
|
+
onKeyDown: e => {
|
|
67
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
68
|
+
e.currentTarget.click()
|
|
69
|
+
e.preventDefault()
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
export const SelectPopoverContent = uic(PopoverContent, {
|
|
76
|
+
baseClass: 'group w-[max(16rem,var(--radix-popover-trigger-width))]',
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
export const SelectCreateNewTrigger = forwardRef<HTMLButtonElement, {}>((props, ref) => <Button variant="outline" size="icon" ref={ref} {...props}><PlusIcon className="w-3 h-3" /></Button>)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ChangeMyPasswordFormErrorCode, useChangeMyPasswordForm } from '@contember/react-identity'
|
|
2
|
+
import { Button } from '../../ui/button'
|
|
3
|
+
import { Loader } from '../../ui/loader'
|
|
4
|
+
import { TenantFormError, TenantFormField } from './common'
|
|
5
|
+
import { dict } from '../../dict'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const ChangeMyPasswordFormFields = () => {
|
|
9
|
+
const form = useChangeMyPasswordForm()
|
|
10
|
+
return (
|
|
11
|
+
<div className="relative flex flex-col gap-2">
|
|
12
|
+
{form.state === 'submitting' ? <Loader position="absolute" /> : null}
|
|
13
|
+
<TenantFormError
|
|
14
|
+
form={form} messages={dict.tenant.changePassword.errorMessages}
|
|
15
|
+
/>
|
|
16
|
+
<TenantFormField
|
|
17
|
+
form={form} messages={dict.tenant.changePassword.errorMessages} field="currentPassword"
|
|
18
|
+
type="password" required autoFocus autoComplete="current-password"
|
|
19
|
+
>
|
|
20
|
+
{dict.tenant.changePassword.currentPassword}
|
|
21
|
+
</TenantFormField>
|
|
22
|
+
<TenantFormField
|
|
23
|
+
form={form} messages={dict.tenant.changePassword.errorMessages} field="newPassword"
|
|
24
|
+
type="password" required autoComplete="new-password"
|
|
25
|
+
>
|
|
26
|
+
{dict.tenant.changePassword.newPassword}
|
|
27
|
+
</TenantFormField>
|
|
28
|
+
<TenantFormField
|
|
29
|
+
form={form} messages={dict.tenant.changePassword.errorMessages} field="passwordConfirmation"
|
|
30
|
+
type="password" required autoComplete="new-password"
|
|
31
|
+
>
|
|
32
|
+
{dict.tenant.changePassword.confirmPassword}
|
|
33
|
+
</TenantFormField>
|
|
34
|
+
|
|
35
|
+
<Button type="submit" className="w-full" disabled={form.state === 'submitting'}>
|
|
36
|
+
{dict.tenant.changePassword.submit}
|
|
37
|
+
</Button>
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { FormContextValue } from '@contember/react-identity'
|
|
2
|
+
import { FormErrorUI } from '../../form'
|
|
3
|
+
import { Input } from '../../ui/input'
|
|
4
|
+
import { HTMLInputTypeAttribute, useState } from 'react'
|
|
5
|
+
import { dataAttribute } from '@contember/utilities'
|
|
6
|
+
import { Label } from '../../ui/label'
|
|
7
|
+
|
|
8
|
+
export interface TenantFormErrorsProps<CtxValue extends FormContextValue<any, any, any>> {
|
|
9
|
+
form: CtxValue
|
|
10
|
+
field?: keyof CtxValue['values']
|
|
11
|
+
messages: Record<CtxValue extends FormContextValue<any, infer E> ? E : never, string>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const TenantFormError = <CtxValue extends FormContextValue<any, any, any>>({ form, field, messages }: TenantFormErrorsProps<CtxValue>) => {
|
|
15
|
+
return (
|
|
16
|
+
<div>
|
|
17
|
+
{form.errors
|
|
18
|
+
.filter(error => error.field === field)
|
|
19
|
+
.filter(it => !(it.code in messages && ((messages as any)[it.code] === undefined)))
|
|
20
|
+
.map(error => [error.code, { error: (messages as any)[error.code] || 'Unknown error', developerMessage: error.developerMessage }])
|
|
21
|
+
.map(([code, error]) => {
|
|
22
|
+
return (<TenantFormSingleError key={code} {...error} />)
|
|
23
|
+
})}
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const TenantFormSingleError = ({ error, developerMessage }: { error: string, developerMessage?: string }) => {
|
|
29
|
+
const [showDeveloperMessage, setShowDeveloperMessage] = useState(false)
|
|
30
|
+
return <>
|
|
31
|
+
<FormErrorUI>{error}</FormErrorUI>
|
|
32
|
+
{/*{developerMessage && <div>*/}
|
|
33
|
+
{/* {showDeveloperMessage*/}
|
|
34
|
+
{/* ? <div className="mt-1 text-xs font-light font-mono bg-gray-50 shadow-inner p-2 rounded border">{developerMessage}</div>*/}
|
|
35
|
+
{/* : <button className="text-xs underline" onClick={() => setShowDeveloperMessage(!showDeveloperMessage)}>Show details</button>}*/}
|
|
36
|
+
{/*</div>}*/}
|
|
37
|
+
</>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type TenantFormInputProps<CtxValue extends FormContextValue<any, any, any>> =
|
|
41
|
+
& {
|
|
42
|
+
form: CtxValue
|
|
43
|
+
type: HTMLInputTypeAttribute
|
|
44
|
+
field: keyof CtxValue['values'] & string
|
|
45
|
+
}
|
|
46
|
+
& Omit<Partial<React.InputHTMLAttributes<HTMLInputElement>>, 'form' | 'field'>
|
|
47
|
+
|
|
48
|
+
export const TenantFormInput = <CtxValue extends FormContextValue<any, any, any>>({ form, field, ...props }: TenantFormInputProps<CtxValue>) => {
|
|
49
|
+
return (
|
|
50
|
+
<Input
|
|
51
|
+
id={field}
|
|
52
|
+
onChange={e => form.setValue(field, e.target.value)}
|
|
53
|
+
value={form.values[field]}
|
|
54
|
+
data-invalid={dataAttribute(form.errors.some(it => it.field === field))}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type TenantFormLabelProps<CtxValue extends FormContextValue<any, any, any>> =
|
|
61
|
+
& {
|
|
62
|
+
form: CtxValue
|
|
63
|
+
field: keyof CtxValue['values'] & string
|
|
64
|
+
}
|
|
65
|
+
& Omit<Partial<React.LabelHTMLAttributes<HTMLLabelElement>>, 'form' | 'htmlFor'>
|
|
66
|
+
|
|
67
|
+
export const TenantFormLabel = <CtxValue extends FormContextValue<any, any, any>>({ form, field, ...props }: TenantFormLabelProps<CtxValue>) => {
|
|
68
|
+
return (
|
|
69
|
+
<Label
|
|
70
|
+
htmlFor={field}
|
|
71
|
+
data-invalid={dataAttribute(form.errors.some(it => it.field === field))}
|
|
72
|
+
{...props}
|
|
73
|
+
/>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type TenantFormFieldProps<CtxValue extends FormContextValue<any, any, any>> =
|
|
78
|
+
& {
|
|
79
|
+
form: CtxValue
|
|
80
|
+
field: keyof CtxValue['values'] & string
|
|
81
|
+
type: HTMLInputTypeAttribute
|
|
82
|
+
messages: Record<CtxValue extends FormContextValue<any, infer E> ? E : never, string>
|
|
83
|
+
}
|
|
84
|
+
& Omit<Partial<React.InputHTMLAttributes<HTMLInputElement>>, 'form' | 'field'>
|
|
85
|
+
|
|
86
|
+
export const TenantFormField = <CtxValue extends FormContextValue<any, any, any>>({ form, field, type, messages, children, ...props }: TenantFormFieldProps<CtxValue>) => {
|
|
87
|
+
return (
|
|
88
|
+
<div className="flex flex-col gap-2">
|
|
89
|
+
<TenantFormLabel form={form} field={field}>{children}</TenantFormLabel>
|
|
90
|
+
<TenantFormInput form={form} field={field} type={type} {...props} />
|
|
91
|
+
<TenantFormError form={form} field={field} messages={messages} />
|
|
92
|
+
</div>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CreateApiKeyFormErrorCode, useCreateApiKeyForm } from '@contember/react-identity'
|
|
2
|
+
import { Button } from '../../ui/button'
|
|
3
|
+
import { Loader } from '../../ui/loader'
|
|
4
|
+
import { TenantFormError, TenantFormField, TenantFormLabel } from './common'
|
|
5
|
+
import { MembershipsControl, useIntrospectionRolesConfig } from './memberships-control'
|
|
6
|
+
import { dict } from '../../dict'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const CreateApiKeyFormFields = ({ projectSlug }: {projectSlug: string}) => {
|
|
10
|
+
const form = useCreateApiKeyForm()
|
|
11
|
+
return (
|
|
12
|
+
<div className="relative flex flex-col gap-2">
|
|
13
|
+
{form.state === 'submitting' ? <Loader position="absolute" /> : null}
|
|
14
|
+
|
|
15
|
+
<TenantFormError
|
|
16
|
+
form={form} messages={dict.tenant.createApiKey.errorMessages}
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<TenantFormField
|
|
20
|
+
form={form} messages={dict.tenant.createApiKey.errorMessages} field="description"
|
|
21
|
+
type="text" required autoFocus
|
|
22
|
+
>
|
|
23
|
+
{dict.tenant.createApiKey.description}
|
|
24
|
+
</TenantFormField>
|
|
25
|
+
|
|
26
|
+
<TenantFormLabel form={form} field="memberships">{dict.tenant.createApiKey.roles}</TenantFormLabel>
|
|
27
|
+
<MembershipsControl
|
|
28
|
+
memberships={form.values.memberships}
|
|
29
|
+
setMemberships={it => form.setValue('memberships', it)}
|
|
30
|
+
roles={useIntrospectionRolesConfig(projectSlug)}
|
|
31
|
+
/>
|
|
32
|
+
<TenantFormError form={form} messages={dict.tenant.createApiKey.errorMessages} field="memberships" />
|
|
33
|
+
|
|
34
|
+
<Button type="submit" className="w-full" disabled={form.state === 'submitting'}>
|
|
35
|
+
{dict.tenant.createApiKey.submit}
|
|
36
|
+
</Button>
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './change-my-password'
|
|
2
|
+
export * from './create-api-key'
|
|
3
|
+
export * from './invite'
|
|
4
|
+
export * from './login'
|
|
5
|
+
export * from './memberships-control'
|
|
6
|
+
export * from './password-reset'
|
|
7
|
+
export * from './password-reset-request'
|
|
8
|
+
export * from './update-project-member'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { InviteFormErrorCode, useInviteForm } from '@contember/react-identity'
|
|
2
|
+
import { Button } from '../../ui/button'
|
|
3
|
+
import { Loader } from '../../ui/loader'
|
|
4
|
+
import { TenantFormError, TenantFormField, TenantFormLabel } from './common'
|
|
5
|
+
import { MembershipsControl, useIntrospectionRolesConfig } from './memberships-control'
|
|
6
|
+
import { dict } from '../../dict'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const InviteFormFields = ({ projectSlug }: {projectSlug: string}) => {
|
|
10
|
+
const form = useInviteForm()
|
|
11
|
+
return (
|
|
12
|
+
<div className="relative flex flex-col gap-2">
|
|
13
|
+
{form.state === 'submitting' ? <Loader position="absolute" /> : null}
|
|
14
|
+
|
|
15
|
+
<TenantFormError
|
|
16
|
+
form={form} messages={dict.tenant.invite.errorMessages}
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<TenantFormField
|
|
20
|
+
form={form} messages={dict.tenant.invite.errorMessages} field="email"
|
|
21
|
+
type="email" required autoFocus
|
|
22
|
+
>
|
|
23
|
+
{dict.tenant.invite.email}
|
|
24
|
+
</TenantFormField>
|
|
25
|
+
|
|
26
|
+
<TenantFormField
|
|
27
|
+
form={form} messages={dict.tenant.invite.errorMessages} field="name"
|
|
28
|
+
type="text"
|
|
29
|
+
>
|
|
30
|
+
{dict.tenant.invite.name}
|
|
31
|
+
</TenantFormField>
|
|
32
|
+
|
|
33
|
+
<TenantFormLabel form={form} field="memberships">{dict.tenant.invite.roles}</TenantFormLabel>
|
|
34
|
+
<TenantFormError form={form} messages={dict.tenant.invite.errorMessages} field="memberships" />
|
|
35
|
+
<MembershipsControl
|
|
36
|
+
memberships={form.values.memberships}
|
|
37
|
+
setMemberships={it => form.setValue('memberships', it)}
|
|
38
|
+
roles={useIntrospectionRolesConfig(projectSlug)}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
<Button type="submit" className="w-full" disabled={form.state === 'submitting'}>
|
|
42
|
+
{dict.tenant.invite.submit}
|
|
43
|
+
</Button>
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { LoginFormErrorCode, useLoginForm } from '@contember/react-identity'
|
|
2
|
+
import { Button } from '../../ui/button'
|
|
3
|
+
import { Loader } from '../../ui/loader'
|
|
4
|
+
import { TenantFormError, TenantFormField } from './common'
|
|
5
|
+
import { dict } from '../../dict'
|
|
6
|
+
import { Link } from '@contember/interface'
|
|
7
|
+
|
|
8
|
+
export const LoginFormFields = () => {
|
|
9
|
+
const form = useLoginForm()
|
|
10
|
+
const fieldErrors = form.errors.map(it => it.field)
|
|
11
|
+
return (
|
|
12
|
+
<div className="relative flex flex-col gap-4">
|
|
13
|
+
{form.state === 'success' || form.state === 'submitting' ? <Loader position="absolute" /> : null}
|
|
14
|
+
|
|
15
|
+
<TenantFormError
|
|
16
|
+
form={form} messages={dict.tenant.login.errorMessages}
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<TenantFormField
|
|
20
|
+
form={form} messages={dict.tenant.login.errorMessages} field="email"
|
|
21
|
+
type="email" required autoFocus={form.state === 'initial'} readOnly={form.state === 'otp-required'} placeholder="me@example.com" autoComplete="email"
|
|
22
|
+
>
|
|
23
|
+
{dict.tenant.login.email}
|
|
24
|
+
</TenantFormField>
|
|
25
|
+
|
|
26
|
+
<TenantFormField
|
|
27
|
+
form={form} messages={dict.tenant.login.errorMessages} field="password" autoComplete="current-password"
|
|
28
|
+
type="password" required readOnly={form.state === 'otp-required'}
|
|
29
|
+
>
|
|
30
|
+
{dict.tenant.login.password}
|
|
31
|
+
<Link to="resetRequest">
|
|
32
|
+
<a className="float-end underline text-gray-600 text-sm font-normal">
|
|
33
|
+
{dict.tenant.login.forgotPassword}
|
|
34
|
+
</a>
|
|
35
|
+
</Link>
|
|
36
|
+
</TenantFormField>
|
|
37
|
+
|
|
38
|
+
{(form.state === 'otp-required' || fieldErrors.includes('otpToken')) && (
|
|
39
|
+
<TenantFormField
|
|
40
|
+
form={form} messages={dict.tenant.login.errorMessages} field="otpToken" autoComplete="one-time-code"
|
|
41
|
+
type="text" required autoFocus maxLength={6}
|
|
42
|
+
>
|
|
43
|
+
{dict.tenant.login.otpToken}
|
|
44
|
+
</TenantFormField>
|
|
45
|
+
)}
|
|
46
|
+
|
|
47
|
+
<Button type="submit" className="w-full" disabled={form.state === 'submitting'}>
|
|
48
|
+
{dict.tenant.login.login}
|
|
49
|
+
</Button>
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { MembershipInput } from '@contember/graphql-client-tenant'
|
|
2
|
+
import { Button } from '../../ui/button'
|
|
3
|
+
import { PlusIcon, TrashIcon } from 'lucide-react'
|
|
4
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '../../ui/dropdown'
|
|
5
|
+
import { Fragment, ReactNode, useMemo } from 'react'
|
|
6
|
+
import { useProjectRolesDefinitionQuery, useTenantQueryLoader } from '@contember/react-client-tenant'
|
|
7
|
+
import { Textarea } from '../../ui/textarea'
|
|
8
|
+
|
|
9
|
+
export type VariableRendererProps = { value: readonly string[]; onChange: (newValues: readonly string[]) => void }
|
|
10
|
+
export type RolesConfig = {
|
|
11
|
+
[K in string]: {
|
|
12
|
+
label: ReactNode
|
|
13
|
+
variables: {
|
|
14
|
+
[K in string]: {
|
|
15
|
+
label: ReactNode
|
|
16
|
+
render: React.ComponentType<VariableRendererProps>
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface MembershipsControlProps {
|
|
23
|
+
memberships: readonly MembershipInput[]
|
|
24
|
+
setMemberships: (memberships: MembershipInput[]) => void
|
|
25
|
+
roles?: RolesConfig
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const MembershipsControl = ({ setMemberships, memberships, roles }: MembershipsControlProps) => {
|
|
29
|
+
const remainingRoles = roles ? Object.keys(roles).filter(role => !memberships.some(it => it.role === role)) : []
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className="flex flex-col gap-4">
|
|
33
|
+
{memberships.map(membership => {
|
|
34
|
+
const role = roles?.[membership.role]
|
|
35
|
+
return (
|
|
36
|
+
<div key={membership.role} className="border rounded p-4">
|
|
37
|
+
<div className="flex justify-between">
|
|
38
|
+
<h2 className="font-semibold">{role?.label ?? membership.role}</h2>
|
|
39
|
+
<Button onClick={() => setMemberships(memberships.filter(it => it.role !== membership.role))} variant="destructive" type="button">
|
|
40
|
+
<TrashIcon className="w-3 h-3" />
|
|
41
|
+
</Button>
|
|
42
|
+
</div>
|
|
43
|
+
<div>
|
|
44
|
+
{Object.entries(role?.variables ?? {}).map(([variableName, variableConfig]) => {
|
|
45
|
+
const value = membership.variables.find(it => it.name === variableName)?.values ?? []
|
|
46
|
+
const VariableComponent = variableConfig.render
|
|
47
|
+
return (
|
|
48
|
+
<Fragment key={variableName}>
|
|
49
|
+
<h3>{variableConfig.label}</h3>
|
|
50
|
+
<div>
|
|
51
|
+
<VariableComponent
|
|
52
|
+
key={variableName}
|
|
53
|
+
value={value}
|
|
54
|
+
onChange={newValues => {
|
|
55
|
+
setMemberships(memberships.map(it =>
|
|
56
|
+
it.role !== membership.role ? it : {
|
|
57
|
+
...it,
|
|
58
|
+
variables: [
|
|
59
|
+
...it.variables.filter(it => it.name !== variableName),
|
|
60
|
+
{ name: variableName, values: newValues },
|
|
61
|
+
],
|
|
62
|
+
}),
|
|
63
|
+
)
|
|
64
|
+
}} />
|
|
65
|
+
</div>
|
|
66
|
+
</Fragment>
|
|
67
|
+
)
|
|
68
|
+
})}
|
|
69
|
+
{membership.variables.map(variable => {
|
|
70
|
+
if (role?.variables[variable.name]) {
|
|
71
|
+
return null
|
|
72
|
+
}
|
|
73
|
+
return (
|
|
74
|
+
<Fragment key={variable.name}>
|
|
75
|
+
<h3>{variable.name}</h3>
|
|
76
|
+
<div>{variable.values.map(it => <div key={it}>{it}</div>)}</div>
|
|
77
|
+
</Fragment>
|
|
78
|
+
)
|
|
79
|
+
})}
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
})}
|
|
84
|
+
<div>
|
|
85
|
+
{remainingRoles.length ? <DropdownMenu>
|
|
86
|
+
<DropdownMenuTrigger>
|
|
87
|
+
<Button variant="outline"><PlusIcon className="w-3 h-3" /></Button>
|
|
88
|
+
</DropdownMenuTrigger>
|
|
89
|
+
<DropdownMenuContent>
|
|
90
|
+
{remainingRoles.map(role => <DropdownMenuItem key={role} onClick={() => setMemberships([...memberships, { role: role, variables: [] }])}>{roles?.[role].label}</DropdownMenuItem>)}
|
|
91
|
+
</DropdownMenuContent>
|
|
92
|
+
</DropdownMenu> : null}
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const useIntrospectionRolesConfig = (projectSlug: string): RolesConfig | undefined => {
|
|
99
|
+
const [result] = useTenantQueryLoader(useProjectRolesDefinitionQuery(), { slug: projectSlug })
|
|
100
|
+
return useMemo(() => {
|
|
101
|
+
if (result.state !== 'success') {
|
|
102
|
+
return undefined
|
|
103
|
+
}
|
|
104
|
+
const roles = result.data
|
|
105
|
+
const rolesConfig: RolesConfig = {}
|
|
106
|
+
for (const role of roles) {
|
|
107
|
+
const variables: RolesConfig[string]['variables'] = {}
|
|
108
|
+
for (const variable of role.variables) {
|
|
109
|
+
if (variable.__typename === 'RolePredefinedVariableDefinition') {
|
|
110
|
+
continue
|
|
111
|
+
}
|
|
112
|
+
variables[variable.name] = {
|
|
113
|
+
label: variable.name,
|
|
114
|
+
render: VariablesEditor,
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
rolesConfig[role.name] = {
|
|
118
|
+
label: role.name,
|
|
119
|
+
variables: variables,
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return rolesConfig
|
|
123
|
+
}, [result])
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const VariablesEditor = ({ value, onChange }: VariableRendererProps) => {
|
|
127
|
+
return <Textarea value={value.join('\n')} onChange={e => onChange(e.target.value.split('\n').filter(Boolean))} />
|
|
128
|
+
}
|
package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset-request.tsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { usePasswordResetRequestForm } from '@contember/react-identity'
|
|
2
|
+
import { Button } from '../../ui/button'
|
|
3
|
+
import { Loader } from '../../ui/loader'
|
|
4
|
+
import { TenantFormError, TenantFormField } from './common'
|
|
5
|
+
import { dict } from '../../dict'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const PasswordResetRequestFormFields = () => {
|
|
9
|
+
const form = usePasswordResetRequestForm()
|
|
10
|
+
return (
|
|
11
|
+
<div className="relative flex flex-col gap-2">
|
|
12
|
+
{form.state === 'success' || form.state === 'submitting' ? <Loader position="absolute" /> : null}
|
|
13
|
+
|
|
14
|
+
<TenantFormError
|
|
15
|
+
form={form} messages={dict.tenant.passwordResetRequest.errorMessages}
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
<TenantFormField
|
|
19
|
+
form={form} messages={dict.tenant.passwordResetRequest.errorMessages} field="email"
|
|
20
|
+
type="email" required autoFocus autoComplete="email"
|
|
21
|
+
>
|
|
22
|
+
{dict.tenant.passwordResetRequest.email}
|
|
23
|
+
</TenantFormField>
|
|
24
|
+
|
|
25
|
+
<Button type="submit" className="w-full" disabled={form.state === 'submitting'}>
|
|
26
|
+
{dict.tenant.passwordReset.submit}
|
|
27
|
+
</Button>
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { usePasswordResetForm } from '@contember/react-identity'
|
|
2
|
+
import { Button } from '../../ui/button'
|
|
3
|
+
import { Loader } from '../../ui/loader'
|
|
4
|
+
import { TenantFormError, TenantFormField } from './common'
|
|
5
|
+
import { dict } from '../../dict'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const PasswordResetFormFields = ({ hasToken }: { hasToken?: boolean }) => {
|
|
9
|
+
const form = usePasswordResetForm()
|
|
10
|
+
return (
|
|
11
|
+
<div className="relative flex flex-col gap-2">
|
|
12
|
+
{form.state === 'success' || form.state === 'submitting' ? <Loader position="absolute" /> : null}
|
|
13
|
+
|
|
14
|
+
<TenantFormError
|
|
15
|
+
form={form} messages={dict.tenant.passwordReset.errorMessages}
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
<TenantFormField
|
|
19
|
+
form={form} messages={dict.tenant.passwordReset.errorMessages} field="token"
|
|
20
|
+
type="text" required readOnly={hasToken} autoComplete="off"
|
|
21
|
+
>
|
|
22
|
+
{dict.tenant.passwordReset.token}
|
|
23
|
+
</TenantFormField>
|
|
24
|
+
|
|
25
|
+
<TenantFormField
|
|
26
|
+
form={form} messages={dict.tenant.passwordReset.errorMessages} field="password"
|
|
27
|
+
type="password" required autoFocus autoComplete="new-password"
|
|
28
|
+
>
|
|
29
|
+
{dict.tenant.passwordReset.password}
|
|
30
|
+
</TenantFormField>
|
|
31
|
+
|
|
32
|
+
<TenantFormField
|
|
33
|
+
form={form} messages={dict.tenant.passwordReset.errorMessages} field="passwordConfirmation"
|
|
34
|
+
type="password" required autoComplete="new-password"
|
|
35
|
+
>
|
|
36
|
+
{dict.tenant.passwordReset.passwordConfirmation}
|
|
37
|
+
</TenantFormField>
|
|
38
|
+
|
|
39
|
+
<Button type="submit" className="w-full" disabled={form.state === 'submitting'}>
|
|
40
|
+
{dict.tenant.passwordReset.submit}
|
|
41
|
+
</Button>
|
|
42
|
+
</div>
|
|
43
|
+
)
|
|
44
|
+
}
|
package/resources/templates/template-workspace/admin/lib/tenant/forms/update-project-member.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useUpdateProjectMemberForm } from '@contember/react-identity'
|
|
2
|
+
import { Button } from '../../ui/button'
|
|
3
|
+
import { Loader } from '../../ui/loader'
|
|
4
|
+
import { TenantFormError, TenantFormLabel } from './common'
|
|
5
|
+
import { MembershipsControl, useIntrospectionRolesConfig } from './memberships-control'
|
|
6
|
+
import { dict } from '../../dict'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const UpdateProjectMemberFormFields = ({ projectSlug }: {projectSlug: string}) => {
|
|
10
|
+
const form = useUpdateProjectMemberForm()
|
|
11
|
+
return (
|
|
12
|
+
<div className="relative flex flex-col gap-2">
|
|
13
|
+
{form.state === 'submitting' || form.state === 'loading' ? <Loader position="absolute" /> : null}
|
|
14
|
+
|
|
15
|
+
<TenantFormError
|
|
16
|
+
form={form} messages={dict.tenant.updateProjectMember.errorMessages}
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<TenantFormLabel form={form} field="memberships">{dict.tenant.updateProjectMember.roles}</TenantFormLabel>
|
|
20
|
+
<TenantFormError form={form} messages={dict.tenant.updateProjectMember.errorMessages} field="memberships" />
|
|
21
|
+
<MembershipsControl
|
|
22
|
+
memberships={form.values?.memberships ?? []}
|
|
23
|
+
setMemberships={it => form.setValue('memberships', it)}
|
|
24
|
+
roles={useIntrospectionRolesConfig(projectSlug)}
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
<Button type="submit" className="w-full" disabled={form.state === 'submitting'}>
|
|
28
|
+
{dict.tenant.updateProjectMember.submit}
|
|
29
|
+
</Button>
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as TenantApi from '@contember/graphql-client-tenant'
|
|
2
|
+
import { useTenantApi } from '@contember/react-client-tenant'
|
|
3
|
+
import { useCallback } from 'react'
|
|
4
|
+
|
|
5
|
+
const InviteFetcher = TenantApi.inviteResponse$$
|
|
6
|
+
.error(TenantApi.inviteError$$)
|
|
7
|
+
.result(TenantApi.inviteResult$$.person(TenantApi.person$$.identity(TenantApi.identity$$.id)))
|
|
8
|
+
|
|
9
|
+
export type InviteErrorCodes = TenantApi.InviteErrorCode
|
|
10
|
+
|
|
11
|
+
export const useInvite = () => {
|
|
12
|
+
const api = useTenantApi()
|
|
13
|
+
|
|
14
|
+
return useCallback(async (variables: {
|
|
15
|
+
email: string,
|
|
16
|
+
projectSlug: string,
|
|
17
|
+
memberships: TenantApi.MembershipInput[],
|
|
18
|
+
}) => {
|
|
19
|
+
return (await api(TenantApi.mutation$.invite(InviteFetcher), {
|
|
20
|
+
variables: {
|
|
21
|
+
options: {
|
|
22
|
+
method: 'RESET_PASSWORD',
|
|
23
|
+
},
|
|
24
|
+
...variables,
|
|
25
|
+
},
|
|
26
|
+
})).invite
|
|
27
|
+
}, [api])
|
|
28
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import { useInvite } from './useInvite'
|
|
4
|
+
import { ToastContent, useShowToast } from '../../toast'
|
|
5
|
+
import { useProjectSlug } from '@contember/react-client'
|
|
6
|
+
import { EntityAccessor } from '@contember/interface'
|
|
7
|
+
import * as TenantApi from '@contember/graphql-client-tenant'
|
|
8
|
+
import { useReferentiallyStableCallback } from '@contember/react-utils'
|
|
9
|
+
import { dict } from '../../dict'
|
|
10
|
+
|
|
11
|
+
export const useInviteUser = ({ emailField, personIdField, memberships }: {
|
|
12
|
+
personIdField: string
|
|
13
|
+
emailField: string
|
|
14
|
+
memberships: TenantApi.MembershipInput[]
|
|
15
|
+
}) => {
|
|
16
|
+
const invite = useInvite()
|
|
17
|
+
const project = useProjectSlug()
|
|
18
|
+
const toast = useShowToast()
|
|
19
|
+
|
|
20
|
+
return useReferentiallyStableCallback(async (getAccessor: () => EntityAccessor) => {
|
|
21
|
+
const accessor = getAccessor()
|
|
22
|
+
const personId = accessor.getField<string>(personIdField)
|
|
23
|
+
const email = accessor.getField<string>(emailField)
|
|
24
|
+
|
|
25
|
+
if (personId.value || !email.value) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const result = await invite({
|
|
30
|
+
email: email.value,
|
|
31
|
+
projectSlug: project!,
|
|
32
|
+
memberships: memberships,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
if (!result?.ok || !result?.result) {
|
|
37
|
+
return toast(<ToastContent title={dict.inviteErrors[result?.error?.code ?? 'fallback']} />, {
|
|
38
|
+
type: 'error',
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
personId.updateValue(result.result.person.id)
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
}
|