@contember/create 2.2.0-alpha.2 → 2.2.0-alpha.4
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/CLAUDE.md +22 -0
- package/dist/development/run.cjs +7 -7
- package/dist/development/run.cjs.map +1 -1
- package/dist/development/run.js +8 -8
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs +27 -13
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js +28 -14
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +72 -60
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js +72 -60
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/run.cjs +7 -7
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js +8 -8
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs +27 -13
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js +28 -14
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +72 -60
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js +72 -60
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/types/commands/WorkspaceCreateCommand.d.ts +15 -3
- package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/types/lib/FileSystem.d.ts.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts +9 -1
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/resources/templates/default/README.md +3 -1
- package/resources/templates/default/admin/app/components/navigation.tsx +95 -8
- package/resources/templates/default/admin/app/pages/tenant.tsx +328 -77
- package/resources/templates/default/admin/entrypoint/components/login.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLink.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLinkSent.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/passwordReset.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequest.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequestSuccess.tsx +1 -1
- package/resources/templates/default/admin/lib/tenant/config/auth-policy-list.tsx +86 -0
- package/resources/templates/default/admin/lib/tenant/config/common.tsx +71 -0
- package/resources/templates/default/admin/lib/tenant/config/identity-provider-list.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/config/index.ts +5 -0
- package/resources/templates/default/admin/lib/tenant/config/mail-template-list.tsx +108 -0
- package/resources/templates/default/admin/lib/tenant/config/tenant-config-view.tsx +182 -0
- package/resources/templates/default/admin/lib/tenant/dict.ts +443 -4
- package/resources/templates/default/admin/lib/tenant/errors.ts +10 -0
- package/resources/templates/default/admin/lib/tenant/forms/add-project-member.tsx +57 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-my-profile.tsx +40 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-profile.tsx +55 -0
- package/resources/templates/default/admin/lib/tenant/forms/common.tsx +9 -2
- package/resources/templates/default/admin/lib/tenant/forms/create-global-api-key.tsx +69 -0
- package/resources/templates/default/admin/lib/tenant/forms/global-roles-control.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/forms/index.ts +11 -0
- package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +42 -4
- package/resources/templates/default/admin/lib/tenant/forms/login.tsx +4 -10
- package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +3 -1
- package/resources/templates/default/admin/lib/tenant/forms/mfa-code-fields.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin.tsx +4 -10
- package/resources/templates/default/admin/lib/tenant/forms/set-person-password.tsx +58 -0
- package/resources/templates/default/admin/lib/tenant/forms/set-project-secret.tsx +59 -0
- package/resources/templates/default/admin/lib/tenant/forms/sign-up.tsx +73 -0
- package/resources/templates/default/admin/lib/tenant/hooks/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/idp/identity-provider-connections.tsx +124 -0
- package/resources/templates/default/admin/lib/tenant/idp/index.ts +1 -0
- package/resources/templates/default/admin/lib/tenant/index.ts +7 -0
- package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +160 -22
- package/resources/templates/default/admin/lib/tenant/listing/auth-log-list.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/global-api-key-list.tsx +149 -0
- package/resources/templates/default/admin/lib/tenant/listing/index.ts +7 -0
- package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +1 -1
- package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +20 -11
- package/resources/templates/default/admin/lib/tenant/listing/mfa.tsx +29 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-actions.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-detail.tsx +141 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +13 -2
- package/resources/templates/default/admin/lib/tenant/listing/persons-list.tsx +128 -0
- package/resources/templates/default/admin/lib/tenant/listing/project-secret-list.tsx +82 -0
- package/resources/templates/default/admin/lib/tenant/otp/backup-codes.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/otp/email-otp-setup.tsx +133 -0
- package/resources/templates/default/admin/lib/tenant/otp/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/security/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/security/passwordless-toggle.tsx +63 -0
- package/resources/templates/default/admin/lib/tenant/security/session-list.tsx +143 -0
- package/resources/templates/default/admin/package.json +1 -0
- package/resources/templates/default/docker/object-storage/README.md +13 -0
- package/resources/templates/default/docker/object-storage/identities.json +13 -0
- package/resources/templates/default/docker-compose.yaml +29 -7
- package/src/commands/WorkspaceCreateCommand.ts +42 -14
- package/src/lib/TemplateInstaller.ts +87 -69
- package/src/run.ts +8 -7
- package/tests/cases/unit/create-process.test.ts +66 -0
- package/tests/cases/unit/template-installer-cleanup.test.ts +150 -0
- package/tests/cases/unit/workspace-create.test.ts +81 -0
|
@@ -10,6 +10,7 @@ import { useProjectSlug } from '@contember/react-client'
|
|
|
10
10
|
import { UpdateProjectMemberForm } from '@contember/interface'
|
|
11
11
|
import { ToastContent, useShowToast } from '~/lib'
|
|
12
12
|
import { dict } from '../dict.js'
|
|
13
|
+
import { actionErrorMessage } from '../errors.js'
|
|
13
14
|
import { MemberDeleteDialog } from './member-delete-dialog.js'
|
|
14
15
|
import { Dialog, DialogContent, DialogTrigger } from '~/lib'
|
|
15
16
|
import { RolesConfig, UpdateProjectMemberFormFields } from '../forms/index.js'
|
|
@@ -27,13 +28,17 @@ export interface MemberListProps {
|
|
|
27
28
|
tableHeaders: string[]
|
|
28
29
|
controller?: { current?: MemberListController }
|
|
29
30
|
roles?: RolesConfig
|
|
31
|
+
canUpdateMember?: boolean
|
|
32
|
+
canRemoveMember?: boolean
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
export interface MemberListController {
|
|
33
36
|
refresh: () => void
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
export const MemberList = (
|
|
39
|
+
export const MemberList = (
|
|
40
|
+
{ filter, labels, tableColumns, controller, tableHeaders, roles, canUpdateMember, canRemoveMember }: MemberListProps,
|
|
41
|
+
) => {
|
|
37
42
|
const projectSlug = useProjectSlug()!
|
|
38
43
|
const [page, setPage] = useState(0)
|
|
39
44
|
|
|
@@ -52,8 +57,8 @@ export const MemberList = ({ filter, labels, tableColumns, controller, tableHead
|
|
|
52
57
|
refresh()
|
|
53
58
|
showToast(<ToastContent>{labels.deleted}</ToastContent>, { type: 'success' })
|
|
54
59
|
}
|
|
55
|
-
const onDeleteError = () => {
|
|
56
|
-
showToast(<ToastContent>{labels.deleteFailed}</ToastContent>, { type: 'error' })
|
|
60
|
+
const onDeleteError = ({ code }: { code: string }) => {
|
|
61
|
+
showToast(<ToastContent>{actionErrorMessage(code, labels.deleteFailed)}</ToastContent>, { type: 'error' })
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
switch (query.state) {
|
|
@@ -95,14 +100,18 @@ export const MemberList = ({ filter, labels, tableColumns, controller, tableHead
|
|
|
95
100
|
{tableColumns(it)}
|
|
96
101
|
<TableCell key="role">{it.memberships.map((m: any) => m.role).join(', ')}</TableCell>
|
|
97
102
|
<TableCell className="space-x-2 whitespace-nowrap">
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
{canRemoveMember !== false && (
|
|
104
|
+
<MemberDeleteDialog
|
|
105
|
+
identityId={it.identity.id}
|
|
106
|
+
projectSlug={projectSlug}
|
|
107
|
+
onSuccess={onDeleteMember}
|
|
108
|
+
onError={onDeleteError}
|
|
109
|
+
title={labels.deleteConfirmation}
|
|
110
|
+
/>
|
|
111
|
+
)}
|
|
112
|
+
{canUpdateMember !== false && (
|
|
113
|
+
<EditMembershipDialog projectSlug={projectSlug} identityId={it.identity.id} onSuccess={refresh} roles={roles} />
|
|
114
|
+
)}
|
|
106
115
|
</TableCell>
|
|
107
116
|
</TableRow>
|
|
108
117
|
))}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { dict } from '../dict.js'
|
|
3
|
+
|
|
4
|
+
export interface MfaBadgesProps {
|
|
5
|
+
otpEnabled?: boolean | null
|
|
6
|
+
emailOtpEnabled?: boolean | null
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const MfaBadges = ({ otpEnabled, emailOtpEnabled }: MfaBadgesProps) => {
|
|
10
|
+
const methods: string[] = []
|
|
11
|
+
if (otpEnabled) {
|
|
12
|
+
methods.push(dict.tenant.mfa.totp)
|
|
13
|
+
}
|
|
14
|
+
if (emailOtpEnabled) {
|
|
15
|
+
methods.push(dict.tenant.mfa.email)
|
|
16
|
+
}
|
|
17
|
+
if (methods.length === 0) {
|
|
18
|
+
return <span className="text-gray-400 italic">{dict.tenant.mfa.none}</span>
|
|
19
|
+
}
|
|
20
|
+
return (
|
|
21
|
+
<span className="flex gap-1 flex-wrap">
|
|
22
|
+
{methods.map(method => (
|
|
23
|
+
<span key={method} className="inline-flex items-center border border-gray-200 rounded-sm px-1.5 py-0.5 text-xs">
|
|
24
|
+
{method}
|
|
25
|
+
</span>
|
|
26
|
+
))}
|
|
27
|
+
</span>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { ReactNode, useState } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
AlertDialog,
|
|
5
|
+
AlertDialogAction,
|
|
6
|
+
AlertDialogCancel,
|
|
7
|
+
AlertDialogContent,
|
|
8
|
+
AlertDialogFooter,
|
|
9
|
+
AlertDialogHeader,
|
|
10
|
+
AlertDialogTitle,
|
|
11
|
+
AlertDialogTrigger,
|
|
12
|
+
Button,
|
|
13
|
+
Input,
|
|
14
|
+
Label,
|
|
15
|
+
ToastContent,
|
|
16
|
+
useShowToast,
|
|
17
|
+
} from '~/lib'
|
|
18
|
+
import { BanIcon, LogOutIcon, ShieldOffIcon, UserCheckIcon } from 'lucide-react'
|
|
19
|
+
import { DisablePersonTrigger, EnablePersonTrigger, ForceSignOutPersonTrigger, ResetPersonMfaTrigger } from '@contember/interface'
|
|
20
|
+
import { dict } from '../dict.js'
|
|
21
|
+
import { actionErrorMessage } from '../errors.js'
|
|
22
|
+
|
|
23
|
+
export interface PersonActionProps {
|
|
24
|
+
personId: string
|
|
25
|
+
onSuccess: () => void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Shared shell: an icon button opening a confirm dialog whose action slot hosts the tenant trigger. */
|
|
29
|
+
const PersonActionDialog = ({ icon, title, confirmation, confirmLabel, destructive, children, action }: {
|
|
30
|
+
icon: ReactNode
|
|
31
|
+
title: string
|
|
32
|
+
confirmation: string
|
|
33
|
+
confirmLabel: string
|
|
34
|
+
destructive?: boolean
|
|
35
|
+
children?: ReactNode
|
|
36
|
+
action: (props: { children: React.ReactElement }) => ReactNode
|
|
37
|
+
}) => {
|
|
38
|
+
const [open, setOpen] = useState(false)
|
|
39
|
+
return (
|
|
40
|
+
<AlertDialog open={open} onOpenChange={setOpen}>
|
|
41
|
+
<AlertDialogTrigger asChild>
|
|
42
|
+
<Button variant={destructive ? 'destructive' : 'outline'} size="sm" title={title}>
|
|
43
|
+
{icon}
|
|
44
|
+
<span className="sr-only">{title}</span>
|
|
45
|
+
</Button>
|
|
46
|
+
</AlertDialogTrigger>
|
|
47
|
+
<AlertDialogContent>
|
|
48
|
+
<AlertDialogHeader>
|
|
49
|
+
<AlertDialogTitle>{confirmation}</AlertDialogTitle>
|
|
50
|
+
</AlertDialogHeader>
|
|
51
|
+
{children}
|
|
52
|
+
<AlertDialogFooter>
|
|
53
|
+
<AlertDialogCancel>{dict.tenant.personActions.cancel}</AlertDialogCancel>
|
|
54
|
+
<AlertDialogAction asChild>
|
|
55
|
+
{action({
|
|
56
|
+
children: <Button variant={destructive ? 'destructive' : 'default'}>{confirmLabel}</Button>,
|
|
57
|
+
})}
|
|
58
|
+
</AlertDialogAction>
|
|
59
|
+
</AlertDialogFooter>
|
|
60
|
+
</AlertDialogContent>
|
|
61
|
+
</AlertDialog>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const DisablePersonAction = ({ personId, onSuccess }: PersonActionProps) => {
|
|
66
|
+
const showToast = useShowToast()
|
|
67
|
+
return (
|
|
68
|
+
<PersonActionDialog
|
|
69
|
+
icon={<BanIcon className="w-3 h-3" />}
|
|
70
|
+
title={dict.tenant.personActions.disableTitle}
|
|
71
|
+
confirmation={dict.tenant.personActions.disableConfirmation}
|
|
72
|
+
confirmLabel={dict.tenant.personActions.disable}
|
|
73
|
+
destructive
|
|
74
|
+
action={({ children }) => (
|
|
75
|
+
<DisablePersonTrigger
|
|
76
|
+
personId={personId}
|
|
77
|
+
onSuccess={() => {
|
|
78
|
+
showToast(<ToastContent>{dict.tenant.personActions.disableSuccess}</ToastContent>, { type: 'success' })
|
|
79
|
+
onSuccess()
|
|
80
|
+
}}
|
|
81
|
+
onError={({ code }) =>
|
|
82
|
+
showToast(<ToastContent>{actionErrorMessage(code, dict.tenant.personActions.disableFailed)}</ToastContent>, { type: 'error' })}
|
|
83
|
+
>
|
|
84
|
+
{children}
|
|
85
|
+
</DisablePersonTrigger>
|
|
86
|
+
)}
|
|
87
|
+
/>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const EnablePersonAction = ({ personId, onSuccess }: PersonActionProps) => {
|
|
92
|
+
const showToast = useShowToast()
|
|
93
|
+
return (
|
|
94
|
+
<PersonActionDialog
|
|
95
|
+
icon={<UserCheckIcon className="w-3 h-3" />}
|
|
96
|
+
title={dict.tenant.personActions.enableTitle}
|
|
97
|
+
confirmation={dict.tenant.personActions.enableConfirmation}
|
|
98
|
+
confirmLabel={dict.tenant.personActions.enable}
|
|
99
|
+
action={({ children }) => (
|
|
100
|
+
<EnablePersonTrigger
|
|
101
|
+
personId={personId}
|
|
102
|
+
onSuccess={() => {
|
|
103
|
+
showToast(<ToastContent>{dict.tenant.personActions.enableSuccess}</ToastContent>, { type: 'success' })
|
|
104
|
+
onSuccess()
|
|
105
|
+
}}
|
|
106
|
+
onError={({ code }) =>
|
|
107
|
+
showToast(<ToastContent>{actionErrorMessage(code, dict.tenant.personActions.enableFailed)}</ToastContent>, { type: 'error' })}
|
|
108
|
+
>
|
|
109
|
+
{children}
|
|
110
|
+
</EnablePersonTrigger>
|
|
111
|
+
)}
|
|
112
|
+
/>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const ForceSignOutPersonAction = ({ personId, onSuccess }: PersonActionProps) => {
|
|
117
|
+
const showToast = useShowToast()
|
|
118
|
+
const [reason, setReason] = useState('')
|
|
119
|
+
return (
|
|
120
|
+
<PersonActionDialog
|
|
121
|
+
icon={<LogOutIcon className="w-3 h-3" />}
|
|
122
|
+
title={dict.tenant.personActions.forceSignOutTitle}
|
|
123
|
+
confirmation={dict.tenant.personActions.forceSignOutConfirmation}
|
|
124
|
+
confirmLabel={dict.tenant.personActions.forceSignOut}
|
|
125
|
+
action={({ children }) => (
|
|
126
|
+
<ForceSignOutPersonTrigger
|
|
127
|
+
personId={personId}
|
|
128
|
+
reason={reason || undefined}
|
|
129
|
+
onSuccess={() => {
|
|
130
|
+
setReason('')
|
|
131
|
+
showToast(<ToastContent>{dict.tenant.personActions.forceSignOutSuccess}</ToastContent>, { type: 'success' })
|
|
132
|
+
onSuccess()
|
|
133
|
+
}}
|
|
134
|
+
onError={({ code }) =>
|
|
135
|
+
showToast(<ToastContent>{actionErrorMessage(code, dict.tenant.personActions.forceSignOutFailed)}</ToastContent>, { type: 'error' })}
|
|
136
|
+
>
|
|
137
|
+
{children}
|
|
138
|
+
</ForceSignOutPersonTrigger>
|
|
139
|
+
)}
|
|
140
|
+
>
|
|
141
|
+
<div className="flex flex-col gap-2">
|
|
142
|
+
<Label htmlFor="force-sign-out-reason">{dict.tenant.personActions.forceSignOutReason}</Label>
|
|
143
|
+
<Input
|
|
144
|
+
id="force-sign-out-reason"
|
|
145
|
+
type="text"
|
|
146
|
+
value={reason}
|
|
147
|
+
placeholder={dict.tenant.personActions.forceSignOutReasonPlaceholder}
|
|
148
|
+
onChange={e => setReason(e.target.value)}
|
|
149
|
+
/>
|
|
150
|
+
</div>
|
|
151
|
+
</PersonActionDialog>
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export const ResetPersonMfaAction = ({ personId, onSuccess }: PersonActionProps) => {
|
|
156
|
+
const showToast = useShowToast()
|
|
157
|
+
return (
|
|
158
|
+
<PersonActionDialog
|
|
159
|
+
icon={<ShieldOffIcon className="w-3 h-3" />}
|
|
160
|
+
title={dict.tenant.personActions.resetMfaTitle}
|
|
161
|
+
confirmation={dict.tenant.personActions.resetMfaConfirmation}
|
|
162
|
+
confirmLabel={dict.tenant.personActions.resetMfa}
|
|
163
|
+
destructive
|
|
164
|
+
action={({ children }) => (
|
|
165
|
+
<ResetPersonMfaTrigger
|
|
166
|
+
personId={personId}
|
|
167
|
+
onSuccess={() => {
|
|
168
|
+
showToast(<ToastContent>{dict.tenant.personActions.resetMfaSuccess}</ToastContent>, { type: 'success' })
|
|
169
|
+
onSuccess()
|
|
170
|
+
}}
|
|
171
|
+
onError={({ code }) =>
|
|
172
|
+
showToast(<ToastContent>{actionErrorMessage(code, dict.tenant.personActions.resetMfaFailed)}</ToastContent>, { type: 'error' })}
|
|
173
|
+
>
|
|
174
|
+
{children}
|
|
175
|
+
</ResetPersonMfaTrigger>
|
|
176
|
+
)}
|
|
177
|
+
/>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
3
|
+
import { Loader, Table, TableCell, TableHead, TableHeader, TableRow, ToastContent, useShowToast } from '~/lib'
|
|
4
|
+
import { usePersonQuery, useTenantQueryLoader } from '@contember/react-client-tenant'
|
|
5
|
+
import { ChangePasswordForm, ChangeProfileForm } from '@contember/interface'
|
|
6
|
+
import { dict } from '../dict.js'
|
|
7
|
+
import { ChangeProfileFormFields, GlobalRolesControl, SetPersonPasswordFormFields } from '../forms/index.js'
|
|
8
|
+
import { SessionList } from '../security/index.js'
|
|
9
|
+
import { MfaBadges } from './mfa.js'
|
|
10
|
+
import { ResetPersonMfaAction } from './person-actions.js'
|
|
11
|
+
|
|
12
|
+
export interface PersonDetailController {
|
|
13
|
+
refresh: () => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PersonDetailProps {
|
|
17
|
+
personId: string
|
|
18
|
+
controller?: { current?: PersonDetailController }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const Section = ({ title, children }: { title: string; children: ReactNode }) => (
|
|
22
|
+
<div className="flex flex-col gap-2">
|
|
23
|
+
<h2 className="text-base font-semibold">{title}</h2>
|
|
24
|
+
{children}
|
|
25
|
+
</div>
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* `PersonDetail` is the administrator view of a single person — profile, password, 2FA, global roles, sessions
|
|
30
|
+
* and connected identity providers. The host application decides the surrounding layout.
|
|
31
|
+
*
|
|
32
|
+
* ## Example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <PersonDetail personId={personId} />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const PersonDetail = ({ personId, controller }: PersonDetailProps) => {
|
|
38
|
+
const [query, { refresh }] = useTenantQueryLoader(usePersonQuery(), { personId })
|
|
39
|
+
if (controller) {
|
|
40
|
+
controller.current = { refresh }
|
|
41
|
+
}
|
|
42
|
+
const showToast = useShowToast()
|
|
43
|
+
|
|
44
|
+
if (query.state === 'error') {
|
|
45
|
+
return <div className="text-destructive italic">{dict.tenant.personDetail.failedToLoadData}</div>
|
|
46
|
+
}
|
|
47
|
+
if (!('data' in query)) {
|
|
48
|
+
return (
|
|
49
|
+
<div className="relative min-h-24">
|
|
50
|
+
<Loader position="absolute" />
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
const person = query.data
|
|
55
|
+
if (person === null) {
|
|
56
|
+
return <div className="text-gray-400 italic">{dict.tenant.personDetail.notFound}</div>
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className="relative flex flex-col gap-8">
|
|
61
|
+
{query.state !== 'success' && <Loader position="absolute" />}
|
|
62
|
+
|
|
63
|
+
<Section title={dict.tenant.personDetail.profile}>
|
|
64
|
+
<div className="flex flex-col gap-1">
|
|
65
|
+
<span className="text-sm font-medium">{dict.tenant.personDetail.identityId}</span>
|
|
66
|
+
<code className="select-all rounded bg-gray-100 px-2 py-1 text-xs">{person.identity.id}</code>
|
|
67
|
+
</div>
|
|
68
|
+
{/* keyed on the loaded values: TenantForm snapshots initialValues on mount, so a refresh would otherwise show stale fields */}
|
|
69
|
+
<ChangeProfileForm
|
|
70
|
+
key={`${person.email ?? ''} ${person.name ?? ''}`}
|
|
71
|
+
personId={personId}
|
|
72
|
+
initialValues={{ email: person.email ?? '', name: person.name ?? '' }}
|
|
73
|
+
onSuccess={() => {
|
|
74
|
+
refresh()
|
|
75
|
+
showToast(<ToastContent>{dict.tenant.personDetail.profileUpdated}</ToastContent>, { type: 'success' })
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<form className="grid gap-4">
|
|
79
|
+
<ChangeProfileFormFields />
|
|
80
|
+
</form>
|
|
81
|
+
</ChangeProfileForm>
|
|
82
|
+
</Section>
|
|
83
|
+
|
|
84
|
+
<Section title={dict.tenant.personDetail.password}>
|
|
85
|
+
<ChangePasswordForm
|
|
86
|
+
personId={personId}
|
|
87
|
+
onSuccess={() => showToast(<ToastContent>{dict.tenant.personDetail.passwordUpdated}</ToastContent>, { type: 'success' })}
|
|
88
|
+
>
|
|
89
|
+
<form className="grid gap-4">
|
|
90
|
+
<SetPersonPasswordFormFields />
|
|
91
|
+
</form>
|
|
92
|
+
</ChangePasswordForm>
|
|
93
|
+
</Section>
|
|
94
|
+
|
|
95
|
+
<Section title={dict.tenant.personDetail.mfa}>
|
|
96
|
+
<div className="flex gap-4 items-center">
|
|
97
|
+
<MfaBadges otpEnabled={person.otpEnabled} emailOtpEnabled={person.emailOtpEnabled} />
|
|
98
|
+
<ResetPersonMfaAction personId={personId} onSuccess={refresh} />
|
|
99
|
+
</div>
|
|
100
|
+
</Section>
|
|
101
|
+
|
|
102
|
+
<Section title={dict.tenant.personDetail.globalRoles}>
|
|
103
|
+
<GlobalRolesControl identityId={person.identity.id} roles={person.identity.roles ?? []} onChange={refresh} />
|
|
104
|
+
</Section>
|
|
105
|
+
|
|
106
|
+
<Section title={dict.tenant.personDetail.sessions}>
|
|
107
|
+
<SessionList personId={personId} />
|
|
108
|
+
</Section>
|
|
109
|
+
|
|
110
|
+
<Section title={dict.tenant.personDetail.identityProviders}>
|
|
111
|
+
<Table>
|
|
112
|
+
<TableHeader>
|
|
113
|
+
<TableRow>
|
|
114
|
+
<TableHead>{dict.tenant.personDetail.identityProvider}</TableHead>
|
|
115
|
+
<TableHead>{dict.tenant.personDetail.identityProviderAccount}</TableHead>
|
|
116
|
+
<TableHead>{dict.tenant.personDetail.identityProviderConnectedAt}</TableHead>
|
|
117
|
+
<TableHead>{dict.tenant.personDetail.identityProviderStatus}</TableHead>
|
|
118
|
+
</TableRow>
|
|
119
|
+
</TableHeader>
|
|
120
|
+
{person.identityProviders.length === 0 && (
|
|
121
|
+
<TableRow>
|
|
122
|
+
<TableCell colSpan={4}>{dict.tenant.personDetail.noIdentityProviders}</TableCell>
|
|
123
|
+
</TableRow>
|
|
124
|
+
)}
|
|
125
|
+
{person.identityProviders.map(connection => (
|
|
126
|
+
<TableRow key={connection.id}>
|
|
127
|
+
<TableCell className="font-medium">{connection.identityProvider.slug}</TableCell>
|
|
128
|
+
<TableCell>{connection.externalIdentifier}</TableCell>
|
|
129
|
+
<TableCell className="whitespace-nowrap">{new Date(connection.createdAt).toLocaleString()}</TableCell>
|
|
130
|
+
<TableCell>
|
|
131
|
+
{connection.identityProvider.disabledAt
|
|
132
|
+
? <span className="text-destructive">{dict.tenant.personDetail.identityProviderDisabled}</span>
|
|
133
|
+
: null}
|
|
134
|
+
</TableCell>
|
|
135
|
+
</TableRow>
|
|
136
|
+
))}
|
|
137
|
+
</Table>
|
|
138
|
+
</Section>
|
|
139
|
+
</div>
|
|
140
|
+
)
|
|
141
|
+
}
|
|
@@ -3,12 +3,20 @@ import * as React from 'react'
|
|
|
3
3
|
import { TableCell } from '~/lib'
|
|
4
4
|
import { dict } from '../dict.js'
|
|
5
5
|
import { MemberList, MemberListController } from './member-list.js'
|
|
6
|
+
import { MfaBadges } from './mfa.js'
|
|
6
7
|
import { RolesConfig } from '../forms/index.js'
|
|
7
8
|
|
|
8
9
|
const filter: ProjectMembersFilter = {
|
|
9
10
|
memberType: 'PERSON',
|
|
10
11
|
}
|
|
11
|
-
export const PersonList = (
|
|
12
|
+
export const PersonList = (
|
|
13
|
+
props: {
|
|
14
|
+
controller?: { current?: MemberListController }
|
|
15
|
+
roles?: RolesConfig
|
|
16
|
+
canUpdateMember?: boolean
|
|
17
|
+
canRemoveMember?: boolean
|
|
18
|
+
},
|
|
19
|
+
) => (
|
|
12
20
|
<MemberList
|
|
13
21
|
{...props}
|
|
14
22
|
filter={filter}
|
|
@@ -17,11 +25,14 @@ export const PersonList = (props: { controller?: { current?: MemberListControlle
|
|
|
17
25
|
deleted: dict.tenant.personList.deleted,
|
|
18
26
|
deleteFailed: dict.tenant.personList.deleteFailed,
|
|
19
27
|
}}
|
|
20
|
-
tableHeaders={[dict.tenant.personList.email, dict.tenant.personList.name]}
|
|
28
|
+
tableHeaders={[dict.tenant.personList.email, dict.tenant.personList.name, dict.tenant.personsList.mfa]}
|
|
21
29
|
tableColumns={it => (
|
|
22
30
|
<>
|
|
23
31
|
<TableCell key="email">{it.identity.person?.email ?? dict.tenant.personList.noEmail}</TableCell>
|
|
24
32
|
<TableCell key="name">{it.identity.person?.name ?? dict.tenant.personList.noName}</TableCell>
|
|
33
|
+
<TableCell key="mfa">
|
|
34
|
+
<MfaBadges otpEnabled={it.identity.person?.otpEnabled} emailOtpEnabled={it.identity.person?.emailOtpEnabled} />
|
|
35
|
+
</TableCell>
|
|
25
36
|
</>
|
|
26
37
|
)}
|
|
27
38
|
/>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { useMemo, useState } from 'react'
|
|
3
|
+
import { Button, Input, Loader, Table, TableCell, TableHead, TableHeader, TableRow } from '~/lib'
|
|
4
|
+
import { ChevronLeftIcon, ChevronRightIcon, RefreshCwIcon } from 'lucide-react'
|
|
5
|
+
import { usePersonsQuery, useTenantQueryLoader } from '@contember/react-client-tenant'
|
|
6
|
+
import { dict } from '../dict.js'
|
|
7
|
+
import { MfaBadges } from './mfa.js'
|
|
8
|
+
import { DisablePersonAction, EnablePersonAction, ForceSignOutPersonAction, ResetPersonMfaAction } from './person-actions.js'
|
|
9
|
+
|
|
10
|
+
const perPage = 20
|
|
11
|
+
|
|
12
|
+
export interface PersonsListController {
|
|
13
|
+
refresh: () => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PersonsListProps {
|
|
17
|
+
controller?: { current?: PersonsListController }
|
|
18
|
+
/** When set, the e-mail cell becomes a button — a host app typically opens `PersonDetail` from it. */
|
|
19
|
+
onSelectPerson?: (personId: string) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const PersonsList = ({ controller, onSelectPerson }: PersonsListProps) => {
|
|
23
|
+
const [page, setPage] = useState(0)
|
|
24
|
+
const [email, setEmail] = useState('')
|
|
25
|
+
|
|
26
|
+
// useTenantQueryLoader compares its variables one level deep, so an inline filter object would refetch on every render
|
|
27
|
+
const filter = useMemo(() => email ? { email } : undefined, [email])
|
|
28
|
+
|
|
29
|
+
const [query, { refresh }] = useTenantQueryLoader(usePersonsQuery(), {
|
|
30
|
+
filter,
|
|
31
|
+
offset: page * perPage,
|
|
32
|
+
limit: perPage + 1,
|
|
33
|
+
})
|
|
34
|
+
if (controller) {
|
|
35
|
+
controller.current = { refresh }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div className="relative flex flex-col gap-4">
|
|
40
|
+
<Input
|
|
41
|
+
type="text"
|
|
42
|
+
value={email}
|
|
43
|
+
placeholder={dict.tenant.personsList.filterEmailPlaceholder}
|
|
44
|
+
onChange={e => {
|
|
45
|
+
setPage(0)
|
|
46
|
+
setEmail(e.target.value)
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
{query.state === 'error'
|
|
50
|
+
? <div className="text-destructive italic">{dict.tenant.personsList.failedToLoadData}</div>
|
|
51
|
+
: (
|
|
52
|
+
<div className="relative">
|
|
53
|
+
{query.state !== 'success' && <Loader position="absolute" />}
|
|
54
|
+
<Table>
|
|
55
|
+
<TableHeader>
|
|
56
|
+
<TableRow>
|
|
57
|
+
<TableHead>{dict.tenant.personsList.email}</TableHead>
|
|
58
|
+
<TableHead>{dict.tenant.personsList.name}</TableHead>
|
|
59
|
+
<TableHead>{dict.tenant.personsList.roles}</TableHead>
|
|
60
|
+
<TableHead>{dict.tenant.personsList.status}</TableHead>
|
|
61
|
+
<TableHead>{dict.tenant.personsList.mfa}</TableHead>
|
|
62
|
+
<TableHead className="w-40">
|
|
63
|
+
<div className="flex gap-2 items-center">
|
|
64
|
+
<span>{dict.tenant.personsList.actions}</span>
|
|
65
|
+
<Button variant="outline" onClick={refresh} className="ml-auto" size="sm">
|
|
66
|
+
<RefreshCwIcon className="w-3 h-3" />
|
|
67
|
+
</Button>
|
|
68
|
+
</div>
|
|
69
|
+
</TableHead>
|
|
70
|
+
</TableRow>
|
|
71
|
+
</TableHeader>
|
|
72
|
+
{'data' in query && query.data.length === 0 && (
|
|
73
|
+
<TableRow>
|
|
74
|
+
<TableCell colSpan={6}>{dict.tenant.personsList.noResults}</TableCell>
|
|
75
|
+
</TableRow>
|
|
76
|
+
)}
|
|
77
|
+
{'data' in query && query.data.slice(0, perPage).map(person => (
|
|
78
|
+
<TableRow key={person.id}>
|
|
79
|
+
<TableCell>
|
|
80
|
+
{onSelectPerson
|
|
81
|
+
? (
|
|
82
|
+
<Button variant="link" size="sm" className="px-0" onClick={() => onSelectPerson(person.id)}>
|
|
83
|
+
{person.email ?? dict.tenant.personsList.noEmail}
|
|
84
|
+
</Button>
|
|
85
|
+
)
|
|
86
|
+
: person.email ?? dict.tenant.personsList.noEmail}
|
|
87
|
+
</TableCell>
|
|
88
|
+
<TableCell>{person.name ?? dict.tenant.personsList.noName}</TableCell>
|
|
89
|
+
<TableCell>
|
|
90
|
+
{person.identity.roles?.length ? person.identity.roles.join(', ') : dict.tenant.personsList.noRoles}
|
|
91
|
+
</TableCell>
|
|
92
|
+
<TableCell className="whitespace-nowrap">
|
|
93
|
+
{person.disabledAt
|
|
94
|
+
? (
|
|
95
|
+
<span className="text-destructive">
|
|
96
|
+
{dict.tenant.personsList.disabled} ({new Date(person.disabledAt).toLocaleString()})
|
|
97
|
+
</span>
|
|
98
|
+
)
|
|
99
|
+
: dict.tenant.personsList.active}
|
|
100
|
+
</TableCell>
|
|
101
|
+
<TableCell>
|
|
102
|
+
<MfaBadges otpEnabled={person.otpEnabled} emailOtpEnabled={person.emailOtpEnabled} />
|
|
103
|
+
</TableCell>
|
|
104
|
+
<TableCell className="space-x-2 whitespace-nowrap">
|
|
105
|
+
{person.disabledAt
|
|
106
|
+
? <EnablePersonAction personId={person.id} onSuccess={refresh} />
|
|
107
|
+
: <DisablePersonAction personId={person.id} onSuccess={refresh} />}
|
|
108
|
+
<ForceSignOutPersonAction personId={person.id} onSuccess={refresh} />
|
|
109
|
+
<ResetPersonMfaAction personId={person.id} onSuccess={refresh} />
|
|
110
|
+
</TableCell>
|
|
111
|
+
</TableRow>
|
|
112
|
+
))}
|
|
113
|
+
</Table>
|
|
114
|
+
<div className="flex gap-2 mt-4 justify-between">
|
|
115
|
+
<Button variant="outline" disabled={page === 0} onClick={() => setPage(page - 1)}>
|
|
116
|
+
<ChevronLeftIcon className="w-4 h-4" />
|
|
117
|
+
<span className="sr-only">{dict.tenant.personsList.previous}</span>
|
|
118
|
+
</Button>
|
|
119
|
+
<Button variant="outline" disabled={'data' in query && query.data.length <= perPage} onClick={() => setPage(page + 1)}>
|
|
120
|
+
<ChevronRightIcon className="w-4 h-4" />
|
|
121
|
+
<span className="sr-only">{dict.tenant.personsList.next}</span>
|
|
122
|
+
</Button>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
)}
|
|
126
|
+
</div>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { Button, Loader, Table, TableCell, TableHead, TableHeader, TableRow } from '~/lib'
|
|
3
|
+
import { RefreshCwIcon } from 'lucide-react'
|
|
4
|
+
import { useProjectSecretsQuery, useTenantQueryLoader } from '@contember/react-client-tenant'
|
|
5
|
+
import { useProjectSlug } from '@contember/react-client'
|
|
6
|
+
import { dict } from '../dict.js'
|
|
7
|
+
|
|
8
|
+
export interface ProjectSecretListController {
|
|
9
|
+
refresh: () => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ProjectSecretListProps {
|
|
13
|
+
controller?: { current?: ProjectSecretListController }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* `ProjectSecretList` lists the project secret keys and their timestamps; values are never returned by the API.
|
|
18
|
+
*
|
|
19
|
+
* The listing does not embed the editing form — a host app renders `SetProjectSecretForm` next to it and reloads
|
|
20
|
+
* the listing through the controller.
|
|
21
|
+
*
|
|
22
|
+
* ## Example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const controller = useRef<ProjectSecretListController>(undefined)
|
|
25
|
+
* return (
|
|
26
|
+
* <>
|
|
27
|
+
* <ProjectSecretList controller={controller} />
|
|
28
|
+
* <SetProjectSecretForm projectSlug={projectSlug} onSuccess={() => controller.current?.refresh()}>
|
|
29
|
+
* <form className="grid gap-4">
|
|
30
|
+
* <SetProjectSecretFormFields />
|
|
31
|
+
* </form>
|
|
32
|
+
* </SetProjectSecretForm>
|
|
33
|
+
* </>
|
|
34
|
+
* )
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const ProjectSecretList = ({ controller }: ProjectSecretListProps) => {
|
|
38
|
+
const projectSlug = useProjectSlug()!
|
|
39
|
+
const [query, { refresh }] = useTenantQueryLoader(useProjectSecretsQuery(), {
|
|
40
|
+
projectSlug,
|
|
41
|
+
})
|
|
42
|
+
if (controller) {
|
|
43
|
+
controller.current = { refresh }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (query.state === 'error') {
|
|
47
|
+
return <div className="text-destructive italic">{dict.tenant.projectSecretList.failedToLoadData}</div>
|
|
48
|
+
}
|
|
49
|
+
return (
|
|
50
|
+
<div className="relative">
|
|
51
|
+
{query.state !== 'success' && <Loader position="absolute" />}
|
|
52
|
+
<Table>
|
|
53
|
+
<TableHeader>
|
|
54
|
+
<TableRow>
|
|
55
|
+
<TableHead>{dict.tenant.projectSecretList.key}</TableHead>
|
|
56
|
+
<TableHead>{dict.tenant.projectSecretList.created}</TableHead>
|
|
57
|
+
<TableHead className="w-32">
|
|
58
|
+
<div className="flex gap-2 items-center">
|
|
59
|
+
<span>{dict.tenant.projectSecretList.updated}</span>
|
|
60
|
+
<Button variant="outline" onClick={refresh} className="ml-auto" size="sm">
|
|
61
|
+
<RefreshCwIcon className="w-3 h-3" />
|
|
62
|
+
</Button>
|
|
63
|
+
</div>
|
|
64
|
+
</TableHead>
|
|
65
|
+
</TableRow>
|
|
66
|
+
</TableHeader>
|
|
67
|
+
{'data' in query && query.data.length === 0 && (
|
|
68
|
+
<TableRow>
|
|
69
|
+
<TableCell colSpan={3}>{dict.tenant.projectSecretList.noResults}</TableCell>
|
|
70
|
+
</TableRow>
|
|
71
|
+
)}
|
|
72
|
+
{'data' in query && query.data.map(secret => (
|
|
73
|
+
<TableRow key={secret.key}>
|
|
74
|
+
<TableCell className="font-mono">{secret.key}</TableCell>
|
|
75
|
+
<TableCell className="whitespace-nowrap">{new Date(secret.createdAt).toLocaleString()}</TableCell>
|
|
76
|
+
<TableCell className="whitespace-nowrap">{new Date(secret.updatedAt).toLocaleString()}</TableCell>
|
|
77
|
+
</TableRow>
|
|
78
|
+
))}
|
|
79
|
+
</Table>
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
82
|
+
}
|