@alepha/ui 0.36.0 → 0.37.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/$pageAccount.d.ts +1 -1
- package/dist/account/$pageAccount.d.ts.map +1 -1
- package/dist/account/$pageAccount.js.map +1 -1
- package/dist/account/AccountDisplay.d.ts +13 -0
- package/dist/account/AccountDisplay.d.ts.map +1 -0
- package/dist/account/AccountDisplay.js +48 -0
- package/dist/account/AccountDisplay.js.map +1 -0
- package/dist/account/AccountProfile.d.ts.map +1 -1
- package/dist/account/AccountProfile.js +14 -10
- package/dist/account/AccountProfile.js.map +1 -1
- package/dist/account/AccountRouter.d.ts +6 -6
- package/dist/account/AccountRouter.d.ts.map +1 -1
- package/dist/account/index.d.ts +5 -0
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +2 -1
- package/dist/admin/$pageAdmin.d.ts +1 -1
- package/dist/admin/$pageAdmin.d.ts.map +1 -1
- package/dist/admin/$pageAdmin.js.map +1 -1
- package/dist/admin/AdminAudits.js.map +1 -1
- package/dist/admin/AdminJobDetail.js.map +1 -1
- package/dist/admin/AdminJobs.js.map +1 -1
- package/dist/admin/AdminNotifications.js.map +1 -1
- package/dist/admin/AdminRouter.d.ts +14 -14
- package/dist/admin/AdminRouter.d.ts.map +1 -1
- package/dist/admin/AdminUserDetail.js.map +1 -1
- package/dist/admin/AdminUsers.js.map +1 -1
- package/dist/admin/ParameterHistoryItem.js.map +1 -1
- package/dist/ai/AiChat.d.ts +26 -39
- package/dist/ai/AiChat.d.ts.map +1 -1
- package/dist/ai/AiChat.js +65 -123
- package/dist/ai/AiChat.js.map +1 -1
- package/dist/ai/AiChatDock.d.ts +23 -0
- package/dist/ai/AiChatDock.d.ts.map +1 -0
- package/dist/ai/AiChatDock.js +90 -0
- package/dist/ai/AiChatDock.js.map +1 -0
- package/dist/ai/AiChatDockSlot.d.ts +15 -0
- package/dist/ai/AiChatDockSlot.d.ts.map +1 -0
- package/dist/ai/AiChatDockSlot.js +20 -0
- package/dist/ai/AiChatDockSlot.js.map +1 -0
- package/dist/ai/AiChatLauncher.d.ts +17 -0
- package/dist/ai/AiChatLauncher.d.ts.map +1 -0
- package/dist/ai/AiChatLauncher.js +42 -0
- package/dist/ai/AiChatLauncher.js.map +1 -0
- package/dist/ai/AiChatMessage.d.ts +7 -1
- package/dist/ai/AiChatMessage.d.ts.map +1 -1
- package/dist/ai/AiChatMessage.js +27 -7
- package/dist/ai/AiChatMessage.js.map +1 -1
- package/dist/ai/AiChatPanel.d.ts +71 -0
- package/dist/ai/AiChatPanel.d.ts.map +1 -0
- package/dist/ai/AiChatPanel.js +143 -0
- package/dist/ai/AiChatPanel.js.map +1 -0
- package/dist/ai/index.d.ts +8 -4
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +5 -1
- package/dist/ai/useAiChat.d.ts +17 -0
- package/dist/ai/useAiChat.d.ts.map +1 -1
- package/dist/ai/useAiChat.js +38 -17
- package/dist/ai/useAiChat.js.map +1 -1
- package/dist/auth/AuthLogin.d.ts +9 -0
- package/dist/auth/AuthLogin.d.ts.map +1 -1
- package/dist/auth/AuthLogin.js +2 -2
- package/dist/auth/AuthLogin.js.map +1 -1
- package/dist/auth/AuthRegister.d.ts +4 -1
- package/dist/auth/AuthRegister.d.ts.map +1 -1
- package/dist/auth/AuthRegister.js +1 -1
- package/dist/auth/AuthRegister.js.map +1 -1
- package/dist/auth/AuthResetPassword.d.ts +8 -0
- package/dist/auth/AuthResetPassword.d.ts.map +1 -1
- package/dist/auth/AuthResetPassword.js +2 -2
- package/dist/auth/AuthResetPassword.js.map +1 -1
- package/dist/auth/AuthRouter.d.ts +4 -4
- package/dist/auth/AuthRouter.d.ts.map +1 -1
- package/dist/core/Badge.d.ts.map +1 -1
- package/dist/core/Badge.js +7 -3
- package/dist/core/Badge.js.map +1 -1
- package/dist/core/Collapsible.d.ts +50 -0
- package/dist/core/Collapsible.d.ts.map +1 -0
- package/dist/core/Collapsible.js +70 -0
- package/dist/core/Collapsible.js.map +1 -0
- package/dist/core/Combobox.d.ts +7 -1
- package/dist/core/Combobox.d.ts.map +1 -1
- package/dist/core/Combobox.js +2 -2
- package/dist/core/Combobox.js.map +1 -1
- package/dist/core/PaneRail.d.ts +24 -7
- package/dist/core/PaneRail.d.ts.map +1 -1
- package/dist/core/PaneRail.js +24 -19
- package/dist/core/PaneRail.js.map +1 -1
- package/dist/core/Stepper.d.ts +36 -0
- package/dist/core/Stepper.d.ts.map +1 -0
- package/dist/core/Stepper.js +54 -0
- package/dist/core/Stepper.js.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -1
- package/dist/core/useToast.js +13 -13
- package/dist/core/useToast.js.map +1 -1
- package/dist/form/AutoForm.d.ts.map +1 -1
- package/dist/form/AutoForm.js +29 -0
- package/dist/form/AutoForm.js.map +1 -1
- package/dist/form/AutoFormErrorPopover.js +13 -3
- package/dist/form/AutoFormErrorPopover.js.map +1 -1
- package/dist/form/Control.d.ts +14 -1
- package/dist/form/Control.d.ts.map +1 -1
- package/dist/form/Control.js +12 -2
- package/dist/form/Control.js.map +1 -1
- package/dist/form/ControlDate.d.ts.map +1 -1
- package/dist/form/ControlDate.js +3 -0
- package/dist/form/ControlDate.js.map +1 -1
- package/dist/form/ControlDateRange.d.ts +12 -1
- package/dist/form/ControlDateRange.d.ts.map +1 -1
- package/dist/form/ControlDateRange.js +11 -1
- package/dist/form/ControlDateRange.js.map +1 -1
- package/dist/form/ControlNumber.d.ts.map +1 -1
- package/dist/form/ControlNumber.js +2 -0
- package/dist/form/ControlNumber.js.map +1 -1
- package/dist/form/ControlObject.d.ts.map +1 -1
- package/dist/form/ControlObject.js +15 -1
- package/dist/form/ControlObject.js.map +1 -1
- package/dist/form/ControlPassword.d.ts +4 -0
- package/dist/form/ControlPassword.d.ts.map +1 -1
- package/dist/form/ControlPassword.js +1 -0
- package/dist/form/ControlPassword.js.map +1 -1
- package/dist/form/ControlSelect.d.ts +23 -1
- package/dist/form/ControlSelect.d.ts.map +1 -1
- package/dist/form/ControlSelect.js +5 -0
- package/dist/form/ControlSelect.js.map +1 -1
- package/dist/form/ControlSelectCombobox.d.ts +11 -1
- package/dist/form/ControlSelectCombobox.d.ts.map +1 -1
- package/dist/form/ControlSelectCombobox.js +9 -1
- package/dist/form/ControlSelectCombobox.js.map +1 -1
- package/dist/form/ControlUpload.d.ts.map +1 -1
- package/dist/form/ControlUpload.js +1 -0
- package/dist/form/ControlUpload.js.map +1 -1
- package/dist/form/FormField.d.ts +5 -0
- package/dist/form/FormField.d.ts.map +1 -1
- package/dist/form/FormField.js +7 -0
- package/dist/form/FormField.js.map +1 -1
- package/dist/i18n/fr/uiFr.d.ts.map +1 -1
- package/dist/i18n/fr/uiFr.js +15 -0
- package/dist/i18n/fr/uiFr.js.map +1 -1
- package/dist/shell/$pageNav.d.ts +2 -2
- package/dist/shell/$pageNav.d.ts.map +1 -1
- package/dist/shell/$pageNav.js.map +1 -1
- package/dist/shell/AppShell.d.ts +6 -0
- package/dist/shell/AppShell.d.ts.map +1 -1
- package/dist/shell/AppShell.js +31 -27
- package/dist/shell/AppShell.js.map +1 -1
- package/dist/shell/ButtonSettings.d.ts +6 -2
- package/dist/shell/ButtonSettings.d.ts.map +1 -1
- package/dist/shell/ButtonSettings.js +17 -3
- package/dist/shell/ButtonSettings.js.map +1 -1
- package/dist/shell/ButtonSettingsVisionMenuItem.d.ts +16 -0
- package/dist/shell/ButtonSettingsVisionMenuItem.d.ts.map +1 -0
- package/dist/shell/ButtonSettingsVisionMenuItem.js +24 -0
- package/dist/shell/ButtonSettingsVisionMenuItem.js.map +1 -0
- package/dist/shell/ButtonVision.d.ts +28 -0
- package/dist/shell/ButtonVision.d.ts.map +1 -0
- package/dist/shell/ButtonVision.js +46 -0
- package/dist/shell/ButtonVision.js.map +1 -0
- package/dist/shell/index.d.ts +6 -3
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +2 -1
- package/dist/styles.css +57 -0
- package/dist/table/DataTable.d.ts.map +1 -1
- package/dist/table/DataTable.js +29 -4
- package/dist/table/DataTable.js.map +1 -1
- package/dist/table/DataTableColumnPicker.d.ts.map +1 -1
- package/dist/table/DataTableColumnPicker.js +1 -0
- package/dist/table/DataTableColumnPicker.js.map +1 -1
- package/dist/table/DataTableFilterBar.d.ts +1 -1
- package/dist/table/DataTableFilterBar.d.ts.map +1 -1
- package/dist/table/DataTableFilterBar.js +5 -108
- package/dist/table/DataTableFilterBar.js.map +1 -1
- package/dist/table/DataTableHeaderFilter.d.ts +51 -0
- package/dist/table/DataTableHeaderFilter.d.ts.map +1 -0
- package/dist/table/DataTableHeaderFilter.js +113 -0
- package/dist/table/DataTableHeaderFilter.js.map +1 -0
- package/dist/table/DataTableHeaderRow.d.ts +7 -0
- package/dist/table/DataTableHeaderRow.d.ts.map +1 -1
- package/dist/table/DataTableHeaderRow.js +92 -74
- package/dist/table/DataTableHeaderRow.js.map +1 -1
- package/dist/table/DataTableTabs.d.ts +42 -0
- package/dist/table/DataTableTabs.d.ts.map +1 -0
- package/dist/table/DataTableTabs.js +55 -0
- package/dist/table/DataTableTabs.js.map +1 -0
- package/dist/table/dataTableBaseProps.d.ts +12 -0
- package/dist/table/dataTableBaseProps.d.ts.map +1 -1
- package/dist/table/dataTablePersistence.d.ts.map +1 -1
- package/dist/table/dataTablePersistence.js +4 -2
- package/dist/table/dataTablePersistence.js.map +1 -1
- package/dist/table/dataTableTypes.d.ts +18 -0
- package/dist/table/dataTableTypes.d.ts.map +1 -1
- package/dist/table/index.d.ts +5 -2
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/index.js +2 -1
- package/dist/table/useDataTableColumns.d.ts.map +1 -1
- package/dist/table/useDataTableColumns.js +1 -0
- package/dist/table/useDataTableColumns.js.map +1 -1
- package/dist/table/useDataTableFilterModel.d.ts +110 -0
- package/dist/table/useDataTableFilterModel.d.ts.map +1 -0
- package/dist/table/useDataTableFilterModel.js +154 -0
- package/dist/table/useDataTableFilterModel.js.map +1 -0
- package/docs/packages-alepha-ui-account.md +4 -0
- package/docs/packages-alepha-ui-ai.md +5 -5
- package/docs/packages-alepha-ui-shell.md +4 -3
- package/docs/packages-alepha-ui-table.md +4 -2
- package/package.json +8 -8
- package/src/account/$pageAccount.tsx +5 -4
- package/src/account/AccountDisplay.tsx +58 -0
- package/src/account/AccountProfile.tsx +30 -42
- package/src/account/__tests__/AccountProfile.browser.spec.tsx +141 -0
- package/src/account/__tests__/AccountRecoveryCodes.browser.spec.tsx +1 -1
- package/src/account/index.ts +5 -0
- package/src/admin/$pageAdmin.tsx +5 -4
- package/src/admin/AdminAudits.tsx +1 -1
- package/src/admin/AdminJobDetail.tsx +1 -1
- package/src/admin/AdminJobs.tsx +1 -1
- package/src/admin/AdminNotifications.tsx +1 -1
- package/src/admin/AdminUserDetail.tsx +1 -1
- package/src/admin/AdminUsers.tsx +1 -1
- package/src/admin/ParameterHistoryItem.tsx +1 -1
- package/src/admin/__tests__/AdminFilesUsageCard.browser.spec.tsx +17 -9
- package/src/ai/AiChat.tsx +94 -183
- package/src/ai/AiChatDock.tsx +129 -0
- package/src/ai/AiChatDockSlot.tsx +23 -0
- package/src/ai/AiChatLauncher.tsx +58 -0
- package/src/ai/AiChatMessage.tsx +48 -9
- package/src/ai/AiChatPanel.tsx +252 -0
- package/src/ai/__tests__/AiChat.browser.spec.tsx +197 -5
- package/src/ai/index.ts +8 -4
- package/src/ai/useAiChat.ts +80 -14
- package/src/auth/AuthLogin.tsx +19 -4
- package/src/auth/AuthRegister.tsx +6 -3
- package/src/auth/AuthResetPassword.tsx +18 -8
- package/src/auth/__tests__/AuthCancel.browser.spec.tsx +129 -0
- package/src/core/Badge.tsx +7 -3
- package/src/core/Collapsible.tsx +95 -0
- package/src/core/Combobox.tsx +11 -3
- package/src/core/PaneRail.tsx +36 -20
- package/src/core/Stepper.tsx +118 -0
- package/src/core/__tests__/Badge.browser.spec.tsx +5 -5
- package/src/core/__tests__/Collapsible.browser.spec.tsx +88 -0
- package/src/core/__tests__/PaneRail.browser.spec.tsx +48 -0
- package/src/core/__tests__/Stepper.browser.spec.tsx +39 -0
- package/src/core/__tests__/primitiveSlots.spec.ts +7 -0
- package/src/core/index.ts +15 -0
- package/src/form/AutoForm.tsx +32 -0
- package/src/form/AutoFormErrorPopover.tsx +27 -6
- package/src/form/Control.tsx +22 -0
- package/src/form/ControlDate.tsx +3 -0
- package/src/form/ControlDateRange.tsx +87 -58
- package/src/form/ControlNumber.tsx +2 -0
- package/src/form/ControlObject.tsx +20 -1
- package/src/form/ControlPassword.tsx +5 -0
- package/src/form/ControlSelect.tsx +32 -1
- package/src/form/ControlSelectCombobox.tsx +82 -56
- package/src/form/ControlUpload.tsx +1 -0
- package/src/form/FormField.tsx +23 -1
- package/src/form/__tests__/ControlFieldErrors.browser.spec.tsx +253 -0
- package/src/form/__tests__/ControlValidateMode.browser.spec.tsx +217 -0
- package/src/form/__tests__/ControlVariantErrors.browser.spec.tsx +133 -0
- package/src/i18n/fr/uiFr.ts +19 -1
- package/src/markdown/css.d.ts +11 -0
- package/src/shell/$pageNav.tsx +6 -4
- package/src/shell/AppShell.tsx +7 -0
- package/src/shell/ButtonSettings.tsx +20 -5
- package/src/shell/ButtonSettingsVisionMenuItem.tsx +40 -0
- package/src/shell/ButtonVision.tsx +73 -0
- package/src/shell/__tests__/ButtonSettings.browser.spec.tsx +42 -2
- package/src/shell/__tests__/ButtonVision.browser.spec.tsx +73 -0
- package/src/shell/__tests__/visionTokens.spec.ts +104 -0
- package/src/shell/index.ts +6 -3
- package/src/styles.css +57 -0
- package/src/table/DataTable.tsx +52 -4
- package/src/table/DataTableColumnPicker.tsx +3 -0
- package/src/table/DataTableFilterBar.tsx +18 -191
- package/src/table/DataTableHeaderFilter.tsx +156 -0
- package/src/table/DataTableHeaderRow.tsx +78 -40
- package/src/table/DataTableTabs.tsx +114 -0
- package/src/table/__tests__/DataTableHeaderFilter.browser.spec.tsx +174 -0
- package/src/table/__tests__/DataTableStaleColumns.browser.spec.tsx +80 -0
- package/src/table/__tests__/DataTableTabs.browser.spec.tsx +72 -0
- package/src/table/dataTableBaseProps.ts +12 -0
- package/src/table/dataTablePersistence.ts +11 -5
- package/src/table/dataTableTypes.ts +18 -0
- package/src/table/index.ts +9 -2
- package/src/table/useDataTableColumns.ts +1 -0
- package/src/table/useDataTableFilterModel.tsx +240 -0
|
@@ -64,5 +64,5 @@ import { type PageNavOptions } from "../shell/$pageNav.tsx";
|
|
|
64
64
|
* }
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
|
-
export declare const $pageAccount: <TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault>(options: Omit<PageNavOptions<TConfig, TProps, TPropsParent>, "parent">) => PagePrimitive<TConfig, TProps, TPropsParent>;
|
|
67
|
+
export declare const $pageAccount: <TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault, TName extends string = string>(options: Omit<PageNavOptions<TConfig, TProps, TPropsParent, TName>, "parent">) => PagePrimitive<TConfig, TProps, TPropsParent, TName>;
|
|
68
68
|
//# sourceMappingURL=$pageAccount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$pageAccount.d.ts","sourceRoot":"","sources":["../../src/account/$pageAccount.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,MAAM,SAAS,MAAM,GAAG,aAAa,EACrC,YAAY,SAAS,MAAM,GAAG,mBAAmB,
|
|
1
|
+
{"version":3,"file":"$pageAccount.d.ts","sourceRoot":"","sources":["../../src/account/$pageAccount.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,MAAM,SAAS,MAAM,GAAG,aAAa,EACrC,YAAY,SAAS,MAAM,GAAG,mBAAmB,EACjD,KAAK,SAAS,MAAM,GAAG,MAAM,WAEpB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,KAC5E,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAOpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$pageAccount.js","names":[],"sources":["../../src/account/$pageAccount.tsx"],"sourcesContent":["import { $context } from \"alepha\";\nimport type {\n PageConfigSchema,\n PagePrimitive,\n TPropsDefault,\n TPropsParentDefault,\n} from \"alepha/react/router\";\n\nimport { $pageNav, type PageNavOptions } from \"../shell/$pageNav.tsx\";\nimport { AccountRouter } from \"./AccountRouter.tsx\";\n\n/**\n * `$pageNav` already parented to {@link AccountRouter}'s `/account` shell:\n * the one-call form of \"a page inside the shared account area\".\n *\n * It carries the `$` prefix to sit with the framework's other declarations at\n * a call site, but it is a plain function wrapping `$pageNav`, which wraps\n * `$page`. Nothing about its lifecycle differs from declaring `$page`\n * yourself.\n *\n * The page appears in the sidebar with no separate registration: the layout\n * is `NavShell root=\"account\"`, which walks the parent chain\n * and reads each page's own `nav`.\n *\n * **Calling this registers `AccountRouter`.** Declaring even one page this\n * way mounts the whole `/account` shell including its five built-in pages:\n * an account page without the account area around it is not a thing. That is\n * the intended reading, but it is a real side effect: an application wanting\n * `/account` to carry only its own pages must build its own layout instead.\n *\n * **Take an order between 100 and 999, in your own `nav.group`.** The\n * built-ins occupy `Account` (order 1) and `Security` (orders 1000-1003), and\n * `useNavEntries` sorts groups by their smallest member, so the application's\n * groups sit between the two: personal first, then the application, then\n * security. An order below 100 competes with Profile, one of 1000 or more\n * sinks the page in among the security pages.\n *\n * **Frame the page with `AccountPage`**: `variant=\"table\"` for a `DataTable`\n * that fills the area, `variant=\"form\"` for a centred column of cards.\n *\n * **Gate with `can: () => this.someApi.someAction.can()`, not `permission`\n * alone.** A permission named by this page's own `$secure` is self-declaring:\n * `$secure` registers it into `SecurityProvider` at definition time, so it\n * exists whether or not any controller backing the page does. An action name\n * resolves against `/api/_links`, which is built only from actions the server\n * actually registered.\n *\n * ```tsx\n * class OrganizationAccountRouter {\n * protected readonly invitationApi =\n * $client<OrganizationInvitationController>();\n *\n * invitations = $pageAccount({\n * path: \"/invitations\",\n * name: \"accountInvitations\",\n * nav: {\n * label: \"Invitations\",\n * // ⚠️ `createElement(Mail)`, never `<Mail />`. This module graph is\n * // imported by `alepha db migrations create` under `tsx` with the\n * // classic JSX transform, where the element form emits a bare\n * // `React.createElement` and breaks migration generation for the\n * // whole app - far from the icon that caused it.\n * icon: createElement(Mail),\n * group: \"Organizations\",\n * order: 100,\n * },\n * can: () => this.invitationApi.getMyOrganizationInvitations.can(),\n * // A lazy page framing `MyOrganizationInvitations` in\n * // `<AccountPage variant=\"table\">`: the component draws the table,\n * // the page owns the frame.\n * lazy: () => import(\"./AccountInvitations.tsx\"),\n * });\n * }\n * ```\n */\nexport const $pageAccount = <\n TConfig extends PageConfigSchema = PageConfigSchema,\n TProps extends object = TPropsDefault,\n TPropsParent extends object = TPropsParentDefault,\n>(\n options: Omit<PageNavOptions<TConfig, TProps, TPropsParent>, \"parent\">,\n): PagePrimitive<TConfig, TProps, TPropsParent> => {\n const { alepha } = $context();\n const account = alepha.inject(AccountRouter);\n return $pageNav<TConfig, TProps, TPropsParent>({\n ...options,\n parent: account.layout,\n } as PageNavOptions<TConfig, TProps, TPropsParent>);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,
|
|
1
|
+
{"version":3,"file":"$pageAccount.js","names":[],"sources":["../../src/account/$pageAccount.tsx"],"sourcesContent":["import { $context } from \"alepha\";\nimport type {\n PageConfigSchema,\n PagePrimitive,\n TPropsDefault,\n TPropsParentDefault,\n} from \"alepha/react/router\";\n\nimport { $pageNav, type PageNavOptions } from \"../shell/$pageNav.tsx\";\nimport { AccountRouter } from \"./AccountRouter.tsx\";\n\n/**\n * `$pageNav` already parented to {@link AccountRouter}'s `/account` shell:\n * the one-call form of \"a page inside the shared account area\".\n *\n * It carries the `$` prefix to sit with the framework's other declarations at\n * a call site, but it is a plain function wrapping `$pageNav`, which wraps\n * `$page`. Nothing about its lifecycle differs from declaring `$page`\n * yourself.\n *\n * The page appears in the sidebar with no separate registration: the layout\n * is `NavShell root=\"account\"`, which walks the parent chain\n * and reads each page's own `nav`.\n *\n * **Calling this registers `AccountRouter`.** Declaring even one page this\n * way mounts the whole `/account` shell including its five built-in pages:\n * an account page without the account area around it is not a thing. That is\n * the intended reading, but it is a real side effect: an application wanting\n * `/account` to carry only its own pages must build its own layout instead.\n *\n * **Take an order between 100 and 999, in your own `nav.group`.** The\n * built-ins occupy `Account` (order 1) and `Security` (orders 1000-1003), and\n * `useNavEntries` sorts groups by their smallest member, so the application's\n * groups sit between the two: personal first, then the application, then\n * security. An order below 100 competes with Profile, one of 1000 or more\n * sinks the page in among the security pages.\n *\n * **Frame the page with `AccountPage`**: `variant=\"table\"` for a `DataTable`\n * that fills the area, `variant=\"form\"` for a centred column of cards.\n *\n * **Gate with `can: () => this.someApi.someAction.can()`, not `permission`\n * alone.** A permission named by this page's own `$secure` is self-declaring:\n * `$secure` registers it into `SecurityProvider` at definition time, so it\n * exists whether or not any controller backing the page does. An action name\n * resolves against `/api/_links`, which is built only from actions the server\n * actually registered.\n *\n * ```tsx\n * class OrganizationAccountRouter {\n * protected readonly invitationApi =\n * $client<OrganizationInvitationController>();\n *\n * invitations = $pageAccount({\n * path: \"/invitations\",\n * name: \"accountInvitations\",\n * nav: {\n * label: \"Invitations\",\n * // ⚠️ `createElement(Mail)`, never `<Mail />`. This module graph is\n * // imported by `alepha db migrations create` under `tsx` with the\n * // classic JSX transform, where the element form emits a bare\n * // `React.createElement` and breaks migration generation for the\n * // whole app - far from the icon that caused it.\n * icon: createElement(Mail),\n * group: \"Organizations\",\n * order: 100,\n * },\n * can: () => this.invitationApi.getMyOrganizationInvitations.can(),\n * // A lazy page framing `MyOrganizationInvitations` in\n * // `<AccountPage variant=\"table\">`: the component draws the table,\n * // the page owns the frame.\n * lazy: () => import(\"./AccountInvitations.tsx\"),\n * });\n * }\n * ```\n */\nexport const $pageAccount = <\n TConfig extends PageConfigSchema = PageConfigSchema,\n TProps extends object = TPropsDefault,\n TPropsParent extends object = TPropsParentDefault,\n TName extends string = string,\n>(\n options: Omit<PageNavOptions<TConfig, TProps, TPropsParent, TName>, \"parent\">,\n): PagePrimitive<TConfig, TProps, TPropsParent, TName> => {\n const { alepha } = $context();\n const account = alepha.inject(AccountRouter);\n return $pageNav<TConfig, TProps, TPropsParent, TName>({\n ...options,\n parent: account.layout,\n } as PageNavOptions<TConfig, TProps, TPropsParent, TName>);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,gBAMX,YACwD;CACxD,MAAM,EAAE,WAAW,SAAS;CAC5B,MAAM,UAAU,OAAO,OAAO,aAAa;CAC3C,OAAO,SAA+C;EACpD,GAAG;EACH,QAAQ,QAAQ;CAClB,CAAyD;AAC3D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the interface is drawn for this viewer: the colour-blind palette.
|
|
3
|
+
*
|
|
4
|
+
* It lives on the account page rather than in the account menu because it is
|
|
5
|
+
* set once, not flipped from every page. The switch is `useVisionMode()`, the
|
|
6
|
+
* preference `ButtonVision` toggles for a signed-out visitor: it is kept in
|
|
7
|
+
* the UI cookie, on this browser, and nothing is saved on the server.
|
|
8
|
+
*
|
|
9
|
+
* The server and the hydration pass read `"normal"` (see `useUiState`), so
|
|
10
|
+
* the form is seeded from the mode and follows it once the cookie is read.
|
|
11
|
+
*/
|
|
12
|
+
export declare const AccountDisplay: () => import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=AccountDisplay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountDisplay.d.ts","sourceRoot":"","sources":["../../src/account/AccountDisplay.tsx"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,mCAqC1B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Control } from "../form/Control.js";
|
|
2
|
+
import { SettingsRow } from "../settings/SettingsRow.js";
|
|
3
|
+
import { SettingsSection } from "../settings/SettingsSection.js";
|
|
4
|
+
import { z } from "alepha";
|
|
5
|
+
import { useI18n } from "alepha/react/i18n";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { useForm } from "alepha/react/form";
|
|
8
|
+
import { useVisionMode } from "alepha/react/ui";
|
|
9
|
+
// src/account/AccountDisplay.tsx
|
|
10
|
+
/**
|
|
11
|
+
* How the interface is drawn for this viewer: the colour-blind palette.
|
|
12
|
+
*
|
|
13
|
+
* It lives on the account page rather than in the account menu because it is
|
|
14
|
+
* set once, not flipped from every page. The switch is `useVisionMode()`, the
|
|
15
|
+
* preference `ButtonVision` toggles for a signed-out visitor: it is kept in
|
|
16
|
+
* the UI cookie, on this browser, and nothing is saved on the server.
|
|
17
|
+
*
|
|
18
|
+
* The server and the hydration pass read `"normal"` (see `useUiState`), so
|
|
19
|
+
* the form is seeded from the mode and follows it once the cookie is read.
|
|
20
|
+
*/
|
|
21
|
+
const AccountDisplay = () => {
|
|
22
|
+
const { tr } = useI18n();
|
|
23
|
+
const { vision, setVision } = useVisionMode();
|
|
24
|
+
const form = useForm({
|
|
25
|
+
schema: z.object({ cvd: z.boolean() }),
|
|
26
|
+
initialValues: { cvd: vision === "cvd" },
|
|
27
|
+
handler: () => {},
|
|
28
|
+
onChange: (_key, value) => setVision(value ? "cvd" : "normal")
|
|
29
|
+
});
|
|
30
|
+
const label = tr("account.display.vision", { default: "Colour-blind mode" });
|
|
31
|
+
return /* @__PURE__ */ jsx(SettingsSection, {
|
|
32
|
+
title: tr("account.display.title", { default: "Display" }),
|
|
33
|
+
description: tr("account.display.description", { default: "How the interface is drawn for you, on this browser." }),
|
|
34
|
+
children: /* @__PURE__ */ jsx(SettingsRow, {
|
|
35
|
+
label,
|
|
36
|
+
description: tr("account.display.visionDescription", { default: "Status colours that stay apart for red-green colour blindness." }),
|
|
37
|
+
children: /* @__PURE__ */ jsx(Control, {
|
|
38
|
+
switch: true,
|
|
39
|
+
input: form.input.cvd,
|
|
40
|
+
label: "",
|
|
41
|
+
inputProps: { "aria-label": label }
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export { AccountDisplay };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=AccountDisplay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountDisplay.js","names":[],"sources":["../../src/account/AccountDisplay.tsx"],"sourcesContent":["import { z } from \"alepha\";\nimport { useForm } from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useVisionMode } from \"alepha/react/ui\";\n\nimport { Control } from \"../form/Control.tsx\";\nimport { SettingsRow } from \"../settings/SettingsRow.tsx\";\nimport { SettingsSection } from \"../settings/SettingsSection.tsx\";\n\n/**\n * How the interface is drawn for this viewer: the colour-blind palette.\n *\n * It lives on the account page rather than in the account menu because it is\n * set once, not flipped from every page. The switch is `useVisionMode()`, the\n * preference `ButtonVision` toggles for a signed-out visitor: it is kept in\n * the UI cookie, on this browser, and nothing is saved on the server.\n *\n * The server and the hydration pass read `\"normal\"` (see `useUiState`), so\n * the form is seeded from the mode and follows it once the cookie is read.\n */\nexport const AccountDisplay = () => {\n const { tr } = useI18n();\n const { vision, setVision } = useVisionMode();\n\n const form = useForm({\n schema: z.object({ cvd: z.boolean() }),\n initialValues: { cvd: vision === \"cvd\" },\n // Saves on change: one switch, with nothing else to submit beside it.\n handler: () => {},\n onChange: (_key, value) => setVision(value ? \"cvd\" : \"normal\"),\n });\n\n const label = tr(\"account.display.vision\", { default: \"Colour-blind mode\" });\n\n return (\n <SettingsSection\n title={tr(\"account.display.title\", { default: \"Display\" })}\n description={tr(\"account.display.description\", {\n default: \"How the interface is drawn for you, on this browser.\",\n })}\n >\n <SettingsRow\n label={label}\n description={tr(\"account.display.visionDescription\", {\n default:\n \"Status colours that stay apart for red-green colour blindness.\",\n })}\n >\n <Control\n switch\n input={form.input.cvd}\n label=\"\"\n inputProps={{ \"aria-label\": label }}\n />\n </SettingsRow>\n </SettingsSection>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,uBAAuB;CAClC,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,EAAE,QAAQ,cAAc,cAAc;CAE5C,MAAM,OAAO,QAAQ;EACnB,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;EACrC,eAAe,EAAE,KAAK,WAAW,MAAM;EAEvC,eAAe,CAAC;EAChB,WAAW,MAAM,UAAU,UAAU,QAAQ,QAAQ,QAAQ;CAC/D,CAAC;CAED,MAAM,QAAQ,GAAG,0BAA0B,EAAE,SAAS,oBAAoB,CAAC;CAE3E,OACE,oBAAC,iBAAD;EACE,OAAO,GAAG,yBAAyB,EAAE,SAAS,UAAU,CAAC;EACzD,aAAa,GAAG,+BAA+B,EAC7C,SAAS,uDACX,CAAC;EAED,UAAA,oBAAC,aAAD;GACS;GACP,aAAa,GAAG,qCAAqC,EACnD,SACE,iEACJ,CAAC;GAED,UAAA,oBAAC,SAAD;IACE,QAAA;IACA,OAAO,KAAK,MAAM;IAClB,OAAM;IACN,YAAY,EAAE,cAAc,MAAM;GACnC,CAAA;EACU,CAAA;CACE,CAAA;AAErB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountProfile.d.ts","sourceRoot":"","sources":["../../src/account/AccountProfile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EAET,WAAW,EACZ,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"AccountProfile.d.ts","sourceRoot":"","sources":["../../src/account/AccountProfile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EAET,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAkB1B,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,QAAA,MAAM,cAAc,UAAW,mBAAmB,uCA4SjD,CAAC;eAEa,cAAc"}
|
|
@@ -5,13 +5,14 @@ import { useToast } from "../core/useToast.js";
|
|
|
5
5
|
import { AutoForm } from "../form/AutoForm.js";
|
|
6
6
|
import { SettingsRow } from "../settings/SettingsRow.js";
|
|
7
7
|
import { SettingsSection } from "../settings/SettingsSection.js";
|
|
8
|
+
import { AccountDisplay } from "./AccountDisplay.js";
|
|
8
9
|
import { AccountPage } from "./AccountPage.js";
|
|
9
10
|
import { useI18n } from "alepha/react/i18n";
|
|
10
11
|
import { AtSign, Camera, Trash2, User } from "lucide-react";
|
|
11
12
|
import { useRef, useState } from "react";
|
|
12
13
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
14
|
import { useAction, useClient } from "alepha/react";
|
|
14
|
-
import {
|
|
15
|
+
import { useActionForm } from "alepha/react/form";
|
|
15
16
|
import { updateMyProfileBodySchema } from "alepha/api/users";
|
|
16
17
|
// src/account/AccountProfile.tsx
|
|
17
18
|
/**
|
|
@@ -40,7 +41,8 @@ const AccountProfile = (props) => {
|
|
|
40
41
|
setProfile(await avatarApi.deleteMyAvatar());
|
|
41
42
|
} }, [avatarApi]);
|
|
42
43
|
const uploading = uploadAvatar.loading || removeAvatar.loading;
|
|
43
|
-
const
|
|
44
|
+
const usernameMode = props.realmConfig?.settings?.username;
|
|
45
|
+
const hasUsername = usernameMode !== "none" && usernameMode !== "email";
|
|
44
46
|
/**
|
|
45
47
|
* Validated against the server's own body schema, so "3 to 30 characters"
|
|
46
48
|
* is enforced before the request rather than only by the 400 that comes
|
|
@@ -59,20 +61,21 @@ const AccountProfile = (props) => {
|
|
|
59
61
|
* users while working for everyone who had set one. `undefined` is what an
|
|
60
62
|
* empty optional field means, and it is what the two name fields would use
|
|
61
63
|
* too if they were not `.nullable()` with a real "clear me" state.
|
|
64
|
+
*
|
|
65
|
+
* Built from the action (`useActionForm`): the values are the body as they
|
|
66
|
+
* are. An emptied name box sends `""`, which `updateMyProfile` stores as
|
|
67
|
+
* "no name" itself (it used to be mapped to `null` here, #Q3225), and an
|
|
68
|
+
* absent `username` stays "leave it alone".
|
|
62
69
|
*/
|
|
63
|
-
const form =
|
|
70
|
+
const form = useActionForm(api.updateMyProfile, {
|
|
64
71
|
initialValues: {
|
|
65
72
|
...hasUsername ? { username: props.profile?.username } : {},
|
|
66
73
|
firstName: props.profile?.firstName ?? "",
|
|
67
74
|
lastName: props.profile?.lastName ?? ""
|
|
68
75
|
},
|
|
69
76
|
schema: updateMyProfileBodySchema,
|
|
70
|
-
|
|
71
|
-
setProfile(
|
|
72
|
-
firstName: values.firstName || null,
|
|
73
|
-
lastName: values.lastName || null,
|
|
74
|
-
username: values.username
|
|
75
|
-
} }));
|
|
77
|
+
onSuccess: (updated) => {
|
|
78
|
+
setProfile(updated);
|
|
76
79
|
toaster.show(tr("account.profile.updated", { default: "Profile updated" }), "success");
|
|
77
80
|
}
|
|
78
81
|
});
|
|
@@ -200,7 +203,8 @@ const AccountProfile = (props) => {
|
|
|
200
203
|
})
|
|
201
204
|
})
|
|
202
205
|
]
|
|
203
|
-
})
|
|
206
|
+
}),
|
|
207
|
+
/* @__PURE__ */ jsx(AccountDisplay, {})
|
|
204
208
|
]
|
|
205
209
|
});
|
|
206
210
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountProfile.js","names":[],"sources":["../../src/account/AccountProfile.tsx"],"sourcesContent":["import type {\n MyAvatarController,\n MyProfile,\n MyProfileController,\n RealmConfig,\n} from \"alepha/api/users\";\nimport { updateMyProfileBodySchema } from \"alepha/api/users\";\nimport { useAction, useClient } from \"alepha/react\";\nimport { useForm } from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { AtSign, Camera, Trash2, User } from \"lucide-react\";\nimport { type ChangeEvent, useRef, useState } from \"react\";\n\nimport { Badge } from \"../core/Badge.tsx\";\nimport { Button } from \"../core/Button.tsx\";\nimport { FileImage } from \"../core/FileImage.tsx\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { AutoForm } from \"../form/AutoForm.tsx\";\nimport { SettingsRow } from \"../settings/SettingsRow.tsx\";\nimport { SettingsSection } from \"../settings/SettingsSection.tsx\";\nimport { AccountPage } from \"./AccountPage.tsx\";\n\nexport interface AccountProfileProps {\n /**\n * Supplied by the route loader. Optional so the page can also be rendered\n * standalone in a story or a test.\n */\n profile?: MyProfile;\n\n /**\n * Supplied by the route loader, and read for one thing: whether this realm\n * collects usernames at all.\n *\n * Optional for the same reason `profile` is. Absent, the username field\n * renders — the historical behaviour, and the right guess for a realm nobody\n * described.\n */\n realmConfig?: RealmConfig;\n}\n\n/**\n * Who you are: avatar, name, and the read-only facts about the account.\n *\n * Email is shown but not editable — changing it is a verification flow, not a\n * profile edit, and `updateMyProfile` deliberately refuses it. Rather than\n * render a disabled input with no explanation, the row says so.\n */\nconst AccountProfile = (props: AccountProfileProps) => {\n const api = useClient<MyProfileController>();\n const avatarApi = useClient<MyAvatarController>();\n const toaster = useToast();\n const { l, tr } = useI18n();\n const fileInput = useRef<HTMLInputElement>(null);\n\n const [profile, setProfile] = useState<MyProfile | undefined>(props.profile);\n // A refused image (too large, a type the realm does not take) is toasted\n // by the app's ActionErrorToaster with the server's message.\n const uploadAvatar = useAction<[file: File]>(\n {\n handler: async (_ctx, file) => {\n setProfile(await avatarApi.updateMyAvatar({ body: { file } }));\n toaster.show(\n tr(\"account.profile.avatarUpdated\", { default: \"Avatar updated\" }),\n \"success\",\n );\n },\n },\n [avatarApi, toaster, tr],\n );\n const removeAvatar = useAction<[]>(\n {\n handler: async () => {\n setProfile(await avatarApi.deleteMyAvatar());\n },\n },\n [avatarApi],\n );\n const uploading = uploadAvatar.loading || removeAvatar.loading;\n\n /*\n * Does this realm have usernames at all?\n *\n * The avatar section above reads its switch through `can()`, because a realm\n * with `features.avatars` off registers no avatar action and the capability\n * is simply absent from `/api/_links`. That cannot work here:\n * `updateMyProfile` is the same call that saves first and last name, so it\n * exists in every realm and its presence says nothing about usernames.\n *\n * The realm's own `settings.username` is the switch, and `\"none\"` is the\n * only value that hides the row: it is the one that means this realm has no\n * such thing as a username, so there is nothing to show and nothing the user\n * could set.\n *\n * Without this, a `\"none\"` realm did not merely render a pointless field:\n * `?? \"\"` seeded an empty string into a column that is `.optional()` but\n * `minLength: 3`, `FormModel` decodes its initial values on construction,\n * and the whole page died at `useForm` with \"Too small: expected string to\n * have >=3 characters at /username\" — before anything rendered. `apps/examples/shop`\n * is such a realm, and `\"none\"` is also the framework default, so this is\n * what any new app hits first.\n *\n * ⚠️ `AuthRegister.tsx` excludes `\"email\"` here as well, and this\n * deliberately does not. In that mode `RegistrationService` derives the\n * handle from the address and drops whatever the client sent, so the\n * registration form is right to hide a field the user does not choose — but\n * the account page is where an existing, already-derived username is shown,\n * and Lore (github.com/alepha-dev/lore) runs exactly this mode. Whether\n * editing it there should be\n * possible at all is a real question (a rename desyncs it from the email\n * that produced it, and `updateMyProfile` does not re-run the slugger), but\n * it is a separate one from \"this realm has no usernames\", and answering it\n * by quietly deleting the field is not the place to start.\n */\n const hasUsername = props.realmConfig?.settings?.username !== \"none\";\n\n /**\n * Validated against the server's own body schema, so \"3 to 30 characters\"\n * is enforced before the request rather than only by the 400 that comes\n * back — and is stated in exactly one place.\n *\n * The schema stays whole and `username` is dropped from the *values*: the\n * column is `.optional()`, so an absent key decodes cleanly, while the empty\n * string does not. Omitting it from `groups` below is what hides the row —\n * `AutoForm` renders the fields its groups name and nothing else — and an\n * absent value is what keeps it out of the request.\n *\n * ⚠️ **`username` is never seeded as `\"\"`, even when the field is shown.**\n * The old `?? \"\"` was not only a `\"none\"`-realm problem: `\"optional\"` is a\n * realm that collects usernames and does not insist, so an account without\n * one is the normal case there — and it crashed the page for exactly those\n * users while working for everyone who had set one. `undefined` is what an\n * empty optional field means, and it is what the two name fields would use\n * too if they were not `.nullable()` with a real \"clear me\" state.\n */\n const form = useForm({\n initialValues: {\n ...(hasUsername ? { username: props.profile?.username } : {}),\n firstName: props.profile?.firstName ?? \"\",\n lastName: props.profile?.lastName ?? \"\",\n },\n schema: updateMyProfileBodySchema,\n handler: async (values) => {\n setProfile(\n await api.updateMyProfile({\n body: {\n // Empty is \"unset\", which the API spells `null` — NOT\n // `undefined`, which means \"leave this column alone\" and made\n // clearing a name a silent no-op that still toasted success.\n firstName: values.firstName || null,\n lastName: values.lastName || null,\n // Absent, not `null`, in a realm without usernames: `null` is the\n // \"clear this column\" signal the two name fields use, and\n // `username` has no such state — absent is \"leave it alone\".\n username: values.username,\n },\n }),\n );\n toaster.show(\n tr(\"account.profile.updated\", { default: \"Profile updated\" }),\n \"success\",\n );\n // No catch. A refusal (the username-taken 409, with its own message)\n // propagates: that keeps the form dirty and errored so Save stays\n // actionable, and `ActionErrorToaster` shows the message once. It used\n // to be toasted here too, which put it on screen twice wherever that\n // listener is mounted. Same division of labour as the auth forms and\n // `AdminUserDetail`: the handler throws, the toaster shows.\n },\n });\n\n if (!profile) {\n return null;\n }\n\n const onPickAvatar = (event: ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n // Cleared at once, so picking the same file again still fires a change.\n event.target.value = \"\";\n if (!file) {\n return;\n }\n void uploadAvatar.run(file);\n };\n\n // Realms opt into avatars (`features.avatars`, off by default), and an\n // unregistered action is absent from `/api/_links` — so this is the realm's\n // own switch read through the mechanism that cannot drift from it. Checking\n // a flag mirrored into the client instead would let the picker render\n // against endpoints that answer 404.\n const canEditAvatar = avatarApi.updateMyAvatar.can();\n\n return (\n <AccountPage variant=\"form\">\n {canEditAvatar && (\n <>\n <SettingsSection\n title={tr(\"account.profile.pictureTitle\", {\n default: \"Profile picture\",\n })}\n description={tr(\"account.profile.pictureDescription\", {\n default: \"Shown next to your name wherever you appear.\",\n })}\n >\n <SettingsRow\n label={tr(\"account.profile.avatar\", { default: \"Avatar\" })}\n description={tr(\"account.profile.avatarDescription\", {\n default: \"PNG, JPEG, GIF or WebP, up to 5 MB.\",\n })}\n >\n <div className=\"flex items-center gap-3\">\n <button\n type=\"button\"\n onClick={() => fileInput.current?.click()}\n disabled={uploading}\n aria-label={tr(\"account.profile.avatarChange\", {\n default: \"Change avatar\",\n })}\n className=\"relative size-14 shrink-0\"\n >\n {/* Only the image is clipped to a circle; the camera badge sits\n outside the wrapper so the round mask cannot crop it. */}\n <div className=\"bg-muted size-full overflow-hidden rounded-full border\">\n <FileImage\n id={profile.picture}\n public\n alt=\"\"\n className=\"size-full object-cover\"\n fallback={\n <div className=\"flex size-full items-center justify-center\">\n <User className=\"size-6\" />\n </div>\n }\n />\n </div>\n <div className=\"bg-card absolute right-0 bottom-0 flex size-5 items-center justify-center rounded-full border\">\n <Camera className=\"size-3\" />\n </div>\n </button>\n {profile.picture ? (\n <Button\n variant=\"minimal\"\n size=\"sm\"\n onClick={() => removeAvatar.run()}\n disabled={uploading}\n >\n <Trash2 className=\"size-4\" />\n {tr(\"account.profile.avatarRemove\", { default: \"Remove\" })}\n </Button>\n ) : null}\n </div>\n </SettingsRow>\n </SettingsSection>\n\n <input\n type=\"file\"\n ref={fileInput}\n onChange={onPickAvatar}\n accept=\"image/jpeg,image/png,image/webp,image/gif\"\n className=\"hidden\"\n />\n </>\n )}\n\n {/* The one section here whose rows are all form fields, so it is an\n `AutoForm` in row layout rather than hand-wired `SettingsRow`s — same\n card, same rows, same heading, plus schema validation, the error\n popover, Reset, and a Save that knows whether anything changed. The\n sections above and below stay hand-wired because their rows are an\n avatar picker and read-only values, not fields. */}\n <AutoForm\n form={form}\n layout=\"row\"\n disabledIfPristine\n groups={[\n {\n title: tr(\"account.profile.nameTitle\", { default: \"Name\" }),\n description: tr(\"account.profile.nameDescription\", {\n default: \"How you are identified to other people.\",\n }),\n fields: hasUsername\n ? [\"username\", \"firstName\", \"lastName\"]\n : [\"firstName\", \"lastName\"],\n },\n ]}\n fields={{\n // Labels are explicit rather than derived: `prettyName` would title\n // -case them into \"First Name\", and this page's wording is settled.\n //\n // Icons are explicit because `Control`'s own fallback would resolve\n // the schema hint, and for a plain string that is the generic \"T\"\n // glyph — the same mark three times, saying \"this is text\" next to a\n // label that already said so. A field earns an icon by having one\n // that means something: `@` is what a handle looks like everywhere.\n username: {\n label: tr(\"account.profile.username\", { default: \"Username\" }),\n description: tr(\"account.profile.usernameDescription\", {\n default: \"Unique across this site.\",\n }),\n autoComplete: \"username\",\n icon: AtSign,\n // No clear button: `updateMyProfile` has no \"unset\" for a\n // username, so the × would offer a deletion the server cannot\n // perform. First and last name keep theirs — those genuinely\n // clear, via `null`.\n clearable: false,\n },\n firstName: {\n label: tr(\"account.profile.firstName\", { default: \"First name\" }),\n autoComplete: \"given-name\",\n icon: User,\n },\n lastName: {\n label: tr(\"account.profile.lastName\", { default: \"Last name\" }),\n autoComplete: \"family-name\",\n icon: User,\n },\n }}\n />\n\n <SettingsSection\n title={tr(\"account.profile.accountTitle\", { default: \"Account\" })}\n description={tr(\"account.profile.accountDescription\", {\n default: \"Details you cannot change from this page.\",\n })}\n >\n <SettingsRow\n label={tr(\"account.profile.email\", { default: \"Email\" })}\n description={tr(\"account.profile.emailDescription\", {\n default:\n \"Changing your email needs verification, so it is not a profile edit.\",\n })}\n >\n <span className=\"text-muted-foreground text-sm\">\n {profile.email ??\n tr(\"account.profile.emailUnset\", { default: \"Not set\" })}\n </span>\n </SettingsRow>\n <SettingsRow label={tr(\"account.profile.roles\", { default: \"Roles\" })}>\n <div className=\"flex flex-wrap gap-1\">\n {profile.roles.length > 0 ? (\n profile.roles.map((role) => (\n <Badge key={role} variant=\"outline\" className=\"text-xs\">\n {role}\n </Badge>\n ))\n ) : (\n <span className=\"text-muted-foreground text-sm\">—</span>\n )}\n </div>\n </SettingsRow>\n <SettingsRow\n label={tr(\"account.profile.memberSince\", { default: \"Member since\" })}\n >\n <span className=\"text-muted-foreground text-sm\">\n {l(profile.createdAt, { date: \"LL\" })}\n </span>\n </SettingsRow>\n </SettingsSection>\n </AccountPage>\n );\n};\n\nexport default AccountProfile;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,kBAAkB,UAA+B;CACrD,MAAM,MAAM,UAA+B;CAC3C,MAAM,YAAY,UAA8B;CAChD,MAAM,UAAU,SAAS;CACzB,MAAM,EAAE,GAAG,OAAO,QAAQ;CAC1B,MAAM,YAAY,OAAyB,IAAI;CAE/C,MAAM,CAAC,SAAS,cAAc,SAAgC,MAAM,OAAO;CAG3E,MAAM,eAAe,UACnB,EACE,SAAS,OAAO,MAAM,SAAS;EAC7B,WAAW,MAAM,UAA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N;;AAEjB"}
|
|
1
|
+
{"version":3,"file":"AccountProfile.js","names":[],"sources":["../../src/account/AccountProfile.tsx"],"sourcesContent":["import type {\n MyAvatarController,\n MyProfile,\n MyProfileController,\n RealmConfig,\n} from \"alepha/api/users\";\nimport { updateMyProfileBodySchema } from \"alepha/api/users\";\nimport { useAction, useClient } from \"alepha/react\";\nimport { useActionForm } from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { AtSign, Camera, Trash2, User } from \"lucide-react\";\nimport { type ChangeEvent, useRef, useState } from \"react\";\n\nimport { Badge } from \"../core/Badge.tsx\";\nimport { Button } from \"../core/Button.tsx\";\nimport { FileImage } from \"../core/FileImage.tsx\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { AutoForm } from \"../form/AutoForm.tsx\";\nimport { SettingsRow } from \"../settings/SettingsRow.tsx\";\nimport { SettingsSection } from \"../settings/SettingsSection.tsx\";\nimport { AccountDisplay } from \"./AccountDisplay.tsx\";\nimport { AccountPage } from \"./AccountPage.tsx\";\n\nexport interface AccountProfileProps {\n /**\n * Supplied by the route loader. Optional so the page can also be rendered\n * standalone in a story or a test.\n */\n profile?: MyProfile;\n\n /**\n * Supplied by the route loader, and read for one thing: whether this realm\n * collects usernames at all.\n *\n * Optional for the same reason `profile` is. Absent, the username field\n * renders — the historical behaviour, and the right guess for a realm nobody\n * described.\n */\n realmConfig?: RealmConfig;\n}\n\n/**\n * Who you are: avatar, name, and the read-only facts about the account.\n *\n * Email is shown but not editable — changing it is a verification flow, not a\n * profile edit, and `updateMyProfile` deliberately refuses it. Rather than\n * render a disabled input with no explanation, the row says so.\n */\nconst AccountProfile = (props: AccountProfileProps) => {\n const api = useClient<MyProfileController>();\n const avatarApi = useClient<MyAvatarController>();\n const toaster = useToast();\n const { l, tr } = useI18n();\n const fileInput = useRef<HTMLInputElement>(null);\n\n const [profile, setProfile] = useState<MyProfile | undefined>(props.profile);\n // A refused image (too large, a type the realm does not take) is toasted\n // by the app's ActionErrorToaster with the server's message.\n const uploadAvatar = useAction<[file: File]>(\n {\n handler: async (_ctx, file) => {\n setProfile(await avatarApi.updateMyAvatar({ body: { file } }));\n toaster.show(\n tr(\"account.profile.avatarUpdated\", { default: \"Avatar updated\" }),\n \"success\",\n );\n },\n },\n [avatarApi, toaster, tr],\n );\n const removeAvatar = useAction<[]>(\n {\n handler: async () => {\n setProfile(await avatarApi.deleteMyAvatar());\n },\n },\n [avatarApi],\n );\n const uploading = uploadAvatar.loading || removeAvatar.loading;\n\n /*\n * Does this realm have usernames at all?\n *\n * The avatar section above reads its switch through `can()`, because a realm\n * with `features.avatars` off registers no avatar action and the capability\n * is simply absent from `/api/_links`. That cannot work here:\n * `updateMyProfile` is the same call that saves first and last name, so it\n * exists in every realm and its presence says nothing about usernames.\n *\n * The realm's own `settings.username` is the switch, and the row is hidden\n * in the two modes where a person does not choose a username, the same rule\n * `AuthRegister.tsx` applies:\n *\n * - `\"none\"`: the realm has no such thing as a username, so there is nothing\n * to show and nothing the user could set. Without this, `?? \"\"` seeded an\n * empty string into a column that is `.optional()` but `minLength: 3`,\n * `FormModel` decodes its initial values on construction, and the whole\n * page died at `useForm` with \"Too small: expected string to have >=3\n * characters at /username\" before anything rendered. `apps/examples/shop`\n * is such a realm, and `\"none\"` is also the framework default.\n * - `\"email\"`: `RegistrationService` derives the handle from the address and\n * the person never chose it. Showing it as an editable row (it once did,\n * for Lore's sake) offered a rename that desyncs it from the email that\n * produced it, since `updateMyProfile` does not re-run the slugger, and\n * apps in that mode read the row as a stray field. Hidden, it is\n * also left out of the request, so the derived handle stays as it is.\n */\n const usernameMode = props.realmConfig?.settings?.username;\n const hasUsername = usernameMode !== \"none\" && usernameMode !== \"email\";\n\n /**\n * Validated against the server's own body schema, so \"3 to 30 characters\"\n * is enforced before the request rather than only by the 400 that comes\n * back — and is stated in exactly one place.\n *\n * The schema stays whole and `username` is dropped from the *values*: the\n * column is `.optional()`, so an absent key decodes cleanly, while the empty\n * string does not. Omitting it from `groups` below is what hides the row —\n * `AutoForm` renders the fields its groups name and nothing else — and an\n * absent value is what keeps it out of the request.\n *\n * ⚠️ **`username` is never seeded as `\"\"`, even when the field is shown.**\n * The old `?? \"\"` was not only a `\"none\"`-realm problem: `\"optional\"` is a\n * realm that collects usernames and does not insist, so an account without\n * one is the normal case there — and it crashed the page for exactly those\n * users while working for everyone who had set one. `undefined` is what an\n * empty optional field means, and it is what the two name fields would use\n * too if they were not `.nullable()` with a real \"clear me\" state.\n *\n * Built from the action (`useActionForm`): the values are the body as they\n * are. An emptied name box sends `\"\"`, which `updateMyProfile` stores as\n * \"no name\" itself (it used to be mapped to `null` here, #Q3225), and an\n * absent `username` stays \"leave it alone\".\n */\n const form = useActionForm(api.updateMyProfile, {\n initialValues: {\n ...(hasUsername ? { username: props.profile?.username } : {}),\n firstName: props.profile?.firstName ?? \"\",\n lastName: props.profile?.lastName ?? \"\",\n },\n schema: updateMyProfileBodySchema,\n onSuccess: (updated) => {\n setProfile(updated);\n toaster.show(\n tr(\"account.profile.updated\", { default: \"Profile updated\" }),\n \"success\",\n );\n // No catch. A refusal (the username-taken 409, with its own message)\n // propagates: that keeps the form dirty and errored so Save stays\n // actionable, and `ActionErrorToaster` shows the message once. It used\n // to be toasted here too, which put it on screen twice wherever that\n // listener is mounted. Same division of labour as the auth forms and\n // `AdminUserDetail`: the handler throws, the toaster shows.\n },\n });\n\n if (!profile) {\n return null;\n }\n\n const onPickAvatar = (event: ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n // Cleared at once, so picking the same file again still fires a change.\n event.target.value = \"\";\n if (!file) {\n return;\n }\n void uploadAvatar.run(file);\n };\n\n // Realms opt into avatars (`features.avatars`, off by default), and an\n // unregistered action is absent from `/api/_links` — so this is the realm's\n // own switch read through the mechanism that cannot drift from it. Checking\n // a flag mirrored into the client instead would let the picker render\n // against endpoints that answer 404.\n const canEditAvatar = avatarApi.updateMyAvatar.can();\n\n return (\n <AccountPage variant=\"form\">\n {canEditAvatar && (\n <>\n <SettingsSection\n title={tr(\"account.profile.pictureTitle\", {\n default: \"Profile picture\",\n })}\n description={tr(\"account.profile.pictureDescription\", {\n default: \"Shown next to your name wherever you appear.\",\n })}\n >\n <SettingsRow\n label={tr(\"account.profile.avatar\", { default: \"Avatar\" })}\n description={tr(\"account.profile.avatarDescription\", {\n default: \"PNG, JPEG, GIF or WebP, up to 5 MB.\",\n })}\n >\n <div className=\"flex items-center gap-3\">\n <button\n type=\"button\"\n onClick={() => fileInput.current?.click()}\n disabled={uploading}\n aria-label={tr(\"account.profile.avatarChange\", {\n default: \"Change avatar\",\n })}\n className=\"relative size-14 shrink-0\"\n >\n {/* Only the image is clipped to a circle; the camera badge sits\n outside the wrapper so the round mask cannot crop it. */}\n <div className=\"bg-muted size-full overflow-hidden rounded-full border\">\n <FileImage\n id={profile.picture}\n public\n alt=\"\"\n className=\"size-full object-cover\"\n fallback={\n <div className=\"flex size-full items-center justify-center\">\n <User className=\"size-6\" />\n </div>\n }\n />\n </div>\n <div className=\"bg-card absolute right-0 bottom-0 flex size-5 items-center justify-center rounded-full border\">\n <Camera className=\"size-3\" />\n </div>\n </button>\n {profile.picture ? (\n <Button\n variant=\"minimal\"\n size=\"sm\"\n onClick={() => removeAvatar.run()}\n disabled={uploading}\n >\n <Trash2 className=\"size-4\" />\n {tr(\"account.profile.avatarRemove\", { default: \"Remove\" })}\n </Button>\n ) : null}\n </div>\n </SettingsRow>\n </SettingsSection>\n\n <input\n type=\"file\"\n ref={fileInput}\n onChange={onPickAvatar}\n accept=\"image/jpeg,image/png,image/webp,image/gif\"\n className=\"hidden\"\n />\n </>\n )}\n\n {/* The one section here whose rows are all form fields, so it is an\n `AutoForm` in row layout rather than hand-wired `SettingsRow`s — same\n card, same rows, same heading, plus schema validation, the error\n popover, Reset, and a Save that knows whether anything changed. The\n sections above and below stay hand-wired because their rows are an\n avatar picker and read-only values, not fields. */}\n <AutoForm\n form={form}\n layout=\"row\"\n disabledIfPristine\n groups={[\n {\n title: tr(\"account.profile.nameTitle\", { default: \"Name\" }),\n description: tr(\"account.profile.nameDescription\", {\n default: \"How you are identified to other people.\",\n }),\n fields: hasUsername\n ? [\"username\", \"firstName\", \"lastName\"]\n : [\"firstName\", \"lastName\"],\n },\n ]}\n fields={{\n // Labels are explicit rather than derived: `prettyName` would title\n // -case them into \"First Name\", and this page's wording is settled.\n //\n // Icons are explicit because `Control`'s own fallback would resolve\n // the schema hint, and for a plain string that is the generic \"T\"\n // glyph — the same mark three times, saying \"this is text\" next to a\n // label that already said so. A field earns an icon by having one\n // that means something: `@` is what a handle looks like everywhere.\n username: {\n label: tr(\"account.profile.username\", { default: \"Username\" }),\n description: tr(\"account.profile.usernameDescription\", {\n default: \"Unique across this site.\",\n }),\n autoComplete: \"username\",\n icon: AtSign,\n // No clear button: `updateMyProfile` has no \"unset\" for a\n // username, so the × would offer a deletion the server cannot\n // perform. First and last name keep theirs — those genuinely\n // clear, via `null`.\n clearable: false,\n },\n firstName: {\n label: tr(\"account.profile.firstName\", { default: \"First name\" }),\n autoComplete: \"given-name\",\n icon: User,\n },\n lastName: {\n label: tr(\"account.profile.lastName\", { default: \"Last name\" }),\n autoComplete: \"family-name\",\n icon: User,\n },\n }}\n />\n\n <SettingsSection\n title={tr(\"account.profile.accountTitle\", { default: \"Account\" })}\n description={tr(\"account.profile.accountDescription\", {\n default: \"Details you cannot change from this page.\",\n })}\n >\n <SettingsRow\n label={tr(\"account.profile.email\", { default: \"Email\" })}\n description={tr(\"account.profile.emailDescription\", {\n default:\n \"Changing your email needs verification, so it is not a profile edit.\",\n })}\n >\n <span className=\"text-muted-foreground text-sm\">\n {profile.email ??\n tr(\"account.profile.emailUnset\", { default: \"Not set\" })}\n </span>\n </SettingsRow>\n <SettingsRow label={tr(\"account.profile.roles\", { default: \"Roles\" })}>\n <div className=\"flex flex-wrap gap-1\">\n {profile.roles.length > 0 ? (\n profile.roles.map((role) => (\n <Badge key={role} variant=\"outline\" className=\"text-xs\">\n {role}\n </Badge>\n ))\n ) : (\n <span className=\"text-muted-foreground text-sm\">—</span>\n )}\n </div>\n </SettingsRow>\n <SettingsRow\n label={tr(\"account.profile.memberSince\", { default: \"Member since\" })}\n >\n <span className=\"text-muted-foreground text-sm\">\n {l(profile.createdAt, { date: \"LL\" })}\n </span>\n </SettingsRow>\n </SettingsSection>\n\n <AccountDisplay />\n </AccountPage>\n );\n};\n\nexport default AccountProfile;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAM,kBAAkB,UAA+B;CACrD,MAAM,MAAM,UAA+B;CAC3C,MAAM,YAAY,UAA8B;CAChD,MAAM,UAAU,SAAS;CACzB,MAAM,EAAE,GAAG,OAAO,QAAQ;CAC1B,MAAM,YAAY,OAAyB,IAAI;CAE/C,MAAM,CAAC,SAAS,cAAc,SAAgC,MAAM,OAAO;CAG3E,MAAM,eAAe,UACnB,EACE,SAAS,OAAO,MAAM,SAAS;EAC7B,WAAW,MAAM,UAAU,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;EAC7D,QAAQ,KACN,GAAG,iCAAiC,EAAE,SAAS,iBAAiB,CAAC,GACjE,SACF;CACF,EACF,GACA;EAAC;EAAW;EAAS;CAAE,CACzB;CACA,MAAM,eAAe,UACnB,EACE,SAAS,YAAY;EACnB,WAAW,MAAM,UAAU,eAAe,CAAC;CAC7C,EACF,GACA,CAAC,SAAS,CACZ;CACA,MAAM,YAAY,aAAa,WAAW,aAAa;CA6BvD,MAAM,eAAe,MAAM,aAAa,UAAU;CAClD,MAAM,cAAc,iBAAiB,UAAU,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;CA0BhE,MAAM,OAAO,cAAc,IAAI,iBAAiB;EAC9C,eAAe;GACb,GAAI,cAAc,EAAE,UAAU,MAAM,SAAS,SAAS,IAAI,CAAC;GAC3D,WAAW,MAAM,SAAS,aAAa;GACvC,UAAU,MAAM,SAAS,YAAY;EACvC;EACA,QAAQ;EACR,YAAY,YAAY;GACt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,CAAA;KACK,CAAA;KACb,oBAAC,aAAD;MAAa,OAAO,GAAG,yBAAyB,EAAE,SAAS,QAAQ,CAAC;MAClE,UAAA,oBAAC,OAAD;OAAK,WAAU;OACZ,UAAA,QAAQ,MAAM,SAAS,IACtB,QAAQ,MAAM,KAAK,SACjB,oBAAC,OAAD;QAAkB,SAAQ;QAAU,WAAU;QAC3C,UAAA;OACI,GAFK,IAEL,CACR,IAED,oBAAC,QAAD;QAAM,WAAU;QAAgC,UAAA;OAAO,CAAA;MAEtD,CAAA;KACM,CAAA;KACb,oBAAC,aAAD;MACE,OAAO,GAAG,+BAA+B,EAAE,SAAS,eAAe,CAAC;MAEpE,UAAA,oBAAC,QAAD;OAAM,WAAU;OACb,UAAA,EAAE,QAAQ,WAAW,EAAE,MAAM,KAAK,CAAC;MAChC,CAAA;KACK,CAAA;IACE;;GAEjB,oBAAC,gBAAD,CAAiB,CAAA;EACN;;AAEjB"}
|
|
@@ -150,7 +150,7 @@ export declare class AccountRouter {
|
|
|
150
150
|
* `/account` resolves to it directly. `AdminRouter` now anchors its
|
|
151
151
|
* dashboard the same way.
|
|
152
152
|
*/
|
|
153
|
-
layout: import("alepha/react/router").PagePrimitive<import("alepha/react/router").PageConfigSchema, any, import("alepha/react/router").TPropsParentDefault>;
|
|
153
|
+
layout: import("alepha/react/router").PagePrimitive<import("alepha/react/router").PageConfigSchema, any, import("alepha/react/router").TPropsParentDefault, "account">;
|
|
154
154
|
profile: import("alepha/react/router").PagePrimitive<import("alepha/react/router").PageConfigSchema, {
|
|
155
155
|
profile: {
|
|
156
156
|
id: string;
|
|
@@ -212,7 +212,7 @@ export declare class AccountRouter {
|
|
|
212
212
|
}[];
|
|
213
213
|
captchaSiteKey?: string | undefined;
|
|
214
214
|
};
|
|
215
|
-
}, any>;
|
|
215
|
+
}, any, "accountProfile">;
|
|
216
216
|
security: import("alepha/react/router").PagePrimitive<import("alepha/react/router").PageConfigSchema, {
|
|
217
217
|
identities: {
|
|
218
218
|
id: string;
|
|
@@ -268,7 +268,7 @@ export declare class AccountRouter {
|
|
|
268
268
|
}[];
|
|
269
269
|
captchaSiteKey?: string | undefined;
|
|
270
270
|
};
|
|
271
|
-
}, any>;
|
|
271
|
+
}, any, "accountSecurity">;
|
|
272
272
|
sessions: import("alepha/react/router").PagePrimitive<import("alepha/react/router").PageConfigSchema, {
|
|
273
273
|
sessions: {
|
|
274
274
|
id: string;
|
|
@@ -284,7 +284,7 @@ export declare class AccountRouter {
|
|
|
284
284
|
} | undefined;
|
|
285
285
|
current: boolean;
|
|
286
286
|
}[];
|
|
287
|
-
}, any>;
|
|
287
|
+
}, any, "accountSessions">;
|
|
288
288
|
keys: import("alepha/react/router").PagePrimitive<import("alepha/react/router").PageConfigSchema, {
|
|
289
289
|
apiKeys: {
|
|
290
290
|
id: string;
|
|
@@ -304,7 +304,7 @@ export declare class AccountRouter {
|
|
|
304
304
|
usageCount: number;
|
|
305
305
|
status: "active" | "expired" | "expiring" | "revoked";
|
|
306
306
|
}[];
|
|
307
|
-
}, any>;
|
|
307
|
+
}, any, "accountKeys">;
|
|
308
308
|
connections: import("alepha/react/router").PagePrimitive<import("alepha/react/router").PageConfigSchema, {
|
|
309
309
|
connections: {
|
|
310
310
|
id: string;
|
|
@@ -322,6 +322,6 @@ export declare class AccountRouter {
|
|
|
322
322
|
} | undefined;
|
|
323
323
|
current: boolean;
|
|
324
324
|
}[];
|
|
325
|
-
}, any>;
|
|
325
|
+
}, any, "accountConnections">;
|
|
326
326
|
}
|
|
327
327
|
//# sourceMappingURL=AccountRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountRouter.d.ts","sourceRoot":"","sources":["../../src/account/AccountRouter.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EAChB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D;IAEH,WAAW;;;;;;;;;;;;;;;;;kCAqBR;CACJ"}
|
package/dist/account/index.d.ts
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* under one layout, each page its own lazy chunk. The pages are exported by
|
|
6
6
|
* name too, for an app that routes them itself.
|
|
7
7
|
*
|
|
8
|
+
* The profile page ends with `AccountDisplay`, the viewer's own display
|
|
9
|
+
* settings: the colour-blind switch, which a signed-in viewer finds here and
|
|
10
|
+
* not in the account menu.
|
|
11
|
+
*
|
|
8
12
|
* @module alepha.ui.account
|
|
9
13
|
*/
|
|
10
14
|
export { $pageAccount } from "./$pageAccount.tsx";
|
|
@@ -14,6 +18,7 @@ export { AccountBackToSiteMenuItem, type AccountBackToSiteMenuItemProps, } from
|
|
|
14
18
|
export { AccountBrand, type AccountBrandProps } from "./AccountBrand.tsx";
|
|
15
19
|
export { AccountLayout } from "./AccountLayout.tsx";
|
|
16
20
|
export { AccountPage, type AccountPageProps } from "./AccountPage.tsx";
|
|
21
|
+
export { AccountDisplay } from "./AccountDisplay.tsx";
|
|
17
22
|
export { default as AccountProfile, type AccountProfileProps, } from "./AccountProfile.tsx";
|
|
18
23
|
export { AccountRouter } from "./AccountRouter.tsx";
|
|
19
24
|
export { type AccountPageName, type AccountRouterOptions, accountRouterOptionsAtom, } from "./AccountRouterOptions.tsx";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/account/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/account/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,OAAO,IAAI,kBAAkB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,OAAO,IAAI,WAAW,EACtB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,yBAAyB,EACzB,KAAK,8BAA8B,GACpC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,OAAO,IAAI,eAAe,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,OAAO,IAAI,eAAe,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC"}
|
package/dist/account/index.js
CHANGED
|
@@ -5,9 +5,10 @@ import { AccountBackToSiteMenuItem } from "./AccountBackToSiteMenuItem.js";
|
|
|
5
5
|
import { AccountBrand } from "./AccountBrand.js";
|
|
6
6
|
import { AccountLayout } from "./AccountLayout.js";
|
|
7
7
|
import { AccountPage } from "./AccountPage.js";
|
|
8
|
+
import { AccountDisplay } from "./AccountDisplay.js";
|
|
8
9
|
import AccountProfile from "./AccountProfile.js";
|
|
9
10
|
import { AccountRouter } from "./AccountRouter.js";
|
|
10
11
|
import { accountRouterOptionsAtom } from "./AccountRouterOptions.js";
|
|
11
12
|
import AccountSecurity from "./AccountSecurity.js";
|
|
12
13
|
import AccountSessions from "./AccountSessions.js";
|
|
13
|
-
export { $pageAccount, AccountBackToSiteMenuItem, AccountBrand, AccountConnections, AccountKeys, AccountLayout, AccountPage, AccountProfile, AccountRouter, AccountSecurity, AccountSessions, accountRouterOptionsAtom };
|
|
14
|
+
export { $pageAccount, AccountBackToSiteMenuItem, AccountBrand, AccountConnections, AccountDisplay, AccountKeys, AccountLayout, AccountPage, AccountProfile, AccountRouter, AccountSecurity, AccountSessions, accountRouterOptionsAtom };
|
|
@@ -60,5 +60,5 @@ import { type PageNavOptions } from "../shell/$pageNav.tsx";
|
|
|
60
60
|
* }
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
|
-
export declare const $pageAdmin: <TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault>(options: Omit<PageNavOptions<TConfig, TProps, TPropsParent>, "parent">) => PagePrimitive<TConfig, TProps, TPropsParent>;
|
|
63
|
+
export declare const $pageAdmin: <TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault, TName extends string = string>(options: Omit<PageNavOptions<TConfig, TProps, TPropsParent, TName>, "parent">) => PagePrimitive<TConfig, TProps, TPropsParent, TName>;
|
|
64
64
|
//# sourceMappingURL=$pageAdmin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$pageAdmin.d.ts","sourceRoot":"","sources":["../../src/admin/$pageAdmin.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,MAAM,SAAS,MAAM,GAAG,aAAa,EACrC,YAAY,SAAS,MAAM,GAAG,mBAAmB,
|
|
1
|
+
{"version":3,"file":"$pageAdmin.d.ts","sourceRoot":"","sources":["../../src/admin/$pageAdmin.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,MAAM,SAAS,MAAM,GAAG,aAAa,EACrC,YAAY,SAAS,MAAM,GAAG,mBAAmB,EACjD,KAAK,SAAS,MAAM,GAAG,MAAM,WAEpB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,KAC5E,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAkCpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$pageAdmin.js","names":[],"sources":["../../src/admin/$pageAdmin.tsx"],"sourcesContent":["import { $context } from \"alepha\";\nimport type {\n PageConfigSchema,\n PagePrimitive,\n TPropsDefault,\n TPropsParentDefault,\n} from \"alepha/react/router\";\n\nimport { $pageNav, type PageNavOptions } from \"../shell/$pageNav.tsx\";\nimport { AdminRouter } from \"./AdminRouter.tsx\";\n\n/**\n * `$pageNav` already parented to {@link AdminRouter}'s `/admin` shell: the\n * one-call form of \"a page inside the shared admin shell\". It exists because\n * the alternative (injecting `AdminRouter` and writing\n * `parent: this.admin.layout` by hand on every page) puts the rules of that\n * composition nowhere an author will read them.\n *\n * It carries the `$` prefix to sit with the framework's other declarations at\n * a call site, but it is a plain function wrapping `$pageNav` (which in turn\n * wraps `$page`) rather than a `createPrimitive` primitive. Nothing about\n * its lifecycle differs from declaring `$page` yourself.\n *\n * The page appears in the shell's sidebar with no separate registration\n * step: `useNavEntries` walks the parent chain and reads each page's own\n * `nav`, the same as any other page hung off `AdminRouter.layout`.\n *\n * **Its tab reads `Admin - <title>`**, the way every built-in page's does: a\n * static `head.title` or the title a `head` function returns is prefixed,\n * with the prefix in the reader's language (`admin.title`). The title itself\n * is the application's to translate: a static one is used as written.\n * When the page names no `nav.label` and no `label`, its unprefixed static\n * title becomes the `label`, so its sidebar entry and breadcrumb do not carry\n * the prefix.\n *\n * **Calling this registers `AdminRouter`.** Declaring even one page this way\n * mounts the whole `/admin` shell, including its fourteen built-in pages (Users,\n * Sessions, Jobs, …): an admin page without the admin shell around it is\n * not a thing. This is the intended reading, but it is a real side effect:\n * an application that wants `/admin` to carry only its own pages, with none\n * of the built-ins, must build its own layout page instead of reaching for\n * this helper.\n *\n * **Stay below `order: 1000`, or declare your own `nav.group`.** The\n * built-ins are parked in a reserved high band, `Identity` (1000-1003) and\n * `System` (1010-1016), precisely so an application's own pages come first:\n * the conventional `order: 100` sorts above them. `useNavEntries` sorts groups\n * by their smallest member, so only an order of 1000 or more sinks a page in\n * among the built-ins.\n *\n * **Gate with `can: () => this.someApi.someAction.can()`, not with\n * `permission` alone.** A permission named by this page's own `$secure` is\n * self-declaring: `$secure` registers it into `SecurityProvider` at\n * definition time, so an admin holding the `*` wildcard is granted it\n * whether or not any controller backing the page exists, and the entry would\n * stay visible over a dead API. An action name resolves against\n * `/api/_links`, a registry built only from actions the server actually\n * registered, so a page whose backend never shipped never appears for\n * anyone to be granted.\n *\n * ```tsx\n * class ShopAdminRouter {\n * products = $pageAdmin({\n * path: \"/products\",\n * nav: { label: \"Catalogue\", icon: <Gem />, group: \"Commerce\", order: 100 },\n * can: () => this.productApi.commerceAdminProductList.can(),\n * lazy: () => import(\"./AdminProducts.tsx\"),\n * });\n * }\n * ```\n */\nexport const $pageAdmin = <\n TConfig extends PageConfigSchema = PageConfigSchema,\n TProps extends object = TPropsDefault,\n TPropsParent extends object = TPropsParentDefault,\n>(\n options: Omit<PageNavOptions<TConfig, TProps, TPropsParent>, \"parent\">,\n): PagePrimitive<TConfig, TProps, TPropsParent> => {\n const { alepha } = $context();\n const admin = alepha.inject(AdminRouter);\n\n // \"Admin - <Page>\" in the tab, like the built-ins, with the prefix in the\n // reader's language: so the head is always a function here, since a\n // static one is read before any request has a language. A static title\n // also stands in for the label when the page names none, since the sidebar\n // and the breadcrumb fall back to it: keeping the unprefixed one there is\n // what keeps a crumb reading \"Produit\" rather than \"Admin - Produit\".\n const head = options.head;\n let label = options.label;\n let prefixed = head;\n if (typeof head === \"function\") {\n prefixed = (props: TProps, previous?: Parameters<typeof head>[1]) => {\n const resolved = head(props, previous);\n return resolved.title\n ? { ...resolved, title: admin.adminTitle(resolved.title) }\n : resolved;\n };\n } else if (head?.title) {\n if (options.nav?.label == null && label == null) {\n label = head.title;\n }\n const title = head.title;\n prefixed = () => ({ ...head, title: admin.adminTitle(title) });\n }\n\n return $pageNav<TConfig, TProps, TPropsParent>({\n ...options,\n ...(label !== undefined ? { label } : {}),\n ...(prefixed !== undefined ? { head: prefixed } : {}),\n parent: admin.layout,\n } as PageNavOptions<TConfig, TProps, TPropsParent>);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAa,
|
|
1
|
+
{"version":3,"file":"$pageAdmin.js","names":[],"sources":["../../src/admin/$pageAdmin.tsx"],"sourcesContent":["import { $context } from \"alepha\";\nimport type {\n PageConfigSchema,\n PagePrimitive,\n TPropsDefault,\n TPropsParentDefault,\n} from \"alepha/react/router\";\n\nimport { $pageNav, type PageNavOptions } from \"../shell/$pageNav.tsx\";\nimport { AdminRouter } from \"./AdminRouter.tsx\";\n\n/**\n * `$pageNav` already parented to {@link AdminRouter}'s `/admin` shell: the\n * one-call form of \"a page inside the shared admin shell\". It exists because\n * the alternative (injecting `AdminRouter` and writing\n * `parent: this.admin.layout` by hand on every page) puts the rules of that\n * composition nowhere an author will read them.\n *\n * It carries the `$` prefix to sit with the framework's other declarations at\n * a call site, but it is a plain function wrapping `$pageNav` (which in turn\n * wraps `$page`) rather than a `createPrimitive` primitive. Nothing about\n * its lifecycle differs from declaring `$page` yourself.\n *\n * The page appears in the shell's sidebar with no separate registration\n * step: `useNavEntries` walks the parent chain and reads each page's own\n * `nav`, the same as any other page hung off `AdminRouter.layout`.\n *\n * **Its tab reads `Admin - <title>`**, the way every built-in page's does: a\n * static `head.title` or the title a `head` function returns is prefixed,\n * with the prefix in the reader's language (`admin.title`). The title itself\n * is the application's to translate: a static one is used as written.\n * When the page names no `nav.label` and no `label`, its unprefixed static\n * title becomes the `label`, so its sidebar entry and breadcrumb do not carry\n * the prefix.\n *\n * **Calling this registers `AdminRouter`.** Declaring even one page this way\n * mounts the whole `/admin` shell, including its fourteen built-in pages (Users,\n * Sessions, Jobs, …): an admin page without the admin shell around it is\n * not a thing. This is the intended reading, but it is a real side effect:\n * an application that wants `/admin` to carry only its own pages, with none\n * of the built-ins, must build its own layout page instead of reaching for\n * this helper.\n *\n * **Stay below `order: 1000`, or declare your own `nav.group`.** The\n * built-ins are parked in a reserved high band, `Identity` (1000-1003) and\n * `System` (1010-1016), precisely so an application's own pages come first:\n * the conventional `order: 100` sorts above them. `useNavEntries` sorts groups\n * by their smallest member, so only an order of 1000 or more sinks a page in\n * among the built-ins.\n *\n * **Gate with `can: () => this.someApi.someAction.can()`, not with\n * `permission` alone.** A permission named by this page's own `$secure` is\n * self-declaring: `$secure` registers it into `SecurityProvider` at\n * definition time, so an admin holding the `*` wildcard is granted it\n * whether or not any controller backing the page exists, and the entry would\n * stay visible over a dead API. An action name resolves against\n * `/api/_links`, a registry built only from actions the server actually\n * registered, so a page whose backend never shipped never appears for\n * anyone to be granted.\n *\n * ```tsx\n * class ShopAdminRouter {\n * products = $pageAdmin({\n * path: \"/products\",\n * nav: { label: \"Catalogue\", icon: <Gem />, group: \"Commerce\", order: 100 },\n * can: () => this.productApi.commerceAdminProductList.can(),\n * lazy: () => import(\"./AdminProducts.tsx\"),\n * });\n * }\n * ```\n */\nexport const $pageAdmin = <\n TConfig extends PageConfigSchema = PageConfigSchema,\n TProps extends object = TPropsDefault,\n TPropsParent extends object = TPropsParentDefault,\n TName extends string = string,\n>(\n options: Omit<PageNavOptions<TConfig, TProps, TPropsParent, TName>, \"parent\">,\n): PagePrimitive<TConfig, TProps, TPropsParent, TName> => {\n const { alepha } = $context();\n const admin = alepha.inject(AdminRouter);\n\n // \"Admin - <Page>\" in the tab, like the built-ins, with the prefix in the\n // reader's language: so the head is always a function here, since a\n // static one is read before any request has a language. A static title\n // also stands in for the label when the page names none, since the sidebar\n // and the breadcrumb fall back to it: keeping the unprefixed one there is\n // what keeps a crumb reading \"Produit\" rather than \"Admin - Produit\".\n const head = options.head;\n let label = options.label;\n let prefixed = head;\n if (typeof head === \"function\") {\n prefixed = (props: TProps, previous?: Parameters<typeof head>[1]) => {\n const resolved = head(props, previous);\n return resolved.title\n ? { ...resolved, title: admin.adminTitle(resolved.title) }\n : resolved;\n };\n } else if (head?.title) {\n if (options.nav?.label == null && label == null) {\n label = head.title;\n }\n const title = head.title;\n prefixed = () => ({ ...head, title: admin.adminTitle(title) });\n }\n\n return $pageNav<TConfig, TProps, TPropsParent, TName>({\n ...options,\n ...(label !== undefined ? { label } : {}),\n ...(prefixed !== undefined ? { head: prefixed } : {}),\n parent: admin.layout,\n } as PageNavOptions<TConfig, TProps, TPropsParent, TName>);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAa,cAMX,YACwD;CACxD,MAAM,EAAE,WAAW,SAAS;CAC5B,MAAM,QAAQ,OAAO,OAAO,WAAW;CAQvC,MAAM,OAAO,QAAQ;CACrB,IAAI,QAAQ,QAAQ;CACpB,IAAI,WAAW;CACf,IAAI,OAAO,SAAS,YAClB,YAAY,OAAe,aAA0C;EACnE,MAAM,WAAW,KAAK,OAAO,QAAQ;EACrC,OAAO,SAAS,QACZ;GAAE,GAAG;GAAU,OAAO,MAAM,WAAW,SAAS,KAAK;EAAE,IACvD;CACN;MACK,IAAI,MAAM,OAAO;EACtB,IAAI,QAAQ,KAAK,SAAS,QAAQ,SAAS,MACzC,QAAQ,KAAK;EAEf,MAAM,QAAQ,KAAK;EACnB,kBAAkB;GAAE,GAAG;GAAM,OAAO,MAAM,WAAW,KAAK;EAAE;CAC9D;CAEA,OAAO,SAA+C;EACpD,GAAG;EACH,GAAI,UAAU,KAAA,IAAY,EAAE,MAAM,IAAI,CAAC;EACvC,GAAI,aAAa,KAAA,IAAY,EAAE,MAAM,SAAS,IAAI,CAAC;EACnD,QAAQ,MAAM;CAChB,CAAyD;AAC3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminAudits.js","names":[],"sources":["../../src/admin/AdminAudits.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport TimeAgo from \"../core/TimeAgo.tsx\";\n\nvoid React;\n\nimport { z } from \"alepha\";\nimport type {\n AdminAuditController,\n AuditActionPair,\n AuditEntity,\n} from \"alepha/api/audits\";\nimport { useClient } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useRouter } from \"alepha/react/router\";\nimport {\n CircleDot,\n Layers,\n SlidersHorizontal,\n Trash2,\n User,\n Zap,\n} from \"lucide-react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\nimport { Badge } from \"../core/Badge.tsx\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { DataTable } from \"../table/DataTable.tsx\";\nimport type {\n DataTableFilterFields,\n DataTableFilterValues,\n} from \"../table/dataTableTypes.ts\";\nimport { AdminPage } from \"./AdminPage.tsx\";\nimport { AdminUserCell } from \"./AdminUserCell.tsx\";\nimport { useConfirmedAction } from \"./useConfirmedAction.tsx\";\n\nexport const AdminAudits = () => {\n const client = useClient<AdminAuditController>();\n const toast = useToast();\n const router = useRouter();\n const { tr } = useI18n();\n\n const [actions, setActions] = useState<AuditActionPair[]>([]);\n\n useEffect(() => {\n let alive = true;\n client\n .getAuditActions()\n .then((rows) => {\n if (!alive) return;\n setActions(rows);\n })\n .catch(() => {});\n return () => {\n alive = false;\n };\n }, [client]);\n\n /**\n * Every filter optional, so this page stays the view that shows everything:\n * an admin who cannot see a row cannot audit it.\n */\n const filterFields = {\n // Here because tenant-scoped events (a project's own activity, read on\n // the project's page) otherwise bury the deployment's security events\n // under their volume.\n layer: {\n schema: z.enum([\"app\", \"scoped\"]),\n label: tr(\"admin.audits.colScope\", { default: \"Scope\" }),\n icon: Layers,\n items: [\n {\n value: \"app\",\n label: tr(\"admin.audits.layerApp\", { default: \"App\" }),\n },\n {\n value: \"scoped\",\n label: tr(\"admin.audits.layerScoped\", { default: \"Scoped\" }),\n },\n ],\n control: {\n clearLabel: tr(\"admin.audits.layerAll\", { default: \"All layers\" }),\n },\n },\n /**\n * When, as a closed range of calendar days.\n *\n * ⚠️ Deliberately NOT a `dateRange` field on `auditQuerySchema`. That\n * schema declares `from`, `to` and `after` with documented semantics\n * (`after` is an exclusive cursor), and two ways to say one thing in a\n * public query schema is a smell. The mapping happens in the fetcher\n * below, which is also what proves a range control can drive an existing\n * from/to endpoint with no API churn at all.\n */\n createdAt: {\n schema: z.dateRange(),\n label: tr(\"admin.audits.colWhen\", { default: \"When\" }),\n placeholder: tr(\"admin.audits.dateAll\", { default: \"Any date\" }),\n },\n status: {\n schema: z.enum([\"ok\", \"failed\"]),\n label: tr(\"admin.audits.colStatus\", { default: \"Status\" }),\n icon: CircleDot,\n items: [\n { value: \"ok\", label: tr(\"admin.audits.ok\", { default: \"OK\" }) },\n {\n value: \"failed\",\n label: tr(\"admin.audits.failed\", { default: \"Failed\" }),\n },\n ],\n control: {\n clearLabel: tr(\"admin.audits.statusAll\", { default: \"All status\" }),\n },\n },\n action: {\n schema: z.string(),\n label: tr(\"admin.audits.colAction\", { default: \"Action\" }),\n icon: Zap,\n // Sorted by type then action on the server, so the list reads grouped:\n // every `parameter:*` row, then every `user:*` row. The label is the\n // column's own `type:action`, and the type rides along as the tag so\n // the group is visible at a glance.\n items: actions.map((pair) => ({\n value: auditActionKey(pair),\n label: auditActionKey(pair),\n tag: pair.type,\n })),\n control: {\n clearLabel: tr(\"admin.audits.actionAll\", { default: \"All actions\" }),\n },\n },\n } satisfies DataTableFilterFields;\n\n const fetcher = useCallback(\n async (params: {\n page: number;\n size: number;\n sort?: string;\n filters?: DataTableFilterValues<typeof filterFields>;\n }) => {\n const f = params.filters;\n // The picked value is a `type:action` key, the shape the Action column\n // prints, and the query takes it apart. `action` alone selected every\n // type's `create` at once (feedback #2049).\n const pair = f?.action\n ? auditActionFromKey(f.action, actions)\n : undefined;\n return client.findAudits({\n query: {\n page: params.page,\n size: params.size,\n sort: params.sort,\n type: pair?.type,\n action: pair?.action,\n layer: f?.layer,\n success: f?.status ? f.status === \"ok\" : undefined,\n // A day resolved to an instant, in UTC. The reader arguably means\n // their local day, but the server is not told their offset and UTC\n // is what makes a shared link select the same rows for everyone. The\n // end runs to the last millisecond so a one-day range selects that\n // day rather than nothing.\n ...(f?.createdAt?.length === 2\n ? {\n from: `${f.createdAt[0]}T00:00:00.000Z`,\n to: `${f.createdAt[1]}T23:59:59.999Z`,\n }\n : {}),\n },\n });\n },\n [client, actions],\n );\n\n const bulkDelete = useConfirmedAction<\n [AuditEntity[], { clearSelection: () => void; refresh: () => void }]\n >(\n {\n confirm: (items) => ({\n title: tr(\"admin.audits.bulkDeleteTitle\", {\n default: \"Delete audit entries\",\n }),\n description: tr(\"admin.audits.bulkDeleteConfirm\", {\n default: `Delete ${items.length} audit record(s)? Audit logs are usually retained for compliance. This cannot be undone.`,\n args: [String(items.length)],\n }),\n destructive: true,\n }),\n handler: async (items, ctx) => {\n if (items.length === 0) return;\n const res = await client.deleteAudits({\n body: { ids: items.map((a) => a.id) },\n });\n toast.success(\n tr(\"admin.audits.bulkDeleted\", {\n default: `${res.deleted.length} audit(s) deleted`,\n args: [String(res.deleted.length)],\n }),\n );\n ctx.clearSelection();\n ctx.refresh();\n },\n },\n [client, toast, tr],\n );\n\n // A resource rendered as an icon + label that links to its admin page.\n const resourceLink = (href: string, icon: React.ReactNode, label: string) => (\n <button\n type=\"button\"\n title={label}\n onClick={() => router.push(href)}\n className=\"hover:text-primary inline-flex items-center gap-1.5 truncate text-left text-xs underline-offset-2 hover:underline\"\n >\n {icon}\n <span className=\"truncate\">{label}</span>\n </button>\n );\n\n return (\n <AdminPage>\n <DataTable<AuditEntity, typeof filterFields>\n className=\"min-h-0 flex-1\"\n persistenceKey=\"admin.audits\"\n fetch={fetcher}\n bulkActions={[\n {\n label: tr(\"admin.audits.bulkDelete\", {\n default: \"Delete selected\",\n }),\n icon: Trash2,\n destructive: true,\n onClick: (items, ctx) => bulkDelete.run(items, ctx),\n },\n ]}\n filters={{ fields: filterFields }}\n columns={{\n createdAt: {\n label: tr(\"admin.audits.colWhen\", { default: \"When\" }),\n sortable: true,\n cell: (a) => (\n <TimeAgo\n value={a.createdAt}\n className=\"text-muted-foreground text-xs\"\n />\n ),\n },\n action: {\n label: tr(\"admin.audits.colAction\", { default: \"Action\" }),\n cell: (a) => (\n <code className=\"text-xs font-medium\">\n {a.type}:{a.action}\n </code>\n ),\n },\n scope: {\n label: tr(\"admin.audits.colScope\", { default: \"Scope\" }),\n // Without this the Scoped filter shows rows with no way to tell\n // which tenant they belong to, which is a filter that narrows to\n // an unreadable list.\n cell: (a) =>\n a.scopeType ? (\n <span className=\"font-mono text-xs\">\n {a.scopeType}:{a.scopeId ?? \"?\"}\n </span>\n ) : (\n <span className=\"text-muted-foreground text-xs\">\n {tr(\"admin.audits.layerApp\", { default: \"App\" })}\n </span>\n ),\n },\n resource: {\n label: tr(\"admin.audits.colResource\", { default: \"Resource\" }),\n cell: (a) => {\n if (a.resourceType === \"parameter\" && a.resourceId) {\n return resourceLink(\n `/admin/parameters?param=${encodeURIComponent(a.resourceId)}`,\n <SlidersHorizontal className=\"size-3.5 shrink-0\" />,\n a.resourceId,\n );\n }\n if (a.resourceType === \"user\" && a.resourceId) {\n return resourceLink(\n `/admin/users/${a.resourceId}`,\n <User className=\"size-3.5 shrink-0\" />,\n a.resourceId,\n );\n }\n return (\n <span className=\"font-mono text-xs\">\n {a.resourceType\n ? `${a.resourceType}:${a.resourceId ?? \"—\"}`\n : \"—\"}\n </span>\n );\n },\n },\n actor: {\n label: tr(\"admin.audits.colActor\", { default: \"Actor\" }),\n /*\n * Audit rows carry a write-time `userEmail` snapshot rather than\n * a live join — the actor's address as it was when the action\n * happened is itself audit data.\n */\n cell: (a) => (\n <AdminUserCell userId={a.userId} fallbackLabel={a.userEmail} />\n ),\n },\n status: {\n label: tr(\"admin.audits.colStatus\", { default: \"Status\" }),\n cell: (a) => (\n <Badge variant={a.success ? \"default\" : \"destructive\"}>\n {a.success\n ? tr(\"admin.audits.ok\", { default: \"OK\" })\n : tr(\"admin.audits.failed\", { default: \"Failed\" })}\n </Badge>\n ),\n },\n }}\n />\n </AdminPage>\n );\n};\n\nexport default AdminAudits;\n\n/**\n * The filter's value for a pair: what the Action column prints.\n */\nexport const auditActionKey = (pair: AuditActionPair): string =>\n `${pair.type}:${pair.action}`;\n\n/**\n * The pair behind a picked key.\n *\n * Looked up in the fetched list rather than split on the colon, so a type\n * that happens to carry one is never cut in the wrong place. The split is\n * only the fallback for a key the list no longer holds (a stale persisted\n * filter), where guessing at the first colon beats sending nothing.\n */\nexport const auditActionFromKey = (\n key: string,\n pairs: AuditActionPair[],\n): AuditActionPair => {\n const known = pairs.find((pair) => auditActionKey(pair) === key);\n if (known) return known;\n const at = key.indexOf(\":\");\n return at < 0\n ? { type: key, action: \"\" }\n : { type: key.slice(0, at), action: key.slice(at + 1) };\n};\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,MAAa,oBAAoB;CAC/B,MAAM,SAAS,UAAgC;CAC/C,MAAM,QAAQ,SAAS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C;CAAE;AAC1D"}
|
|
1
|
+
{"version":3,"file":"AdminAudits.js","names":[],"sources":["../../src/admin/AdminAudits.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport TimeAgo from \"../core/TimeAgo.tsx\";\n\nvoid React;\n\nimport { z } from \"alepha\";\nimport type {\n AdminAuditController,\n AuditActionPair,\n AuditEntity,\n} from \"alepha/api/audits\";\nimport { useClient } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useRouter } from \"alepha/react/router\";\nimport {\n CircleDot,\n Layers,\n SlidersHorizontal,\n Trash2,\n User,\n Zap,\n} from \"lucide-react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\nimport { Badge } from \"../core/Badge.tsx\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { DataTable } from \"../table/DataTable.tsx\";\nimport type {\n DataTableFilterFields,\n DataTableFilterValues,\n} from \"../table/dataTableTypes.ts\";\nimport { AdminPage } from \"./AdminPage.tsx\";\nimport { AdminUserCell } from \"./AdminUserCell.tsx\";\nimport { useConfirmedAction } from \"./useConfirmedAction.tsx\";\n\nexport const AdminAudits = () => {\n const client = useClient<AdminAuditController>();\n const toast = useToast();\n const router = useRouter<any>();\n const { tr } = useI18n();\n\n const [actions, setActions] = useState<AuditActionPair[]>([]);\n\n useEffect(() => {\n let alive = true;\n client\n .getAuditActions()\n .then((rows) => {\n if (!alive) return;\n setActions(rows);\n })\n .catch(() => {});\n return () => {\n alive = false;\n };\n }, [client]);\n\n /**\n * Every filter optional, so this page stays the view that shows everything:\n * an admin who cannot see a row cannot audit it.\n */\n const filterFields = {\n // Here because tenant-scoped events (a project's own activity, read on\n // the project's page) otherwise bury the deployment's security events\n // under their volume.\n layer: {\n schema: z.enum([\"app\", \"scoped\"]),\n label: tr(\"admin.audits.colScope\", { default: \"Scope\" }),\n icon: Layers,\n items: [\n {\n value: \"app\",\n label: tr(\"admin.audits.layerApp\", { default: \"App\" }),\n },\n {\n value: \"scoped\",\n label: tr(\"admin.audits.layerScoped\", { default: \"Scoped\" }),\n },\n ],\n control: {\n clearLabel: tr(\"admin.audits.layerAll\", { default: \"All layers\" }),\n },\n },\n /**\n * When, as a closed range of calendar days.\n *\n * ⚠️ Deliberately NOT a `dateRange` field on `auditQuerySchema`. That\n * schema declares `from`, `to` and `after` with documented semantics\n * (`after` is an exclusive cursor), and two ways to say one thing in a\n * public query schema is a smell. The mapping happens in the fetcher\n * below, which is also what proves a range control can drive an existing\n * from/to endpoint with no API churn at all.\n */\n createdAt: {\n schema: z.dateRange(),\n label: tr(\"admin.audits.colWhen\", { default: \"When\" }),\n placeholder: tr(\"admin.audits.dateAll\", { default: \"Any date\" }),\n },\n status: {\n schema: z.enum([\"ok\", \"failed\"]),\n label: tr(\"admin.audits.colStatus\", { default: \"Status\" }),\n icon: CircleDot,\n items: [\n { value: \"ok\", label: tr(\"admin.audits.ok\", { default: \"OK\" }) },\n {\n value: \"failed\",\n label: tr(\"admin.audits.failed\", { default: \"Failed\" }),\n },\n ],\n control: {\n clearLabel: tr(\"admin.audits.statusAll\", { default: \"All status\" }),\n },\n },\n action: {\n schema: z.string(),\n label: tr(\"admin.audits.colAction\", { default: \"Action\" }),\n icon: Zap,\n // Sorted by type then action on the server, so the list reads grouped:\n // every `parameter:*` row, then every `user:*` row. The label is the\n // column's own `type:action`, and the type rides along as the tag so\n // the group is visible at a glance.\n items: actions.map((pair) => ({\n value: auditActionKey(pair),\n label: auditActionKey(pair),\n tag: pair.type,\n })),\n control: {\n clearLabel: tr(\"admin.audits.actionAll\", { default: \"All actions\" }),\n },\n },\n } satisfies DataTableFilterFields;\n\n const fetcher = useCallback(\n async (params: {\n page: number;\n size: number;\n sort?: string;\n filters?: DataTableFilterValues<typeof filterFields>;\n }) => {\n const f = params.filters;\n // The picked value is a `type:action` key, the shape the Action column\n // prints, and the query takes it apart. `action` alone selected every\n // type's `create` at once (feedback #2049).\n const pair = f?.action\n ? auditActionFromKey(f.action, actions)\n : undefined;\n return client.findAudits({\n query: {\n page: params.page,\n size: params.size,\n sort: params.sort,\n type: pair?.type,\n action: pair?.action,\n layer: f?.layer,\n success: f?.status ? f.status === \"ok\" : undefined,\n // A day resolved to an instant, in UTC. The reader arguably means\n // their local day, but the server is not told their offset and UTC\n // is what makes a shared link select the same rows for everyone. The\n // end runs to the last millisecond so a one-day range selects that\n // day rather than nothing.\n ...(f?.createdAt?.length === 2\n ? {\n from: `${f.createdAt[0]}T00:00:00.000Z`,\n to: `${f.createdAt[1]}T23:59:59.999Z`,\n }\n : {}),\n },\n });\n },\n [client, actions],\n );\n\n const bulkDelete = useConfirmedAction<\n [AuditEntity[], { clearSelection: () => void; refresh: () => void }]\n >(\n {\n confirm: (items) => ({\n title: tr(\"admin.audits.bulkDeleteTitle\", {\n default: \"Delete audit entries\",\n }),\n description: tr(\"admin.audits.bulkDeleteConfirm\", {\n default: `Delete ${items.length} audit record(s)? Audit logs are usually retained for compliance. This cannot be undone.`,\n args: [String(items.length)],\n }),\n destructive: true,\n }),\n handler: async (items, ctx) => {\n if (items.length === 0) return;\n const res = await client.deleteAudits({\n body: { ids: items.map((a) => a.id) },\n });\n toast.success(\n tr(\"admin.audits.bulkDeleted\", {\n default: `${res.deleted.length} audit(s) deleted`,\n args: [String(res.deleted.length)],\n }),\n );\n ctx.clearSelection();\n ctx.refresh();\n },\n },\n [client, toast, tr],\n );\n\n // A resource rendered as an icon + label that links to its admin page.\n const resourceLink = (href: string, icon: React.ReactNode, label: string) => (\n <button\n type=\"button\"\n title={label}\n onClick={() => router.push(href)}\n className=\"hover:text-primary inline-flex items-center gap-1.5 truncate text-left text-xs underline-offset-2 hover:underline\"\n >\n {icon}\n <span className=\"truncate\">{label}</span>\n </button>\n );\n\n return (\n <AdminPage>\n <DataTable<AuditEntity, typeof filterFields>\n className=\"min-h-0 flex-1\"\n persistenceKey=\"admin.audits\"\n fetch={fetcher}\n bulkActions={[\n {\n label: tr(\"admin.audits.bulkDelete\", {\n default: \"Delete selected\",\n }),\n icon: Trash2,\n destructive: true,\n onClick: (items, ctx) => bulkDelete.run(items, ctx),\n },\n ]}\n filters={{ fields: filterFields }}\n columns={{\n createdAt: {\n label: tr(\"admin.audits.colWhen\", { default: \"When\" }),\n sortable: true,\n cell: (a) => (\n <TimeAgo\n value={a.createdAt}\n className=\"text-muted-foreground text-xs\"\n />\n ),\n },\n action: {\n label: tr(\"admin.audits.colAction\", { default: \"Action\" }),\n cell: (a) => (\n <code className=\"text-xs font-medium\">\n {a.type}:{a.action}\n </code>\n ),\n },\n scope: {\n label: tr(\"admin.audits.colScope\", { default: \"Scope\" }),\n // Without this the Scoped filter shows rows with no way to tell\n // which tenant they belong to, which is a filter that narrows to\n // an unreadable list.\n cell: (a) =>\n a.scopeType ? (\n <span className=\"font-mono text-xs\">\n {a.scopeType}:{a.scopeId ?? \"?\"}\n </span>\n ) : (\n <span className=\"text-muted-foreground text-xs\">\n {tr(\"admin.audits.layerApp\", { default: \"App\" })}\n </span>\n ),\n },\n resource: {\n label: tr(\"admin.audits.colResource\", { default: \"Resource\" }),\n cell: (a) => {\n if (a.resourceType === \"parameter\" && a.resourceId) {\n return resourceLink(\n `/admin/parameters?param=${encodeURIComponent(a.resourceId)}`,\n <SlidersHorizontal className=\"size-3.5 shrink-0\" />,\n a.resourceId,\n );\n }\n if (a.resourceType === \"user\" && a.resourceId) {\n return resourceLink(\n `/admin/users/${a.resourceId}`,\n <User className=\"size-3.5 shrink-0\" />,\n a.resourceId,\n );\n }\n return (\n <span className=\"font-mono text-xs\">\n {a.resourceType\n ? `${a.resourceType}:${a.resourceId ?? \"—\"}`\n : \"—\"}\n </span>\n );\n },\n },\n actor: {\n label: tr(\"admin.audits.colActor\", { default: \"Actor\" }),\n /*\n * Audit rows carry a write-time `userEmail` snapshot rather than\n * a live join — the actor's address as it was when the action\n * happened is itself audit data.\n */\n cell: (a) => (\n <AdminUserCell userId={a.userId} fallbackLabel={a.userEmail} />\n ),\n },\n status: {\n label: tr(\"admin.audits.colStatus\", { default: \"Status\" }),\n cell: (a) => (\n <Badge variant={a.success ? \"default\" : \"destructive\"}>\n {a.success\n ? tr(\"admin.audits.ok\", { default: \"OK\" })\n : tr(\"admin.audits.failed\", { default: \"Failed\" })}\n </Badge>\n ),\n },\n }}\n />\n </AdminPage>\n );\n};\n\nexport default AdminAudits;\n\n/**\n * The filter's value for a pair: what the Action column prints.\n */\nexport const auditActionKey = (pair: AuditActionPair): string =>\n `${pair.type}:${pair.action}`;\n\n/**\n * The pair behind a picked key.\n *\n * Looked up in the fetched list rather than split on the colon, so a type\n * that happens to carry one is never cut in the wrong place. The split is\n * only the fallback for a key the list no longer holds (a stale persisted\n * filter), where guessing at the first colon beats sending nothing.\n */\nexport const auditActionFromKey = (\n key: string,\n pairs: AuditActionPair[],\n): AuditActionPair => {\n const known = pairs.find((pair) => auditActionKey(pair) === key);\n if (known) return known;\n const at = key.indexOf(\":\");\n return at < 0\n ? { type: key, action: \"\" }\n : { type: key.slice(0, at), action: key.slice(at + 1) };\n};\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,MAAa,oBAAoB;CAC/B,MAAM,SAAS,UAAgC;CAC/C,MAAM,QAAQ,SAAS;CACvB,MAAM,SAAS,UAAe;CAC9B,MAAM,EAAE,OAAO,QAAQ;CAEvB,MAAM,CAAC,SAAS,cAAc,SAA4B,CAAC,CAAC;CAE5D,gBAAgB;EACd,IAAI,QAAQ;EACZ,OACG,gBAAgB,CAAC,CACjB,MAAM,SAAS;GACd,IAAI,CAAC,OAAO;GACZ,WAAW,IAAI;EACjB,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACjB,aAAa;GACX,QAAQ;EACV;CACF,GAAG,CAAC,MAAM,CAAC;;;;;CAMX,MAAM,eAAe;EAInB,OAAO;GACL,QAAQ,EAAE,KAAK,CAAC,OAAO,QAAQ,CAAC;GAChC,OAAO,GAAG,yBAAyB,EAAE,SAAS,QAAQ,CAAC;GACvD,MAAM;GACN,OAAO,CACL;IACE,OAAO;IACP,OAAO,GAAG,yB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O,MACL,oBAAC,eAAD;KAAe,QAAQ,EAAE;KAAQ,eAAe,EAAE;IAAY,CAAA;GAElE;GACA,QAAQ;IACN,OAAO,GAAG,0BAA0B,EAAE,SAAS,SAAS,CAAC;IACzD,OAAO,MACL,oBAAC,OAAD;KAAO,SAAS,EAAE,UAAU,YAAY;KACrC,UAAA,EAAE,UACC,GAAG,mBAAmB,EAAE,SAAS,KAAK,CAAC,IACvC,GAAG,uBAAuB,EAAE,SAAS,SAAS,CAAC;IAC9C,CAAA;GAEX;EACF;CACD,CAAA,EACQ,CAAA;AAEf;;;;AAOA,MAAa,kBAAkB,SAC7B,GAAG,KAAK,KAAK,GAAG,KAAK;;;;;;;;;AAUvB,MAAa,sBACX,KACA,UACoB;CACpB,MAAM,QAAQ,MAAM,MAAM,SAAS,eAAe,IAAI,MAAM,GAAG;CAC/D,IAAI,OAAO,OAAO;CAClB,MAAM,KAAK,IAAI,QAAQ,GAAG;CAC1B,OAAO,KAAK,IACR;EAAE,MAAM;EAAK,QAAQ;CAAG,IACxB;EAAE,MAAM,IAAI,MAAM,GAAG,EAAE;EAAG,QAAQ,IAAI,MAAM,KAAK,CAAC;CAAE;AAC1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminJobDetail.js","names":[],"sources":["../../src/admin/AdminJobDetail.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { z } from \"alepha\";\nimport type { AdminJobController } from \"alepha/api/jobs\";\nimport { useAction, useClient, useQuery } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useQueryParams, useRouter, useRouterState } from \"alepha/react/router\";\nimport { History, Play } from \"lucide-react\";\nimport { useState } from \"react\";\n\nimport { Button } from \"../core/Button.tsx\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { DetailLayout } from \"../shell/DetailLayout.tsx\";\nimport { useDetailTab } from \"../shell/useDetailTab.tsx\";\nimport { AdminJobDetailAside } from \"./AdminJobDetailAside.tsx\";\nimport { AdminJobDetailExecutions } from \"./AdminJobDetailExecutions.tsx\";\nimport { AdminJobExecutionSheet } from \"./AdminJobExecutionSheet.tsx\";\n\nexport interface AdminJobDetailProps {\n /**\n * Where \"Back\" goes when the job does not exist. Defaults to\n * `/admin/jobs`, the list `AdminRouter` mounts; an application rendering\n * the list somewhere else passes its own path.\n */\n backPath?: string;\n}\n\nconst executionQuerySchema = z.object({\n execution: z.string().optional(),\n});\n\n/**\n * One job, on its own page: what it is in the aside, its executions in a\n * table that sorts, filters, pages and deletes, and one execution's logs,\n * error and payload in a drawer inside the page.\n *\n * The drawer is bound to `?execution=<id>` so a run can be linked. The job\n * comes from the route's `:jobName`; while leaving the page the router state\n * re-renders this component with the next route's params, so nothing is\n * fetched for an empty name.\n */\nexport const AdminJobDetail = (props: AdminJobDetailProps) => {\n const router = useRouter();\n const routerState = useRouterState();\n const jobName = String(\n (routerState.params as { jobName?: string }).jobName ?? \"\",\n );\n const client = useClient<AdminJobController>();\n const { tr } = useI18n();\n const toast = useToast();\n const [tab, setTab] = useDetailTab<\"executions\">(\"executions\");\n const [query, setQuery] = useQueryParams(executionQuerySchema, {\n format: \"querystring\",\n });\n // Bumped after a trigger, so the table reads the run it just made instead\n // of waiting for its next poll.\n const [tableKey, setTableKey] = useState(0);\n const backPath = props.backPath ?? \"/admin/jobs\";\n\n const jobs = useQuery(\n {\n enabled: jobName !== \"\",\n handler: () => client.listJobs(),\n },\n [client, jobName],\n );\n const job = jobs.data?.find((j) => j.name === jobName);\n\n const trigger = useAction(\n {\n handler: async () => {\n await client.triggerJob({ params: { name: jobName }, body: {} });\n toast.success(\n tr(\"admin.jobs.triggered\", {\n default: `Triggered ${jobName}`,\n args: [jobName],\n }),\n );\n setTableKey((k) => k + 1);\n await jobs.refetch();\n },\n },\n [client, jobName, toast, tr],\n );\n\n // A cron only: a pushed job needs a payload this button cannot send.\n const canTrigger = job?.type === \"cron\" && client.triggerJob.can();\n\n return (\n <>\n <DetailLayout\n loading={jobs.loading && !jobs.data}\n notFound={\n job\n ? undefined\n : {\n message: tr(\"admin.jobs.notFound\", {\n default: \"Job not found.\",\n }),\n backLabel: tr(\"admin.jobs.back\", { default: \"Back to jobs\" }),\n onBack: () => void router.push(backPath),\n }\n }\n aside={job ? <AdminJobDetailAside job={job} /> : null}\n tabs={[\n {\n value: \"executions\",\n icon: History,\n label: tr(\"admin.jobs.tabExecutions\", { default: \"Executions\" }),\n },\n ]}\n tab={tab}\n onTabChange={(value) => setTab(value as \"executions\")}\n actions={\n canTrigger ? (\n <Button\n variant=\"outlined\"\n size=\"lg\"\n loading={trigger.loading}\n onClick={() => void trigger.run()}\n >\n <Play className=\"size-4\" />\n {tr(\"admin.jobs.trigger\", { default: \"Trigger now\" })}\n </Button>\n ) : undefined\n }\n >\n {job && (\n <div className=\"flex min-h-0 flex-1 flex-col p-2\">\n <AdminJobDetailExecutions\n key={tableKey}\n jobName={job.name}\n onOpen={(execution) => setQuery({ execution: execution.id })}\n />\n </div>\n )}\n </DetailLayout>\n\n <AdminJobExecutionSheet\n executionId={query.execution || undefined}\n onClose={() => setQuery({ execution: undefined })}\n />\n </>\n );\n};\n\nexport default AdminJobDetail;\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,MAAM,uBAAuB,EAAE,OAAO,EACpC,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,EACjC,CAAC;;;;;;;;;;;AAYD,MAAa,kBAAkB,UAA+B;CAC5D,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"AdminJobDetail.js","names":[],"sources":["../../src/admin/AdminJobDetail.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { z } from \"alepha\";\nimport type { AdminJobController } from \"alepha/api/jobs\";\nimport { useAction, useClient, useQuery } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useQueryParams, useRouter, useRouterState } from \"alepha/react/router\";\nimport { History, Play } from \"lucide-react\";\nimport { useState } from \"react\";\n\nimport { Button } from \"../core/Button.tsx\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { DetailLayout } from \"../shell/DetailLayout.tsx\";\nimport { useDetailTab } from \"../shell/useDetailTab.tsx\";\nimport { AdminJobDetailAside } from \"./AdminJobDetailAside.tsx\";\nimport { AdminJobDetailExecutions } from \"./AdminJobDetailExecutions.tsx\";\nimport { AdminJobExecutionSheet } from \"./AdminJobExecutionSheet.tsx\";\n\nexport interface AdminJobDetailProps {\n /**\n * Where \"Back\" goes when the job does not exist. Defaults to\n * `/admin/jobs`, the list `AdminRouter` mounts; an application rendering\n * the list somewhere else passes its own path.\n */\n backPath?: string;\n}\n\nconst executionQuerySchema = z.object({\n execution: z.string().optional(),\n});\n\n/**\n * One job, on its own page: what it is in the aside, its executions in a\n * table that sorts, filters, pages and deletes, and one execution's logs,\n * error and payload in a drawer inside the page.\n *\n * The drawer is bound to `?execution=<id>` so a run can be linked. The job\n * comes from the route's `:jobName`; while leaving the page the router state\n * re-renders this component with the next route's params, so nothing is\n * fetched for an empty name.\n */\nexport const AdminJobDetail = (props: AdminJobDetailProps) => {\n const router = useRouter<any>();\n const routerState = useRouterState();\n const jobName = String(\n (routerState.params as { jobName?: string }).jobName ?? \"\",\n );\n const client = useClient<AdminJobController>();\n const { tr } = useI18n();\n const toast = useToast();\n const [tab, setTab] = useDetailTab<\"executions\">(\"executions\");\n const [query, setQuery] = useQueryParams(executionQuerySchema, {\n format: \"querystring\",\n });\n // Bumped after a trigger, so the table reads the run it just made instead\n // of waiting for its next poll.\n const [tableKey, setTableKey] = useState(0);\n const backPath = props.backPath ?? \"/admin/jobs\";\n\n const jobs = useQuery(\n {\n enabled: jobName !== \"\",\n handler: () => client.listJobs(),\n },\n [client, jobName],\n );\n const job = jobs.data?.find((j) => j.name === jobName);\n\n const trigger = useAction(\n {\n handler: async () => {\n await client.triggerJob({ params: { name: jobName }, body: {} });\n toast.success(\n tr(\"admin.jobs.triggered\", {\n default: `Triggered ${jobName}`,\n args: [jobName],\n }),\n );\n setTableKey((k) => k + 1);\n await jobs.refetch();\n },\n },\n [client, jobName, toast, tr],\n );\n\n // A cron only: a pushed job needs a payload this button cannot send.\n const canTrigger = job?.type === \"cron\" && client.triggerJob.can();\n\n return (\n <>\n <DetailLayout\n loading={jobs.loading && !jobs.data}\n notFound={\n job\n ? undefined\n : {\n message: tr(\"admin.jobs.notFound\", {\n default: \"Job not found.\",\n }),\n backLabel: tr(\"admin.jobs.back\", { default: \"Back to jobs\" }),\n onBack: () => void router.push(backPath),\n }\n }\n aside={job ? <AdminJobDetailAside job={job} /> : null}\n tabs={[\n {\n value: \"executions\",\n icon: History,\n label: tr(\"admin.jobs.tabExecutions\", { default: \"Executions\" }),\n },\n ]}\n tab={tab}\n onTabChange={(value) => setTab(value as \"executions\")}\n actions={\n canTrigger ? (\n <Button\n variant=\"outlined\"\n size=\"lg\"\n loading={trigger.loading}\n onClick={() => void trigger.run()}\n >\n <Play className=\"size-4\" />\n {tr(\"admin.jobs.trigger\", { default: \"Trigger now\" })}\n </Button>\n ) : undefined\n }\n >\n {job && (\n <div className=\"flex min-h-0 flex-1 flex-col p-2\">\n <AdminJobDetailExecutions\n key={tableKey}\n jobName={job.name}\n onOpen={(execution) => setQuery({ execution: execution.id })}\n />\n </div>\n )}\n </DetailLayout>\n\n <AdminJobExecutionSheet\n executionId={query.execution || undefined}\n onClose={() => setQuery({ execution: undefined })}\n />\n </>\n );\n};\n\nexport default AdminJobDetail;\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,MAAM,uBAAuB,EAAE,OAAO,EACpC,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,EACjC,CAAC;;;;;;;;;;;AAYD,MAAa,kBAAkB,UAA+B;CAC5D,MAAM,SAAS,UAAe;CAC9B,MAAM,cAAc,eAAe;CACnC,MAAM,UAAU,OACb,YAAY,OAAgC,WAAW,EAC1D;CACA,MAAM,SAAS,UAA8B;CAC7C,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,QAAQ,SAAS;CACvB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