@alepha/ui 0.32.0 → 0.33.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/account/AccountConnections.js +1 -1
- package/dist/account/AccountConnections.js.map +1 -1
- package/dist/account/AccountDeleteDialog.d.ts.map +1 -1
- package/dist/account/AccountDeleteDialog.js +17 -17
- package/dist/account/AccountDeleteDialog.js.map +1 -1
- package/dist/account/AccountKeys.js +2 -2
- package/dist/account/AccountKeys.js.map +1 -1
- package/dist/account/AccountMfaDialog.d.ts.map +1 -1
- package/dist/account/AccountMfaDialog.js +19 -25
- package/dist/account/AccountMfaDialog.js.map +1 -1
- package/dist/account/AccountPasswordDialog.d.ts.map +1 -1
- package/dist/account/AccountPasswordDialog.js +25 -24
- package/dist/account/AccountPasswordDialog.js.map +1 -1
- package/dist/account/AccountProfile.d.ts.map +1 -1
- package/dist/account/AccountProfile.js +17 -24
- package/dist/account/AccountProfile.js.map +1 -1
- package/dist/account/AccountSecurity.d.ts.map +1 -1
- package/dist/account/AccountSecurity.js +21 -19
- package/dist/account/AccountSecurity.js.map +1 -1
- package/dist/account/AccountSessions.js +1 -1
- package/dist/account/AccountSessions.js.map +1 -1
- package/dist/account/ApiKeyCreateDialog.d.ts.map +1 -1
- package/dist/account/ApiKeyCreateDialog.js +8 -12
- package/dist/account/ApiKeyCreateDialog.js.map +1 -1
- package/dist/admin/AdminFiles.js +1 -1
- package/dist/admin/AdminFiles.js.map +1 -1
- package/dist/admin/AdminJobs.js +1 -1
- package/dist/admin/AdminJobs.js.map +1 -1
- package/dist/admin/AdminKeys.js +1 -1
- package/dist/admin/AdminKeys.js.map +1 -1
- package/dist/admin/AdminParameters.d.ts.map +1 -1
- package/dist/admin/AdminParameters.js +7 -5
- package/dist/admin/AdminParameters.js.map +1 -1
- package/dist/admin/AdminParametersTreeFooterActions.d.ts +2 -2
- package/dist/admin/AdminParametersTreeFooterActions.d.ts.map +1 -1
- package/dist/admin/AdminParametersTreeFooterActions.js.map +1 -1
- package/dist/admin/AdminParametersTreePane.d.ts +2 -2
- package/dist/admin/AdminParametersTreePane.d.ts.map +1 -1
- package/dist/admin/AdminParametersTreePane.js.map +1 -1
- package/dist/admin/AdminRouter.d.ts +1 -3
- package/dist/admin/AdminRouter.d.ts.map +1 -1
- package/dist/admin/AdminRouter.js +2 -4
- package/dist/admin/AdminRouter.js.map +1 -1
- package/dist/admin/AdminSessions.js +1 -1
- package/dist/admin/AdminSessions.js.map +1 -1
- package/dist/admin/AdminUserAvatarControl.d.ts.map +1 -1
- package/dist/admin/AdminUserAvatarControl.js +9 -16
- package/dist/admin/AdminUserAvatarControl.js.map +1 -1
- package/dist/admin/AdminUserDetail.js +4 -4
- package/dist/admin/AdminUserDetail.js.map +1 -1
- package/dist/admin/AdminUsers.d.ts.map +1 -1
- package/dist/admin/AdminUsers.js +10 -12
- package/dist/admin/AdminUsers.js.map +1 -1
- package/dist/admin/AdminUsersRolesPicker.d.ts +5 -1
- package/dist/admin/AdminUsersRolesPicker.d.ts.map +1 -1
- package/dist/admin/AdminUsersRolesPicker.js +2 -3
- package/dist/admin/AdminUsersRolesPicker.js.map +1 -1
- package/dist/admin/analytics/QueryPanel.js +1 -1
- package/dist/admin/analytics/QueryPanel.js.map +1 -1
- package/dist/admin/useConfirmedAction.d.ts +8 -2
- package/dist/admin/useConfirmedAction.d.ts.map +1 -1
- package/dist/admin/useConfirmedAction.js +15 -4
- package/dist/admin/useConfirmedAction.js.map +1 -1
- package/dist/auth/AuthLogin.d.ts.map +1 -1
- package/dist/auth/AuthLogin.js +4 -4
- package/dist/auth/AuthLogin.js.map +1 -1
- package/dist/auth/AuthRegister.js.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/form/AutoForm.js +1 -1
- package/dist/form/AutoForm.js.map +1 -1
- package/dist/form/Control.js +1 -1
- package/dist/form/Control.js.map +1 -1
- package/dist/form/ControlArray.js +5 -5
- package/dist/form/ControlArray.js.map +1 -1
- package/dist/form/ControlSelect.js +2 -2
- package/dist/form/ControlSelect.js.map +1 -1
- package/dist/form/ControlUpload.d.ts +1 -1
- package/dist/form/ControlUpload.js.map +1 -1
- package/dist/i18n/fr/uiFr.d.ts.map +1 -1
- package/dist/i18n/fr/uiFr.js +0 -9
- package/dist/i18n/fr/uiFr.js.map +1 -1
- package/dist/organizations/MyOrganizationInvitations.js +2 -2
- package/dist/organizations/MyOrganizationInvitations.js.map +1 -1
- package/dist/organizations/OrganizationInviteDialog.js +1 -1
- package/dist/organizations/OrganizationInviteDialog.js.map +1 -1
- package/dist/organizations/OrganizationMembers.js +1 -1
- package/dist/organizations/OrganizationMembers.js.map +1 -1
- package/dist/organizations/OrganizationPendingInvitations.js +1 -1
- package/dist/organizations/OrganizationPendingInvitations.js.map +1 -1
- package/dist/organizations/OrganizationRanks.js +3 -3
- package/dist/organizations/OrganizationRanks.js.map +1 -1
- package/dist/organizations/useInviteOrganizationMember.d.ts +6 -1
- package/dist/organizations/useInviteOrganizationMember.d.ts.map +1 -1
- package/dist/organizations/useInviteOrganizationMember.js +13 -13
- package/dist/organizations/useInviteOrganizationMember.js.map +1 -1
- package/dist/organizations/useRevokeOrganizationInvitation.d.ts +7 -1
- package/dist/organizations/useRevokeOrganizationInvitation.d.ts.map +1 -1
- package/dist/organizations/useRevokeOrganizationInvitation.js +13 -2
- package/dist/organizations/useRevokeOrganizationInvitation.js.map +1 -1
- package/dist/shell/ButtonUser.d.ts +1 -2
- package/dist/shell/ButtonUser.d.ts.map +1 -1
- package/dist/shell/ButtonUser.js +14 -42
- package/dist/shell/ButtonUser.js.map +1 -1
- package/dist/shell/ButtonUserContent.d.ts +13 -0
- package/dist/shell/ButtonUserContent.d.ts.map +1 -0
- package/dist/shell/ButtonUserContent.js +52 -0
- package/dist/shell/ButtonUserContent.js.map +1 -0
- package/dist/shell/ButtonUserPlaceholder.d.ts +14 -0
- package/dist/shell/ButtonUserPlaceholder.d.ts.map +1 -0
- package/dist/shell/ButtonUserPlaceholder.js +17 -0
- package/dist/shell/ButtonUserPlaceholder.js.map +1 -0
- package/dist/styles.css +31 -0
- package/dist/table/DataTable.js +1 -1
- package/dist/table/DataTable.js.map +1 -1
- package/dist/table/DataTableFilterBar.js +2 -2
- package/dist/table/DataTableFilterBar.js.map +1 -1
- package/dist/table/dataTableBaseProps.d.ts +1 -1
- package/dist/table/dataTableTypes.d.ts +3 -3
- package/dist/table/dataTableTypes.d.ts.map +1 -1
- package/dist/table/useDataTableData.d.ts.map +1 -1
- package/dist/table/useDataTableData.js +3 -1
- package/dist/table/useDataTableData.js.map +1 -1
- package/dist/table/useDataTableRefresh.js +2 -2
- package/dist/table/useDataTableRefresh.js.map +1 -1
- package/dist/table/useDataTableSummary.d.ts.map +1 -1
- package/dist/table/useDataTableSummary.js +2 -1
- package/dist/table/useDataTableSummary.js.map +1 -1
- package/package.json +6 -6
- package/src/account/AccountConnections.tsx +1 -1
- package/src/account/AccountDeleteDialog.tsx +25 -31
- package/src/account/AccountKeys.tsx +2 -2
- package/src/account/AccountMfaDialog.tsx +33 -27
- package/src/account/AccountPasswordDialog.tsx +36 -39
- package/src/account/AccountProfile.tsx +29 -43
- package/src/account/AccountSecurity.tsx +57 -64
- package/src/account/AccountSessions.tsx +1 -1
- package/src/account/ApiKeyCreateDialog.tsx +12 -20
- package/src/account/__tests__/AccountRouter.spec.ts +2 -1
- package/src/admin/AdminFiles.tsx +1 -1
- package/src/admin/AdminJobs.tsx +1 -1
- package/src/admin/AdminKeys.tsx +1 -1
- package/src/admin/AdminParameters.tsx +7 -5
- package/src/admin/AdminParametersTreeFooterActions.tsx +2 -2
- package/src/admin/AdminParametersTreePane.tsx +2 -2
- package/src/admin/AdminRouter.tsx +2 -4
- package/src/admin/AdminSessions.tsx +1 -1
- package/src/admin/AdminUserAvatarControl.tsx +17 -22
- package/src/admin/AdminUserDetail.tsx +4 -4
- package/src/admin/AdminUsers.tsx +10 -12
- package/src/admin/AdminUsersRolesPicker.tsx +11 -4
- package/src/admin/__tests__/AdminRouter.spec.ts +3 -2
- package/src/admin/analytics/QueryPanel.tsx +1 -1
- package/src/admin/useConfirmedAction.tsx +24 -10
- package/src/auth/AuthLogin.tsx +10 -9
- package/src/auth/AuthRegister.tsx +2 -2
- package/src/form/AutoForm.tsx +1 -1
- package/src/form/Control.tsx +1 -1
- package/src/form/ControlArray.tsx +5 -5
- package/src/form/ControlSelect.tsx +2 -2
- package/src/form/ControlUpload.tsx +1 -1
- package/src/form/__tests__/ControlArrayChildChange.browser.spec.tsx +1 -1
- package/src/i18n/fr/uiFr.ts +0 -9
- package/src/organizations/MyOrganizationInvitations.tsx +2 -2
- package/src/organizations/OrganizationInviteDialog.tsx +1 -1
- package/src/organizations/OrganizationMembers.tsx +1 -1
- package/src/organizations/OrganizationPendingInvitations.tsx +1 -1
- package/src/organizations/OrganizationRanks.tsx +3 -3
- package/src/organizations/useInviteOrganizationMember.ts +22 -15
- package/src/organizations/useRevokeOrganizationInvitation.ts +23 -4
- package/src/shell/ButtonUser.tsx +14 -79
- package/src/shell/ButtonUserContent.tsx +92 -0
- package/src/shell/ButtonUserPlaceholder.tsx +25 -0
- package/src/shell/__tests__/ActionErrorToaster.browser.spec.tsx +1 -1
- package/src/shell/__tests__/ActionErrorToasterHandled.browser.spec.tsx +1 -2
- package/src/shell/__tests__/AppShell.pageCache.spec.tsx +67 -0
- package/src/styles.css +31 -0
- package/src/table/DataTable.tsx +1 -1
- package/src/table/DataTableFilterBar.tsx +2 -2
- package/src/table/__tests__/DataTableFilterDateRange.browser.spec.tsx +1 -1
- package/src/table/__tests__/DataTableQuerySeed.browser.spec.tsx +1 -1
- package/src/table/__tests__/DataTableShareFilters.browser.spec.tsx +1 -1
- package/src/table/dataTableBaseProps.ts +1 -1
- package/src/table/dataTableTypes.ts +3 -3
- package/src/table/useDataTableData.ts +2 -0
- package/src/table/useDataTableRefresh.ts +3 -3
- package/src/table/useDataTableSummary.ts +2 -1
|
@@ -25,8 +25,12 @@ export interface AdminUsersRolesPickerProps {
|
|
|
25
25
|
* Persist the row's full role list. The picker computes it: it is the only
|
|
26
26
|
* place that knows the roles already toggled on this row, since the table
|
|
27
27
|
* does not reload the row after a toggle.
|
|
28
|
+
*
|
|
29
|
+
* Resolves whether the change was saved: the picker shows it only then, so
|
|
30
|
+
* a failed save, or a toggle dropped while another was in flight, leaves
|
|
31
|
+
* the row as it was.
|
|
28
32
|
*/
|
|
29
|
-
onToggle: (roles: string[]) => Promise<
|
|
33
|
+
onToggle: (roles: string[]) => Promise<boolean>;
|
|
30
34
|
rolesLabel: string;
|
|
31
35
|
noRolesLabel: string;
|
|
32
36
|
}
|
|
@@ -36,6 +40,8 @@ export interface AdminUsersRolesPickerProps {
|
|
|
36
40
|
*/
|
|
37
41
|
export const AdminUsersRolesPicker = (props: AdminUsersRolesPickerProps) => {
|
|
38
42
|
const [open, setOpen] = useState(false);
|
|
43
|
+
// The role being saved. While one is, every checkbox is disabled: a second
|
|
44
|
+
// toggle would be dropped by the action anyway.
|
|
39
45
|
const [pending, setPending] = useState<string | null>(null);
|
|
40
46
|
// The users table no longer hard-reloads after a role toggle, so the row's
|
|
41
47
|
// `user.roles` would stay stale. Track an optimistic override locally so the
|
|
@@ -84,7 +90,7 @@ export const AdminUsersRolesPicker = (props: AdminUsersRolesPickerProps) => {
|
|
|
84
90
|
<div className="flex flex-col">
|
|
85
91
|
{rows.map((role) => {
|
|
86
92
|
const checked = userRoles.includes(role.name);
|
|
87
|
-
const disabled = role.default === true || pending
|
|
93
|
+
const disabled = role.default === true || pending !== null;
|
|
88
94
|
return (
|
|
89
95
|
// `cursor-pointer` stays: the global rule in
|
|
90
96
|
// `@alepha/ui/src/styles.css` covers controls and menu items,
|
|
@@ -111,8 +117,9 @@ export const AdminUsersRolesPicker = (props: AdminUsersRolesPickerProps) => {
|
|
|
111
117
|
? Array.from(new Set([...userRoles, role.name]))
|
|
112
118
|
: userRoles.filter((r) => r !== role.name);
|
|
113
119
|
try {
|
|
114
|
-
await props.onToggle(roles)
|
|
115
|
-
|
|
120
|
+
if (await props.onToggle(roles)) {
|
|
121
|
+
setOptimisticRoles(roles);
|
|
122
|
+
}
|
|
116
123
|
} finally {
|
|
117
124
|
setPending(null);
|
|
118
125
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { $inject, Alepha
|
|
1
|
+
import { $inject, Alepha } from "alepha";
|
|
2
|
+
import { OPTIONS } from "alepha/internal";
|
|
2
3
|
import { $dictionary, AlephaReactI18n, I18nProvider } from "alepha/react/i18n";
|
|
3
4
|
import {
|
|
4
5
|
$page,
|
|
@@ -107,7 +108,7 @@ describe("AdminRouter", () => {
|
|
|
107
108
|
[router.audits, ["admin:audit:read"]],
|
|
108
109
|
[router.files, ["admin:file:read"]],
|
|
109
110
|
[router.parameters, ["admin:parameter:read"]],
|
|
110
|
-
[router.payments, ["admin:payment:read"
|
|
111
|
+
[router.payments, ["admin:payment:read"]],
|
|
111
112
|
[router.analytics, ["admin:analytics:read"]],
|
|
112
113
|
];
|
|
113
114
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useAction } from "alepha/react";
|
|
2
|
-
import type
|
|
1
|
+
import { type RunResult, useAction } from "alepha/react";
|
|
2
|
+
import { type DependencyList, useCallback } from "react";
|
|
3
3
|
|
|
4
4
|
import { type ConfirmOptions, useDialog } from "../core/useDialog.tsx";
|
|
5
5
|
import { useToast } from "../core/useToast.tsx";
|
|
@@ -24,7 +24,12 @@ export interface UseConfirmedActionConfig<TArgs extends unknown[]> {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface UseConfirmedActionReturn<TArgs extends unknown[]> {
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Ask, then run. Resolves `{ ok: true }` when the mutation ran,
|
|
29
|
+
* `{ ok: false, reason: "cancelled" }` when the user declined the confirm,
|
|
30
|
+
* and `useAction`'s other results otherwise.
|
|
31
|
+
*/
|
|
32
|
+
run: (...args: TArgs) => Promise<RunResult<void>>;
|
|
28
33
|
loading: boolean;
|
|
29
34
|
}
|
|
30
35
|
|
|
@@ -62,18 +67,15 @@ export function useConfirmedAction<TArgs extends unknown[]>(
|
|
|
62
67
|
const dialog = useDialog();
|
|
63
68
|
const toast = useToast();
|
|
64
69
|
|
|
65
|
-
const action = useAction<TArgs,
|
|
70
|
+
const action = useAction<TArgs, boolean>(
|
|
66
71
|
{
|
|
67
|
-
handler: async (...
|
|
68
|
-
// useAction appends an ActionContext as the last argument — strip it so
|
|
69
|
-
// the caller's `confirm` / `handler` / `success` see only their args.
|
|
70
|
-
const args = argsWithCtx.slice(0, -1) as unknown as TArgs;
|
|
72
|
+
handler: async (_ctx, ...args) => {
|
|
71
73
|
const options =
|
|
72
74
|
typeof config.confirm === "function"
|
|
73
75
|
? config.confirm(...args)
|
|
74
76
|
: config.confirm;
|
|
75
77
|
const confirmed = await dialog.confirm(options);
|
|
76
|
-
if (!confirmed) return;
|
|
78
|
+
if (!confirmed) return false;
|
|
77
79
|
await config.handler(...args);
|
|
78
80
|
if (config.success != null) {
|
|
79
81
|
toast.success(
|
|
@@ -82,10 +84,22 @@ export function useConfirmedAction<TArgs extends unknown[]>(
|
|
|
82
84
|
: config.success,
|
|
83
85
|
);
|
|
84
86
|
}
|
|
87
|
+
return true;
|
|
85
88
|
},
|
|
86
89
|
},
|
|
87
90
|
deps,
|
|
88
91
|
);
|
|
89
92
|
|
|
90
|
-
|
|
93
|
+
const run = useCallback(
|
|
94
|
+
async (...args: TArgs): Promise<RunResult<void>> => {
|
|
95
|
+
const result = await action.run(...args);
|
|
96
|
+
if (!result.ok) return result;
|
|
97
|
+
return result.value
|
|
98
|
+
? { ok: true, value: undefined }
|
|
99
|
+
: { ok: false, reason: "cancelled" };
|
|
100
|
+
},
|
|
101
|
+
[action.run],
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return { run, loading: action.loading };
|
|
91
105
|
}
|
package/src/auth/AuthLogin.tsx
CHANGED
|
@@ -4,11 +4,15 @@ void React;
|
|
|
4
4
|
|
|
5
5
|
import { AlephaError, SchemaValidationError, z } from "alepha";
|
|
6
6
|
import type { RealmConfig } from "alepha/api/users";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
type MfaChallenge,
|
|
9
|
+
MfaRequiredError,
|
|
10
|
+
useAuth,
|
|
11
|
+
} from "alepha/react/auth";
|
|
8
12
|
import { FormValidationError, useForm, useFormState } from "alepha/react/form";
|
|
9
13
|
import { useI18n } from "alepha/react/i18n";
|
|
10
14
|
import { useRouter } from "alepha/react/router";
|
|
11
|
-
import { HttpError } from "alepha/server";
|
|
15
|
+
import { HttpError, isHttpError } from "alepha/server";
|
|
12
16
|
import { AlertCircle, Mail, User } from "lucide-react";
|
|
13
17
|
import { type ReactNode, useMemo, useState } from "react";
|
|
14
18
|
|
|
@@ -148,17 +152,14 @@ export const AuthLogin = (props: AuthLoginProps) => {
|
|
|
148
152
|
} catch (err) {
|
|
149
153
|
// The password was right and the realm wants a second factor. Not a
|
|
150
154
|
// failure: swap the form for the code step and carry on.
|
|
151
|
-
if (
|
|
155
|
+
if (err instanceof MfaRequiredError) {
|
|
152
156
|
setChallenge(err.data);
|
|
153
157
|
return;
|
|
154
158
|
}
|
|
155
159
|
// A 401 from the password grant is a refused password. Matched on the
|
|
156
|
-
// status
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
// the alert as an untranslated "Invalid credentials" instead of the
|
|
160
|
-
// password field.
|
|
161
|
-
if (HttpError.is(err, 401)) {
|
|
160
|
+
// status rather than on `INVALID_CREDENTIALS`, so any refusal of the
|
|
161
|
+
// grant lands on the password field instead of the alert.
|
|
162
|
+
if (isHttpError(err, 401)) {
|
|
162
163
|
throw new FormValidationError({
|
|
163
164
|
message: tr("auth.login.invalid", {
|
|
164
165
|
default: "Invalid identifier or password",
|
|
@@ -147,11 +147,11 @@ export const AuthRegister = (props: AuthRegisterProps) => {
|
|
|
147
147
|
const schema = useMemo(() => {
|
|
148
148
|
// Optionality is decided as each field is built, because that is the only
|
|
149
149
|
// thing the form reads: `FormModel` derives both the required marker and
|
|
150
|
-
// the pre-submit check from `z.schema.
|
|
150
|
+
// the pre-submit check from `z.schema.requiredInputKeys(schema)`, which asks
|
|
151
151
|
// whether the field is optional or defaulted.
|
|
152
152
|
//
|
|
153
153
|
// This used to declare every field optional and then push the configured
|
|
154
|
-
// names onto the array returned by `z.schema.
|
|
154
|
+
// names onto the array returned by `z.schema.requiredInputKeys(s)` , a TypeBox
|
|
155
155
|
// habit, where a JSON Schema's `required` was a live array hanging off the
|
|
156
156
|
// schema. The zod implementation computes a fresh array from the shape, so
|
|
157
157
|
// the pushes mutated a detached value and vanished: a realm with
|
package/src/form/AutoForm.tsx
CHANGED
|
@@ -237,7 +237,7 @@ export const AutoForm = <T extends ZObject>(props: AutoFormProps<T>) => {
|
|
|
237
237
|
useEffect(() => {
|
|
238
238
|
if (!autoSaveEnabled) return;
|
|
239
239
|
let handle: ReturnType<typeof setTimeout> | undefined;
|
|
240
|
-
const off = alepha.events.on("form:
|
|
240
|
+
const off = alepha.events.on("form:changed", (ev) => {
|
|
241
241
|
if (ev.id !== props.form.id) return;
|
|
242
242
|
if (ev.initial) return;
|
|
243
243
|
// FormModel paths look like "/title" or "/contacts/0/email". The
|
package/src/form/Control.tsx
CHANGED
|
@@ -924,7 +924,7 @@ export const useDynamicControlRefresh = (input: BaseInputField | undefined) => {
|
|
|
924
924
|
useEffect(() => {
|
|
925
925
|
if (!isDynamic || !input?.form) return;
|
|
926
926
|
const formId = input.form.id;
|
|
927
|
-
return alepha.events.on("form:
|
|
927
|
+
return alepha.events.on("form:changed", (e) => {
|
|
928
928
|
if (e.id === formId && e.path !== input.path) bump((n) => n + 1);
|
|
929
929
|
});
|
|
930
930
|
}, [alepha, input?.form, input?.path, isDynamic]);
|
|
@@ -149,7 +149,7 @@ const useArrayItems = (input: BaseInputField | undefined) => {
|
|
|
149
149
|
/**
|
|
150
150
|
* Tell the CHILD paths what changed.
|
|
151
151
|
*
|
|
152
|
-
* `input.set()` writes the whole array and `FormModel` emits `form:
|
|
152
|
+
* `input.set()` writes the whole array and `FormModel` emits `form:changed`
|
|
153
153
|
* for the array's own path only. The per-item and per-field inputs this
|
|
154
154
|
* component builds carry paths of their own (`.../2/name`), so a child
|
|
155
155
|
* subscribed through `useFieldValue` never heard about its own edit and
|
|
@@ -166,7 +166,7 @@ const useArrayItems = (input: BaseInputField | undefined) => {
|
|
|
166
166
|
|
|
167
167
|
const emit = (path: string, value: unknown) =>
|
|
168
168
|
void alepha.events.emit(
|
|
169
|
-
"form:
|
|
169
|
+
"form:changed",
|
|
170
170
|
{ id: form.id, path, value },
|
|
171
171
|
{ catch: true },
|
|
172
172
|
);
|
|
@@ -220,7 +220,7 @@ const useArrayItems = (input: BaseInputField | undefined) => {
|
|
|
220
220
|
if (!input?.form) return;
|
|
221
221
|
const formId = input.form.id;
|
|
222
222
|
const path = input.path;
|
|
223
|
-
return alepha.events.on("form:
|
|
223
|
+
return alepha.events.on("form:changed", (e) => {
|
|
224
224
|
if (e.id === formId && e.path === path) sync(e.value as unknown[]);
|
|
225
225
|
});
|
|
226
226
|
}, [alepha, input, sync]);
|
|
@@ -336,7 +336,7 @@ const buildFieldInput = (
|
|
|
336
336
|
): BaseInputField => ({
|
|
337
337
|
schema: z.schema.shape(itemSchema)[fieldName],
|
|
338
338
|
path: `${parent.path}/${index}/${fieldName}`,
|
|
339
|
-
required: z.schema.
|
|
339
|
+
required: z.schema.requiredInputKeys(itemSchema).includes(fieldName),
|
|
340
340
|
form: parent.form,
|
|
341
341
|
initialValue: itemValue?.[fieldName],
|
|
342
342
|
props: {
|
|
@@ -433,7 +433,7 @@ export const ControlArray = (props: ControlArrayProps) => {
|
|
|
433
433
|
if (shape) {
|
|
434
434
|
value = {};
|
|
435
435
|
for (const [k, p] of Object.entries(z.schema.shape(shape))) {
|
|
436
|
-
const def = z.schema.
|
|
436
|
+
const def = z.schema.defaultValue(p);
|
|
437
437
|
if (def !== undefined) (value as Record<string, unknown>)[k] = def;
|
|
438
438
|
// Stamp the discriminant so the new item resolves to its variant.
|
|
439
439
|
const literal = literalValueOf(p);
|
|
@@ -370,7 +370,7 @@ export const ControlSelect = (props: ControlSelectProps) => {
|
|
|
370
370
|
value={value}
|
|
371
371
|
onChange={(v) => setValue(v)}
|
|
372
372
|
coerce={coerce}
|
|
373
|
-
onSearch={mode === "long" ? search.run : undefined}
|
|
373
|
+
onSearch={mode === "long" ? (text) => search.run(text) : undefined}
|
|
374
374
|
createNewEntry={props.createNewEntry}
|
|
375
375
|
icon={props.icon}
|
|
376
376
|
// Used to be dropped on this path, so a filter chip sized `w-40` lost
|
|
@@ -548,7 +548,7 @@ const useAsyncLoader = (
|
|
|
548
548
|
const search = useAction<[string]>(
|
|
549
549
|
{
|
|
550
550
|
debounce: debounceMs,
|
|
551
|
-
handler: async (text) => {
|
|
551
|
+
handler: async (_ctx, text) => {
|
|
552
552
|
if (!loader || mode !== "long") return;
|
|
553
553
|
if (cache.current.has(text)) {
|
|
554
554
|
setData(cache.current.get(text)!);
|
|
@@ -75,7 +75,7 @@ export interface ControlUploadProps {
|
|
|
75
75
|
* image the decoder chokes on is uploaded as-is, and the storage's own
|
|
76
76
|
* `maxSize` remains what actually bounds it. That trade is deliberate — a
|
|
77
77
|
* server-side codec able to close the gap costs more bundle than the case is
|
|
78
|
-
* worth on an edge runtime, and encodes worse (see `files:
|
|
78
|
+
* worth on an edge runtime, and encodes worse (see `files:upload:before` in
|
|
79
79
|
* `alepha/api/files` for where it would attach if you want it anyway).
|
|
80
80
|
*
|
|
81
81
|
* @example { maxWidth: 256 }
|
|
@@ -12,7 +12,7 @@ import { AutoForm } from "../AutoForm.tsx";
|
|
|
12
12
|
/**
|
|
13
13
|
* `ControlArray` builds an input of its own for each item and each item field,
|
|
14
14
|
* with a path of its own (`.../1/name`), but wrote through `input.set()` -
|
|
15
|
-
* which sets the ARRAY and makes `FormModel` emit `form:
|
|
15
|
+
* which sets the ARRAY and makes `FormModel` emit `form:changed` for the
|
|
16
16
|
* array's path alone.
|
|
17
17
|
*
|
|
18
18
|
* So a child subscribed through `useFieldValue` never heard about its own
|
package/src/i18n/fr/uiFr.ts
CHANGED
|
@@ -791,7 +791,6 @@ export const uiFr: Record<string, string> = {
|
|
|
791
791
|
"admin.userDetail.avatar.replaced": "Avatar remplacé.",
|
|
792
792
|
"admin.userDetail.avatar.remove": "Retirer",
|
|
793
793
|
"admin.userDetail.avatar.removed": "Avatar retiré.",
|
|
794
|
-
"admin.userDetail.avatar.failed": "Impossible de changer l'avatar.",
|
|
795
794
|
"admin.userDetail.credentials": "Identifiants",
|
|
796
795
|
"admin.userDetail.credentialsHasPassword":
|
|
797
796
|
"Un mot de passe est défini. Vous ne pouvez pas le retirer, mais vous pouvez en définir un nouveau.",
|
|
@@ -950,7 +949,6 @@ export const uiFr: Record<string, string> = {
|
|
|
950
949
|
"account.delete.currentPassword": "Mot de passe actuel",
|
|
951
950
|
"account.delete.description":
|
|
952
951
|
"Cela supprime définitivement votre compte, ses méthodes de connexion et toutes vos sessions. C'est irréversible.",
|
|
953
|
-
"account.delete.error": "Impossible de supprimer votre compte",
|
|
954
952
|
"account.delete.submit": "Supprimer le compte",
|
|
955
953
|
"account.delete.title": "Supprimer votre compte",
|
|
956
954
|
"account.keys.access": "Accès",
|
|
@@ -974,7 +972,6 @@ export const uiFr: Record<string, string> = {
|
|
|
974
972
|
"account.keys.statusAll": "Tous les statuts",
|
|
975
973
|
"account.keys.copied": "Copiée",
|
|
976
974
|
"account.keys.copy": "Copier",
|
|
977
|
-
"account.keys.createError": "Impossible de créer cette clé",
|
|
978
975
|
"account.keys.description":
|
|
979
976
|
"Une clé agit en votre nom. Révoquez celles que vous ne reconnaissez plus.",
|
|
980
977
|
"account.keys.descriptionLabel": "Description",
|
|
@@ -1032,7 +1029,6 @@ export const uiFr: Record<string, string> = {
|
|
|
1032
1029
|
"account.mfa.copyCodes": "Copier les codes",
|
|
1033
1030
|
"account.mfa.enrollError":
|
|
1034
1031
|
"Impossible de démarrer l'activation. Fermez cette fenêtre et réessayez.",
|
|
1035
|
-
"account.mfa.invalidCode": "Ce code n'est pas valide",
|
|
1036
1032
|
"account.mfa.preparing": "Préparation…",
|
|
1037
1033
|
"account.mfa.recoveryCopied": "Codes de secours copiés",
|
|
1038
1034
|
"account.mfa.recoveryDescription":
|
|
@@ -1064,7 +1060,6 @@ export const uiFr: Record<string, string> = {
|
|
|
1064
1060
|
"Mot de passe changé - $1 autre(s) session(s) déconnectée(s)",
|
|
1065
1061
|
"account.password.confirm": "Confirmer le nouveau mot de passe",
|
|
1066
1062
|
"account.password.current": "Mot de passe actuel",
|
|
1067
|
-
"account.password.error": "Impossible d'enregistrer ce mot de passe",
|
|
1068
1063
|
"account.password.mismatch": "Les deux mots de passe ne correspondent pas",
|
|
1069
1064
|
"account.password.new": "Nouveau mot de passe",
|
|
1070
1065
|
"account.password.set": "Mot de passe défini",
|
|
@@ -1078,9 +1073,7 @@ export const uiFr: Record<string, string> = {
|
|
|
1078
1073
|
"account.profile.avatarChange": "Changer l'avatar",
|
|
1079
1074
|
"account.profile.avatarDescription": "PNG, JPEG, GIF ou WebP, jusqu'à 5 Mo.",
|
|
1080
1075
|
"account.profile.avatarRemove": "Supprimer",
|
|
1081
|
-
"account.profile.avatarRemoveError": "Impossible de supprimer votre avatar",
|
|
1082
1076
|
"account.profile.avatarUpdated": "Avatar mis à jour",
|
|
1083
|
-
"account.profile.avatarUploadError": "Impossible d'envoyer cette image",
|
|
1084
1077
|
"account.profile.email": "E-mail",
|
|
1085
1078
|
"account.profile.emailDescription":
|
|
1086
1079
|
"Changer d'e-mail demande une vérification, ce n'est donc pas une modification de profil.",
|
|
@@ -1104,7 +1097,6 @@ export const uiFr: Record<string, string> = {
|
|
|
1104
1097
|
"account.security.deleteButton": "Supprimer le compte",
|
|
1105
1098
|
"account.security.deleteDescription":
|
|
1106
1099
|
"Supprime votre compte, ses méthodes de connexion et toutes vos sessions.",
|
|
1107
|
-
"account.security.invalidCode": "Ce code n'est pas valide",
|
|
1108
1100
|
"account.security.methodsDescription":
|
|
1109
1101
|
"Il doit en rester au moins une. Supprimer la dernière vous priverait définitivement d'accès.",
|
|
1110
1102
|
"account.security.methodsTitle": "Méthodes de connexion",
|
|
@@ -1137,7 +1129,6 @@ export const uiFr: Record<string, string> = {
|
|
|
1137
1129
|
"account.security.unlinkAria": "Supprimer $1",
|
|
1138
1130
|
"account.security.unlinkDescription":
|
|
1139
1131
|
"Vous ne pourrez plus vous connecter avec $1.",
|
|
1140
|
-
"account.security.unlinkError": "Impossible de supprimer cette méthode",
|
|
1141
1132
|
"account.security.unlinkTitle": "Supprimer $1 ?",
|
|
1142
1133
|
"account.sessions.colDevice": "Appareil",
|
|
1143
1134
|
"account.sessions.colIp": "IP",
|
|
@@ -78,7 +78,7 @@ export const MyOrganizationInvitations = (
|
|
|
78
78
|
);
|
|
79
79
|
const accept = useAction<[invitationId: string], void>(
|
|
80
80
|
{
|
|
81
|
-
handler: async (invitationId) => {
|
|
81
|
+
handler: async (_ctx, invitationId) => {
|
|
82
82
|
const organizationId = props.accept
|
|
83
83
|
? await props.accept(invitationId)
|
|
84
84
|
: (
|
|
@@ -99,7 +99,7 @@ export const MyOrganizationInvitations = (
|
|
|
99
99
|
);
|
|
100
100
|
const decline = useAction<[invitationId: string], void>(
|
|
101
101
|
{
|
|
102
|
-
handler: async (invitationId) => {
|
|
102
|
+
handler: async (_ctx, invitationId) => {
|
|
103
103
|
if (props.decline) {
|
|
104
104
|
await props.decline(invitationId);
|
|
105
105
|
} else {
|
|
@@ -46,7 +46,7 @@ export const OrganizationInviteDialog = (
|
|
|
46
46
|
props.onBusyChange?.(true);
|
|
47
47
|
try {
|
|
48
48
|
const invited = await invite.invite(props.organizationId, email, rank);
|
|
49
|
-
if (!invited) return;
|
|
49
|
+
if (!invited.ok) return;
|
|
50
50
|
setEmail("");
|
|
51
51
|
form.input.rank.set("member");
|
|
52
52
|
props.onOpenChange(false);
|
|
@@ -90,7 +90,7 @@ export const OrganizationMembers = (props: OrganizationMembersProps) => {
|
|
|
90
90
|
|
|
91
91
|
const remove = useAction<[OrganizationMemberResource], void>(
|
|
92
92
|
{
|
|
93
|
-
handler: async (member) => {
|
|
93
|
+
handler: async (_ctx, member) => {
|
|
94
94
|
const name =
|
|
95
95
|
member.user.username ||
|
|
96
96
|
member.user.email ||
|
|
@@ -121,7 +121,7 @@ export const OrganizationRanks = (props: OrganizationRanksProps) => {
|
|
|
121
121
|
);
|
|
122
122
|
const create = useAction<[OrganizationRankPreset | undefined], void>(
|
|
123
123
|
{
|
|
124
|
-
handler: async (preset) => {
|
|
124
|
+
handler: async (_ctx, preset) => {
|
|
125
125
|
const name = await dialog.prompt({
|
|
126
126
|
title: tr("organizations.ranks.createTitle", {
|
|
127
127
|
default: "Create a rank",
|
|
@@ -152,7 +152,7 @@ export const OrganizationRanks = (props: OrganizationRanksProps) => {
|
|
|
152
152
|
);
|
|
153
153
|
const rename = useAction<[OrganizationRankResource], void>(
|
|
154
154
|
{
|
|
155
|
-
handler: async (rank) => {
|
|
155
|
+
handler: async (_ctx, rank) => {
|
|
156
156
|
const name = await dialog.prompt({
|
|
157
157
|
title: tr("organizations.ranks.renameTitle", {
|
|
158
158
|
default: "Rename $1",
|
|
@@ -178,7 +178,7 @@ export const OrganizationRanks = (props: OrganizationRanksProps) => {
|
|
|
178
178
|
);
|
|
179
179
|
const remove = useAction<[OrganizationRankResource], void>(
|
|
180
180
|
{
|
|
181
|
-
handler: async (rank) => {
|
|
181
|
+
handler: async (_ctx, rank) => {
|
|
182
182
|
const confirmed = await dialog.confirm({
|
|
183
183
|
title: tr("organizations.ranks.deleteTitle", {
|
|
184
184
|
default: "Delete $1?",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OrganizationInvitationController } from "alepha/api/organizations";
|
|
2
|
-
import { useAction, useClient } from "alepha/react";
|
|
2
|
+
import { type RunResult, useAction, useClient } from "alepha/react";
|
|
3
3
|
import { useI18n } from "alepha/react/i18n";
|
|
4
|
+
import { useCallback } from "react";
|
|
4
5
|
|
|
5
6
|
import { useToast } from "../core/useToast.tsx";
|
|
6
7
|
|
|
@@ -15,13 +16,17 @@ export interface InviteOrganizationMember {
|
|
|
15
16
|
* because a rank says what you may do as staff and a role says whether you
|
|
16
17
|
* are a coach, and the framework has no business knowing that club has
|
|
17
18
|
* coaches.
|
|
19
|
+
*
|
|
20
|
+
* Resolves `{ ok: true }` once sent, `{ ok: false, reason: "cancelled" }`
|
|
21
|
+
* when a local check refused it (an empty address, toasted here), and
|
|
22
|
+
* `useAction`'s other results otherwise.
|
|
18
23
|
*/
|
|
19
24
|
invite: (
|
|
20
25
|
organizationId: string,
|
|
21
26
|
email: string,
|
|
22
27
|
rank: string | undefined,
|
|
23
28
|
metadata?: Record<string, unknown>,
|
|
24
|
-
) => Promise<
|
|
29
|
+
) => Promise<RunResult<void>>;
|
|
25
30
|
loading: boolean;
|
|
26
31
|
can: boolean;
|
|
27
32
|
}
|
|
@@ -40,18 +45,7 @@ export const useInviteOrganizationMember = (): InviteOrganizationMember => {
|
|
|
40
45
|
boolean
|
|
41
46
|
>(
|
|
42
47
|
{
|
|
43
|
-
handler: async (organizationId, email, rank,
|
|
44
|
-
/**
|
|
45
|
-
* ⚠️ `useAction` appends `{ signal }` as the LAST argument to the
|
|
46
|
-
* handler, so a caller passing three arguments lands its abort signal
|
|
47
|
-
* in this fourth parameter. Reading it as metadata put an
|
|
48
|
-
* `AbortSignal` on the invitation row.
|
|
49
|
-
*
|
|
50
|
-
* Hence the shape check rather than a plain `?? undefined`: an
|
|
51
|
-
* application's metadata is its own object, and the framework's is the
|
|
52
|
-
* one carrying `signal`.
|
|
53
|
-
*/
|
|
54
|
-
const metadata = passed && !("signal" in passed) ? passed : undefined;
|
|
48
|
+
handler: async (_ctx, organizationId, email, rank, metadata) => {
|
|
55
49
|
const trimmed = email.trim();
|
|
56
50
|
if (!trimmed) {
|
|
57
51
|
toaster.error(
|
|
@@ -81,8 +75,21 @@ export const useInviteOrganizationMember = (): InviteOrganizationMember => {
|
|
|
81
75
|
[api, toaster, tr],
|
|
82
76
|
);
|
|
83
77
|
|
|
78
|
+
const invite = useCallback(
|
|
79
|
+
async (
|
|
80
|
+
...args: Parameters<typeof action.run>
|
|
81
|
+
): Promise<RunResult<void>> => {
|
|
82
|
+
const result = await action.run(...args);
|
|
83
|
+
if (!result.ok) return result;
|
|
84
|
+
return result.value
|
|
85
|
+
? { ok: true, value: undefined }
|
|
86
|
+
: { ok: false, reason: "cancelled" };
|
|
87
|
+
},
|
|
88
|
+
[action.run],
|
|
89
|
+
);
|
|
90
|
+
|
|
84
91
|
return {
|
|
85
|
-
invite
|
|
92
|
+
invite,
|
|
86
93
|
loading: action.loading,
|
|
87
94
|
can: api.createOrganizationInvitation.can(),
|
|
88
95
|
};
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import type { OrganizationInvitationController } from "alepha/api/organizations";
|
|
2
|
-
import { useAction, useClient } from "alepha/react";
|
|
2
|
+
import { type RunResult, useAction, useClient } from "alepha/react";
|
|
3
3
|
import { useI18n } from "alepha/react/i18n";
|
|
4
|
+
import { useCallback } from "react";
|
|
4
5
|
|
|
5
6
|
import { useDialog } from "../core/useDialog.tsx";
|
|
6
7
|
import { useToast } from "../core/useToast.tsx";
|
|
7
8
|
|
|
8
9
|
export interface RevokeOrganizationInvitation {
|
|
10
|
+
/**
|
|
11
|
+
* Ask, then revoke. Resolves `{ ok: true }` once revoked,
|
|
12
|
+
* `{ ok: false, reason: "cancelled" }` when the user declined the confirm,
|
|
13
|
+
* and `useAction`'s other results otherwise.
|
|
14
|
+
*/
|
|
9
15
|
revoke: (
|
|
10
16
|
organizationId: string,
|
|
11
17
|
invitationId: string,
|
|
12
18
|
email: string,
|
|
13
|
-
) => Promise<
|
|
19
|
+
) => Promise<RunResult<void>>;
|
|
14
20
|
loading: boolean;
|
|
15
21
|
can: boolean;
|
|
16
22
|
}
|
|
@@ -26,7 +32,7 @@ export const useRevokeOrganizationInvitation =
|
|
|
26
32
|
boolean
|
|
27
33
|
>(
|
|
28
34
|
{
|
|
29
|
-
handler: async (organizationId, invitationId, email) => {
|
|
35
|
+
handler: async (_ctx, organizationId, invitationId, email) => {
|
|
30
36
|
const confirmed = await dialog.confirm({
|
|
31
37
|
title: tr("organizations.invitations.revokeTitle", {
|
|
32
38
|
default: "Revoke the invitation for $1?",
|
|
@@ -58,8 +64,21 @@ export const useRevokeOrganizationInvitation =
|
|
|
58
64
|
[api, dialog, toaster, tr],
|
|
59
65
|
);
|
|
60
66
|
|
|
67
|
+
const revoke = useCallback(
|
|
68
|
+
async (
|
|
69
|
+
...args: Parameters<typeof action.run>
|
|
70
|
+
): Promise<RunResult<void>> => {
|
|
71
|
+
const result = await action.run(...args);
|
|
72
|
+
if (!result.ok) return result;
|
|
73
|
+
return result.value
|
|
74
|
+
? { ok: true, value: undefined }
|
|
75
|
+
: { ok: false, reason: "cancelled" };
|
|
76
|
+
},
|
|
77
|
+
[action.run],
|
|
78
|
+
);
|
|
79
|
+
|
|
61
80
|
return {
|
|
62
|
-
revoke
|
|
81
|
+
revoke,
|
|
63
82
|
loading: action.loading,
|
|
64
83
|
can: api.revokeOrganizationInvitation.can(),
|
|
65
84
|
};
|