@krak-stack/auth 0.1.43 → 0.1.44
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/admin/api.group.d.ts +5 -0
- package/dist/admin/schema.d.ts +4 -0
- package/dist/admin/schema.js +4 -0
- package/dist/api.d.ts +228 -223
- package/dist/components/admin-organizations.d.ts +1 -1
- package/dist/components/admin-organizations.js +17 -12
- package/dist/components/admin-users.d.ts +1 -1
- package/dist/components/admin-users.js +21 -2
- package/dist/components/auth-client-api.d.ts +5 -0
- package/dist/components/organization-switcher.js +46 -27
- package/dist/components/user-button.js +8 -17
- package/package.json +1 -1
|
@@ -3,5 +3,5 @@ import { type TableParams } from "@/components/ui/data-table";
|
|
|
3
3
|
export declare function AdminOrganizationsTable({ from, reloadKey, search, }: {
|
|
4
4
|
from?: ValidateFromPath;
|
|
5
5
|
reloadKey?: number;
|
|
6
|
-
search
|
|
6
|
+
search?: TableParams;
|
|
7
7
|
}): import("react").JSX.Element;
|
|
@@ -8,26 +8,21 @@ import { useState } from "react";
|
|
|
8
8
|
import { DataTable } from "@/components/ui/data-table";
|
|
9
9
|
import { ErrorMessage } from "@/components/ui/form";
|
|
10
10
|
import { AppBrand } from "@/components/ui/app-brand";
|
|
11
|
-
import { Badge } from "@/components/ui/badge";
|
|
12
11
|
import { authClientApi } from "./auth-client-api";
|
|
13
12
|
import { useKrakstackAuth } from "./auth-provider";
|
|
14
13
|
import { assetUrl, organizationBranding } from "./utils";
|
|
15
14
|
const defaultMessages = {
|
|
16
15
|
en: {
|
|
17
16
|
admin_column_created: "Created",
|
|
17
|
+
admin_column_members: "Members",
|
|
18
18
|
admin_column_organization: "Organization",
|
|
19
|
-
admin_none: "None",
|
|
20
|
-
oauth_client_logo_configured: "Configured",
|
|
21
19
|
organization_fetch_error: "Unable to load organizations.",
|
|
22
|
-
organization_field_logo_url: "Logo",
|
|
23
20
|
},
|
|
24
21
|
fr: {
|
|
25
22
|
admin_column_created: "Créé",
|
|
23
|
+
admin_column_members: "Membres",
|
|
26
24
|
admin_column_organization: "Organisation",
|
|
27
|
-
admin_none: "Aucun",
|
|
28
|
-
oauth_client_logo_configured: "Configuré",
|
|
29
25
|
organization_fetch_error: "Impossible de charger les organisations.",
|
|
30
|
-
organization_field_logo_url: "Logo",
|
|
31
26
|
},
|
|
32
27
|
};
|
|
33
28
|
const labels = (locale) => ({
|
|
@@ -72,11 +67,15 @@ export function AdminOrganizationsTable({ from, reloadKey = 0, search, }) {
|
|
|
72
67
|
const baseUrl = auth?.baseUrl;
|
|
73
68
|
const projectId = auth?.projectId;
|
|
74
69
|
const [refreshKey, setRefreshKey] = useState(0);
|
|
70
|
+
const [localSearch, setLocalSearch] = useState({
|
|
71
|
+
globalFilter: "",
|
|
72
|
+
});
|
|
73
|
+
const tableSearch = search ?? localSearch;
|
|
75
74
|
const result = useAtomValue(organizationsAtom({
|
|
76
75
|
baseUrl,
|
|
77
76
|
projectId,
|
|
78
77
|
reloadKey: reloadKey + refreshKey,
|
|
79
|
-
search,
|
|
78
|
+
search: tableSearch,
|
|
80
79
|
}));
|
|
81
80
|
const organizations = AsyncResult.match(result, {
|
|
82
81
|
onInitial: () => [],
|
|
@@ -98,7 +97,13 @@ export function AdminOrganizationsTable({ from, reloadKey = 0, search, }) {
|
|
|
98
97
|
onFailure: () => false,
|
|
99
98
|
onSuccess: () => false,
|
|
100
99
|
});
|
|
101
|
-
return (_jsxs("div", { className: "flex flex-col gap-4", children: [error ? _jsx(ErrorMessage, { text: error }) : null, _jsx(DataTable, { columns: organizationColumns(m, locale, baseUrl), data: organizations, exportFileName: "organizations.csv", features: { gallery: false }, ...(from ? { from } : {}),
|
|
100
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [error ? _jsx(ErrorMessage, { text: error }) : null, _jsx(DataTable, { columns: organizationColumns(m, locale, baseUrl), data: organizations, exportFileName: "organizations.csv", features: { gallery: false }, ...(from ? { from } : {}), ...(!search
|
|
101
|
+
? {
|
|
102
|
+
search: tableSearch,
|
|
103
|
+
onSearchChange: setLocalSearch,
|
|
104
|
+
searchState: "local",
|
|
105
|
+
}
|
|
106
|
+
: {}), isLoading: isLoading, onRefresh: () => setRefreshKey((current) => current + 1), serverPagination: { rowCount: total } })] }));
|
|
102
107
|
}
|
|
103
108
|
const organizationColumns = (m, locale, baseUrl) => [
|
|
104
109
|
{
|
|
@@ -110,9 +115,9 @@ const organizationColumns = (m, locale, baseUrl) => [
|
|
|
110
115
|
},
|
|
111
116
|
},
|
|
112
117
|
{
|
|
113
|
-
accessorKey: "
|
|
114
|
-
header: m.
|
|
115
|
-
cell: ({ row }) =>
|
|
118
|
+
accessorKey: "memberCount",
|
|
119
|
+
header: m.admin_column_members,
|
|
120
|
+
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground text-sm tabular-nums", children: (row.original.memberCount ?? 0).toLocaleString() })),
|
|
116
121
|
},
|
|
117
122
|
{
|
|
118
123
|
accessorKey: "createdAt",
|
|
@@ -3,6 +3,6 @@ import { type TableParams } from "@/components/ui/data-table";
|
|
|
3
3
|
export declare function AdminUsersTable({ from, reloadKey, search, }: {
|
|
4
4
|
from?: ValidateFromPath;
|
|
5
5
|
reloadKey?: number;
|
|
6
|
-
search
|
|
6
|
+
search?: TableParams;
|
|
7
7
|
}): import("react").JSX.Element;
|
|
8
8
|
export declare function useAdminUsersTotal(search: TableParams): number;
|
|
@@ -22,6 +22,7 @@ const defaultMessages = {
|
|
|
22
22
|
admin_ban_description: "Are you sure you want to ban {name} ({email})? They will not be able to sign in.",
|
|
23
23
|
admin_ban_title: "Ban user",
|
|
24
24
|
admin_column_created: "Created",
|
|
25
|
+
admin_column_last_signed_in: "Last signed in",
|
|
25
26
|
admin_column_role: "Role",
|
|
26
27
|
admin_column_status: "Status",
|
|
27
28
|
admin_column_unverified: "Unverified",
|
|
@@ -45,6 +46,7 @@ const defaultMessages = {
|
|
|
45
46
|
admin_ban_description: "Êtes-vous sûr de vouloir bannir {name} ({email}) ? Il ne pourra plus se connecter.",
|
|
46
47
|
admin_ban_title: "Bannir l'utilisateur",
|
|
47
48
|
admin_column_created: "Créé",
|
|
49
|
+
admin_column_last_signed_in: "Dernière connexion",
|
|
48
50
|
admin_column_role: "Rôle",
|
|
49
51
|
admin_column_status: "Statut",
|
|
50
52
|
admin_column_unverified: "Non vérifié",
|
|
@@ -116,10 +118,14 @@ export function AdminUsersTable({ from, reloadKey = 0, search, }) {
|
|
|
116
118
|
const [impersonatingUserId, setImpersonatingUserId] = useState(null);
|
|
117
119
|
const [impersonateError, setImpersonateError] = useState("");
|
|
118
120
|
const [refreshKey, setRefreshKey] = useState(0);
|
|
121
|
+
const [localSearch, setLocalSearch] = useState({
|
|
122
|
+
globalFilter: "",
|
|
123
|
+
});
|
|
124
|
+
const tableSearch = search ?? localSearch;
|
|
119
125
|
const result = useAtomValue(usersAtom({
|
|
120
126
|
baseUrl,
|
|
121
127
|
projectId,
|
|
122
|
-
search,
|
|
128
|
+
search: tableSearch,
|
|
123
129
|
reloadKey: reloadKey + refreshKey,
|
|
124
130
|
}));
|
|
125
131
|
const [banningUser, setBanningUser] = useState(null);
|
|
@@ -144,7 +150,13 @@ export function AdminUsersTable({ from, reloadKey = 0, search, }) {
|
|
|
144
150
|
onFailure: () => false,
|
|
145
151
|
onSuccess: () => false,
|
|
146
152
|
});
|
|
147
|
-
return (_jsxs(_Fragment, { children: [error ? _jsx(ErrorMessage, { text: error }) : null, impersonateError ? _jsx(ErrorMessage, { text: impersonateError }) : null, _jsx(DataTable, { columns: userColumns(m), data: users, exportFileName: "users.csv", features: { gallery: false }, ...(from ? { from } : {}),
|
|
153
|
+
return (_jsxs(_Fragment, { children: [error ? _jsx(ErrorMessage, { text: error }) : null, impersonateError ? _jsx(ErrorMessage, { text: impersonateError }) : null, _jsx(DataTable, { columns: userColumns(m), data: users, exportFileName: "users.csv", features: { gallery: false }, ...(from ? { from } : {}), ...(!search
|
|
154
|
+
? {
|
|
155
|
+
search: tableSearch,
|
|
156
|
+
onSearchChange: setLocalSearch,
|
|
157
|
+
searchState: "local",
|
|
158
|
+
}
|
|
159
|
+
: {}), isLoading: isLoading, onRefresh: () => setRefreshKey((current) => current + 1), serverPagination: { rowCount: total }, rowActions: [
|
|
148
160
|
{
|
|
149
161
|
name: m.admin_action_impersonate,
|
|
150
162
|
icon: impersonatingUserId ? (_jsx(Loader2, { className: "size-4 animate-spin" })) : (_jsx(UserCog, { className: "size-4" })),
|
|
@@ -226,6 +238,13 @@ const userColumns = (m) => [
|
|
|
226
238
|
header: m.admin_column_status,
|
|
227
239
|
cell: ({ row }) => row.original.banned ? (_jsx(Badge, { variant: "destructive", children: m.admin_status_banned })) : (_jsx(Badge, { variant: "outline", children: m.admin_status_active })),
|
|
228
240
|
},
|
|
241
|
+
{
|
|
242
|
+
accessorKey: "lastSignedIn",
|
|
243
|
+
header: m.admin_column_last_signed_in,
|
|
244
|
+
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: row.original.lastSignedIn
|
|
245
|
+
? new Date(row.original.lastSignedIn).toLocaleString()
|
|
246
|
+
: "-" })),
|
|
247
|
+
},
|
|
229
248
|
{
|
|
230
249
|
accessorKey: "createdAt",
|
|
231
250
|
header: m.admin_column_created,
|
|
@@ -30,6 +30,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
30
30
|
readonly slug: import("effect/Schema").String;
|
|
31
31
|
readonly logo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
32
32
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
33
|
+
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").Number>;
|
|
33
34
|
readonly createdAt: import("effect/Schema").Date;
|
|
34
35
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"dashboardStats", "GET", "/api/auth/admin/dashboard-stats", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
35
36
|
readonly days: import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"7">, import("effect/Schema").Literal<"14">, import("effect/Schema").Literal<"30">, import("effect/Schema").Literal<"90">]>>;
|
|
@@ -80,6 +81,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
80
81
|
readonly slug: import("effect/Schema").String;
|
|
81
82
|
readonly logo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
82
83
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
84
|
+
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").Number>;
|
|
83
85
|
readonly createdAt: import("effect/Schema").Date;
|
|
84
86
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getDomainRecords", "GET", "/api/auth/admin/domains/:id/records", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
85
87
|
readonly id: import("effect/Schema").NonEmptyString;
|
|
@@ -120,6 +122,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
120
122
|
readonly slug: string;
|
|
121
123
|
readonly logo?: string | null | undefined;
|
|
122
124
|
readonly metadata?: string | null | undefined;
|
|
125
|
+
readonly memberCount?: number | undefined;
|
|
123
126
|
readonly createdAt: Date;
|
|
124
127
|
}>>;
|
|
125
128
|
readonly meta: import("effect/Schema").Struct<{
|
|
@@ -145,6 +148,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
145
148
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
146
149
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
147
150
|
readonly createdAt: import("effect/Schema").Date;
|
|
151
|
+
readonly lastSignedIn: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
148
152
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
149
153
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
150
154
|
readonly banReason: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
@@ -191,6 +195,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
191
195
|
readonly slug: import("effect/Schema").String;
|
|
192
196
|
readonly logo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
193
197
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
198
|
+
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").Number>;
|
|
194
199
|
readonly createdAt: import("effect/Schema").Date;
|
|
195
200
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never>, false> | import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"authExtra", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"createApiKey", "POST", "/api/auth/create-api-key", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
196
201
|
readonly configId: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>;
|
|
@@ -6,7 +6,7 @@ import { Effect, Schema } from "effect";
|
|
|
6
6
|
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
7
7
|
import { Building2, Check, ChevronsUpDown, Copy, KeyRound, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
|
|
8
8
|
import { createContext, useContext, useEffect, useState, } from "react";
|
|
9
|
-
import { DataTable } from "@/components/ui/data-table";
|
|
9
|
+
import { DataTable, DataTableRelationshipCell, } from "@/components/ui/data-table";
|
|
10
10
|
import { EditingLocaleSwitcher } from "@/components/ui/editing-locale-switcher";
|
|
11
11
|
import { AppBrand } from "@/components/ui/app-brand";
|
|
12
12
|
import { useAppForm } from "@/components/ui/form";
|
|
@@ -14,11 +14,10 @@ import { Badge } from "@/components/ui/badge";
|
|
|
14
14
|
import { Button } from "@/components/ui/button";
|
|
15
15
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
16
16
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
17
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select";
|
|
18
17
|
import { Separator } from "@/components/ui/separator";
|
|
19
18
|
import { OrganizationMetadata, } from "@krak-stack/auth/schema";
|
|
20
19
|
import { authClientApi } from "./auth-client-api";
|
|
21
|
-
import {
|
|
20
|
+
import { useKrakstackAuth } from "./auth-provider";
|
|
22
21
|
import { createApiKey } from "./api-key";
|
|
23
22
|
import { useOpenedOnce } from "./hooks";
|
|
24
23
|
import { ExtraUploadedAsset } from "../extra/schema";
|
|
@@ -209,7 +208,7 @@ const userInvitationsAtom = Atom.family((authClient) => Atom.keepAlive(Atom.make
|
|
|
209
208
|
throw new Error(result.error.message ??
|
|
210
209
|
"Could not load organization invitations.");
|
|
211
210
|
}
|
|
212
|
-
return result.data ?? [];
|
|
211
|
+
return (result.data ?? []).filter((invitation) => invitation.status === "pending");
|
|
213
212
|
},
|
|
214
213
|
catch: (error) => error,
|
|
215
214
|
}))));
|
|
@@ -233,7 +232,7 @@ const organizationMembersAtom = Atom.family((authClient) => Atom.family((organiz
|
|
|
233
232
|
}
|
|
234
233
|
return {
|
|
235
234
|
members: membersResult.data?.members ?? [],
|
|
236
|
-
invitations: invitationsResult.data ?? [],
|
|
235
|
+
invitations: (invitationsResult.data ?? []).filter((invitation) => invitation.status === "pending"),
|
|
237
236
|
};
|
|
238
237
|
},
|
|
239
238
|
catch: (error) => error,
|
|
@@ -380,8 +379,11 @@ const organizationMetadataFromForm = async (value, m, uploadImage) => {
|
|
|
380
379
|
return { translations };
|
|
381
380
|
};
|
|
382
381
|
export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl, side = "bottom", className, defaultDialog = null, hideTrigger = false, renderUnauthenticated, locked = false, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, }) {
|
|
383
|
-
const
|
|
384
|
-
const authClient = providedAuthClient ??
|
|
382
|
+
const auth = useKrakstackAuth();
|
|
383
|
+
const authClient = providedAuthClient ?? auth?.authClient;
|
|
384
|
+
if (!authClient) {
|
|
385
|
+
throw new Error("KrakstackAuthProvider is required to use authClient.");
|
|
386
|
+
}
|
|
385
387
|
const labels = organizationSwitcherMessages(messages);
|
|
386
388
|
const m = organizationMessageFns(labels);
|
|
387
389
|
const session = authClient.useSession();
|
|
@@ -405,6 +407,8 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
405
407
|
onSuccess: () => null,
|
|
406
408
|
});
|
|
407
409
|
const loadingUserInvitations = invitationsResult._tag === "Initial";
|
|
410
|
+
const activeMemberRole = normalizeOrganizationRole(activeOrganization.data?.members.find((member) => member.userId === session.data?.user.id)?.role);
|
|
411
|
+
const canManageApiKeys = activeMemberRole === "owner" || activeMemberRole === "admin";
|
|
408
412
|
const setDialog = (next) => {
|
|
409
413
|
const nextDialog = typeof next === "function" ? next(dialog) : next;
|
|
410
414
|
if (nextDialog === dialog)
|
|
@@ -461,11 +465,11 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
461
465
|
}, children: _jsx(AppBrand, { to: null, label: display.name, subtitle: display.subtitle, icon: Building2, className: "w-full text-left [&>div:first-child]:size-7", ...(display.image ? { imageSrc: display.image } : {}) }) }, organization.id));
|
|
462
466
|
})) : !locked && !organizations.isPending ? (_jsx(DropdownMenuItem, { disabled: true, children: active
|
|
463
467
|
? m.organization_switcher_no_other_organizations()
|
|
464
|
-
: m.organization_switcher_empty() })) : null, _jsx(DropdownMenuSeparator, {}),
|
|
465
|
-
|
|
466
|
-
|
|
468
|
+
: m.organization_switcher_empty() })) : null, !locked ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: openCreate, children: [_jsx(Plus, {}), m.organization_create_title()] }), _jsxs(DropdownMenuItem, { onClick: () => {
|
|
469
|
+
setDialog("invitations");
|
|
470
|
+
}, children: [_jsx(Mail, {}), _jsxs("span", { className: "flex flex-1 items-center justify-between gap-3", children: [m.organization_user_invitations_title(), userInvitations.length ? (_jsx(Badge, { variant: "secondary", children: userInvitations.length })) : null] })] })] })) : null, activeOrganization.data ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: () => {
|
|
467
471
|
void navigator.clipboard.writeText(activeOrganization.data.id);
|
|
468
|
-
}, children: [_jsx(Copy, {}), m.organization_copy_id()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("manage"), children: [_jsx(PencilIcon, {}), m.organization_switcher_manage()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("members"), children: [_jsx(Users, {}), m.organization_members_title()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] })] })) : null] }) })] })), _jsx(Dialog, { open: dialog === "create", onOpenChange: (open) => {
|
|
472
|
+
}, children: [_jsx(Copy, {}), m.organization_copy_id()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("manage"), children: [_jsx(PencilIcon, {}), m.organization_switcher_manage()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("members"), children: [_jsx(Users, {}), m.organization_members_title()] }), canManageApiKeys ? (_jsxs(DropdownMenuItem, { onClick: () => setDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] })) : null] })) : null] }) })] })), _jsx(Dialog, { open: dialog === "create", onOpenChange: (open) => {
|
|
469
473
|
setDialog((current) => open ? "create" : current === "create" ? null : current);
|
|
470
474
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_create_title() }), _jsx(DialogDescription, { children: m.organization_create_description() })] }), _jsx(Separator, {}), _jsx(CreateOrganizationSection, { authClient: authClient, baseUrl: baseUrl, onCreated: async (organization) => {
|
|
471
475
|
setDialog(null);
|
|
@@ -481,9 +485,9 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
481
485
|
setDialog((current) => open ? "manage" : current === "manage" ? null : current);
|
|
482
486
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_switcher_manage() }), _jsx(DialogDescription, { children: m.organization_edit_description() })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(EditOrganizationSection, { authClient: authClient, baseUrl: baseUrl, organization: activeOrganization.data, onUpdated: refresh })) : null] }) }), _jsx(Dialog, { open: dialog === "members", onOpenChange: (open) => {
|
|
483
487
|
setDialog((current) => open ? "members" : current === "members" ? null : current);
|
|
484
|
-
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-
|
|
488
|
+
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-4xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_members_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationMembersManager, { authClient: authClient, baseUrl: baseUrl, organization: activeOrganization.data, currentUserId: session.data.user.id, active: dialog === "members" })) : null] }) }), _jsx(Dialog, { open: dialog === "apiKeys" && canManageApiKeys, onOpenChange: (open) => {
|
|
485
489
|
setDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
486
|
-
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_api_keys_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationApiKeyManager, { authClient: authClient, organization: activeOrganization.data, active: dialog === "apiKeys" })) : null] }) }), _jsx(Dialog, { open: dialog === "invitations", onOpenChange: (open) => {
|
|
490
|
+
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_api_keys_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationApiKeyManager, { authClient: authClient, organization: activeOrganization.data, active: dialog === "apiKeys" && canManageApiKeys })) : null] }) }), _jsx(Dialog, { open: dialog === "invitations" && !locked, onOpenChange: (open) => {
|
|
487
491
|
setDialog((current) => open ? "invitations" : current === "invitations" ? null : current);
|
|
488
492
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-4xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_user_invitations_title() }), _jsx(DialogDescription, { children: m.organization_user_invitations_description() })] }), _jsx(Separator, {}), _jsx(UserInvitationsManager, { authClient: authClient, invitations: userInvitations, loading: loadingUserInvitations, error: userInvitationsError, activeOrganizationId: activeOrganization.data?.id, onActionComplete: refreshAfterInvitationAction })] }) })] }));
|
|
489
493
|
}
|
|
@@ -519,7 +523,7 @@ function UserInvitationsManager({ authClient, invitations, loading, error, activ
|
|
|
519
523
|
};
|
|
520
524
|
return (_jsxs("section", { className: "flex flex-col gap-4", children: [error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, actionError ? (_jsx("p", { className: "text-destructive text-sm", children: actionError })) : null, _jsx(DataTable, { columns: userInvitationColumns({
|
|
521
525
|
m,
|
|
522
|
-
}), data: invitations, emptyLabel: loading ? m.user_loading() : m.organization_user_invitations_empty(), exportFileName: "organization-invitations.csv", features: { gallery: false }, rowActions: userInvitationRowActions({
|
|
526
|
+
}), data: invitations, emptyLabel: loading ? m.user_loading() : m.organization_user_invitations_empty(), exportFileName: "organization-invitations.csv", features: { gallery: false }, searchState: "local", rowActions: userInvitationRowActions({
|
|
523
527
|
m,
|
|
524
528
|
actingInvitationId,
|
|
525
529
|
onAccept: acceptInvitation,
|
|
@@ -752,6 +756,9 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
752
756
|
onSuccess: () => null,
|
|
753
757
|
});
|
|
754
758
|
const loading = membersResult._tag === "Initial";
|
|
759
|
+
const currentMemberRole = normalizeOrganizationRole(members.find((member) => member.userId === currentUserId)?.role);
|
|
760
|
+
const canChangeMemberRoles = currentMemberRole === "owner" || currentMemberRole === "admin";
|
|
761
|
+
const canRemoveMembers = canChangeMemberRoles;
|
|
755
762
|
const inviteForm = useAppForm({
|
|
756
763
|
defaultValues: { email: "", role: "member" },
|
|
757
764
|
onSubmit: async ({ value, formApi }) => {
|
|
@@ -823,24 +830,26 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
823
830
|
}, children: [_jsxs("div", { className: "sm:col-span-3", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(UserPlus, { className: "size-4" }), m.organization_invite_member_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_invite_member_description() })] }), _jsx(inviteForm.AppField, { name: "email", children: (field) => (_jsx(field.TextField, { label: m.organization_member_email(), placeholder: "teammate@example.com", type: "email", required: true })) }), _jsx(inviteForm.AppField, { name: "role", children: (field) => (_jsx(field.SelectField, { label: m.organization_member_role(), options: organizationRoles.map((role) => ({
|
|
824
831
|
label: organizationRoleLabel(role, m),
|
|
825
832
|
value: role,
|
|
826
|
-
})) })) }), _jsx("div", { className: "self-end", children: _jsx(inviteForm.SubmitButton, {}) }), _jsx(inviteForm.FormError, {})] }) }), membersError ? (_jsx("p", { className: "text-destructive text-sm", children: membersError })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsxs("section", { className: "flex min-w-0 flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_members_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_members_description() })] }), _jsx("div", { className: "min-w-0 overflow-x-auto", children: _jsx(DataTable, { columns: memberColumns({
|
|
833
|
+
})) })) }), _jsx("div", { className: "self-end", children: _jsx(inviteForm.SubmitButton, {}) }), _jsx(inviteForm.FormError, {})] }) }), membersError ? (_jsx("p", { className: "text-destructive text-sm", children: membersError })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsxs("section", { className: "flex min-w-0 flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_members_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_members_description() })] }), _jsx("div", { className: "-m-1 min-w-0 overflow-x-auto p-1", children: _jsx(DataTable, { columns: memberColumns({
|
|
827
834
|
m,
|
|
828
835
|
baseUrl,
|
|
836
|
+
canChangeRoles: canChangeMemberRoles,
|
|
829
837
|
updatingMemberId,
|
|
830
838
|
onRoleChange: updateRole,
|
|
831
|
-
}), data: members, emptyLabel: loading ? m.user_loading() : m.organization_members_empty(), exportFileName: `${organization.slug}-members.csv`, features: { gallery: false }, rowActions: memberRowActions({
|
|
839
|
+
}), data: members, emptyLabel: loading ? m.user_loading() : m.organization_members_empty(), exportFileName: `${organization.slug}-members.csv`, features: { gallery: false }, searchState: "local", rowActions: memberRowActions({
|
|
832
840
|
m,
|
|
841
|
+
canRemoveMembers,
|
|
833
842
|
currentUserId,
|
|
834
843
|
onRemove: removeMember,
|
|
835
|
-
}) }) })] }), _jsxs("section", { className: "flex min-w-0 flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_invitations_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_invitations_description() })] }), _jsx("div", { className: "min-w-0 overflow-x-auto", children: _jsx(DataTable, { columns: invitationColumns({
|
|
844
|
+
}) }) })] }), _jsxs("section", { className: "flex min-w-0 flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_invitations_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_invitations_description() })] }), _jsx("div", { className: "-m-1 min-w-0 overflow-x-auto p-1", children: _jsx(DataTable, { columns: invitationColumns({
|
|
836
845
|
m,
|
|
837
|
-
}), data: invitations, emptyLabel: loading ? m.user_loading() : m.organization_invitations_empty(), exportFileName: `${organization.slug}-invitations.csv`, features: { gallery: false }, rowActions: invitationRowActions({
|
|
846
|
+
}), data: invitations, emptyLabel: loading ? m.user_loading() : m.organization_invitations_empty(), exportFileName: `${organization.slug}-invitations.csv`, features: { gallery: false }, searchState: "local", rowActions: invitationRowActions({
|
|
838
847
|
m,
|
|
839
848
|
cancellingInvitationId,
|
|
840
849
|
onCancel: cancelInvitation,
|
|
841
850
|
}) }) })] })] }));
|
|
842
851
|
}
|
|
843
|
-
const memberColumns = ({ m, baseUrl, updatingMemberId, onRoleChange, }) => [
|
|
852
|
+
const memberColumns = ({ m, baseUrl, canChangeRoles, updatingMemberId, onRoleChange, }) => [
|
|
844
853
|
{
|
|
845
854
|
id: "user",
|
|
846
855
|
header: m.organization_member_user(),
|
|
@@ -854,15 +863,23 @@ const memberColumns = ({ m, baseUrl, updatingMemberId, onRoleChange, }) => [
|
|
|
854
863
|
header: m.organization_member_role(),
|
|
855
864
|
cell: ({ row }) => {
|
|
856
865
|
const member = row.original;
|
|
857
|
-
const
|
|
858
|
-
|
|
866
|
+
const role = normalizeOrganizationRole(member.role);
|
|
867
|
+
if (!canChangeRoles || updatingMemberId === member.id) {
|
|
868
|
+
return _jsx(Badge, { variant: "secondary", children: organizationRoleLabel(role, m) });
|
|
869
|
+
}
|
|
870
|
+
return (_jsx(DataTableRelationshipCell, { emptyLabel: m.organization_member_role(), manageLabel: m.organization_member_role(), options: organizationRoles.map((role) => ({
|
|
859
871
|
label: organizationRoleLabel(role, m),
|
|
860
872
|
value: role,
|
|
861
|
-
})), value:
|
|
862
|
-
|
|
873
|
+
})), value: [
|
|
874
|
+
{
|
|
875
|
+
label: organizationRoleLabel(role, m),
|
|
876
|
+
value: role,
|
|
877
|
+
},
|
|
878
|
+
], onAdd: (value) => {
|
|
879
|
+
if ((value === "owner" || value === "admin" || value === "member")) {
|
|
863
880
|
onRoleChange(member, value);
|
|
864
881
|
}
|
|
865
|
-
}
|
|
882
|
+
} }));
|
|
866
883
|
},
|
|
867
884
|
},
|
|
868
885
|
{
|
|
@@ -871,12 +888,14 @@ const memberColumns = ({ m, baseUrl, updatingMemberId, onRoleChange, }) => [
|
|
|
871
888
|
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: formatOrganizationDate(row.original.createdAt) })),
|
|
872
889
|
},
|
|
873
890
|
];
|
|
874
|
-
const memberRowActions = ({ m, currentUserId, onRemove, }) => [
|
|
891
|
+
const memberRowActions = ({ m, canRemoveMembers, currentUserId, onRemove, }) => [
|
|
875
892
|
{
|
|
876
893
|
name: m.organization_member_remove(),
|
|
877
894
|
icon: _jsx(Trash2, {}),
|
|
878
895
|
variant: "destructive",
|
|
879
|
-
visible: (member) =>
|
|
896
|
+
visible: (member) => canRemoveMembers &&
|
|
897
|
+
member.userId !== currentUserId &&
|
|
898
|
+
normalizeOrganizationRole(member.role) !== "owner",
|
|
880
899
|
onClick: onRemove,
|
|
881
900
|
},
|
|
882
901
|
];
|
|
@@ -974,7 +993,7 @@ function OrganizationApiKeyManager({ authClient, organization, active, }) {
|
|
|
974
993
|
event.preventDefault();
|
|
975
994
|
event.stopPropagation();
|
|
976
995
|
createForm.handleSubmit();
|
|
977
|
-
}, children: [_jsx("p", { className: "text-muted-foreground text-sm", children: m.api_key_rate_limit_notice() }), _jsx(createForm.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.user_api_key_name(), required: true })) }), _jsx(createForm.FormError, {}), _jsx(createForm.SubmitButton, {})] }) }), createdKey ? (_jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-4", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(KeyRound, {}), m.user_api_key_created_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_api_key_created_description() }), _jsx("code", { className: "bg-muted overflow-x-auto rounded-md p-3 text-sm", children: createdKey })] })) : null, keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsx(Separator, {}), _jsx(DataTable, { columns: apiKeyColumns({ m }), data: keys, emptyLabel: loading ? m.user_loading() : m.table_empty(), exportFileName: `${organization.slug}-api-keys.csv`, features: { gallery: false }, rowActions: apiKeyRowActions({ m, onDelete: deleteKey }) })] }));
|
|
996
|
+
}, children: [_jsx("p", { className: "text-muted-foreground text-sm", children: m.api_key_rate_limit_notice() }), _jsx(createForm.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.user_api_key_name(), required: true })) }), _jsx(createForm.FormError, {}), _jsx(createForm.SubmitButton, {})] }) }), createdKey ? (_jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-4", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(KeyRound, {}), m.user_api_key_created_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_api_key_created_description() }), _jsx("code", { className: "bg-muted overflow-x-auto rounded-md p-3 text-sm", children: createdKey })] })) : null, keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsx(Separator, {}), _jsx(DataTable, { columns: apiKeyColumns({ m }), data: keys, emptyLabel: loading ? m.user_loading() : m.table_empty(), exportFileName: `${organization.slug}-api-keys.csv`, features: { gallery: false }, searchState: "local", rowActions: apiKeyRowActions({ m, onDelete: deleteKey }) })] }));
|
|
978
997
|
}
|
|
979
998
|
const apiKeyColumns = ({ m, }) => [
|
|
980
999
|
{
|
|
@@ -18,18 +18,13 @@ import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLeg
|
|
|
18
18
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
19
19
|
import { Separator } from "@/components/ui/separator";
|
|
20
20
|
import { authClientApi } from "./auth-client-api";
|
|
21
|
-
import {
|
|
21
|
+
import { useKrakstackAuth } from "./auth-provider";
|
|
22
22
|
import { createApiKey } from "./api-key";
|
|
23
23
|
import { useOpenedOnce } from "./hooks";
|
|
24
24
|
import { ExtraUploadedAsset } from "../extra/schema";
|
|
25
25
|
import { assetPath, assetUrl } from "./utils";
|
|
26
26
|
import { AdminOrganizationsTable } from "./admin-organizations";
|
|
27
27
|
import { AdminUsersTable } from "./admin-users";
|
|
28
|
-
const defaultAdminTableSearch = {
|
|
29
|
-
page: 0,
|
|
30
|
-
pageSize: 10,
|
|
31
|
-
globalFilter: "",
|
|
32
|
-
};
|
|
33
28
|
const messages = {
|
|
34
29
|
en: {
|
|
35
30
|
api_key_rate_limit_notice: "API keys are subject to the same rate limits as your account.",
|
|
@@ -270,8 +265,10 @@ const userApiKeysAtom = Atom.family((authClient) => Atom.keepAlive(Atom.make(Eff
|
|
|
270
265
|
const emptyApiKeysAtom = Atom.make(Effect.succeed([]));
|
|
271
266
|
export const UserButton = ({ authClient: providedAuthClient, baseUrl, signOutRedirect = "/", side = "bottom", defaultDialog = null, hideTrigger = false, renderUnauthenticated, apiKeyPermissions, messages, dialog: controlledDialog, onDialogChange, }) => {
|
|
272
267
|
const auth = useKrakstackAuth();
|
|
273
|
-
const
|
|
274
|
-
|
|
268
|
+
const authClient = providedAuthClient ?? auth?.authClient;
|
|
269
|
+
if (!authClient) {
|
|
270
|
+
throw new Error("KrakstackAuthProvider is required to use authClient.");
|
|
271
|
+
}
|
|
275
272
|
const labels = userButtonMessages(messages);
|
|
276
273
|
const m = userButtonMessageFns(labels);
|
|
277
274
|
const projectConfig = auth?.projectConfig ?? null;
|
|
@@ -279,12 +276,6 @@ export const UserButton = ({ authClient: providedAuthClient, baseUrl, signOutRed
|
|
|
279
276
|
const currentSiteHref = useRouterState({
|
|
280
277
|
select: (state) => `${import.meta.env.VITE_SITE_URL}${state.location.href}`,
|
|
281
278
|
});
|
|
282
|
-
const adminTableSearch = useRouterState({
|
|
283
|
-
select: (state) => ({
|
|
284
|
-
...defaultAdminTableSearch,
|
|
285
|
-
...state.location.search,
|
|
286
|
-
}),
|
|
287
|
-
});
|
|
288
279
|
const { data: session, isPending, refetch } = authClient.useSession();
|
|
289
280
|
const [uncontrolledDialog, setUncontrolledDialog] = useState(defaultDialog);
|
|
290
281
|
const [isStoppingImpersonation, setIsStoppingImpersonation] = useState(false);
|
|
@@ -386,13 +377,13 @@ export const UserButton = ({ authClient: providedAuthClient, baseUrl, signOutRed
|
|
|
386
377
|
setSettingsDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
387
378
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_api_keys_title() }), _jsx(DialogDescription, { children: m.user_api_keys_description() })] }), _jsx(Separator, {}), _jsx(ApiKeyManager, { authClient: authClient, active: settingsDialog === "apiKeys", permissions: apiKeyPermissions ?? {} })] }) }), isAdmin ? (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: settingsDialog === "adminUsers", onOpenChange: (open) => {
|
|
388
379
|
setSettingsDialog((current) => open ? "adminUsers" : current === "adminUsers" ? null : current);
|
|
389
|
-
}, children: _jsxs(DialogContent, { className: "flex h-[85vh] flex-col overflow-y-auto sm:max-w-6xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_button_admin_users() }), _jsx(DialogDescription, { children: m.user_button_admin_users_description() })] }), _jsx(Separator, {}), _jsx("div", { className: "min-h-0 flex-1", children: _jsx(AdminUsersTable, {
|
|
380
|
+
}, children: _jsxs(DialogContent, { className: "flex h-[85vh] flex-col overflow-y-auto sm:max-w-6xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_button_admin_users() }), _jsx(DialogDescription, { children: m.user_button_admin_users_description() })] }), _jsx(Separator, {}), _jsx("div", { className: "min-h-0 flex-1", children: _jsx(AdminUsersTable, {}) })] }) }), _jsx(Dialog, { open: settingsDialog === "adminOrganizations", onOpenChange: (open) => {
|
|
390
381
|
setSettingsDialog((current) => open
|
|
391
382
|
? "adminOrganizations"
|
|
392
383
|
: current === "adminOrganizations"
|
|
393
384
|
? null
|
|
394
385
|
: current);
|
|
395
|
-
}, children: _jsxs(DialogContent, { className: "flex h-[85vh] flex-col overflow-y-auto sm:max-w-6xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_button_admin_organizations() }), _jsx(DialogDescription, { children: m.user_button_admin_organizations_description() })] }), _jsx(Separator, {}), _jsx("div", { className: "min-h-0 flex-1", children: _jsx(AdminOrganizationsTable, {
|
|
386
|
+
}, children: _jsxs(DialogContent, { className: "flex h-[85vh] flex-col overflow-y-auto sm:max-w-6xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_button_admin_organizations() }), _jsx(DialogDescription, { children: m.user_button_admin_organizations_description() })] }), _jsx(Separator, {}), _jsx("div", { className: "min-h-0 flex-1", children: _jsx(AdminOrganizationsTable, {}) })] }) })] })) : null] }));
|
|
396
387
|
};
|
|
397
388
|
function ConnectedAccounts({ authClient, baseUrl, accountCache, googleEnabled, currentSiteHref, navigate, }) {
|
|
398
389
|
const m = useUserButtonMessages();
|
|
@@ -770,7 +761,7 @@ function ApiKeyManager({ authClient, active, permissions = {}, }) {
|
|
|
770
761
|
event.preventDefault();
|
|
771
762
|
event.stopPropagation();
|
|
772
763
|
createForm.handleSubmit();
|
|
773
|
-
}, children: [_jsx("p", { className: "text-muted-foreground text-sm", children: m.api_key_rate_limit_notice() }), _jsx(createForm.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.user_api_key_name(), required: true })) }), permissionOptions.length > 0 ? (_jsxs(FieldSet, { children: [_jsx(FieldLegend, { children: m.user_api_key_permissions() }), _jsx(FieldDescription, { children: m.user_api_key_permissions_description() }), _jsx(FieldGroup, { "data-slot": "checkbox-group", className: "gap-3", children: permissionOptions.map((permission) => (_jsxs(Field, { orientation: "horizontal", children: [_jsx(Checkbox, { id: permission.id, checked: selectedPermissions[permission.id] ?? false, onCheckedChange: (checked) => togglePermission(permission.id, checked) }), _jsx(FieldContent, { children: _jsx(FieldLabel, { htmlFor: permission.id, children: permission.id }) })] }, permission.id))) })] })) : null, _jsx(createForm.FormError, {}), _jsx(createForm.SubmitButton, {})] }) }), createdKey ? (_jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-4", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(KeyRound, {}), m.user_api_key_created_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_api_key_created_description() }), _jsxs("div", { className: "grid min-w-0 gap-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center", children: [_jsx("code", { className: "bg-muted block max-w-full overflow-x-auto rounded-md p-3 text-sm whitespace-nowrap", children: createdKey }), _jsxs(Button, { type: "button", variant: "outline", onClick: copyCreatedKey, className: "self-start sm:self-auto", children: [copiedKey ? _jsx(Check, {}) : _jsx(Copy, {}), copiedKey ? m.user_api_key_copied() : m.user_api_key_copy()] })] })] })) : null, keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsx(Separator, {}), _jsx(DataTable, { columns: apiKeyColumns({ m }), data: keys, emptyLabel: loading ? m.user_loading() : m.table_empty(), exportFileName: m.user_api_keys_export_file_name(), features: { gallery: false }, rowActions: apiKeyRowActions({ m, onDelete: deleteKey }) })] }));
|
|
764
|
+
}, children: [_jsx("p", { className: "text-muted-foreground text-sm", children: m.api_key_rate_limit_notice() }), _jsx(createForm.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.user_api_key_name(), required: true })) }), permissionOptions.length > 0 ? (_jsxs(FieldSet, { children: [_jsx(FieldLegend, { children: m.user_api_key_permissions() }), _jsx(FieldDescription, { children: m.user_api_key_permissions_description() }), _jsx(FieldGroup, { "data-slot": "checkbox-group", className: "gap-3", children: permissionOptions.map((permission) => (_jsxs(Field, { orientation: "horizontal", children: [_jsx(Checkbox, { id: permission.id, checked: selectedPermissions[permission.id] ?? false, onCheckedChange: (checked) => togglePermission(permission.id, checked) }), _jsx(FieldContent, { children: _jsx(FieldLabel, { htmlFor: permission.id, children: permission.id }) })] }, permission.id))) })] })) : null, _jsx(createForm.FormError, {}), _jsx(createForm.SubmitButton, {})] }) }), createdKey ? (_jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-4", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(KeyRound, {}), m.user_api_key_created_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_api_key_created_description() }), _jsxs("div", { className: "grid min-w-0 gap-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center", children: [_jsx("code", { className: "bg-muted block max-w-full overflow-x-auto rounded-md p-3 text-sm whitespace-nowrap", children: createdKey }), _jsxs(Button, { type: "button", variant: "outline", onClick: copyCreatedKey, className: "self-start sm:self-auto", children: [copiedKey ? _jsx(Check, {}) : _jsx(Copy, {}), copiedKey ? m.user_api_key_copied() : m.user_api_key_copy()] })] })] })) : null, keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsx(Separator, {}), _jsx(DataTable, { columns: apiKeyColumns({ m }), data: keys, emptyLabel: loading ? m.user_loading() : m.table_empty(), exportFileName: m.user_api_keys_export_file_name(), features: { gallery: false }, searchState: "local", rowActions: apiKeyRowActions({ m, onDelete: deleteKey }) })] }));
|
|
774
765
|
}
|
|
775
766
|
const apiKeyColumns = ({ m, }) => [
|
|
776
767
|
{
|