@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
|
@@ -21,10 +21,12 @@ Data tables.
|
|
|
21
21
|
`DataTable` is a table wired for server-side pagination, sorting and
|
|
22
22
|
filtering, with row and bulk actions, persisted filters and a static mode for
|
|
23
23
|
local data (`paginateLocal`). Its filters are a record of fields
|
|
24
|
-
(`DataTableFilterFields`) that it draws on its own filter bar
|
|
24
|
+
(`DataTableFilterFields`) that it draws on its own filter bar, and a field
|
|
25
|
+
naming a `column` also behind a funnel in that column's header. Above that
|
|
25
26
|
bar it can hold a collapsible summary (`DataTableSummary`): stat cards
|
|
26
27
|
(`DataTableStatCard`) given or fetched with the table's filters, and any
|
|
27
|
-
node beside them
|
|
28
|
+
node beside them, and above everything a band of `tabs` (`DataTableTab`),
|
|
29
|
+
views of the same page with their counts. A `help` node sits behind a `?` at the end of the
|
|
28
30
|
toolbar's icons.
|
|
29
31
|
`DataTableFilterMenu`, `DataTableFilterDialog` and `DataTableBulkMenu`
|
|
30
32
|
are its parts, and `useTableSelection` its selection state. `PermissionMatrix` is the grid of
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alepha/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Shared Base UI and Tailwind components for Alepha apps. Edited directly; bugfixes propagate via normal dep updates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"alepha",
|
|
@@ -198,39 +198,39 @@
|
|
|
198
198
|
"@fontsource-variable/inter": "^5.3.0",
|
|
199
199
|
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
|
200
200
|
"class-variance-authority": "^0.7.1",
|
|
201
|
-
"cn": "^0.5.
|
|
201
|
+
"cn": "^0.5.2",
|
|
202
202
|
"date-fns": "^4.4.0",
|
|
203
203
|
"graphre": "^0.1.3",
|
|
204
204
|
"hast-util-to-text": "^4.0.3",
|
|
205
205
|
"highlight.js": "^11.12.0",
|
|
206
206
|
"input-otp": "^1.5.0",
|
|
207
207
|
"lowlight": "^3.3.0",
|
|
208
|
-
"lucide-react": "^1.
|
|
208
|
+
"lucide-react": "^1.70.0",
|
|
209
209
|
"react-day-picker": "^10.0.2",
|
|
210
210
|
"react-is": "^19.3.1",
|
|
211
211
|
"react-markdown": "^10.1.0",
|
|
212
|
-
"react-resizable-panels": "^4.
|
|
212
|
+
"react-resizable-panels": "^4.21.0",
|
|
213
213
|
"remark-gfm": "^4.0.1",
|
|
214
214
|
"sonner": "^2.0.8",
|
|
215
215
|
"tw-animate-css": "^1.4.0",
|
|
216
216
|
"unist-util-visit": "^5.2.0"
|
|
217
217
|
},
|
|
218
218
|
"devDependencies": {
|
|
219
|
-
"@playwright/test": "^1.
|
|
219
|
+
"@playwright/test": "^1.65.0",
|
|
220
220
|
"@testing-library/dom": "^10.4.2",
|
|
221
221
|
"@testing-library/react": "^16.3.3",
|
|
222
222
|
"@types/bun": "^1.4.4",
|
|
223
223
|
"@types/node": "^26.6.6",
|
|
224
224
|
"@types/react": "^19.3.0",
|
|
225
|
-
"alepha": "0.
|
|
225
|
+
"alepha": "0.37.0",
|
|
226
226
|
"react": "^19.3.1",
|
|
227
227
|
"react-dom": "^19.3.1",
|
|
228
228
|
"recharts": "^3.10.1",
|
|
229
|
-
"tsdown": "^0.23.
|
|
229
|
+
"tsdown": "^0.23.7",
|
|
230
230
|
"typescript": "^7.0.2"
|
|
231
231
|
},
|
|
232
232
|
"peerDependencies": {
|
|
233
|
-
"alepha": "^0.
|
|
233
|
+
"alepha": "^0.37.0",
|
|
234
234
|
"react": "^19.3.0",
|
|
235
235
|
"react-dom": "^19.3.0",
|
|
236
236
|
"recharts": "^3",
|
|
@@ -77,13 +77,14 @@ export const $pageAccount = <
|
|
|
77
77
|
TConfig extends PageConfigSchema = PageConfigSchema,
|
|
78
78
|
TProps extends object = TPropsDefault,
|
|
79
79
|
TPropsParent extends object = TPropsParentDefault,
|
|
80
|
+
TName extends string = string,
|
|
80
81
|
>(
|
|
81
|
-
options: Omit<PageNavOptions<TConfig, TProps, TPropsParent>, "parent">,
|
|
82
|
-
): PagePrimitive<TConfig, TProps, TPropsParent> => {
|
|
82
|
+
options: Omit<PageNavOptions<TConfig, TProps, TPropsParent, TName>, "parent">,
|
|
83
|
+
): PagePrimitive<TConfig, TProps, TPropsParent, TName> => {
|
|
83
84
|
const { alepha } = $context();
|
|
84
85
|
const account = alepha.inject(AccountRouter);
|
|
85
|
-
return $pageNav<TConfig, TProps, TPropsParent>({
|
|
86
|
+
return $pageNav<TConfig, TProps, TPropsParent, TName>({
|
|
86
87
|
...options,
|
|
87
88
|
parent: account.layout,
|
|
88
|
-
} as PageNavOptions<TConfig, TProps, TPropsParent>);
|
|
89
|
+
} as PageNavOptions<TConfig, TProps, TPropsParent, TName>);
|
|
89
90
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from "alepha";
|
|
2
|
+
import { useForm } from "alepha/react/form";
|
|
3
|
+
import { useI18n } from "alepha/react/i18n";
|
|
4
|
+
import { useVisionMode } from "alepha/react/ui";
|
|
5
|
+
|
|
6
|
+
import { Control } from "../form/Control.tsx";
|
|
7
|
+
import { SettingsRow } from "../settings/SettingsRow.tsx";
|
|
8
|
+
import { SettingsSection } from "../settings/SettingsSection.tsx";
|
|
9
|
+
|
|
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
|
+
export const AccountDisplay = () => {
|
|
22
|
+
const { tr } = useI18n();
|
|
23
|
+
const { vision, setVision } = useVisionMode();
|
|
24
|
+
|
|
25
|
+
const form = useForm({
|
|
26
|
+
schema: z.object({ cvd: z.boolean() }),
|
|
27
|
+
initialValues: { cvd: vision === "cvd" },
|
|
28
|
+
// Saves on change: one switch, with nothing else to submit beside it.
|
|
29
|
+
handler: () => {},
|
|
30
|
+
onChange: (_key, value) => setVision(value ? "cvd" : "normal"),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const label = tr("account.display.vision", { default: "Colour-blind mode" });
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<SettingsSection
|
|
37
|
+
title={tr("account.display.title", { default: "Display" })}
|
|
38
|
+
description={tr("account.display.description", {
|
|
39
|
+
default: "How the interface is drawn for you, on this browser.",
|
|
40
|
+
})}
|
|
41
|
+
>
|
|
42
|
+
<SettingsRow
|
|
43
|
+
label={label}
|
|
44
|
+
description={tr("account.display.visionDescription", {
|
|
45
|
+
default:
|
|
46
|
+
"Status colours that stay apart for red-green colour blindness.",
|
|
47
|
+
})}
|
|
48
|
+
>
|
|
49
|
+
<Control
|
|
50
|
+
switch
|
|
51
|
+
input={form.input.cvd}
|
|
52
|
+
label=""
|
|
53
|
+
inputProps={{ "aria-label": label }}
|
|
54
|
+
/>
|
|
55
|
+
</SettingsRow>
|
|
56
|
+
</SettingsSection>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
} from "alepha/api/users";
|
|
7
7
|
import { updateMyProfileBodySchema } from "alepha/api/users";
|
|
8
8
|
import { useAction, useClient } from "alepha/react";
|
|
9
|
-
import {
|
|
9
|
+
import { useActionForm } from "alepha/react/form";
|
|
10
10
|
import { useI18n } from "alepha/react/i18n";
|
|
11
11
|
import { AtSign, Camera, Trash2, User } from "lucide-react";
|
|
12
12
|
import { type ChangeEvent, useRef, useState } from "react";
|
|
@@ -18,6 +18,7 @@ import { useToast } from "../core/useToast.tsx";
|
|
|
18
18
|
import { AutoForm } from "../form/AutoForm.tsx";
|
|
19
19
|
import { SettingsRow } from "../settings/SettingsRow.tsx";
|
|
20
20
|
import { SettingsSection } from "../settings/SettingsSection.tsx";
|
|
21
|
+
import { AccountDisplay } from "./AccountDisplay.tsx";
|
|
21
22
|
import { AccountPage } from "./AccountPage.tsx";
|
|
22
23
|
|
|
23
24
|
export interface AccountProfileProps {
|
|
@@ -86,32 +87,26 @@ const AccountProfile = (props: AccountProfileProps) => {
|
|
|
86
87
|
* `updateMyProfile` is the same call that saves first and last name, so it
|
|
87
88
|
* exists in every realm and its presence says nothing about usernames.
|
|
88
89
|
*
|
|
89
|
-
* The realm's own `settings.username` is the switch, and
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* could set.
|
|
90
|
+
* The realm's own `settings.username` is the switch, and the row is hidden
|
|
91
|
+
* in the two modes where a person does not choose a username, the same rule
|
|
92
|
+
* `AuthRegister.tsx` applies:
|
|
93
93
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* and Lore (github.com/alepha-dev/lore) runs exactly this mode. Whether
|
|
108
|
-
* editing it there should be
|
|
109
|
-
* possible at all is a real question (a rename desyncs it from the email
|
|
110
|
-
* that produced it, and `updateMyProfile` does not re-run the slugger), but
|
|
111
|
-
* it is a separate one from "this realm has no usernames", and answering it
|
|
112
|
-
* by quietly deleting the field is not the place to start.
|
|
94
|
+
* - `"none"`: the realm has no such thing as a username, so there is nothing
|
|
95
|
+
* to show and nothing the user could set. Without this, `?? ""` seeded an
|
|
96
|
+
* empty string into a column that is `.optional()` but `minLength: 3`,
|
|
97
|
+
* `FormModel` decodes its initial values on construction, and the whole
|
|
98
|
+
* page died at `useForm` with "Too small: expected string to have >=3
|
|
99
|
+
* characters at /username" before anything rendered. `apps/examples/shop`
|
|
100
|
+
* is such a realm, and `"none"` is also the framework default.
|
|
101
|
+
* - `"email"`: `RegistrationService` derives the handle from the address and
|
|
102
|
+
* the person never chose it. Showing it as an editable row (it once did,
|
|
103
|
+
* for Lore's sake) offered a rename that desyncs it from the email that
|
|
104
|
+
* produced it, since `updateMyProfile` does not re-run the slugger, and
|
|
105
|
+
* apps in that mode read the row as a stray field. Hidden, it is
|
|
106
|
+
* also left out of the request, so the derived handle stays as it is.
|
|
113
107
|
*/
|
|
114
|
-
const
|
|
108
|
+
const usernameMode = props.realmConfig?.settings?.username;
|
|
109
|
+
const hasUsername = usernameMode !== "none" && usernameMode !== "email";
|
|
115
110
|
|
|
116
111
|
/**
|
|
117
112
|
* Validated against the server's own body schema, so "3 to 30 characters"
|
|
@@ -131,30 +126,21 @@ const AccountProfile = (props: AccountProfileProps) => {
|
|
|
131
126
|
* users while working for everyone who had set one. `undefined` is what an
|
|
132
127
|
* empty optional field means, and it is what the two name fields would use
|
|
133
128
|
* too if they were not `.nullable()` with a real "clear me" state.
|
|
129
|
+
*
|
|
130
|
+
* Built from the action (`useActionForm`): the values are the body as they
|
|
131
|
+
* are. An emptied name box sends `""`, which `updateMyProfile` stores as
|
|
132
|
+
* "no name" itself (it used to be mapped to `null` here, #Q3225), and an
|
|
133
|
+
* absent `username` stays "leave it alone".
|
|
134
134
|
*/
|
|
135
|
-
const form =
|
|
135
|
+
const form = useActionForm(api.updateMyProfile, {
|
|
136
136
|
initialValues: {
|
|
137
137
|
...(hasUsername ? { username: props.profile?.username } : {}),
|
|
138
138
|
firstName: props.profile?.firstName ?? "",
|
|
139
139
|
lastName: props.profile?.lastName ?? "",
|
|
140
140
|
},
|
|
141
141
|
schema: updateMyProfileBodySchema,
|
|
142
|
-
|
|
143
|
-
setProfile(
|
|
144
|
-
await api.updateMyProfile({
|
|
145
|
-
body: {
|
|
146
|
-
// Empty is "unset", which the API spells `null` — NOT
|
|
147
|
-
// `undefined`, which means "leave this column alone" and made
|
|
148
|
-
// clearing a name a silent no-op that still toasted success.
|
|
149
|
-
firstName: values.firstName || null,
|
|
150
|
-
lastName: values.lastName || null,
|
|
151
|
-
// Absent, not `null`, in a realm without usernames: `null` is the
|
|
152
|
-
// "clear this column" signal the two name fields use, and
|
|
153
|
-
// `username` has no such state — absent is "leave it alone".
|
|
154
|
-
username: values.username,
|
|
155
|
-
},
|
|
156
|
-
}),
|
|
157
|
-
);
|
|
142
|
+
onSuccess: (updated) => {
|
|
143
|
+
setProfile(updated);
|
|
158
144
|
toaster.show(
|
|
159
145
|
tr("account.profile.updated", { default: "Profile updated" }),
|
|
160
146
|
"success",
|
|
@@ -356,6 +342,8 @@ const AccountProfile = (props: AccountProfileProps) => {
|
|
|
356
342
|
</span>
|
|
357
343
|
</SettingsRow>
|
|
358
344
|
</SettingsSection>
|
|
345
|
+
|
|
346
|
+
<AccountDisplay />
|
|
359
347
|
</AccountPage>
|
|
360
348
|
);
|
|
361
349
|
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
+
import { Alepha } from "alepha";
|
|
3
|
+
import type { MyProfile, RealmConfig } from "alepha/api/users";
|
|
4
|
+
import { AlephaLogger } from "alepha/logger";
|
|
5
|
+
import { AlephaContext, AlephaReact } from "alepha/react";
|
|
6
|
+
import { AlephaReactI18n, I18nProvider } from "alepha/react/i18n";
|
|
7
|
+
import { AlephaReactUi, uiAtom } from "alepha/react/ui";
|
|
8
|
+
import { LinkProvider } from "alepha/server/links";
|
|
9
|
+
import { setupJsdomMocks } from "alepha/testing/react";
|
|
10
|
+
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
|
11
|
+
|
|
12
|
+
import AccountProfile from "../AccountProfile.tsx";
|
|
13
|
+
|
|
14
|
+
const profile = {
|
|
15
|
+
id: "00000000-0000-4000-8000-000000000001",
|
|
16
|
+
email: "jane@example.test",
|
|
17
|
+
username: "jane",
|
|
18
|
+
firstName: "Jane",
|
|
19
|
+
lastName: "Doe",
|
|
20
|
+
roles: ["user"],
|
|
21
|
+
} as unknown as MyProfile;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Every action exists and answers nothing: the page only reads the realm.
|
|
25
|
+
*/
|
|
26
|
+
class Links extends LinkProvider {
|
|
27
|
+
override client(): any {
|
|
28
|
+
return new Proxy(
|
|
29
|
+
{},
|
|
30
|
+
{
|
|
31
|
+
get: () => {
|
|
32
|
+
const action: any = async () => undefined;
|
|
33
|
+
action.can = () => true;
|
|
34
|
+
return action;
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The username row follows the realm's `settings.username`: shown where a
|
|
43
|
+
* person chooses one, hidden where the realm has none (`"none"`) or derives
|
|
44
|
+
* it from the address (`"email"`), the same rule as the registration form.
|
|
45
|
+
*/
|
|
46
|
+
describe("AccountProfile", () => {
|
|
47
|
+
let alepha: Alepha | undefined;
|
|
48
|
+
|
|
49
|
+
beforeAll(() => {
|
|
50
|
+
setupJsdomMocks();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
afterEach(async () => {
|
|
54
|
+
await alepha?.stop();
|
|
55
|
+
alepha = undefined;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const mount = async (username?: string) => {
|
|
59
|
+
alepha = Alepha.create()
|
|
60
|
+
.with(AlephaLogger)
|
|
61
|
+
.with({ provide: LinkProvider, use: Links })
|
|
62
|
+
.with(AlephaReact)
|
|
63
|
+
.with(AlephaReactUi)
|
|
64
|
+
.with(AlephaReactI18n);
|
|
65
|
+
await alepha.start();
|
|
66
|
+
await alepha.inject(I18nProvider).setLang("en");
|
|
67
|
+
const realmConfig = (username ? { settings: { username } } : undefined) as
|
|
68
|
+
| RealmConfig
|
|
69
|
+
| undefined;
|
|
70
|
+
render(
|
|
71
|
+
<AlephaContext.Provider value={alepha}>
|
|
72
|
+
<AccountProfile profile={profile} realmConfig={realmConfig} />
|
|
73
|
+
</AlephaContext.Provider>,
|
|
74
|
+
);
|
|
75
|
+
await screen.findByText("First name");
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
it.each(["optional", "required"])(
|
|
79
|
+
"shows the username in a %s realm",
|
|
80
|
+
async (mode) => {
|
|
81
|
+
await mount(mode);
|
|
82
|
+
expect(screen.queryByText("Username")).not.toBeNull();
|
|
83
|
+
},
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
it.each(["none", "email"])(
|
|
87
|
+
"hides the username in a %s realm",
|
|
88
|
+
async (mode) => {
|
|
89
|
+
await mount(mode);
|
|
90
|
+
expect(screen.queryByText("Username")).toBeNull();
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
it("shows the username when no realm is described", async () => {
|
|
95
|
+
await mount();
|
|
96
|
+
expect(screen.queryByText("Username")).not.toBeNull();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Colour-blind mode is set here, not in the account menu: one switch bound
|
|
101
|
+
* to the vision preference, both ways.
|
|
102
|
+
*/
|
|
103
|
+
it("holds the colour-blind switch, bound to the vision preference", async () => {
|
|
104
|
+
await mount();
|
|
105
|
+
|
|
106
|
+
expect(screen.getByText("Display")).toBeTruthy();
|
|
107
|
+
const toggle = screen.getByRole("switch", { name: "Colour-blind mode" });
|
|
108
|
+
expect(toggle.getAttribute("aria-checked")).toBe("false");
|
|
109
|
+
|
|
110
|
+
await act(async () => fireEvent.click(toggle));
|
|
111
|
+
expect(alepha!.store.get(uiAtom).vision).toBe("cvd");
|
|
112
|
+
expect(
|
|
113
|
+
screen
|
|
114
|
+
.getByRole("switch", { name: "Colour-blind mode" })
|
|
115
|
+
.getAttribute("aria-checked"),
|
|
116
|
+
).toBe("true");
|
|
117
|
+
|
|
118
|
+
await act(async () =>
|
|
119
|
+
fireEvent.click(
|
|
120
|
+
screen.getByRole("switch", { name: "Colour-blind mode" }),
|
|
121
|
+
),
|
|
122
|
+
);
|
|
123
|
+
expect(alepha!.store.get(uiAtom).vision).toBe("normal");
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("shows the switch on when the preference already is", async () => {
|
|
127
|
+
await mount();
|
|
128
|
+
await act(async () =>
|
|
129
|
+
alepha!.store.set(uiAtom, {
|
|
130
|
+
...alepha!.store.get(uiAtom),
|
|
131
|
+
vision: "cvd",
|
|
132
|
+
}),
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
expect(
|
|
136
|
+
screen
|
|
137
|
+
.getByRole("switch", { name: "Colour-blind mode" })
|
|
138
|
+
.getAttribute("aria-checked"),
|
|
139
|
+
).toBe("true");
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -13,7 +13,7 @@ const CODES = ["aaaa-1111", "bbbb-2222", "cccc-3333", "dddd-4444"];
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Answers `enrollTotp` and `activateTotp`. Substitution rather than
|
|
16
|
-
* `vi.mock`, per `
|
|
16
|
+
* `vi.mock`, per `AGENTS.md`.
|
|
17
17
|
*/
|
|
18
18
|
class MfaLinkProvider extends LinkProvider {
|
|
19
19
|
override client(): any {
|
package/src/account/index.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
|
|
|
@@ -24,6 +28,7 @@ export {
|
|
|
24
28
|
export { AccountBrand, type AccountBrandProps } from "./AccountBrand.tsx";
|
|
25
29
|
export { AccountLayout } from "./AccountLayout.tsx";
|
|
26
30
|
export { AccountPage, type AccountPageProps } from "./AccountPage.tsx";
|
|
31
|
+
export { AccountDisplay } from "./AccountDisplay.tsx";
|
|
27
32
|
export {
|
|
28
33
|
default as AccountProfile,
|
|
29
34
|
type AccountProfileProps,
|
package/src/admin/$pageAdmin.tsx
CHANGED
|
@@ -73,9 +73,10 @@ export const $pageAdmin = <
|
|
|
73
73
|
TConfig extends PageConfigSchema = PageConfigSchema,
|
|
74
74
|
TProps extends object = TPropsDefault,
|
|
75
75
|
TPropsParent extends object = TPropsParentDefault,
|
|
76
|
+
TName extends string = string,
|
|
76
77
|
>(
|
|
77
|
-
options: Omit<PageNavOptions<TConfig, TProps, TPropsParent>, "parent">,
|
|
78
|
-
): PagePrimitive<TConfig, TProps, TPropsParent> => {
|
|
78
|
+
options: Omit<PageNavOptions<TConfig, TProps, TPropsParent, TName>, "parent">,
|
|
79
|
+
): PagePrimitive<TConfig, TProps, TPropsParent, TName> => {
|
|
79
80
|
const { alepha } = $context();
|
|
80
81
|
const admin = alepha.inject(AdminRouter);
|
|
81
82
|
|
|
@@ -103,10 +104,10 @@ export const $pageAdmin = <
|
|
|
103
104
|
prefixed = () => ({ ...head, title: admin.adminTitle(title) });
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
return $pageNav<TConfig, TProps, TPropsParent>({
|
|
107
|
+
return $pageNav<TConfig, TProps, TPropsParent, TName>({
|
|
107
108
|
...options,
|
|
108
109
|
...(label !== undefined ? { label } : {}),
|
|
109
110
|
...(prefixed !== undefined ? { head: prefixed } : {}),
|
|
110
111
|
parent: admin.layout,
|
|
111
|
-
} as PageNavOptions<TConfig, TProps, TPropsParent>);
|
|
112
|
+
} as PageNavOptions<TConfig, TProps, TPropsParent, TName>);
|
|
112
113
|
};
|
|
@@ -37,7 +37,7 @@ import { useConfirmedAction } from "./useConfirmedAction.tsx";
|
|
|
37
37
|
export const AdminAudits = () => {
|
|
38
38
|
const client = useClient<AdminAuditController>();
|
|
39
39
|
const toast = useToast();
|
|
40
|
-
const router = useRouter();
|
|
40
|
+
const router = useRouter<any>();
|
|
41
41
|
const { tr } = useI18n();
|
|
42
42
|
|
|
43
43
|
const [actions, setActions] = useState<AuditActionPair[]>([]);
|
|
@@ -42,7 +42,7 @@ const executionQuerySchema = z.object({
|
|
|
42
42
|
* fetched for an empty name.
|
|
43
43
|
*/
|
|
44
44
|
export const AdminJobDetail = (props: AdminJobDetailProps) => {
|
|
45
|
-
const router = useRouter();
|
|
45
|
+
const router = useRouter<any>();
|
|
46
46
|
const routerState = useRouterState();
|
|
47
47
|
const jobName = String(
|
|
48
48
|
(routerState.params as { jobName?: string }).jobName ?? "",
|
package/src/admin/AdminJobs.tsx
CHANGED
|
@@ -40,7 +40,7 @@ export const AdminJobs = () => {
|
|
|
40
40
|
const { l, tr } = useI18n();
|
|
41
41
|
const toast = useToast();
|
|
42
42
|
const retention = useJobRetentionLabels();
|
|
43
|
-
const router = useRouter();
|
|
43
|
+
const router = useRouter<any>();
|
|
44
44
|
const [jobs, setJobs] = useState<JobRegistration[]>([]);
|
|
45
45
|
|
|
46
46
|
const load = useAction(
|
|
@@ -56,7 +56,7 @@ export const AdminNotifications = () => {
|
|
|
56
56
|
const client = useClient<AdminNotificationController>();
|
|
57
57
|
const userClient = useClient<AdminUserController>();
|
|
58
58
|
const toast = useToast();
|
|
59
|
-
const router = useRouter();
|
|
59
|
+
const router = useRouter<any>();
|
|
60
60
|
const { tr } = useI18n();
|
|
61
61
|
const statusLabels = useNotificationStatusLabels();
|
|
62
62
|
const [selected, setSelected] = useState<{ id: string; tab: string } | null>(
|
|
@@ -94,7 +94,7 @@ export const resolveUserDetailId = (params: {
|
|
|
94
94
|
* one; they render what they are given and hold no fetching of their own.
|
|
95
95
|
*/
|
|
96
96
|
export const AdminUserDetail = (props: AdminUserDetailProps) => {
|
|
97
|
-
const router = useRouter();
|
|
97
|
+
const router = useRouter<any>();
|
|
98
98
|
const routerState = useRouterState();
|
|
99
99
|
const userId = resolveUserDetailId(routerState.params);
|
|
100
100
|
const userClient = useClient<AdminUserController>();
|
package/src/admin/AdminUsers.tsx
CHANGED
|
@@ -74,7 +74,7 @@ export const AdminUsers = (props: AdminUsersProps) => {
|
|
|
74
74
|
const client = useClient<AdminUserController>();
|
|
75
75
|
const toast = useToast();
|
|
76
76
|
const { user: currentUser } = useAuth();
|
|
77
|
-
const router = useRouter();
|
|
77
|
+
const router = useRouter<any>();
|
|
78
78
|
const { l, tr } = useI18n();
|
|
79
79
|
const dialog = useDialog();
|
|
80
80
|
|
|
@@ -51,7 +51,7 @@ export interface ParameterHistoryItemProps {
|
|
|
51
51
|
*/
|
|
52
52
|
export const ParameterHistoryItem = (props: ParameterHistoryItemProps) => {
|
|
53
53
|
const { l, tr } = useI18n();
|
|
54
|
-
const router = useRouter();
|
|
54
|
+
const router = useRouter<any>();
|
|
55
55
|
const v = props.version;
|
|
56
56
|
const [open, setOpen] = useState(false);
|
|
57
57
|
const [jsonOpen, setJsonOpen] = useState(false);
|
|
@@ -55,6 +55,11 @@ describe("AdminFilesUsageCard", () => {
|
|
|
55
55
|
const segment = (view: ReturnType<typeof render>, bucket: string) =>
|
|
56
56
|
view.container.querySelector<HTMLElement>(`[data-bucket="${bucket}"]`);
|
|
57
57
|
|
|
58
|
+
// A segment's width in percent. jsdom, like a browser, serializes a CSS
|
|
59
|
+
// percentage to six significant digits, so it is compared as a number.
|
|
60
|
+
const width = (view: ReturnType<typeof render>, bucket: string) =>
|
|
61
|
+
Number.parseFloat(segment(view, bucket)?.style.width ?? "0");
|
|
62
|
+
|
|
58
63
|
it("says what is used out of the quota, and what is free", async () => {
|
|
59
64
|
const view = await mount(stats(10 * GB));
|
|
60
65
|
const text = view.container.textContent;
|
|
@@ -77,8 +82,9 @@ describe("AdminFilesUsageCard", () => {
|
|
|
77
82
|
it("draws each bucket as its share of the quota", async () => {
|
|
78
83
|
const view = await mount(stats(10 * GB));
|
|
79
84
|
|
|
80
|
-
expect(
|
|
81
|
-
|
|
85
|
+
expect(width(view, "artifacts")).toBeCloseTo(
|
|
86
|
+
((150 * MB) / (10 * GB)) * 100,
|
|
87
|
+
3,
|
|
82
88
|
);
|
|
83
89
|
});
|
|
84
90
|
|
|
@@ -90,8 +96,9 @@ describe("AdminFilesUsageCard", () => {
|
|
|
90
96
|
expect(text).toContain("used");
|
|
91
97
|
expect(text).toContain("14 file(s), no quota");
|
|
92
98
|
expect(text).not.toContain("free");
|
|
93
|
-
expect(
|
|
94
|
-
|
|
99
|
+
expect(width(view, "artifacts")).toBeCloseTo(
|
|
100
|
+
((150 * MB) / (200 * MB + 1024)) * 100,
|
|
101
|
+
3,
|
|
95
102
|
);
|
|
96
103
|
});
|
|
97
104
|
|
|
@@ -151,8 +158,9 @@ describe("AdminFilesUsageCard", () => {
|
|
|
151
158
|
const view = await mount(stats(10 * GB));
|
|
152
159
|
|
|
153
160
|
expect(quotaOption().getAttribute("aria-checked")).toBe("true");
|
|
154
|
-
expect(
|
|
155
|
-
|
|
161
|
+
expect(width(view, "artifacts")).toBeCloseTo(
|
|
162
|
+
((150 * MB) / (10 * GB)) * 100,
|
|
163
|
+
3,
|
|
156
164
|
);
|
|
157
165
|
expect(screen.queryAllByTestId("usage-share")).toEqual([]);
|
|
158
166
|
});
|
|
@@ -164,10 +172,10 @@ describe("AdminFilesUsageCard", () => {
|
|
|
164
172
|
|
|
165
173
|
const total = 150 * MB + 50 * MB + 1024;
|
|
166
174
|
const widths = ["artifacts", "backups", "seeds"].map((bucket) =>
|
|
167
|
-
|
|
175
|
+
width(view, bucket),
|
|
168
176
|
);
|
|
169
|
-
expect(widths[0]).toBeCloseTo(((150 * MB) / total) * 100,
|
|
170
|
-
expect(widths.reduce((sum,
|
|
177
|
+
expect(widths[0]).toBeCloseTo(((150 * MB) / total) * 100, 3);
|
|
178
|
+
expect(widths.reduce((sum, w) => sum + w, 0)).toBeCloseTo(100, 3);
|
|
171
179
|
expect(
|
|
172
180
|
screen.getAllByTestId("usage-share").map((node) => node.textContent),
|
|
173
181
|
).toEqual(["75%", "25%", "0%"]);
|