@schemavaults/auth-ui 0.17.2 → 0.19.0
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/components/ApiServersCard/api_servers_card.d.ts +20 -4
- package/dist/components/ApiServersCard/api_servers_card.js +36 -34
- package/dist/components/ApiServersCard/api_servers_card.js.map +1 -1
- package/dist/components/AppsCard/apps_card.d.ts +19 -4
- package/dist/components/AppsCard/apps_card.js +36 -36
- package/dist/components/AppsCard/apps_card.js.map +1 -1
- package/dist/components/CreateApiServerDialog/CreateApiServerDialog.d.ts +5 -4
- package/dist/components/CreateApiServerDialog/CreateApiServerDialog.js.map +1 -1
- package/dist/components/CreateApiServerDialog/CreateApiServerForm.d.ts +5 -4
- package/dist/components/CreateApiServerDialog/CreateApiServerForm.js +27 -8
- package/dist/components/CreateApiServerDialog/CreateApiServerForm.js.map +1 -1
- package/dist/components/CreateAppDialog/CreateAppDialog.d.ts +5 -4
- package/dist/components/CreateAppDialog/CreateAppDialog.js.map +1 -1
- package/dist/components/CreateAppDialog/CreateAppForm.d.ts +5 -4
- package/dist/components/CreateAppDialog/CreateAppForm.js +27 -8
- package/dist/components/CreateAppDialog/CreateAppForm.js.map +1 -1
- package/dist/components/MfaChallengeForm/mfa-challenge-form.d.ts +1 -0
- package/dist/components/MfaChallengeForm/mfa-challenge-form.js +10 -1
- package/dist/components/MfaChallengeForm/mfa-challenge-form.js.map +1 -1
- package/dist/components/ResourceOwnershipPicker/ResourceOwnershipPicker.d.ts +31 -0
- package/dist/components/ResourceOwnershipPicker/ResourceOwnershipPicker.js +107 -0
- package/dist/components/ResourceOwnershipPicker/ResourceOwnershipPicker.js.map +1 -0
- package/dist/components/ResourceOwnershipPicker/index.d.ts +8 -0
- package/dist/components/ResourceOwnershipPicker/index.js +5 -0
- package/dist/components/ResourceOwnershipPicker/index.js.map +1 -0
- package/dist/components/ResourceOwnershipPicker/resource-ownership-choices.d.ts +158 -0
- package/dist/components/ResourceOwnershipPicker/resource-ownership-choices.js +203 -0
- package/dist/components/ResourceOwnershipPicker/resource-ownership-choices.js.map +1 -0
- package/dist/components/ResourceOwnershipPicker/useResourceOwnershipChoices.d.ts +39 -0
- package/dist/components/ResourceOwnershipPicker/useResourceOwnershipChoices.js +50 -0
- package/dist/components/ResourceOwnershipPicker/useResourceOwnershipChoices.js.map +1 -0
- package/dist/components/ResourceOwnershipPicker/useResourceOwnershipSelection.d.ts +19 -0
- package/dist/components/ResourceOwnershipPicker/useResourceOwnershipSelection.js +21 -0
- package/dist/components/ResourceOwnershipPicker/useResourceOwnershipSelection.js.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/package.json +7 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Button, Checkbox, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, Input, Textarea, useToast, } from "@schemavaults/ui";
|
|
4
|
-
import { useMemo, useTransition } from "react";
|
|
4
|
+
import { useMemo, useState, useTransition } from "react";
|
|
5
5
|
import { DialogDescription, DialogFooter, DialogHeader, DialogTitle, useForm, } from "@schemavaults/ui";
|
|
6
6
|
import { useAppEnvironment, useAuth } from "@schemavaults/auth-react-provider";
|
|
7
7
|
import { useSWRConfig } from "swr";
|
|
@@ -10,9 +10,12 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|
|
10
10
|
import { AppWindow } from "lucide-react";
|
|
11
11
|
import { useAuthUiFriendlyName } from "../FriendlyNameProvider";
|
|
12
12
|
import { requestedOwnershipToDefinitionFields } from "../CreateAppDialog/requested-ownership-fields";
|
|
13
|
+
import { ResourceOwnershipPicker, describeRequestedResourceOwnership, resourceOwnershipSelectionToRequestedOwnership, useResourceOwnershipChoices, useResourceOwnershipSelection, } from "../ResourceOwnershipPicker";
|
|
13
14
|
export default function CreateAppForm({ ownership, clearFrontendAppsCache, onSuccess, uuid, }) {
|
|
14
15
|
const friendlyName = useAuthUiFriendlyName();
|
|
15
|
-
const
|
|
16
|
+
const { choices, currentUserUid } = useResourceOwnershipChoices(ownership);
|
|
17
|
+
const { selection, setSelection } = useResourceOwnershipSelection(ownership.defaultOwnership, choices);
|
|
18
|
+
const [organizationError, setOrganizationError] = useState(undefined);
|
|
16
19
|
const defaultValues = useMemo(() => {
|
|
17
20
|
return {
|
|
18
21
|
app_name: "",
|
|
@@ -22,9 +25,8 @@ export default function CreateAppForm({ ownership, clearFrontendAppsCache, onSuc
|
|
|
22
25
|
web: true,
|
|
23
26
|
created_at: Date.now(),
|
|
24
27
|
hardcoded: false,
|
|
25
|
-
...ownershipFields,
|
|
26
28
|
};
|
|
27
|
-
}, [
|
|
29
|
+
}, [uuid]);
|
|
28
30
|
const form = useForm({
|
|
29
31
|
resolver: zodResolver(schemaVaultsAppDefinitionSchema),
|
|
30
32
|
defaultValues,
|
|
@@ -42,13 +44,26 @@ export default function CreateAppForm({ ownership, clearFrontendAppsCache, onSuc
|
|
|
42
44
|
title: "Submitting frontend app creation form...",
|
|
43
45
|
});
|
|
44
46
|
}
|
|
47
|
+
const requestedOwnership = selection
|
|
48
|
+
? resourceOwnershipSelectionToRequestedOwnership(selection, currentUserUid)
|
|
49
|
+
: null;
|
|
50
|
+
if (!requestedOwnership) {
|
|
51
|
+
if (selection?.owner_type === "organization") {
|
|
52
|
+
setOrganizationError("Choose the organization that will own this app.");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
toast({
|
|
56
|
+
variant: "destructive",
|
|
57
|
+
title: "Choose who will own this app",
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
45
61
|
startSubmitting(async () => {
|
|
46
62
|
const authClient = auth.ready ? auth.client.current : undefined;
|
|
47
63
|
const createAppRequestBody = {
|
|
48
64
|
...values,
|
|
49
|
-
// The owner
|
|
50
|
-
|
|
51
|
-
...ownershipFields,
|
|
65
|
+
// The owner comes from the "Owner" field only.
|
|
66
|
+
...requestedOwnershipToDefinitionFields(requestedOwnership),
|
|
52
67
|
};
|
|
53
68
|
// if we're creating it from this form then it must be non-hardcoded/dynamic...
|
|
54
69
|
createAppRequestBody["hardcoded"] = false;
|
|
@@ -80,6 +95,7 @@ export default function CreateAppForm({ ownership, clearFrontendAppsCache, onSuc
|
|
|
80
95
|
toast({
|
|
81
96
|
variant: "default",
|
|
82
97
|
title: "Created new frontend client application successfully",
|
|
98
|
+
description: describeRequestedResourceOwnership(requestedOwnership, choices, friendlyName),
|
|
83
99
|
});
|
|
84
100
|
clearFrontendAppsCache(mutate);
|
|
85
101
|
onSuccess();
|
|
@@ -95,6 +111,9 @@ export default function CreateAppForm({ ownership, clearFrontendAppsCache, onSuc
|
|
|
95
111
|
title: "Failed to validate create app form inputs",
|
|
96
112
|
description: "See console for full error message",
|
|
97
113
|
});
|
|
98
|
-
}), className: "flex flex-col justify-start gap-4", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Create a new application" }), _jsxs(DialogDescription, { children: ["Create a new frontend/client application which can access", " ", friendlyName, " APIs."] })] }), _jsx(
|
|
114
|
+
}), className: "flex flex-col justify-start gap-4", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Create a new application" }), _jsxs(DialogDescription, { children: ["Create a new frontend/client application which can access", " ", friendlyName, " APIs."] })] }), _jsx(ResourceOwnershipPicker, { id: "create-app-owner", resourceKind: "app", choices: choices, value: selection, onValueChange: (next) => {
|
|
115
|
+
setSelection(next);
|
|
116
|
+
setOrganizationError(undefined);
|
|
117
|
+
}, disabled: submitting, organizationError: organizationError }), _jsx(FormField, { control: form.control, name: "app_name", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: "App Name" }), _jsx(FormControl, { children: _jsx(Input, { placeholder: "My New React App", ...field, disabled: submitting }) }), _jsx(FormDescription, { children: "Give a user-friendly name to the new application." }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "app_id", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: "App ID" }), _jsx(FormControl, { children: _jsx(Input, { placeholder: "my-new-react-app", ...field, disabled: submitting }) }), _jsx(FormDescription, { children: "A unique identifier for the application. Must start with a lowercase letter or number, and contain only lowercase letters, numbers, hyphens, and underscores. Defaults to a randomly generated ID." }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "app_description", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: "Description" }), _jsx(FormControl, { children: _jsx(Textarea, { placeholder: "This app connects to my new API", ...field, disabled: submitting }) }), _jsx(FormDescription, { children: "Describe what this app does." }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "public", render: ({ field }) => (_jsxs(FormItem, { className: "flex flex-row gap-2 items-center flex-wrap", children: [_jsx(FormLabel, { className: "w-full", children: "Public?" }), _jsx(FormControl, { children: _jsx(Checkbox, { checked: field.value, onCheckedChange: field.onChange, disabled: submitting, onBlur: field.onBlur }) }), _jsx(FormDescription, { className: "w-full", children: "Is this app publicly listed to end-users? I.e. can they find it without having authorized it first" }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "web", render: ({ field }) => (_jsxs(FormItem, { className: "flex flex-row gap-2 items-center flex-wrap", children: [_jsx(FormLabel, { className: "w-full", children: "Web Application?" }), _jsx(FormControl, { children: _jsx(Checkbox, { checked: field.value, onCheckedChange: field.onChange, disabled: submitting, onBlur: field.onBlur }) }), _jsx(FormDescription, { className: "w-full", children: "Is this a web application? Web apps receive authorization codes via URL redirect. Native/desktop apps receive codes via a POST request." }), _jsx(FormMessage, {})] })) }), _jsx(DialogFooter, { children: _jsxs(Button, { id: "submit-create-app-form-button", type: "submit", disabled: submitting || !selection, children: [_jsx(AppWindow, { className: "h-4 w-4 mr-2" }), "Create client application"] }) })] }) }));
|
|
99
118
|
}
|
|
100
119
|
//# sourceMappingURL=CreateAppForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateAppForm.js","sourceRoot":"","sources":["../../../src/components/CreateAppDialog/CreateAppForm.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,eAAe,EACf,SAAS,EACT,QAAQ,EACR,SAAS,EACT,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAqB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CreateAppForm.js","sourceRoot":"","sources":["../../../src/components/CreateAppDialog/CreateAppForm.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,eAAe,EACf,SAAS,EACT,QAAQ,EACR,SAAS,EACT,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAqB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,OAAO,GACR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EAGL,+BAA+B,GAEhC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,oCAAoC,EAAE,MAAM,yDAAyD,CAAC;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KAAC,eAAe,IAAC,SAAS,EAAC,QAAQ,wJAIjB,EAClB,KAAC,WAAW,KAAG,IACN,CACZ,GACD,EACF,KAAC,YAAY,cACX,MAAC,MAAM,IACL,EAAE,EAAC,+BAA+B,EAClC,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,UAAU,IAAI,CAAC,SAAS,aAElC,KAAC,SAAS,IAAC,SAAS,EAAC,cAAc,GAAG,iCAE/B,GACI,IACV,GACF,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -8,6 +8,7 @@ export interface MfaChallengeFormProps {
|
|
|
8
8
|
recovery_codes_available: boolean;
|
|
9
9
|
onAuthenticated: (authorization_code: string) => Promise<void> | void;
|
|
10
10
|
onChallengeExpired?: () => void;
|
|
11
|
+
onEmailVerificationRequired?: (message: string) => Promise<void> | void;
|
|
11
12
|
renderPasskeyAction?: (args: {
|
|
12
13
|
factor_id: string;
|
|
13
14
|
onError: (message: string) => void;
|
|
@@ -5,7 +5,7 @@ import { Button, Card, CardContent, CardDescription, CardFooter, CardHeader, Car
|
|
|
5
5
|
import { useMfa } from "@schemavaults/auth-react-provider";
|
|
6
6
|
import { ShieldCheck } from "lucide-react";
|
|
7
7
|
import { MfaFactorPicker } from "../MfaFactorPicker";
|
|
8
|
-
export const MfaChallengeForm = ({ challenge_id, client_app_id, expires_at, available_factors, recovery_codes_available, onAuthenticated, onChallengeExpired, renderPasskeyAction, }) => {
|
|
8
|
+
export const MfaChallengeForm = ({ challenge_id, client_app_id, expires_at, available_factors, recovery_codes_available, onAuthenticated, onChallengeExpired, onEmailVerificationRequired, renderPasskeyAction, }) => {
|
|
9
9
|
const { submitChallenge } = useMfa();
|
|
10
10
|
const [useRecovery, setUseRecovery] = useState(false);
|
|
11
11
|
const [value, setValue] = useState("");
|
|
@@ -43,6 +43,15 @@ export const MfaChallengeForm = ({ challenge_id, client_app_id, expires_at, avai
|
|
|
43
43
|
setError(result.message || "Verification failed");
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
+
if (result.kind === "email_verification_required") {
|
|
47
|
+
if (onEmailVerificationRequired) {
|
|
48
|
+
await onEmailVerificationRequired(result.message);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
setError(result.message ||
|
|
52
|
+
"Please verify your email address before continuing.");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
46
55
|
setError(`Unexpected response kind: ${result.kind}`);
|
|
47
56
|
}
|
|
48
57
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mfa-challenge-form.js","sourceRoot":"","sources":["../../../src/components/MfaChallengeForm/mfa-challenge-form.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,QAAQ,GAKT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,EACT,KAAK,GACN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAK3D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"mfa-challenge-form.js","sourceRoot":"","sources":["../../../src/components/MfaChallengeForm/mfa-challenge-form.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,QAAQ,GAKT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,EACT,KAAK,GACN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAK3D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAmC/D,MAAM,CAAC,MAAM,gB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IACjD,EACb,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACnB,KAAC,UAAU,cACT,MAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,SAAS,iBACR,sBAAsB,EAClC,SAAS,EAAC,iCAAiC,aAE3C,KAAC,WAAW,IAAC,SAAS,EAAC,SAAS,GAAG,EAClC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,IAC9B,GACE,CACd,IACI,IACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import { type ResourceOwnershipChoices, type ResourceOwnershipSelection } from "./resource-ownership-choices";
|
|
3
|
+
export type ResourceOwnershipPickerResourceKind = "app" | "api-server";
|
|
4
|
+
export interface ResourceOwnershipPickerProps {
|
|
5
|
+
/** The owners offered (see `useResourceOwnershipChoices()`). */
|
|
6
|
+
choices: ResourceOwnershipChoices;
|
|
7
|
+
/** The picked owner; `null` when no owner is available at all. */
|
|
8
|
+
value: ResourceOwnershipSelection | null;
|
|
9
|
+
onValueChange: (value: ResourceOwnershipSelection) => void;
|
|
10
|
+
/** What is being created; used in the copy. */
|
|
11
|
+
resourceKind: ResourceOwnershipPickerResourceKind;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Error shown under the organization select (e.g. none chosen). */
|
|
14
|
+
organizationError?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Prefix of the element ids / test ids (`<id>-user`, `<id>-organization`,
|
|
18
|
+
* `<id>-platform`, `<id>-organization-select`, `<id>-summary`).
|
|
19
|
+
*/
|
|
20
|
+
id?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @description The "Owner" field of the create app / API server dialogs: a
|
|
24
|
+
* radio card per owner type (Personal / Organization / Platform) plus an
|
|
25
|
+
* organization select, and a sentence stating who will own the new
|
|
26
|
+
* resource. Owners the viewer can never use are hidden (Platform for
|
|
27
|
+
* non-admins); owners they cannot use right now are disabled with the
|
|
28
|
+
* reason.
|
|
29
|
+
*/
|
|
30
|
+
export declare function ResourceOwnershipPicker({ choices, value, onValueChange, resourceKind, disabled, organizationError, className, id, }: ResourceOwnershipPickerProps): ReactElement;
|
|
31
|
+
export default ResourceOwnershipPicker;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Label, RadioCard, RadioCardDescription, RadioCardGroup, RadioCardHeader, RadioCardIcon, RadioCardTitle, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, cn, } from "@schemavaults/ui";
|
|
4
|
+
import { Building2, Server, User as UserIcon } from "lucide-react";
|
|
5
|
+
import { useAuthUiFriendlyName } from "../FriendlyNameProvider";
|
|
6
|
+
import { CREATABLE_RESOURCE_OWNER_TYPES, defaultOrganizationForSelection, } from "./resource-ownership-choices";
|
|
7
|
+
const RESOURCE_NOUNS = {
|
|
8
|
+
app: { singular: "app", plural: "apps" },
|
|
9
|
+
"api-server": { singular: "API server", plural: "API servers" },
|
|
10
|
+
};
|
|
11
|
+
function isCreatableResourceOwnerType(value) {
|
|
12
|
+
return CREATABLE_RESOURCE_OWNER_TYPES.includes(value);
|
|
13
|
+
}
|
|
14
|
+
function unavailableReasonText(reason, nounPlural) {
|
|
15
|
+
switch (reason) {
|
|
16
|
+
case "personal-creation-disabled":
|
|
17
|
+
return `An administrator has turned off personal ${nounPlural} on this server.`;
|
|
18
|
+
case "account-loading":
|
|
19
|
+
return "Loading your account…";
|
|
20
|
+
case "organizations-loading":
|
|
21
|
+
return "Loading your organizations…";
|
|
22
|
+
case "organizations-error":
|
|
23
|
+
return "Couldn't load your organizations.";
|
|
24
|
+
case "not-organization-admin":
|
|
25
|
+
return `Only an organization's owners and admins can add ${nounPlural} to it.`;
|
|
26
|
+
case "no-organizations":
|
|
27
|
+
return "You aren't a member of any organization.";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @description The "Owner" field of the create app / API server dialogs: a
|
|
32
|
+
* radio card per owner type (Personal / Organization / Platform) plus an
|
|
33
|
+
* organization select, and a sentence stating who will own the new
|
|
34
|
+
* resource. Owners the viewer can never use are hidden (Platform for
|
|
35
|
+
* non-admins); owners they cannot use right now are disabled with the
|
|
36
|
+
* reason.
|
|
37
|
+
*/
|
|
38
|
+
export function ResourceOwnershipPicker({ choices, value, onValueChange, resourceKind, disabled = false, organizationError, className, id = "resource-ownership", }) {
|
|
39
|
+
const friendlyName = useAuthUiFriendlyName();
|
|
40
|
+
const noun = RESOURCE_NOUNS[resourceKind];
|
|
41
|
+
const labelId = `${id}-label`;
|
|
42
|
+
const organizationSelectId = `${id}-organization-select`;
|
|
43
|
+
const organizationErrorId = `${id}-organization-error`;
|
|
44
|
+
const options = {
|
|
45
|
+
user: {
|
|
46
|
+
title: "Personal",
|
|
47
|
+
description: "Owned by your account. Only you can manage it.",
|
|
48
|
+
icon: _jsx(UserIcon, {}),
|
|
49
|
+
},
|
|
50
|
+
organization: {
|
|
51
|
+
title: "Organization",
|
|
52
|
+
description: "Owned by an organization. Its owners and admins manage it; its members can view it.",
|
|
53
|
+
icon: _jsx(Building2, {}),
|
|
54
|
+
},
|
|
55
|
+
platform: {
|
|
56
|
+
title: "Platform",
|
|
57
|
+
description: `Owned by the ${friendlyName} platform. Only administrators can manage it.`,
|
|
58
|
+
icon: _jsx(Server, {}),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
const selectedOrganization = value?.owner_type === "organization" && value.owner_organization_id
|
|
62
|
+
? choices.organizations.find((o) => o.organization_id === value.owner_organization_id)
|
|
63
|
+
: undefined;
|
|
64
|
+
let summary;
|
|
65
|
+
switch (value?.owner_type) {
|
|
66
|
+
case "user":
|
|
67
|
+
summary = (_jsxs(_Fragment, { children: ["This ", noun.singular, " will be owned by", " ", _jsx("span", { className: "font-medium text-foreground", children: "your account" }), "."] }));
|
|
68
|
+
break;
|
|
69
|
+
case "organization":
|
|
70
|
+
summary = selectedOrganization ? (_jsxs(_Fragment, { children: ["This ", noun.singular, " will be owned by", " ", _jsx("span", { className: "font-medium text-foreground", children: selectedOrganization.organization_name ??
|
|
71
|
+
selectedOrganization.organization_id }), "."] })) : (_jsxs(_Fragment, { children: ["Choose the organization that will own this ", noun.singular, "."] }));
|
|
72
|
+
break;
|
|
73
|
+
case "platform":
|
|
74
|
+
summary = (_jsxs(_Fragment, { children: ["This ", noun.singular, " will be owned by the", " ", _jsxs("span", { className: "font-medium text-foreground", children: [friendlyName, " platform"] }), "."] }));
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
summary = _jsxs(_Fragment, { children: ["You can't create ", noun.plural, " for any owner."] });
|
|
78
|
+
}
|
|
79
|
+
return (_jsxs("div", { className: cn("space-y-2", className), "data-testid": id, children: [_jsx("p", { id: labelId, className: "text-sm font-medium leading-none", children: "Owner" }), _jsx(RadioCardGroup, { "aria-labelledby": labelId, value: value?.owner_type ?? "", onValueChange: (next) => {
|
|
80
|
+
if (!isCreatableResourceOwnerType(next)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
onValueChange({
|
|
84
|
+
owner_type: next,
|
|
85
|
+
owner_organization_id: next === "organization"
|
|
86
|
+
? value?.owner_type === "organization" &&
|
|
87
|
+
value.owner_organization_id
|
|
88
|
+
? value.owner_organization_id
|
|
89
|
+
: defaultOrganizationForSelection(choices)
|
|
90
|
+
: null,
|
|
91
|
+
});
|
|
92
|
+
}, disabled: disabled, size: "sm", className: "gap-2", children: CREATABLE_RESOURCE_OWNER_TYPES.map((owner_type) => {
|
|
93
|
+
const state = choices[owner_type];
|
|
94
|
+
if (state.status === "hidden") {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const option = options[owner_type];
|
|
98
|
+
return (_jsx(RadioCard, { value: owner_type, id: `${id}-${owner_type}`, "data-testid": `${id}-${owner_type}`, "data-availability": state.status, disabled: disabled || state.status === "disabled", children: _jsxs(RadioCardHeader, { children: [_jsx(RadioCardIcon, { children: option.icon }), _jsxs("div", { className: "flex flex-col gap-1 pr-6", children: [_jsx(RadioCardTitle, { children: option.title }), _jsx(RadioCardDescription, { children: state.status === "disabled"
|
|
99
|
+
? unavailableReasonText(state.reason, noun.plural)
|
|
100
|
+
: option.description })] })] }) }, owner_type));
|
|
101
|
+
}) }), value?.owner_type === "organization" && (_jsxs("div", { className: "space-y-2 pt-1", children: [_jsx(Label, { htmlFor: organizationSelectId, children: "Organization" }), _jsxs(Select, { value: value.owner_organization_id ?? "", onValueChange: (organization_id) => {
|
|
102
|
+
onValueChange({ owner_type: "organization", owner_organization_id: organization_id });
|
|
103
|
+
}, disabled: disabled, children: [_jsx(SelectTrigger, { id: organizationSelectId, "data-testid": organizationSelectId, className: "w-full", "aria-invalid": organizationError ? true : undefined, "aria-describedby": organizationError ? organizationErrorId : undefined, children: _jsx(SelectValue, { placeholder: "Choose an organization" }) }), _jsx(SelectContent, { children: choices.organizations.map((organization) => (_jsx(SelectItem, { value: organization.organization_id, "data-testid": `${organizationSelectId}-option-${organization.organization_id}`, children: organization.organization_name ??
|
|
104
|
+
organization.organization_id }, organization.organization_id))) })] }), organizationError && (_jsx("p", { id: organizationErrorId, className: "text-sm font-medium text-destructive", children: organizationError }))] })), _jsx("p", { id: `${id}-summary`, "data-testid": `${id}-summary`, "data-owner-type": value?.owner_type ?? "", className: "text-sm text-muted-foreground", "aria-live": "polite", children: organizationError ? null : summary })] }));
|
|
105
|
+
}
|
|
106
|
+
export default ResourceOwnershipPicker;
|
|
107
|
+
//# sourceMappingURL=ResourceOwnershipPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceOwnershipPicker.js","sourceRoot":"","sources":["../../../src/components/ResourceOwnershipPicker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ACD,QAAQ,EAAE,QAAQ,aAElB,KAAC,aAAa,IACZ,EAAE,EAAE,oBAAoB,iBACX,oBAAoB,EACjC,SAAS,EAAC,QAAQ,kBACJ,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,sBAChC,iBAAiB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,YAErE,KAAC,WAAW,IAAC,WAAW,EAAC,wBAAwB,GAAG,GACtC,EAChB,KAAC,aAAa,cACX,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAC3C,KAAC,UAAU,IAET,KAAK,EAAE,YAAY,CAAC,eAAe,iBACtB,GAAG,oBAAoB,WAAW,YAAY,CAAC,eAAe,EAAE,YAE5E,YAAY,CAAC,iBAAiB;wCAC7B,YAAY,CAAC,eAAe,IALzB,YAAY,CAAC,eAAe,CAMtB,CACd,CAAC,GACY,IACT,EACR,iBAAiB,IAAI,CACpB,YACE,EAAE,EAAE,mBAAmB,EACvB,SAAS,EAAC,sCAAsC,YAE/C,iBAAiB,GAChB,CACL,IACG,CACP,EACD,YACE,EAAE,EAAE,GAAG,EAAE,UAAU,iBACN,GAAG,EAAE,UAAU,qBACX,KAAK,EAAE,UAAU,IAAI,EAAE,EACxC,SAAS,EAAC,+BAA+B,eAC/B,QAAQ,YAGjB,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,GACjC,IACA,CACP,CAAC;AACJ,CAAC;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ResourceOwnershipPicker, ResourceOwnershipPicker as default, } from "./ResourceOwnershipPicker";
|
|
2
|
+
export type * from "./ResourceOwnershipPicker";
|
|
3
|
+
export { useResourceOwnershipChoices } from "./useResourceOwnershipChoices";
|
|
4
|
+
export type * from "./useResourceOwnershipChoices";
|
|
5
|
+
export { useResourceOwnershipSelection } from "./useResourceOwnershipSelection";
|
|
6
|
+
export type * from "./useResourceOwnershipSelection";
|
|
7
|
+
export { CREATABLE_RESOURCE_OWNER_TYPES, computeResourceOwnershipChoices, hasAvailableResourceOwnership, isResourceOwnershipSelectionAvailable, defaultOrganizationForSelection, resolveDefaultResourceOwnershipSelection, resourceOwnershipSelectionToRequestedOwnership, describeRequestedResourceOwnership, preferredResourceOwnershipForList, } from "./resource-ownership-choices";
|
|
8
|
+
export type * from "./resource-ownership-choices";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ResourceOwnershipPicker, ResourceOwnershipPicker as default, } from "./ResourceOwnershipPicker";
|
|
2
|
+
export { useResourceOwnershipChoices } from "./useResourceOwnershipChoices";
|
|
3
|
+
export { useResourceOwnershipSelection } from "./useResourceOwnershipSelection";
|
|
4
|
+
export { CREATABLE_RESOURCE_OWNER_TYPES, computeResourceOwnershipChoices, hasAvailableResourceOwnership, isResourceOwnershipSelectionAvailable, defaultOrganizationForSelection, resolveDefaultResourceOwnershipSelection, resourceOwnershipSelectionToRequestedOwnership, describeRequestedResourceOwnership, preferredResourceOwnershipForList, } from "./resource-ownership-choices";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ResourceOwnershipPicker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,uBAAuB,IAAI,OAAO,GACnC,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAG5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAGhF,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,6BAA6B,EAC7B,qCAAqC,EACrC,+BAA+B,EAC/B,wCAAwC,EACxC,8CAA8C,EAC9C,kCAAkC,EAClC,iCAAiC,GAClC,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { RequestedResourceOwnership } from "@schemavaults/app-definitions";
|
|
2
|
+
import type { OrganizationMembershipRoleDetails } from "@schemavaults/auth-common";
|
|
3
|
+
/**
|
|
4
|
+
* The owner types a create dialog can offer. Dynamically registered clients
|
|
5
|
+
* are never requested through the create dialogs (only
|
|
6
|
+
* `POST /api/oidc/register` creates them).
|
|
7
|
+
*/
|
|
8
|
+
export type CreatableResourceOwnerType = RequestedResourceOwnership["owner_type"];
|
|
9
|
+
/** Display order of the owner options in the create dialogs. */
|
|
10
|
+
export declare const CREATABLE_RESOURCE_OWNER_TYPES: readonly ["user", "organization", "platform"];
|
|
11
|
+
/**
|
|
12
|
+
* The owner a create dialog preselects: derived from where the dialog was
|
|
13
|
+
* opened (the admin console → platform, an organization page → that
|
|
14
|
+
* organization, the `/apps` / `/apis` pages → the viewer's account). The
|
|
15
|
+
* viewer can pick another owner in the dialog.
|
|
16
|
+
*/
|
|
17
|
+
export type PreferredResourceOwnership = {
|
|
18
|
+
owner_type: "user";
|
|
19
|
+
} | {
|
|
20
|
+
owner_type: "organization";
|
|
21
|
+
owner_organization_id?: string | null;
|
|
22
|
+
} | {
|
|
23
|
+
owner_type: "platform";
|
|
24
|
+
};
|
|
25
|
+
/** An organization the viewer can pick as the owner of a new resource. */
|
|
26
|
+
export interface ResourceOwnershipOrganizationChoice {
|
|
27
|
+
organization_id: string;
|
|
28
|
+
/** Display name; `null` when unknown (the id is shown instead). */
|
|
29
|
+
organization_name: string | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Why an owner option is offered but cannot be picked:
|
|
33
|
+
* - `personal-creation-disabled`: the `allow_user_owned_resource_creation`
|
|
34
|
+
* server setting is off (and the viewer is not a global admin).
|
|
35
|
+
* - `account-loading`: the viewer's user id is not known yet.
|
|
36
|
+
* - `organizations-loading` / `organizations-error`: the viewer's
|
|
37
|
+
* organization memberships are still loading / failed to load.
|
|
38
|
+
* - `not-organization-admin`: the viewer belongs to organizations, but is
|
|
39
|
+
* not an owner/admin of any of them.
|
|
40
|
+
* - `no-organizations`: the viewer does not belong to any organization.
|
|
41
|
+
*/
|
|
42
|
+
export type ResourceOwnershipUnavailableReason = "personal-creation-disabled" | "account-loading" | "organizations-loading" | "organizations-error" | "not-organization-admin" | "no-organizations";
|
|
43
|
+
/**
|
|
44
|
+
* Whether an owner option is shown, and whether it can be picked. Options
|
|
45
|
+
* the viewer can never use (platform ownership for non-admins) are hidden;
|
|
46
|
+
* options they could use under other circumstances are shown disabled with
|
|
47
|
+
* the reason.
|
|
48
|
+
*/
|
|
49
|
+
export type ResourceOwnershipOptionState = {
|
|
50
|
+
status: "available";
|
|
51
|
+
} | {
|
|
52
|
+
status: "disabled";
|
|
53
|
+
reason: ResourceOwnershipUnavailableReason;
|
|
54
|
+
} | {
|
|
55
|
+
status: "hidden";
|
|
56
|
+
};
|
|
57
|
+
export interface ResourceOwnershipChoices {
|
|
58
|
+
user: ResourceOwnershipOptionState;
|
|
59
|
+
organization: ResourceOwnershipOptionState;
|
|
60
|
+
platform: ResourceOwnershipOptionState;
|
|
61
|
+
/** The organizations the viewer may create resources for. */
|
|
62
|
+
organizations: readonly ResourceOwnershipOrganizationChoice[];
|
|
63
|
+
}
|
|
64
|
+
export interface ComputeResourceOwnershipChoicesInput {
|
|
65
|
+
/** Global admins may create resources for any owner. */
|
|
66
|
+
isGlobalAdmin: boolean;
|
|
67
|
+
/** The viewer's user id; `null` while unknown. */
|
|
68
|
+
currentUserUid: string | null;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the viewer may create personal (user-owned) resources: the
|
|
71
|
+
* `allow_user_owned_resource_creation` server setting, which global
|
|
72
|
+
* admins are exempt from.
|
|
73
|
+
*/
|
|
74
|
+
allowPersonal: boolean;
|
|
75
|
+
/** The viewer's organization memberships (`useMyOrganizations()`). */
|
|
76
|
+
memberships: readonly OrganizationMembershipRoleDetails[] | undefined;
|
|
77
|
+
membershipsLoading: boolean;
|
|
78
|
+
membershipsError: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* The platform's virtual organization; never offered as an organization
|
|
81
|
+
* owner (platform ownership is its own option).
|
|
82
|
+
*/
|
|
83
|
+
platformOrganizationId: string;
|
|
84
|
+
/**
|
|
85
|
+
* The organization the dialog was opened for (an organization page whose
|
|
86
|
+
* viewer may manage it). Offered even when the viewer is not a member of
|
|
87
|
+
* it (global admins).
|
|
88
|
+
*/
|
|
89
|
+
contextOrganization?: ResourceOwnershipOrganizationChoice;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @description Works out which owners a create dialog offers the viewer,
|
|
93
|
+
* mirroring the server's rules (`resolveRequestedOwnershipForCreation`):
|
|
94
|
+
* personal ownership needs the `allow_user_owned_resource_creation`
|
|
95
|
+
* setting (global admins are exempt), organization ownership needs the
|
|
96
|
+
* owner/admin role in that organization (global admins may use any), and
|
|
97
|
+
* platform ownership is for global admins only.
|
|
98
|
+
*/
|
|
99
|
+
export declare function computeResourceOwnershipChoices(input: ComputeResourceOwnershipChoicesInput): ResourceOwnershipChoices;
|
|
100
|
+
/**
|
|
101
|
+
* @description Whether any owner can be picked, i.e. whether a create
|
|
102
|
+
* dialog could submit at all.
|
|
103
|
+
*/
|
|
104
|
+
export declare function hasAvailableResourceOwnership(choices: ResourceOwnershipChoices): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* The owner picked in a create dialog. `owner_organization_id` is the
|
|
107
|
+
* chosen organization when `owner_type` is `organization` (`null` until one
|
|
108
|
+
* is chosen) and always `null` otherwise.
|
|
109
|
+
*/
|
|
110
|
+
export interface ResourceOwnershipSelection {
|
|
111
|
+
owner_type: CreatableResourceOwnerType;
|
|
112
|
+
owner_organization_id: string | null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* @description Whether a selection can still be submitted as picked: its
|
|
116
|
+
* owner option is available and its organization (if already chosen) is
|
|
117
|
+
* one the viewer may create resources for.
|
|
118
|
+
*/
|
|
119
|
+
export declare function isResourceOwnershipSelectionAvailable(selection: ResourceOwnershipSelection, choices: ResourceOwnershipChoices): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* @description The organization preselected when the organization owner is
|
|
122
|
+
* picked: the preferred one when the viewer may use it, the only one when
|
|
123
|
+
* there is exactly one, and none (the viewer must choose) otherwise.
|
|
124
|
+
*/
|
|
125
|
+
export declare function defaultOrganizationForSelection(choices: ResourceOwnershipChoices, preferred_organization_id?: string | null): string | null;
|
|
126
|
+
/**
|
|
127
|
+
* @description The owner a create dialog preselects: the preferred owner
|
|
128
|
+
* when the viewer may use it, otherwise the first available option (in
|
|
129
|
+
* {@link CREATABLE_RESOURCE_OWNER_TYPES} order). `null` when no owner is
|
|
130
|
+
* available at all.
|
|
131
|
+
*/
|
|
132
|
+
export declare function resolveDefaultResourceOwnershipSelection(preferred: PreferredResourceOwnership, choices: ResourceOwnershipChoices): ResourceOwnershipSelection | null;
|
|
133
|
+
/**
|
|
134
|
+
* @description Turns the owner picked in a create dialog into the ownership
|
|
135
|
+
* of the creation request. `null` when the selection is incomplete (no
|
|
136
|
+
* organization chosen yet, or the viewer's user id is unknown).
|
|
137
|
+
*/
|
|
138
|
+
export declare function resourceOwnershipSelectionToRequestedOwnership(selection: ResourceOwnershipSelection, currentUserUid: string | null): RequestedResourceOwnership | null;
|
|
139
|
+
/**
|
|
140
|
+
* @description One sentence naming the owner of a newly created resource,
|
|
141
|
+
* e.g. for the success toast of a create dialog.
|
|
142
|
+
*/
|
|
143
|
+
export declare function describeRequestedResourceOwnership(ownership: RequestedResourceOwnership, choices: ResourceOwnershipChoices, friendlyName: string): string;
|
|
144
|
+
/**
|
|
145
|
+
* @description The owner a create button preselects, from the list it sits
|
|
146
|
+
* on: the admin console's "all" list → platform, an organization's list →
|
|
147
|
+
* that organization, the viewer's own ("owned" / "accessible") lists → the
|
|
148
|
+
* viewer's account. An owner-type filter applied to the list takes
|
|
149
|
+
* precedence, so e.g. `/apps` filtered to "Organization" preselects an
|
|
150
|
+
* organization. `null` for lists that do not offer creation.
|
|
151
|
+
*/
|
|
152
|
+
export declare function preferredResourceOwnershipForList({ queryType, organization_id, platformOrganizationId, ownerTypeFilter, }: {
|
|
153
|
+
queryType: string;
|
|
154
|
+
organization_id?: string;
|
|
155
|
+
platformOrganizationId: string;
|
|
156
|
+
/** The list's owner-type filter (`OwnerTypeFilterValue`), if any. */
|
|
157
|
+
ownerTypeFilter?: string;
|
|
158
|
+
}): PreferredResourceOwnership | null;
|