@nexys/user-management-web 0.0.26
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/README.md +61 -0
- package/components.json +21 -0
- package/package.json +66 -0
- package/src/components/audit/audit-log-table.test.tsx +91 -0
- package/src/components/audit/audit-log-table.tsx +226 -0
- package/src/components/auth/accept-invitation-card.tsx +100 -0
- package/src/components/auth/forgot-password-form.tsx +92 -0
- package/src/components/auth/reset-password-form.tsx +143 -0
- package/src/components/auth/sign-in-form.test.tsx +140 -0
- package/src/components/auth/sign-in-form.tsx +509 -0
- package/src/components/auth/sign-up-form.tsx +123 -0
- package/src/components/layout/app-shell.tsx +189 -0
- package/src/components/layout/auth-shell.tsx +28 -0
- package/src/components/layout/theme-toggle.tsx +55 -0
- package/src/components/layout/user-menu.tsx +84 -0
- package/src/components/primitives/empty-state.tsx +40 -0
- package/src/components/primitives/page-header.tsx +27 -0
- package/src/components/primitives/spinner.tsx +28 -0
- package/src/components/profile/api-tokens-card.tsx +235 -0
- package/src/components/profile/change-password-form.tsx +158 -0
- package/src/components/profile/passkeys-card.tsx +180 -0
- package/src/components/profile/profile-card.tsx +33 -0
- package/src/components/profile/two-factor-card.tsx +226 -0
- package/src/components/projects/project-consents.tsx +572 -0
- package/src/components/projects/project-create-dialog.tsx +209 -0
- package/src/components/projects/project-detail-tabs.tsx +63 -0
- package/src/components/projects/project-email-templates.tsx +282 -0
- package/src/components/projects/project-notices.tsx +458 -0
- package/src/components/projects/project-settings.tsx +1133 -0
- package/src/components/projects/project-tenants.tsx +107 -0
- package/src/components/projects/projects-table.test.tsx +95 -0
- package/src/components/projects/projects-table.tsx +240 -0
- package/src/components/roles/role-badge.tsx +91 -0
- package/src/components/roles/role-select.tsx +76 -0
- package/src/components/tenants/tenant-create-dialog.tsx +163 -0
- package/src/components/tenants/tenant-detail-tabs.tsx +51 -0
- package/src/components/tenants/tenant-members.tsx +578 -0
- package/src/components/tenants/tenant-roles.test.tsx +91 -0
- package/src/components/tenants/tenant-roles.tsx +414 -0
- package/src/components/tenants/tenant-settings.tsx +385 -0
- package/src/components/tenants/tenants-table.test.tsx +71 -0
- package/src/components/tenants/tenants-table.tsx +245 -0
- package/src/components/ui/alert.tsx +52 -0
- package/src/components/ui/avatar.tsx +46 -0
- package/src/components/ui/badge.tsx +32 -0
- package/src/components/ui/button.tsx +64 -0
- package/src/components/ui/card.tsx +65 -0
- package/src/components/ui/dialog.tsx +99 -0
- package/src/components/ui/dropdown-menu.tsx +97 -0
- package/src/components/ui/field.tsx +44 -0
- package/src/components/ui/input.tsx +23 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/components/ui/select.tsx +87 -0
- package/src/components/ui/separator.tsx +22 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/table.tsx +87 -0
- package/src/components/ui/tabs.tsx +51 -0
- package/src/components/ui/textarea.tsx +22 -0
- package/src/components/ui/tooltip.tsx +27 -0
- package/src/components/users/user-create-dialog.tsx +267 -0
- package/src/components/users/user-delete-dialog.tsx +88 -0
- package/src/components/users/user-detail.tsx +843 -0
- package/src/components/users/users-table.test.tsx +97 -0
- package/src/components/users/users-table.tsx +382 -0
- package/src/context/auth-context.tsx +124 -0
- package/src/context/theme-context.test.tsx +78 -0
- package/src/context/theme-context.tsx +110 -0
- package/src/hooks/use-call.ts +64 -0
- package/src/index.ts +159 -0
- package/src/lib/error-message.ts +16 -0
- package/src/lib/utils.test.ts +61 -0
- package/src/lib/utils.ts +79 -0
- package/src/lib/webauthn.ts +36 -0
- package/src/styles.css +107 -0
- package/src/test-setup.ts +5 -0
- package/tailwind.preset.cjs +15 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { AlertCircle, Plus } from "lucide-react";
|
|
2
|
+
import { useState, type FormEvent, type ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import { useUmClient } from "../../context/auth-context.js";
|
|
5
|
+
import { useCall } from "../../hooks/use-call.js";
|
|
6
|
+
import { errorMessage } from "../../lib/error-message.js";
|
|
7
|
+
import { Alert, AlertDescription } from "../ui/alert.js";
|
|
8
|
+
import { Button } from "../ui/button.js";
|
|
9
|
+
import {
|
|
10
|
+
Dialog,
|
|
11
|
+
DialogContent,
|
|
12
|
+
DialogDescription,
|
|
13
|
+
DialogFooter,
|
|
14
|
+
DialogHeader,
|
|
15
|
+
DialogTitle,
|
|
16
|
+
DialogTrigger,
|
|
17
|
+
} from "../ui/dialog.js";
|
|
18
|
+
import { Field } from "../ui/field.js";
|
|
19
|
+
import { Input } from "../ui/input.js";
|
|
20
|
+
import {
|
|
21
|
+
Select,
|
|
22
|
+
SelectContent,
|
|
23
|
+
SelectItem,
|
|
24
|
+
SelectTrigger,
|
|
25
|
+
SelectValue,
|
|
26
|
+
} from "../ui/select.js";
|
|
27
|
+
|
|
28
|
+
export interface TenantCreateDialogProps {
|
|
29
|
+
/** Override the trigger button. */
|
|
30
|
+
trigger?: ReactNode;
|
|
31
|
+
onCreated?: (tenant: { id: string; name: string; slug: string }) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const TenantCreateDialog = ({ trigger, onCreated }: TenantCreateDialogProps) => {
|
|
35
|
+
const client = useUmClient();
|
|
36
|
+
const [open, setOpen] = useState(false);
|
|
37
|
+
const [name, setName] = useState("");
|
|
38
|
+
const [slug, setSlug] = useState("");
|
|
39
|
+
const [projectId, setProjectId] = useState<string>("none");
|
|
40
|
+
const [loading, setLoading] = useState(false);
|
|
41
|
+
const [error, setError] = useState<string | null>(null);
|
|
42
|
+
// Products the caller may attach the tenant to (superadmin: all).
|
|
43
|
+
const projects = useCall("listProjects");
|
|
44
|
+
const projectOptions = projects.data?.projects ?? [];
|
|
45
|
+
|
|
46
|
+
const reset = () => {
|
|
47
|
+
setName("");
|
|
48
|
+
setSlug("");
|
|
49
|
+
setProjectId("none");
|
|
50
|
+
setError(null);
|
|
51
|
+
setLoading(false);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const submit = async (e: FormEvent) => {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
setLoading(true);
|
|
57
|
+
setError(null);
|
|
58
|
+
const res = await client.createTenant({
|
|
59
|
+
name: name.trim(),
|
|
60
|
+
slug: slug.trim() || undefined,
|
|
61
|
+
projectId: projectId === "none" ? undefined : projectId,
|
|
62
|
+
});
|
|
63
|
+
setLoading(false);
|
|
64
|
+
if (res.ok) {
|
|
65
|
+
onCreated?.({ id: res.data.id, name: res.data.name, slug: res.data.slug });
|
|
66
|
+
reset();
|
|
67
|
+
setOpen(false);
|
|
68
|
+
} else {
|
|
69
|
+
setError(errorMessage(res.error, "Couldn't create tenant."));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Dialog
|
|
75
|
+
open={open}
|
|
76
|
+
onOpenChange={(o) => {
|
|
77
|
+
setOpen(o);
|
|
78
|
+
if (!o) reset();
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<DialogTrigger asChild>
|
|
82
|
+
{trigger ?? (
|
|
83
|
+
<Button>
|
|
84
|
+
<Plus />
|
|
85
|
+
New tenant
|
|
86
|
+
</Button>
|
|
87
|
+
)}
|
|
88
|
+
</DialogTrigger>
|
|
89
|
+
<DialogContent>
|
|
90
|
+
<DialogHeader>
|
|
91
|
+
<DialogTitle>Create a new tenant</DialogTitle>
|
|
92
|
+
<DialogDescription>
|
|
93
|
+
Each tenant is an isolated workspace. You'll be added as the owner.
|
|
94
|
+
</DialogDescription>
|
|
95
|
+
</DialogHeader>
|
|
96
|
+
<form onSubmit={submit} className="grid gap-4" noValidate>
|
|
97
|
+
<Field label="Name" htmlFor="tenant-name" required>
|
|
98
|
+
<Input
|
|
99
|
+
id="tenant-name"
|
|
100
|
+
autoFocus
|
|
101
|
+
required
|
|
102
|
+
value={name}
|
|
103
|
+
onChange={(e) => setName(e.target.value)}
|
|
104
|
+
placeholder="Acme Inc."
|
|
105
|
+
/>
|
|
106
|
+
</Field>
|
|
107
|
+
<Field
|
|
108
|
+
label="Slug"
|
|
109
|
+
htmlFor="tenant-slug"
|
|
110
|
+
description="URL-safe identifier. Leave blank to derive from the name."
|
|
111
|
+
>
|
|
112
|
+
<Input
|
|
113
|
+
id="tenant-slug"
|
|
114
|
+
value={slug}
|
|
115
|
+
onChange={(e) => setSlug(e.target.value.toLowerCase().replace(/\s+/g, "-"))}
|
|
116
|
+
placeholder="acme"
|
|
117
|
+
/>
|
|
118
|
+
</Field>
|
|
119
|
+
{projectOptions.length > 0 ? (
|
|
120
|
+
<Field
|
|
121
|
+
label="Product"
|
|
122
|
+
htmlFor="tenant-project"
|
|
123
|
+
description="Attach the tenant to a product. Gated by the product's tenancy settings."
|
|
124
|
+
>
|
|
125
|
+
<Select value={projectId} onValueChange={setProjectId}>
|
|
126
|
+
<SelectTrigger id="tenant-project">
|
|
127
|
+
<SelectValue />
|
|
128
|
+
</SelectTrigger>
|
|
129
|
+
<SelectContent>
|
|
130
|
+
<SelectItem value="none">No product</SelectItem>
|
|
131
|
+
{projectOptions.map((p) => (
|
|
132
|
+
<SelectItem key={p.id} value={p.id}>
|
|
133
|
+
{p.name}
|
|
134
|
+
</SelectItem>
|
|
135
|
+
))}
|
|
136
|
+
</SelectContent>
|
|
137
|
+
</Select>
|
|
138
|
+
</Field>
|
|
139
|
+
) : null}
|
|
140
|
+
{error ? (
|
|
141
|
+
<Alert variant="destructive">
|
|
142
|
+
<AlertCircle />
|
|
143
|
+
<AlertDescription>{error}</AlertDescription>
|
|
144
|
+
</Alert>
|
|
145
|
+
) : null}
|
|
146
|
+
<DialogFooter>
|
|
147
|
+
<Button
|
|
148
|
+
type="button"
|
|
149
|
+
variant="ghost"
|
|
150
|
+
onClick={() => setOpen(false)}
|
|
151
|
+
disabled={loading}
|
|
152
|
+
>
|
|
153
|
+
Cancel
|
|
154
|
+
</Button>
|
|
155
|
+
<Button type="submit" loading={loading} disabled={!name.trim()}>
|
|
156
|
+
Create tenant
|
|
157
|
+
</Button>
|
|
158
|
+
</DialogFooter>
|
|
159
|
+
</form>
|
|
160
|
+
</DialogContent>
|
|
161
|
+
</Dialog>
|
|
162
|
+
);
|
|
163
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs.js";
|
|
2
|
+
import { TenantMembers } from "./tenant-members.js";
|
|
3
|
+
import { TenantRoles } from "./tenant-roles.js";
|
|
4
|
+
import { TenantSettings } from "./tenant-settings.js";
|
|
5
|
+
|
|
6
|
+
export interface TenantDetailTabsProps {
|
|
7
|
+
organizationId: string;
|
|
8
|
+
canManage?: boolean;
|
|
9
|
+
canDelete?: boolean;
|
|
10
|
+
/** Superadmin: add members by picking from the system-wide user list. */
|
|
11
|
+
userPicker?: boolean;
|
|
12
|
+
onDeleted?: () => void;
|
|
13
|
+
/** Called with the new uuid after a successful id change. */
|
|
14
|
+
onIdChanged?: (newId: string) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const TenantDetailTabs = ({
|
|
18
|
+
organizationId,
|
|
19
|
+
canManage = false,
|
|
20
|
+
canDelete = false,
|
|
21
|
+
userPicker = false,
|
|
22
|
+
onDeleted,
|
|
23
|
+
onIdChanged,
|
|
24
|
+
}: TenantDetailTabsProps) => (
|
|
25
|
+
<Tabs defaultValue="members">
|
|
26
|
+
<TabsList>
|
|
27
|
+
<TabsTrigger value="members">Members</TabsTrigger>
|
|
28
|
+
<TabsTrigger value="roles">Roles</TabsTrigger>
|
|
29
|
+
<TabsTrigger value="settings">Settings</TabsTrigger>
|
|
30
|
+
</TabsList>
|
|
31
|
+
<TabsContent value="members" className="mt-4">
|
|
32
|
+
<TenantMembers
|
|
33
|
+
organizationId={organizationId}
|
|
34
|
+
canManage={canManage}
|
|
35
|
+
userPicker={userPicker}
|
|
36
|
+
/>
|
|
37
|
+
</TabsContent>
|
|
38
|
+
<TabsContent value="roles" className="mt-4">
|
|
39
|
+
<TenantRoles organizationId={organizationId} canManage={canManage} />
|
|
40
|
+
</TabsContent>
|
|
41
|
+
<TabsContent value="settings" className="mt-4">
|
|
42
|
+
<TenantSettings
|
|
43
|
+
organizationId={organizationId}
|
|
44
|
+
canManage={canManage}
|
|
45
|
+
canDelete={canDelete}
|
|
46
|
+
onDeleted={onDeleted}
|
|
47
|
+
onIdChanged={onIdChanged}
|
|
48
|
+
/>
|
|
49
|
+
</TabsContent>
|
|
50
|
+
</Tabs>
|
|
51
|
+
);
|