@alepha/ui 0.28.0 → 0.29.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/README.md +31 -2
- package/dist/components/account/account-connections.d.ts.map +1 -1
- package/dist/components/account/account-connections.js +4 -1
- package/dist/components/account/account-connections.js.map +1 -1
- package/dist/components/account/account-delete-dialog.d.ts.map +1 -1
- package/dist/components/account/account-delete-dialog.js +12 -15
- package/dist/components/account/account-delete-dialog.js.map +1 -1
- package/dist/components/account/account-keys.d.ts.map +1 -1
- package/dist/components/account/account-keys.js +22 -28
- package/dist/components/account/account-keys.js.map +1 -1
- package/dist/components/account/account-mfa-dialog.js +1 -4
- package/dist/components/account/account-mfa-dialog.js.map +1 -1
- package/dist/components/account/account-password-dialog.d.ts.map +1 -1
- package/dist/components/account/account-password-dialog.js +11 -14
- package/dist/components/account/account-password-dialog.js.map +1 -1
- package/dist/components/account/account-profile.js +3 -2
- package/dist/components/account/account-profile.js.map +1 -1
- package/dist/components/account/account-router-options.d.ts +38 -0
- package/dist/components/account/account-router-options.d.ts.map +1 -1
- package/dist/components/account/account-router-options.js.map +1 -1
- package/dist/components/account/account-router-page.d.ts +11 -1
- package/dist/components/account/account-router-page.d.ts.map +1 -1
- package/dist/components/account/account-router-page.js +11 -1
- package/dist/components/account/account-router-page.js.map +1 -1
- package/dist/components/account/account-router.d.ts +11 -0
- package/dist/components/account/account-router.d.ts.map +1 -1
- package/dist/components/account/account-router.js +16 -5
- package/dist/components/account/account-router.js.map +1 -1
- package/dist/components/admin/admin-audits.d.ts.map +1 -1
- package/dist/components/admin/admin-audits.js +91 -34
- package/dist/components/admin/admin-audits.js.map +1 -1
- package/dist/components/admin/admin-files.d.ts.map +1 -1
- package/dist/components/admin/admin-files.js +6 -17
- package/dist/components/admin/admin-files.js.map +1 -1
- package/dist/components/admin/admin-jobs-executions-panel.d.ts.map +1 -1
- package/dist/components/admin/admin-jobs-executions-panel.js +39 -8
- package/dist/components/admin/admin-jobs-executions-panel.js.map +1 -1
- package/dist/components/admin/admin-jobs-payload-dialog.d.ts +19 -0
- package/dist/components/admin/admin-jobs-payload-dialog.d.ts.map +1 -0
- package/dist/components/admin/admin-jobs-payload-dialog.js +33 -0
- package/dist/components/admin/admin-jobs-payload-dialog.js.map +1 -0
- package/dist/components/admin/admin-keys.d.ts.map +1 -1
- package/dist/components/admin/admin-keys.js +5 -4
- package/dist/components/admin/admin-keys.js.map +1 -1
- package/dist/components/admin/admin-notifications-channel-label.d.ts +14 -0
- package/dist/components/admin/admin-notifications-channel-label.d.ts.map +1 -0
- package/dist/components/admin/admin-notifications-channel-label.js +26 -0
- package/dist/components/admin/admin-notifications-channel-label.js.map +1 -0
- package/dist/components/admin/admin-notifications-preview-body.d.ts.map +1 -1
- package/dist/components/admin/admin-notifications-preview-body.js +23 -13
- package/dist/components/admin/admin-notifications-preview-body.js.map +1 -1
- package/dist/components/admin/admin-notifications.d.ts.map +1 -1
- package/dist/components/admin/admin-notifications.js +11 -12
- package/dist/components/admin/admin-notifications.js.map +1 -1
- package/dist/components/admin/admin-payments.d.ts.map +1 -1
- package/dist/components/admin/admin-payments.js +9 -7
- package/dist/components/admin/admin-payments.js.map +1 -1
- package/dist/components/admin/admin-router-options.d.ts +12 -0
- package/dist/components/admin/admin-router-options.d.ts.map +1 -1
- package/dist/components/admin/admin-router-options.js.map +1 -1
- package/dist/components/admin/admin-router.d.ts +5 -8
- package/dist/components/admin/admin-router.d.ts.map +1 -1
- package/dist/components/admin/admin-router.js +6 -29
- package/dist/components/admin/admin-router.js.map +1 -1
- package/dist/components/admin/admin-sessions.d.ts.map +1 -1
- package/dist/components/admin/admin-sessions.js +9 -7
- package/dist/components/admin/admin-sessions.js.map +1 -1
- package/dist/components/admin/admin-user-detail-audits-tab.d.ts.map +1 -1
- package/dist/components/admin/admin-user-detail-audits-tab.js +5 -4
- package/dist/components/admin/admin-user-detail-audits-tab.js.map +1 -1
- package/dist/components/admin/admin-user-detail-sessions-tab.d.ts.map +1 -1
- package/dist/components/admin/admin-user-detail-sessions-tab.js +7 -5
- package/dist/components/admin/admin-user-detail-sessions-tab.js.map +1 -1
- package/dist/components/admin/admin-user-detail.js +3 -2
- package/dist/components/admin/admin-user-detail.js.map +1 -1
- package/dist/components/admin/admin-users-roles-picker.d.ts.map +1 -1
- package/dist/components/admin/admin-users-roles-picker.js.map +1 -1
- package/dist/components/admin/admin-users.d.ts.map +1 -1
- package/dist/components/admin/admin-users.js +6 -4
- package/dist/components/admin/admin-users.js.map +1 -1
- package/dist/components/admin/analytics/AnalyticsChartBars.js +2 -1
- package/dist/components/admin/analytics/AnalyticsChartBars.js.map +1 -1
- package/dist/components/admin/parameter-history-item.d.ts.map +1 -1
- package/dist/components/admin/parameter-history-item.js +3 -2
- package/dist/components/admin/parameter-history-item.js.map +1 -1
- package/dist/components/alepha-table/alepha-table-bulk-menu.js +2 -1
- package/dist/components/alepha-table/alepha-table-bulk-menu.js.map +1 -1
- package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts +60 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.js +88 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.js.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.d.ts +35 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.d.ts.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.js +54 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.js.map +1 -0
- package/dist/components/alepha-table/alepha-table.d.ts +188 -3
- package/dist/components/alepha-table/alepha-table.d.ts.map +1 -1
- package/dist/components/alepha-table/alepha-table.js +551 -162
- package/dist/components/alepha-table/alepha-table.js.map +1 -1
- package/dist/components/alepha-table/query-filters.d.ts +73 -0
- package/dist/components/alepha-table/query-filters.d.ts.map +1 -0
- package/dist/components/alepha-table/query-filters.js +118 -0
- package/dist/components/alepha-table/query-filters.js.map +1 -0
- package/dist/components/app-actions/app-actions.d.ts +21 -0
- package/dist/components/app-actions/app-actions.d.ts.map +1 -1
- package/dist/components/app-actions/app-actions.js +11 -5
- package/dist/components/app-actions/app-actions.js.map +1 -1
- package/dist/components/app-shell/app-shell.d.ts +45 -0
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/app-shell.js +119 -16
- package/dist/components/app-shell/app-shell.js.map +1 -1
- package/dist/components/auth/auth-register.js +31 -30
- package/dist/components/auth/auth-register.js.map +1 -1
- package/dist/components/auto-form/auto-form.d.ts.map +1 -1
- package/dist/components/auto-form/auto-form.js +68 -30
- package/dist/components/auto-form/auto-form.js.map +1 -1
- package/dist/components/button-dark/button-dark.d.ts.map +1 -1
- package/dist/components/button-dark/button-dark.js +39 -8
- package/dist/components/button-dark/button-dark.js.map +1 -1
- package/dist/components/button-inbox/button-inbox.d.ts +66 -0
- package/dist/components/button-inbox/button-inbox.d.ts.map +1 -0
- package/dist/components/button-inbox/button-inbox.js +167 -0
- package/dist/components/button-inbox/button-inbox.js.map +1 -0
- package/dist/components/button-inbox/inbox-unread-atom.d.ts +22 -0
- package/dist/components/button-inbox/inbox-unread-atom.d.ts.map +1 -0
- package/dist/components/button-inbox/inbox-unread-atom.js +29 -0
- package/dist/components/button-inbox/inbox-unread-atom.js.map +1 -0
- package/dist/components/button-theme/button-theme.d.ts +4 -3
- package/dist/components/button-theme/button-theme.d.ts.map +1 -1
- package/dist/components/button-theme/button-theme.js +8 -25
- package/dist/components/button-theme/button-theme.js.map +1 -1
- package/dist/components/button-user/button-user.d.ts +19 -0
- package/dist/components/button-user/button-user.d.ts.map +1 -1
- package/dist/components/button-user/button-user.js +1 -1
- package/dist/components/button-user/button-user.js.map +1 -1
- package/dist/components/control/control.d.ts +51 -0
- package/dist/components/control/control.d.ts.map +1 -1
- package/dist/components/control/control.js +49 -5
- package/dist/components/control/control.js.map +1 -1
- package/dist/components/control-array/control-array.js +2 -1
- package/dist/components/control-array/control-array.js.map +1 -1
- package/dist/components/control-date/control-date.d.ts +27 -0
- package/dist/components/control-date/control-date.d.ts.map +1 -1
- package/dist/components/control-date/control-date.js +15 -19
- package/dist/components/control-date/control-date.js.map +1 -1
- package/dist/components/control-date/date-only.d.ts +18 -0
- package/dist/components/control-date/date-only.d.ts.map +1 -0
- package/dist/components/control-date/date-only.js +29 -0
- package/dist/components/control-date/date-only.js.map +1 -0
- package/dist/components/control-date-range/control-date-range.d.ts +56 -0
- package/dist/components/control-date-range/control-date-range.d.ts.map +1 -0
- package/dist/components/control-date-range/control-date-range.js +148 -0
- package/dist/components/control-date-range/control-date-range.js.map +1 -0
- package/dist/components/control-object/control-object.js +2 -1
- package/dist/components/control-object/control-object.js.map +1 -1
- package/dist/components/control-select/control-select.d.ts.map +1 -1
- package/dist/components/control-select/control-select.js +177 -37
- package/dist/components/control-select/control-select.js.map +1 -1
- package/dist/components/control-upload/control-upload.d.ts.map +1 -1
- package/dist/components/control-upload/control-upload.js +1 -11
- package/dist/components/control-upload/control-upload.js.map +1 -1
- package/dist/components/detail/detail-aside.d.ts.map +1 -1
- package/dist/components/detail/detail-aside.js +4 -3
- package/dist/components/detail/detail-aside.js.map +1 -1
- package/dist/components/file-image/file-image.js +2 -1
- package/dist/components/file-image/file-image.js.map +1 -1
- package/dist/components/markdown-view/SpoilerSpan.d.ts +28 -0
- package/dist/components/markdown-view/SpoilerSpan.d.ts.map +1 -0
- package/dist/components/markdown-view/SpoilerSpan.js +53 -0
- package/dist/components/markdown-view/SpoilerSpan.js.map +1 -0
- package/dist/components/markdown-view/diagram/layoutSequence.js +13 -23
- package/dist/components/markdown-view/diagram/layoutSequence.js.map +1 -1
- package/dist/components/markdown-view/diagram/textMetrics.js +2 -2
- package/dist/components/markdown-view/diagram/textMetrics.js.map +1 -1
- package/dist/components/markdown-view/markdown-view.css +44 -0
- package/dist/components/markdown-view/markdown-view.d.ts +12 -0
- package/dist/components/markdown-view/markdown-view.d.ts.map +1 -1
- package/dist/components/markdown-view/markdown-view.js +22 -1
- package/dist/components/markdown-view/markdown-view.js.map +1 -1
- package/dist/components/markdown-view/remarkSpoiler.d.ts +17 -0
- package/dist/components/markdown-view/remarkSpoiler.d.ts.map +1 -0
- package/dist/components/markdown-view/remarkSpoiler.js +117 -0
- package/dist/components/markdown-view/remarkSpoiler.js.map +1 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts +34 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts.map +1 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.js +109 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.js.map +1 -0
- package/dist/components/permission-matrix/permission-matrix.d.ts +145 -0
- package/dist/components/permission-matrix/permission-matrix.d.ts.map +1 -0
- package/dist/components/permission-matrix/permission-matrix.js +113 -0
- package/dist/components/permission-matrix/permission-matrix.js.map +1 -0
- package/dist/components/plate-layout/plate-layout.d.ts +5 -0
- package/dist/components/plate-layout/plate-layout.d.ts.map +1 -1
- package/dist/components/plate-layout/plate-layout.js +2 -1
- package/dist/components/plate-layout/plate-layout.js.map +1 -1
- package/dist/components/plate-layout/plate-tab-bar.d.ts +10 -0
- package/dist/components/plate-layout/plate-tab-bar.d.ts.map +1 -1
- package/dist/components/plate-layout/plate-tab-bar.js +1 -1
- package/dist/components/plate-layout/plate-tab-bar.js.map +1 -1
- package/dist/components/settings/settings-nav.js +2 -1
- package/dist/components/settings/settings-nav.js.map +1 -1
- package/dist/components/time-ago/time-ago.d.ts +57 -0
- package/dist/components/time-ago/time-ago.d.ts.map +1 -0
- package/dist/components/time-ago/time-ago.js +60 -0
- package/dist/components/time-ago/time-ago.js.map +1 -0
- package/dist/components/tree-view/tree-model.d.ts +128 -0
- package/dist/components/tree-view/tree-model.d.ts.map +1 -0
- package/dist/components/tree-view/tree-model.js +226 -0
- package/dist/components/tree-view/tree-model.js.map +1 -0
- package/dist/components/tree-view/tree-view-rename-input.d.ts +31 -0
- package/dist/components/tree-view/tree-view-rename-input.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-rename-input.js +68 -0
- package/dist/components/tree-view/tree-view-rename-input.js.map +1 -0
- package/dist/components/tree-view/tree-view-resizer.d.ts +38 -0
- package/dist/components/tree-view/tree-view-resizer.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-resizer.js +73 -0
- package/dist/components/tree-view/tree-view-resizer.js.map +1 -0
- package/dist/components/tree-view/tree-view-row.d.ts +177 -0
- package/dist/components/tree-view/tree-view-row.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-row.js +241 -0
- package/dist/components/tree-view/tree-view-row.js.map +1 -0
- package/dist/components/tree-view/tree-view.d.ts +186 -0
- package/dist/components/tree-view/tree-view.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view.js +112 -0
- package/dist/components/tree-view/tree-view.js.map +1 -0
- package/dist/components/tree-view/use-tree-state.d.ts +79 -0
- package/dist/components/tree-view/use-tree-state.d.ts.map +1 -0
- package/dist/components/tree-view/use-tree-state.js +93 -0
- package/dist/components/tree-view/use-tree-state.js.map +1 -0
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/select.d.ts +7 -0
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +7 -0
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/lib/i18n-fr.d.ts.map +1 -1
- package/dist/lib/i18n-fr.js +31 -47
- package/dist/lib/i18n-fr.js.map +1 -1
- package/dist/lib/utils.d.ts +22 -2
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +29 -5
- package/dist/lib/utils.js.map +1 -1
- package/dist/styles.css +255 -0
- package/package.json +13 -14
- package/src/components/account/__tests__/account-router.spec.ts +95 -0
- package/src/components/account/account-connections.tsx +14 -1
- package/src/components/account/account-delete-dialog.tsx +3 -2
- package/src/components/account/account-keys.tsx +11 -4
- package/src/components/account/account-mfa-dialog.tsx +1 -1
- package/src/components/account/account-password-dialog.tsx +3 -2
- package/src/components/account/account-profile.tsx +1 -1
- package/src/components/account/account-router-options.tsx +45 -0
- package/src/components/account/account-router-page.tsx +11 -1
- package/src/components/account/account-router.tsx +23 -6
- package/src/components/admin/__tests__/admin-jobs-payload-dialog.browser.spec.tsx +68 -0
- package/src/components/admin/__tests__/admin-notifications-preview-body.browser.spec.tsx +20 -4
- package/src/components/admin/__tests__/admin-status-labels.browser.spec.tsx +0 -31
- package/src/components/admin/admin-audits.tsx +99 -5
- package/src/components/admin/admin-files.tsx +7 -16
- package/src/components/admin/admin-jobs-executions-panel.tsx +152 -114
- package/src/components/admin/admin-jobs-payload-dialog.tsx +57 -0
- package/src/components/admin/admin-keys.tsx +7 -4
- package/src/components/admin/admin-notifications-channel-label.ts +18 -0
- package/src/components/admin/admin-notifications-preview-body.tsx +7 -2
- package/src/components/admin/admin-notifications.tsx +19 -8
- package/src/components/admin/admin-payments.tsx +7 -4
- package/src/components/admin/admin-router-options.tsx +12 -0
- package/src/components/admin/admin-router.tsx +5 -27
- package/src/components/admin/admin-sessions.tsx +10 -6
- package/src/components/admin/admin-user-detail-audits-tab.tsx +7 -4
- package/src/components/admin/admin-user-detail-sessions-tab.tsx +7 -4
- package/src/components/admin/admin-users-roles-picker.tsx +4 -0
- package/src/components/admin/admin-users.tsx +6 -3
- package/src/components/admin/parameter-history-item.tsx +4 -2
- package/src/components/alepha-table/__tests__/alepha-table-default-hidden.browser.spec.tsx +108 -0
- package/src/components/alepha-table/__tests__/alepha-table-empty-state.browser.spec.tsx +233 -0
- package/src/components/alepha-table/__tests__/alepha-table-persist-facets.browser.spec.tsx +177 -0
- package/src/components/alepha-table/__tests__/alepha-table-persisted-filters.browser.spec.tsx +182 -0
- package/src/components/alepha-table/__tests__/alepha-table-query-seed.browser.spec.tsx +170 -0
- package/src/components/alepha-table/__tests__/alepha-table-row-action-checked.browser.spec.tsx +210 -0
- package/src/components/alepha-table/__tests__/alepha-table-row-action-group.browser.spec.tsx +202 -0
- package/src/components/alepha-table/__tests__/alepha-table-scope.browser.spec.tsx +161 -0
- package/src/components/alepha-table/__tests__/alepha-table-share-filters.browser.spec.tsx +309 -0
- package/src/components/alepha-table/__tests__/query-filters.spec.ts +212 -0
- package/src/components/alepha-table/alepha-table-filter-dialog.tsx +162 -0
- package/src/components/alepha-table/alepha-table-filter-menu.tsx +77 -0
- package/src/components/alepha-table/alepha-table.tsx +1113 -207
- package/src/components/alepha-table/query-filters.ts +159 -0
- package/src/components/app-actions/app-actions.tsx +32 -3
- package/src/components/app-shell/__tests__/sidebar-nav-accordion.browser.spec.tsx +163 -0
- package/src/components/app-shell/app-shell.tsx +255 -12
- package/src/components/auto-form/__tests__/auto-form-settings-card.browser.spec.tsx +1 -1
- package/src/components/auto-form/auto-form.tsx +98 -30
- package/src/components/button-dark/button-dark.tsx +47 -8
- package/src/components/button-inbox/__tests__/button-inbox.browser.spec.tsx +247 -0
- package/src/components/button-inbox/button-inbox.tsx +303 -0
- package/src/components/button-inbox/inbox-unread-atom.ts +27 -0
- package/src/components/button-theme/button-theme.tsx +16 -29
- package/src/components/button-user/__tests__/button-user-avatar.browser.spec.tsx +88 -0
- package/src/components/button-user/button-user.tsx +24 -1
- package/src/components/control/__tests__/control-date-range.browser.spec.tsx +177 -0
- package/src/components/control/control.tsx +119 -12
- package/src/components/control-date/control-date.tsx +117 -22
- package/src/components/control-date/date-only.ts +26 -0
- package/src/components/control-date-range/control-date-range.tsx +250 -0
- package/src/components/control-select/__tests__/control-select-clear-label.browser.spec.tsx +129 -15
- package/src/components/control-select/__tests__/control-select-deselect.browser.spec.tsx +27 -6
- package/src/components/control-select/__tests__/control-select-multi.browser.spec.tsx +204 -1
- package/src/components/control-select/__tests__/control-select-size-minimal.browser.spec.tsx +77 -1
- package/src/components/control-select/control-select.tsx +317 -83
- package/src/components/control-upload/control-upload.tsx +1 -10
- package/src/components/detail/detail-aside.tsx +30 -6
- package/src/components/markdown-view/SpoilerSpan.tsx +66 -0
- package/src/components/markdown-view/__tests__/markdown-view-spoiler.browser.spec.tsx +165 -0
- package/src/components/markdown-view/diagram/textMetrics.spec.ts +1 -1
- package/src/components/markdown-view/diagram/textMetrics.ts +2 -2
- package/src/components/markdown-view/markdown-view.css +44 -0
- package/src/components/markdown-view/markdown-view.tsx +37 -1
- package/src/components/markdown-view/remarkSpoiler.ts +150 -0
- package/src/components/permission-matrix/__tests__/permission-matrix.browser.spec.tsx +237 -0
- package/src/components/permission-matrix/permission-matrix-group-rows.tsx +240 -0
- package/src/components/permission-matrix/permission-matrix.tsx +286 -0
- package/src/components/plate-layout/__tests__/plate-layout.browser.spec.tsx +22 -0
- package/src/components/plate-layout/plate-layout.tsx +6 -0
- package/src/components/plate-layout/plate-tab-bar.tsx +27 -1
- package/src/components/time-ago/time-ago.browser.spec.tsx +110 -0
- package/src/components/time-ago/time-ago.tsx +80 -0
- package/src/components/tree-view/__tests__/tree-model.spec.ts +441 -0
- package/src/components/tree-view/__tests__/tree-view-drag.browser.spec.tsx +295 -0
- package/src/components/tree-view/__tests__/tree-view-rename.browser.spec.tsx +278 -0
- package/src/components/tree-view/__tests__/tree-view-resizer.browser.spec.tsx +112 -0
- package/src/components/tree-view/__tests__/tree-view.browser.spec.tsx +260 -0
- package/src/components/tree-view/__tests__/use-tree-state.browser.spec.tsx +238 -0
- package/src/components/tree-view/tree-model.ts +369 -0
- package/src/components/tree-view/tree-view-rename-input.tsx +95 -0
- package/src/components/tree-view/tree-view-resizer.tsx +83 -0
- package/src/components/tree-view/tree-view-row.tsx +414 -0
- package/src/components/tree-view/tree-view.tsx +300 -0
- package/src/components/tree-view/use-tree-state.ts +184 -0
- package/src/components/ui/button.tsx +79 -1
- package/src/components/ui/dropdown-menu.tsx +1 -1
- package/src/components/ui/select.tsx +7 -0
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/tooltip.tsx +1 -1
- package/src/lib/i18n-fr.ts +34 -51
- package/src/lib/utils.ts +32 -4
- package/src/styles.css +255 -0
- package/dist/components/admin/admin-workflows-execution-sheet.d.ts +0 -11
- package/dist/components/admin/admin-workflows-execution-sheet.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-execution-sheet.js +0 -190
- package/dist/components/admin/admin-workflows-execution-sheet.js.map +0 -1
- package/dist/components/admin/admin-workflows-executions-panel.d.ts +0 -9
- package/dist/components/admin/admin-workflows-executions-panel.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-executions-panel.js +0 -121
- package/dist/components/admin/admin-workflows-executions-panel.js.map +0 -1
- package/dist/components/admin/admin-workflows-status-badge.d.ts +0 -12
- package/dist/components/admin/admin-workflows-status-badge.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-status-badge.js +0 -30
- package/dist/components/admin/admin-workflows-status-badge.js.map +0 -1
- package/dist/components/admin/admin-workflows-status-labels.d.ts +0 -19
- package/dist/components/admin/admin-workflows-status-labels.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-status-labels.js +0 -48
- package/dist/components/admin/admin-workflows-status-labels.js.map +0 -1
- package/dist/components/admin/admin-workflows.d.ts +0 -4
- package/dist/components/admin/admin-workflows.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows.js +0 -145
- package/dist/components/admin/admin-workflows.js.map +0 -1
- package/src/components/admin/admin-workflows-execution-sheet.tsx +0 -285
- package/src/components/admin/admin-workflows-executions-panel.tsx +0 -169
- package/src/components/admin/admin-workflows-status-badge.tsx +0 -41
- package/src/components/admin/admin-workflows-status-labels.ts +0 -51
- package/src/components/admin/admin-workflows.tsx +0 -209
package/README.md
CHANGED
|
@@ -55,6 +55,12 @@ out by hand.
|
|
|
55
55
|
**`alepha-table`** - data table wired for server-side pagination, sorting and
|
|
56
56
|
filtering.
|
|
57
57
|
|
|
58
|
+
**`tree-view`** - a controlled tree. `tree-model.ts` is the pure half (build,
|
|
59
|
+
flatten, cycle-safe parents, drop resolution), `TreeView` draws the rows with
|
|
60
|
+
their indent guides and ARIA tree roles, and drag and drop, inline rename and a
|
|
61
|
+
context-menu slot are opt-ins. `useTreeState` holds the gesture state, and
|
|
62
|
+
`TreeViewResizer` is the pane handle.
|
|
63
|
+
|
|
58
64
|
**Application shells** - `app-shell` and `nav-shell` for page scaffolding,
|
|
59
65
|
`app-actions` for toolbars, plus ready-made `auth`, `account`, `settings`, and
|
|
60
66
|
`admin` screens.
|
|
@@ -71,8 +77,9 @@ under `components/`; `use-mobile` lives under `hooks/`.
|
|
|
71
77
|
> toast twice - so a standalone mount (or `app-shell` with `embedded`) has to
|
|
72
78
|
> wrap them itself.
|
|
73
79
|
|
|
74
|
-
**`lib/*`** - `utils` exports `cn()
|
|
75
|
-
component uses. Also `resize-image` and
|
|
80
|
+
**`lib/*`** - `utils` re-exports `cn()` from shadcn's `cn` package, the
|
|
81
|
+
zero-dependency class merger every component uses. Also `resize-image` and
|
|
82
|
+
`i18n-fr`.
|
|
76
83
|
|
|
77
84
|
## Example
|
|
78
85
|
|
|
@@ -155,6 +162,28 @@ to text, never promoted to markup: it renders content authored by one user to
|
|
|
155
162
|
another, so a live raw tag would be an injection point on every surface built on
|
|
156
163
|
this package.
|
|
157
164
|
|
|
165
|
+
### Spoilers
|
|
166
|
+
|
|
167
|
+
`||text||` renders as a covered box that reveals on click, on Enter or on
|
|
168
|
+
Space. Discord's syntax, and Discord's behaviour: inline markdown inside it
|
|
169
|
+
survives (`||see [the docs](/d) **now**||` hides a link and a bold word, not
|
|
170
|
+
the text of them), a code span and a fence keep their pipes literally, and an
|
|
171
|
+
unterminated `||` renders as the two characters that were typed rather than
|
|
172
|
+
swallowing the rest of the paragraph. A pair cannot cross a paragraph break.
|
|
173
|
+
|
|
174
|
+
⚠️ **It is not a security feature, and must never be described as one.** The
|
|
175
|
+
covered text is in the DOM from the first paint - the box is a colour, not an
|
|
176
|
+
absence - and it is also in the raw markdown, in an export, in whatever an API
|
|
177
|
+
or an MCP tool serves, and in any search snippet built from the source. It
|
|
178
|
+
hides a plot point from a reader's eye. It does not store a secret, and the
|
|
179
|
+
same words go in any UI that explains it.
|
|
180
|
+
|
|
181
|
+
A revealed spoiler stays revealed: re-hiding on blur would make it unreadable
|
|
182
|
+
with a keyboard, since reading what is around it is exactly what a reader does
|
|
183
|
+
next.
|
|
184
|
+
|
|
185
|
+
### Diagrams
|
|
186
|
+
|
|
158
187
|
A ` ```mermaid ` fence containing a **`flowchart`** or a **`sequenceDiagram`**
|
|
159
188
|
is drawn as an SVG diagram instead of a code block. The renderer is in-house
|
|
160
189
|
rather than mermaid itself: mermaid is roughly 500-900 kB gzip in a browser and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-connections.d.ts","sourceRoot":"","sources":["../../../src/components/account/account-connections.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAA0B,MAAM,kBAAkB,CAAC;AAO7E,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,kBAAkB,UAAW,uBAAuB,
|
|
1
|
+
{"version":3,"file":"account-connections.d.ts","sourceRoot":"","sources":["../../../src/components/account/account-connections.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAA0B,MAAM,kBAAkB,CAAC;AAO7E,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,kBAAkB,UAAW,uBAAuB,gCAgIzD,CAAC;eAEa,kBAAkB"}
|
|
@@ -71,7 +71,10 @@ const AccountConnections = (props) => {
|
|
|
71
71
|
}) + (connection.lastUsedAt ? tr("account.connections.lastUsedAt", {
|
|
72
72
|
default: " · last used $1",
|
|
73
73
|
args: [dt.of(connection.lastUsedAt).fromNow()]
|
|
74
|
-
}) : tr("account.connections.neverUsed", { default: " · never used" })),
|
|
74
|
+
}) : tr("account.connections.neverUsed", { default: " · never used" })) + (connection.sessionCount > 1 ? tr("account.connections.sessionCount", {
|
|
75
|
+
default: " · $1 sessions",
|
|
76
|
+
args: [String(connection.sessionCount)]
|
|
77
|
+
}) : ""),
|
|
75
78
|
children: /* @__PURE__ */ jsx(Button, {
|
|
76
79
|
variant: "ghost",
|
|
77
80
|
size: "sm",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-connections.js","names":[],"sources":["../../../src/components/account/account-connections.tsx"],"sourcesContent":["import { SettingsRow } from \"@alepha/ui/components/settings/settings-row\";\nimport { SettingsSection } from \"@alepha/ui/components/settings/settings-section\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport { useDialog } from \"@alepha/ui/components/use-dialog/use-dialog\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport type { MyConnection, MyConnectionController } from \"alepha/api/users\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { useClient, useInject } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { Plug } from \"lucide-react\";\nimport { useState } from \"react\";\n\nexport interface AccountConnectionsProps {\n connections?: MyConnection[];\n}\n\n/**\n * Applications holding access to this account through OAuth — an MCP client,\n * a CLI, a third-party integration.\n *\n * Confirmed on revoke, unlike a plain session. A session comes back by\n * signing in again; a connection comes back only by re-running whatever\n * authorization flow created it, which for an MCP client means the person has\n * to go and reconnect it from the other side.\n */\nconst AccountConnections = (props: AccountConnectionsProps) => {\n const api = useClient<MyConnectionController>();\n const dt = useInject(DateTimeProvider);\n const dialog = useDialog();\n const toaster = useToast();\n const { tr } = useI18n();\n\n const [connections, setConnections] = useState<MyConnection[]>(\n props.connections ?? [],\n );\n\n const revoke = async (connection: MyConnection) => {\n const ok = await dialog.confirm({\n title: tr(\"account.connections.revokeTitle\", {\n default: \"Disconnect $1?\",\n args: [connection.clientName],\n }),\n description: tr(\"account.connections.revokeDescription\", {\n default:\n \"It loses access immediately and has to be authorized again to come back.\",\n }),\n confirmLabel: tr(\"account.connections.revoke\", {\n default: \"Disconnect\",\n }),\n destructive: true,\n });\n if (!ok) {\n return;\n }\n try {\n await api.revokeMyConnection({ params: { id: connection.id } });\n setConnections((prev) => prev.filter((it) => it.id !== connection.id));\n } catch (error: any) {\n toaster.show(\n error?.message ??\n tr(\"account.connections.revokeError\", {\n default: \"Could not disconnect it\",\n }),\n \"danger\",\n );\n }\n };\n\n if (connections.length === 0) {\n /*\n Same title AND description as the populated branch below. An empty page\n that drops its description reads as a different page, and the sentence is\n exactly what a reader with nothing on screen needs.\n */\n return (\n <SettingsSection\n title={tr(\"account.connections.title\", { default: \"Connected apps\" })}\n description={tr(\"account.connections.description\", {\n default: \"Applications that can act on your behalf.\",\n })}\n >\n <SettingsRow\n label={\n <span className=\"text-muted-foreground flex items-center gap-2\">\n <Plug className=\"size-4\" />\n {tr(\"account.connections.empty\", {\n default: \"Nothing is connected\",\n })}\n </span>\n }\n description={tr(\"account.connections.emptyDescription\", {\n default: \"Applications you authorize will appear here.\",\n })}\n />\n </SettingsSection>\n );\n }\n\n return (\n <SettingsSection\n title={tr(\"account.connections.title\", { default: \"Connected apps\" })}\n description={tr(\"account.connections.description\", {\n default: \"Applications that can act on your behalf.\",\n })}\n >\n {connections.map((connection) => (\n <SettingsRow\n key={connection.id}\n label={\n <span className=\"flex items-center gap-2\">\n {connection.clientName}\n {connection.current ? (\n <span className=\"text-muted-foreground text-xs\">\n {tr(\"account.connections.current\", { default: \"(this one)\" })}\n </span>\n ) : null}\n </span>\n }\n description={\n tr(\"account.connections.connectedAt\", {\n default: \"Connected $1\",\n args: [dt.of(connection.createdAt).fromNow()],\n }) +\n (connection.lastUsedAt\n ? tr(\"account.connections.lastUsedAt\", {\n default: \" · last used $1\",\n args: [dt.of(connection.lastUsedAt).fromNow()],\n })\n : tr(\"account.connections.neverUsed\", {\n default: \" · never used\",\n }))\n }\n >\n <Button variant=\"ghost\" size=\"sm\" onClick={() => revoke(connection)}>\n {tr(\"account.connections.revoke\", { default: \"Disconnect\" })}\n </Button>\n </SettingsRow>\n ))}\n </SettingsSection>\n );\n};\n\nexport default AccountConnections;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,sBAAsB,UAAmC;CAC7D,MAAM,MAAM,UAAkC;CAC9C,MAAM,KAAK,UAAU,gBAAgB;CACrC,MAAM,SAAS,UAAU;CACzB,MAAM,UAAU,SAAS;CACzB,MAAM,EAAE,OAAO,QAAQ;CAEvB,MAAM,CAAC,aAAa,kBAAkB,SACpC,MAAM,eAAe,CAAC,CACxB;CAEA,MAAM,SAAS,OAAO,eAA6B;EAejD,IAAI,CAAC,MAdY,OAAO,QAAQ;GAC9B,OAAO,GAAG,mCAAmC;IAC3C,SAAS;IACT,MAAM,CAAC,WAAW,UAAU;GAC9B,CAAC;GACD,aAAa,GAAG,yCAAyC,EACvD,SACE,2EACJ,CAAC;GACD,cAAc,GAAG,8BAA8B,EAC7C,SAAS,aACX,CAAC;GACD,aAAa;EACf,CAAC,GAEC;EAEF,IAAI;GACF,MAAM,IAAI,mBAAmB,EAAE,QAAQ,EAAE,IAAI,WAAW,GAAG,EAAE,CAAC;GAC9D,gBAAgB,SAAS,KAAK,QAAQ,OAAO,GAAG,OAAO,WAAW,EAAE,CAAC;EACvE,SAAS,OAAY;GACnB,QAAQ,KACN,OAAO,WACL,GAAG,mCAAmC,EACpC,SAAS,0BACX,CAAC,GACH,QACF;EACF;CACF;CAEA,IAAI,YAAY,WAAW,GAMzB,OACE,oBAAC,iBAAD;EACE,OAAO,GAAG,6BAA6B,EAAE,SAAS,iBAAiB,CAAC;EACpE,aAAa,GAAG,mCAAmC,EACjD,SAAS,4CACX,CAAC;EAED,UAAA,oBAAC,aAAD;GACE,OACE,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACE,oBAAC,MAAD,EAAM,WAAU,SAAU,CAAA,GACzB,GAAG,6BAA6B,EAC/B,SAAS,uBACX,CAAC,CACG;;GAER,aAAa,GAAG,wCAAwC,EACtD,SAAS,+CACX,CAAC;EACF,CAAA;CACc,CAAA;CAIrB,OACE,oBAAC,iBAAD;EACE,OAAO,GAAG,6BAA6B,EAAE,SAAS,iBAAiB,CAAC;EACpE,aAAa,GAAG,mCAAmC,EACjD,SAAS,4CACX,CAAC;EAEA,UAAA,YAAY,KAAK,eAChB,oBAAC,aAAD;GAEE,OACE,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACG,WAAW,YACX,WAAW,UACV,oBAAC,QAAD;KAAM,WAAU;KACb,UAAA,GAAG,+BAA+B,EAAE,SAAS,aAAa,CAAC;IACxD,CAAA,IACJ,IACA;;GAER,aACE,GAAG,mCAAmC;IACpC,SAAS;IACT,MAAM,CAAC,GAAG,GAAG,WAAW,SAAS,CAAC,CAAC,QAAQ,CAAC;GAC9C,CAAC,KACA,WAAW,aACR,GAAG,kCAAkC;IACnC,SAAS;IACT,MAAM,CAAC,GAAG,GAAG,WAAW,UAAU,CAAC,CAAC,QAAQ,CAAC;GAC/C,CAAC,IACD,GAAG,iCAAiC,EAClC,SAAS,gBACX,CAAC;
|
|
1
|
+
{"version":3,"file":"account-connections.js","names":[],"sources":["../../../src/components/account/account-connections.tsx"],"sourcesContent":["import { SettingsRow } from \"@alepha/ui/components/settings/settings-row\";\nimport { SettingsSection } from \"@alepha/ui/components/settings/settings-section\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport { useDialog } from \"@alepha/ui/components/use-dialog/use-dialog\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport type { MyConnection, MyConnectionController } from \"alepha/api/users\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { useClient, useInject } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { Plug } from \"lucide-react\";\nimport { useState } from \"react\";\n\nexport interface AccountConnectionsProps {\n connections?: MyConnection[];\n}\n\n/**\n * Applications holding access to this account through OAuth — an MCP client,\n * a CLI, a third-party integration.\n *\n * Confirmed on revoke, unlike a plain session. A session comes back by\n * signing in again; a connection comes back only by re-running whatever\n * authorization flow created it, which for an MCP client means the person has\n * to go and reconnect it from the other side.\n */\nconst AccountConnections = (props: AccountConnectionsProps) => {\n const api = useClient<MyConnectionController>();\n const dt = useInject(DateTimeProvider);\n const dialog = useDialog();\n const toaster = useToast();\n const { tr } = useI18n();\n\n const [connections, setConnections] = useState<MyConnection[]>(\n props.connections ?? [],\n );\n\n const revoke = async (connection: MyConnection) => {\n const ok = await dialog.confirm({\n title: tr(\"account.connections.revokeTitle\", {\n default: \"Disconnect $1?\",\n args: [connection.clientName],\n }),\n description: tr(\"account.connections.revokeDescription\", {\n default:\n \"It loses access immediately and has to be authorized again to come back.\",\n }),\n confirmLabel: tr(\"account.connections.revoke\", {\n default: \"Disconnect\",\n }),\n destructive: true,\n });\n if (!ok) {\n return;\n }\n try {\n await api.revokeMyConnection({ params: { id: connection.id } });\n setConnections((prev) => prev.filter((it) => it.id !== connection.id));\n } catch (error: any) {\n toaster.show(\n error?.message ??\n tr(\"account.connections.revokeError\", {\n default: \"Could not disconnect it\",\n }),\n \"danger\",\n );\n }\n };\n\n if (connections.length === 0) {\n /*\n Same title AND description as the populated branch below. An empty page\n that drops its description reads as a different page, and the sentence is\n exactly what a reader with nothing on screen needs.\n */\n return (\n <SettingsSection\n title={tr(\"account.connections.title\", { default: \"Connected apps\" })}\n description={tr(\"account.connections.description\", {\n default: \"Applications that can act on your behalf.\",\n })}\n >\n <SettingsRow\n label={\n <span className=\"text-muted-foreground flex items-center gap-2\">\n <Plug className=\"size-4\" />\n {tr(\"account.connections.empty\", {\n default: \"Nothing is connected\",\n })}\n </span>\n }\n description={tr(\"account.connections.emptyDescription\", {\n default: \"Applications you authorize will appear here.\",\n })}\n />\n </SettingsSection>\n );\n }\n\n return (\n <SettingsSection\n title={tr(\"account.connections.title\", { default: \"Connected apps\" })}\n description={tr(\"account.connections.description\", {\n default: \"Applications that can act on your behalf.\",\n })}\n >\n {connections.map((connection) => (\n <SettingsRow\n key={connection.id}\n label={\n <span className=\"flex items-center gap-2\">\n {connection.clientName}\n {connection.current ? (\n <span className=\"text-muted-foreground text-xs\">\n {tr(\"account.connections.current\", { default: \"(this one)\" })}\n </span>\n ) : null}\n </span>\n }\n description={\n tr(\"account.connections.connectedAt\", {\n default: \"Connected $1\",\n args: [dt.of(connection.createdAt).fromNow()],\n }) +\n (connection.lastUsedAt\n ? tr(\"account.connections.lastUsedAt\", {\n default: \" · last used $1\",\n args: [dt.of(connection.lastUsedAt).fromNow()],\n })\n : tr(\"account.connections.neverUsed\", {\n default: \" · never used\",\n })) +\n /*\n ⚠️ Said out loud, not hidden. Since the list groups by client\n one row can stand for several authorizations, and a reader\n deciding whether to disconnect should know how many go with\n it. Omitted at one, which is every ordinary case - \"1 session\"\n on every row would be noise.\n */\n (connection.sessionCount > 1\n ? tr(\"account.connections.sessionCount\", {\n default: \" · $1 sessions\",\n args: [String(connection.sessionCount)],\n })\n : \"\")\n }\n >\n <Button variant=\"ghost\" size=\"sm\" onClick={() => revoke(connection)}>\n {tr(\"account.connections.revoke\", { default: \"Disconnect\" })}\n </Button>\n </SettingsRow>\n ))}\n </SettingsSection>\n );\n};\n\nexport default AccountConnections;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,sBAAsB,UAAmC;CAC7D,MAAM,MAAM,UAAkC;CAC9C,MAAM,KAAK,UAAU,gBAAgB;CACrC,MAAM,SAAS,UAAU;CACzB,MAAM,UAAU,SAAS;CACzB,MAAM,EAAE,OAAO,QAAQ;CAEvB,MAAM,CAAC,aAAa,kBAAkB,SACpC,MAAM,eAAe,CAAC,CACxB;CAEA,MAAM,SAAS,OAAO,eAA6B;EAejD,IAAI,CAAC,MAdY,OAAO,QAAQ;GAC9B,OAAO,GAAG,mCAAmC;IAC3C,SAAS;IACT,MAAM,CAAC,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,CAAC,QAAQ,CAAC;GAC9C,CAAC,KACA,WAAW,aACR,GAAG,kCAAkC;IACnC,SAAS;IACT,MAAM,CAAC,GAAG,GAAG,WAAW,UAAU,CAAC,CAAC,QAAQ,CAAC;GAC/C,CAAC,IACD,GAAG,iCAAiC,EAClC,SAAS,gBACX,CAAC,MAQJ,WAAW,eAAe,IACvB,GAAG,oCAAoC;IACrC,SAAS;IACT,MAAM,CAAC,OAAO,WAAW,YAAY,CAAC;GACxC,CAAC,IACD;GAGN,UAAA,oBAAC,QAAD;IAAQ,SAAQ;IAAQ,MAAK;IAAK,eAAe,OAAO,UAAU;IAC/D,UAAA,GAAG,8BAA8B,EAAE,SAAS,aAAa,CAAC;GACrD,CAAA;EACG,GA1CN,WAAW,EA0CL,CACd;CACc,CAAA;AAErB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-delete-dialog.d.ts","sourceRoot":"","sources":["../../../src/components/account/account-delete-dialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account-delete-dialog.d.ts","sourceRoot":"","sources":["../../../src/components/account/account-delete-dialog.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAkB,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAE5E,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,OAAO,CAAC;IAEd;;;;OAIG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAEtC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB;;;OAGG;IACH,SAAS,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,UAAW,wBAAwB,gCAqIlE,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { Input } from "../ui/input.js";
|
|
|
3
3
|
import { useToast } from "../use-toast/use-toast.js";
|
|
4
4
|
import { Label } from "../ui/label.js";
|
|
5
5
|
import { ControlPassword } from "../control-password/control-password.js";
|
|
6
|
-
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/dialog.js";
|
|
6
|
+
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "../ui/dialog.js";
|
|
7
7
|
import { useEffect, useState } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { useI18n } from "alepha/react/i18n";
|
|
@@ -106,20 +106,17 @@ const AccountDeleteDialog = (props) => {
|
|
|
106
106
|
required: true
|
|
107
107
|
})]
|
|
108
108
|
}),
|
|
109
|
-
/* @__PURE__ */ jsxs(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
children: tr("account.delete.submit", { default: "Delete account" })
|
|
121
|
-
})]
|
|
122
|
-
})
|
|
109
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
110
|
+
type: "button",
|
|
111
|
+
variant: "ghost",
|
|
112
|
+
onClick: close,
|
|
113
|
+
children: tr("account.delete.cancel", { default: "Cancel" })
|
|
114
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
115
|
+
type: "submit",
|
|
116
|
+
variant: "destructive",
|
|
117
|
+
disabled: submitting || !ready,
|
|
118
|
+
children: tr("account.delete.submit", { default: "Delete account" })
|
|
119
|
+
})] })
|
|
123
120
|
]
|
|
124
121
|
})] })
|
|
125
122
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-delete-dialog.js","names":[],"sources":["../../../src/components/account/account-delete-dialog.tsx"],"sourcesContent":["import { ControlPassword } from \"@alepha/ui/components/control-password/control-password\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogHeader,\n DialogTitle,\n} from \"@alepha/ui/components/ui/dialog\";\nimport { Input } from \"@alepha/ui/components/ui/input\";\nimport { Label } from \"@alepha/ui/components/ui/label\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport type {\n MyAccountController,\n MyProfileController,\n} from \"alepha/api/users\";\nimport { useClient } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { type FormEvent, type ReactNode, useEffect, useState } from \"react\";\n\nexport interface AccountDeleteDialogProps {\n open: boolean;\n\n /**\n * Whether the account has a `credentials` identity. An OAuth-only account\n * has no password to prove knowledge of, so the field is not shown — and\n * the server agrees, accepting the confirmation phrase alone.\n */\n hasPassword: boolean;\n\n onOpenChange: (open: boolean) => void;\n\n /**\n * Application-supplied consequences, rendered above the confirmation field.\n *\n * The framework can say what deleting an *account* does; it cannot say what\n * that costs inside your data. An application whose foreign keys cascade —\n * rows the account authored inside other people's projects, say — puts the\n * count here so the person reads it *before* confirming rather than\n * discovering it afterwards.\n *\n * A `ReactNode` rather than a string because the honest version of this is\n * usually a live count, which means a component that fetches one.\n */\n warning?: ReactNode;\n\n /**\n * Called once the account is gone. The caller signs the (now orphaned)\n * session out.\n */\n onDeleted: () => void | Promise<void>;\n}\n\n/**\n * Permanently delete your own account.\n *\n * Asks for two independent things because the two failure modes are different\n * people: the password proves it is *you* (against someone at your unlocked\n * laptop), and typing the confirmation phrase proves you *meant it* (against\n * you, five seconds from now).\n *\n * The phrase is fetched rather than guessed. The server accepts the account's\n * email, falling back to username and then the literal `DELETE`, and this\n * dialog must ask for exactly what the server will accept — a hardcoded\n * \"type DELETE\" would be refused for every account that has an email.\n */\nexport const AccountDeleteDialog = (props: AccountDeleteDialogProps) => {\n const accountApi = useClient<MyAccountController>();\n const profileApi = useClient<MyProfileController>();\n const toaster = useToast();\n const { tr } = useI18n();\n\n const [expected, setExpected] = useState<string | undefined>();\n const [confirm, setConfirm] = useState(\"\");\n const [currentPassword, setCurrentPassword] = useState(\"\");\n const [submitting, setSubmitting] = useState(false);\n\n useEffect(() => {\n if (!props.open) {\n return;\n }\n let cancelled = false;\n profileApi\n .getMyProfile()\n .then((profile) => {\n if (!cancelled) {\n setExpected(profile.email ?? profile.username ?? \"DELETE\");\n }\n })\n .catch(() => {\n if (!cancelled) {\n setExpected(\"DELETE\");\n }\n });\n return () => {\n cancelled = true;\n };\n }, [props.open, profileApi]);\n\n const close = () => {\n setConfirm(\"\");\n setCurrentPassword(\"\");\n props.onOpenChange(false);\n };\n\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n setSubmitting(true);\n try {\n await accountApi.deleteMyAccount({\n body: {\n confirm,\n currentPassword: props.hasPassword ? currentPassword : undefined,\n },\n });\n await props.onDeleted();\n } catch (error: any) {\n /*\n An application's `user:delete:before` hook refuses here — \"You still\n own 3 projects\" — and the framework's fast-path emit delivers that\n message unwrapped. Showing it verbatim is the entire reason the emit\n avoids `{ log: true }`; a generic \"could not delete\" would waste it.\n */\n toaster.show(\n error?.message ??\n tr(\"account.delete.error\", {\n default: \"Could not delete your account\",\n }),\n \"danger\",\n );\n } finally {\n setSubmitting(false);\n }\n };\n\n const ready = expected !== undefined && confirm === expected;\n\n return (\n <Dialog open={props.open} onOpenChange={(next) => !next && close()}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n {tr(\"account.delete.title\", { default: \"Delete your account\" })}\n </DialogTitle>\n </DialogHeader>\n <form onSubmit={submit} className=\"flex flex-col gap-4\">\n <span className=\"text-muted-foreground text-sm\">\n {tr(\"account.delete.description\", {\n default:\n \"This permanently removes your account, its sign-in methods and every session. It cannot be undone.\",\n })}\n </span>\n\n {props.warning}\n\n {props.hasPassword ? (\n <ControlPassword\n id=\"deleteCurrentPassword\"\n label={tr(\"account.delete.currentPassword\", {\n default: \"Current password\",\n })}\n value={currentPassword}\n onChange={setCurrentPassword}\n autoComplete=\"current-password\"\n required\n />\n ) : null}\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor=\"deleteConfirm\">\n {tr(\"account.delete.confirmBefore\", { default: \"Type\" })}{\" \"}\n <span className=\"font-mono\">{expected ?? \"…\"}</span>{\" \"}\n {tr(\"account.delete.confirmAfter\", { default: \"to confirm\" })}\n </Label>\n <Input\n id=\"deleteConfirm\"\n value={confirm}\n onChange={(event) => setConfirm(event.target.value)}\n autoComplete=\"off\"\n required\n />\n </div>\n\n <
|
|
1
|
+
{"version":3,"file":"account-delete-dialog.js","names":[],"sources":["../../../src/components/account/account-delete-dialog.tsx"],"sourcesContent":["import { ControlPassword } from \"@alepha/ui/components/control-password/control-password\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from \"@alepha/ui/components/ui/dialog\";\nimport { Input } from \"@alepha/ui/components/ui/input\";\nimport { Label } from \"@alepha/ui/components/ui/label\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport type {\n MyAccountController,\n MyProfileController,\n} from \"alepha/api/users\";\nimport { useClient } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { type FormEvent, type ReactNode, useEffect, useState } from \"react\";\n\nexport interface AccountDeleteDialogProps {\n open: boolean;\n\n /**\n * Whether the account has a `credentials` identity. An OAuth-only account\n * has no password to prove knowledge of, so the field is not shown — and\n * the server agrees, accepting the confirmation phrase alone.\n */\n hasPassword: boolean;\n\n onOpenChange: (open: boolean) => void;\n\n /**\n * Application-supplied consequences, rendered above the confirmation field.\n *\n * The framework can say what deleting an *account* does; it cannot say what\n * that costs inside your data. An application whose foreign keys cascade —\n * rows the account authored inside other people's projects, say — puts the\n * count here so the person reads it *before* confirming rather than\n * discovering it afterwards.\n *\n * A `ReactNode` rather than a string because the honest version of this is\n * usually a live count, which means a component that fetches one.\n */\n warning?: ReactNode;\n\n /**\n * Called once the account is gone. The caller signs the (now orphaned)\n * session out.\n */\n onDeleted: () => void | Promise<void>;\n}\n\n/**\n * Permanently delete your own account.\n *\n * Asks for two independent things because the two failure modes are different\n * people: the password proves it is *you* (against someone at your unlocked\n * laptop), and typing the confirmation phrase proves you *meant it* (against\n * you, five seconds from now).\n *\n * The phrase is fetched rather than guessed. The server accepts the account's\n * email, falling back to username and then the literal `DELETE`, and this\n * dialog must ask for exactly what the server will accept — a hardcoded\n * \"type DELETE\" would be refused for every account that has an email.\n */\nexport const AccountDeleteDialog = (props: AccountDeleteDialogProps) => {\n const accountApi = useClient<MyAccountController>();\n const profileApi = useClient<MyProfileController>();\n const toaster = useToast();\n const { tr } = useI18n();\n\n const [expected, setExpected] = useState<string | undefined>();\n const [confirm, setConfirm] = useState(\"\");\n const [currentPassword, setCurrentPassword] = useState(\"\");\n const [submitting, setSubmitting] = useState(false);\n\n useEffect(() => {\n if (!props.open) {\n return;\n }\n let cancelled = false;\n profileApi\n .getMyProfile()\n .then((profile) => {\n if (!cancelled) {\n setExpected(profile.email ?? profile.username ?? \"DELETE\");\n }\n })\n .catch(() => {\n if (!cancelled) {\n setExpected(\"DELETE\");\n }\n });\n return () => {\n cancelled = true;\n };\n }, [props.open, profileApi]);\n\n const close = () => {\n setConfirm(\"\");\n setCurrentPassword(\"\");\n props.onOpenChange(false);\n };\n\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n setSubmitting(true);\n try {\n await accountApi.deleteMyAccount({\n body: {\n confirm,\n currentPassword: props.hasPassword ? currentPassword : undefined,\n },\n });\n await props.onDeleted();\n } catch (error: any) {\n /*\n An application's `user:delete:before` hook refuses here — \"You still\n own 3 projects\" — and the framework's fast-path emit delivers that\n message unwrapped. Showing it verbatim is the entire reason the emit\n avoids `{ log: true }`; a generic \"could not delete\" would waste it.\n */\n toaster.show(\n error?.message ??\n tr(\"account.delete.error\", {\n default: \"Could not delete your account\",\n }),\n \"danger\",\n );\n } finally {\n setSubmitting(false);\n }\n };\n\n const ready = expected !== undefined && confirm === expected;\n\n return (\n <Dialog open={props.open} onOpenChange={(next) => !next && close()}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n {tr(\"account.delete.title\", { default: \"Delete your account\" })}\n </DialogTitle>\n </DialogHeader>\n <form onSubmit={submit} className=\"flex flex-col gap-4\">\n <span className=\"text-muted-foreground text-sm\">\n {tr(\"account.delete.description\", {\n default:\n \"This permanently removes your account, its sign-in methods and every session. It cannot be undone.\",\n })}\n </span>\n\n {props.warning}\n\n {props.hasPassword ? (\n <ControlPassword\n id=\"deleteCurrentPassword\"\n label={tr(\"account.delete.currentPassword\", {\n default: \"Current password\",\n })}\n value={currentPassword}\n onChange={setCurrentPassword}\n autoComplete=\"current-password\"\n required\n />\n ) : null}\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor=\"deleteConfirm\">\n {tr(\"account.delete.confirmBefore\", { default: \"Type\" })}{\" \"}\n <span className=\"font-mono\">{expected ?? \"…\"}</span>{\" \"}\n {tr(\"account.delete.confirmAfter\", { default: \"to confirm\" })}\n </Label>\n <Input\n id=\"deleteConfirm\"\n value={confirm}\n onChange={(event) => setConfirm(event.target.value)}\n autoComplete=\"off\"\n required\n />\n </div>\n\n <DialogFooter>\n <Button type=\"button\" variant=\"ghost\" onClick={close}>\n {tr(\"account.delete.cancel\", { default: \"Cancel\" })}\n </Button>\n <Button\n type=\"submit\"\n variant=\"destructive\"\n disabled={submitting || !ready}\n >\n {tr(\"account.delete.submit\", { default: \"Delete account\" })}\n </Button>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAa,uBAAuB,UAAoC;CACtE,MAAM,aAAa,UAA+B;CAClD,MAAM,aAAa,UAA+B;CAClD,MAAM,UAAU,SAAS;CACzB,MAAM,EAAE,OAAO,QAAQ;CAEvB,MAAM,CAAC,UAAU,eAAe,SAA6B;CAC7D,MAAM,CAAC,SAAS,cAAc,SAAS,EAAE;CACzC,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,EAAE;CACzD,MAAM,CAAC,YA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IAAG;KACH,OAAO,GAAG,kCAAkC,EAC1C,SAAS,mBACX,CAAC;KACD,OAAO;KACP,UAAU;KACV,cAAa;KACb,UAAA;IACD,CAAA,IACC;IAEJ,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,qBAAC,OAAD;MAAO,SAAQ;MAAf,UAAA;OACG,GAAG,gCAAgC,EAAE,SAAS,OAAO,CAAC;OAAG;OAC1D,oBAAC,QAAD;QAAM,WAAU;QAAa,UAAA,YAAY;OAAU,CAAA;OAAE;OACpD,GAAG,+BAA+B,EAAE,SAAS,aAAa,CAAC;MACvD;KACP,CAAA,GAAA,oBAAC,OAAD;MACE,IAAG;MACH,OAAO;MACP,WAAW,UAAU,WAAW,MAAM,OAAO,KAAK;MAClD,cAAa;MACb,UAAA;KACD,CAAA,CACE;;IAEL,qBAAC,cAAD,EAAA,UAAA,CACE,oBAAC,QAAD;KAAQ,MAAK;KAAS,SAAQ;KAAQ,SAAS;KAC5C,UAAA,GAAG,yBAAyB,EAAE,SAAS,SAAS,CAAC;IAC5C,CAAA,GACR,oBAAC,QAAD;KACE,MAAK;KACL,SAAQ;KACR,UAAU,cAAc,CAAC;KAExB,UAAA,GAAG,yBAAyB,EAAE,SAAS,iBAAiB,CAAC;IACpD,CAAA,CACI,EAAA,CAAA;GACV;EACO,CAAA,CAAA,EAAA,CAAA;CACT,CAAA;AAEZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-keys.d.ts","sourceRoot":"","sources":["../../../src/components/account/account-keys.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account-keys.d.ts","sourceRoot":"","sources":["../../../src/components/account/account-keys.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAoB,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAO9E;;;;GAIG;AACH,KAAK,SAAS,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEpD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,WAAW,UAAW,gBAAgB,gCAmO3C,CAAC;eAEa,WAAW"}
|
|
@@ -5,7 +5,7 @@ import { Input } from "../ui/input.js";
|
|
|
5
5
|
import { useDialog } from "../use-dialog/use-dialog.js";
|
|
6
6
|
import { useToast } from "../use-toast/use-toast.js";
|
|
7
7
|
import { Label } from "../ui/label.js";
|
|
8
|
-
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/dialog.js";
|
|
8
|
+
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "../ui/dialog.js";
|
|
9
9
|
import { useState } from "react";
|
|
10
10
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { Check, Clipboard, Plus, Trash2 } from "lucide-react";
|
|
@@ -123,19 +123,16 @@ const AccountKeys = (props) => {
|
|
|
123
123
|
placeholder: tr("account.keys.namePlaceholder", { default: "CI pipeline" }),
|
|
124
124
|
required: true
|
|
125
125
|
})]
|
|
126
|
-
}), /* @__PURE__ */ jsxs(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
children: tr("account.keys.submit", { default: "Create" })
|
|
137
|
-
})]
|
|
138
|
-
})]
|
|
126
|
+
}), /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
127
|
+
type: "button",
|
|
128
|
+
variant: "ghost",
|
|
129
|
+
onClick: () => setCreateOpen(false),
|
|
130
|
+
children: tr("account.keys.cancel", { default: "Cancel" })
|
|
131
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
132
|
+
type: "submit",
|
|
133
|
+
disabled: creating,
|
|
134
|
+
children: tr("account.keys.submit", { default: "Create" })
|
|
135
|
+
})] })]
|
|
139
136
|
})] })
|
|
140
137
|
}),
|
|
141
138
|
/* @__PURE__ */ jsx(Dialog, {
|
|
@@ -157,20 +154,17 @@ const AccountKeys = (props) => {
|
|
|
157
154
|
className: "bg-muted rounded-md border p-3 font-mono text-xs break-all",
|
|
158
155
|
children: freshToken
|
|
159
156
|
}),
|
|
160
|
-
/* @__PURE__ */ jsxs(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
children: tr("account.keys.done", { default: "Done" })
|
|
172
|
-
})]
|
|
173
|
-
})
|
|
157
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsxs(Button, {
|
|
158
|
+
variant: "secondary",
|
|
159
|
+
onClick: copy,
|
|
160
|
+
children: [copied ? /* @__PURE__ */ jsx(Check, { className: "size-4" }) : /* @__PURE__ */ jsx(Clipboard, { className: "size-4" }), copied ? tr("account.keys.copied", { default: "Copied" }) : tr("account.keys.copy", { default: "Copy" })]
|
|
161
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
162
|
+
onClick: () => {
|
|
163
|
+
setFreshToken(void 0);
|
|
164
|
+
setCopied(false);
|
|
165
|
+
},
|
|
166
|
+
children: tr("account.keys.done", { default: "Done" })
|
|
167
|
+
})] })
|
|
174
168
|
]
|
|
175
169
|
})] })
|
|
176
170
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-keys.js","names":[],"sources":["../../../src/components/account/account-keys.tsx"],"sourcesContent":["import { SettingsRow } from \"@alepha/ui/components/settings/settings-row\";\nimport { SettingsSection } from \"@alepha/ui/components/settings/settings-section\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogHeader,\n DialogTitle,\n} from \"@alepha/ui/components/ui/dialog\";\nimport { Input } from \"@alepha/ui/components/ui/input\";\nimport { Label } from \"@alepha/ui/components/ui/label\";\nimport { useDialog } from \"@alepha/ui/components/use-dialog/use-dialog\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport type { Infer } from \"alepha\";\nimport type { ApiKeyController, listApiKeyItemSchema } from \"alepha/api/keys\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { useClient, useInject } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { Check, Clipboard, Plus, Trash2 } from \"lucide-react\";\nimport { type FormEvent, useState } from \"react\";\n\n/**\n * Derived from the framework's own response schema rather than restated, so a\n * field added to the endpoint is available here the day it lands — and a\n * field removed is a compile error rather than a blank cell.\n */\ntype ApiKeyRow = Infer<typeof listApiKeyItemSchema>;\n\nexport interface AccountKeysProps {\n apiKeys?: ApiKeyRow[];\n}\n\n/**\n * Your own API keys: mint, see, revoke.\n *\n * The freshly created token is shown **once**, in a dialog that stays open\n * until dismissed, because the server stores only a hash and cannot show it\n * again. That is also why the create form and the reveal are separate steps\n * rather than one inline row — a token that scrolls out of view behind a\n * re-render is gone.\n */\nconst AccountKeys = (props: AccountKeysProps) => {\n const api = useClient<ApiKeyController>();\n const dt = useInject(DateTimeProvider);\n const dialog = useDialog();\n const toaster = useToast();\n const { tr } = useI18n();\n\n const [keys, setKeys] = useState<ApiKeyRow[]>(props.apiKeys ?? []);\n const [createOpen, setCreateOpen] = useState(false);\n const [name, setName] = useState(\"\");\n const [creating, setCreating] = useState(false);\n const [freshToken, setFreshToken] = useState<string | undefined>();\n const [copied, setCopied] = useState(false);\n\n const create = async (event: FormEvent) => {\n event.preventDefault();\n setCreating(true);\n try {\n const created: any = await api.createApiKey({ body: { name } });\n setFreshToken(created.token);\n setKeys(await (api.listApiKeys() as Promise<any>));\n setName(\"\");\n setCreateOpen(false);\n } catch (error: any) {\n toaster.show(\n error?.message ??\n tr(\"account.keys.createError\", {\n default: \"Could not create that key\",\n }),\n \"danger\",\n );\n } finally {\n setCreating(false);\n }\n };\n\n const revoke = async (key: ApiKeyRow) => {\n const ok = await dialog.confirm({\n title: tr(\"account.keys.revokeTitle\", {\n default: \"Revoke $1?\",\n args: [key.name],\n }),\n description: tr(\"account.keys.revokeDescription\", {\n default:\n \"Anything still using this key stops working immediately. This cannot be undone.\",\n }),\n confirmLabel: tr(\"account.keys.revoke\", { default: \"Revoke\" }),\n destructive: true,\n });\n if (!ok) {\n return;\n }\n try {\n await api.revokeMyApiKey({ params: { id: key.id } });\n setKeys((prev) => prev.filter((it) => it.id !== key.id));\n } catch (error: any) {\n toaster.show(\n error?.message ??\n tr(\"account.keys.revokeError\", {\n default: \"Could not revoke that key\",\n }),\n \"danger\",\n );\n }\n };\n\n const copy = async () => {\n if (!freshToken) {\n return;\n }\n await navigator.clipboard.writeText(freshToken);\n setCopied(true);\n };\n\n return (\n <>\n <SettingsSection\n title={tr(\"account.keys.title\", { default: \"API keys\" })}\n description={tr(\"account.keys.description\", {\n default: \"Keys act as you. Revoke any you no longer recognise.\",\n })}\n >\n {keys.map((key) => (\n <SettingsRow\n key={key.id}\n label={key.name}\n description={\n tr(\"account.keys.createdAt\", {\n default: \"…$1 · created $2\",\n args: [key.tokenSuffix, dt.of(key.createdAt).fromNow()],\n }) +\n (key.lastUsedAt\n ? tr(\"account.keys.lastUsedAt\", {\n default: \" · last used $1\",\n args: [dt.of(key.lastUsedAt).fromNow()],\n })\n : tr(\"account.keys.neverUsed\", { default: \" · never used\" }))\n }\n >\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => revoke(key)}\n aria-label={tr(\"account.keys.revokeAria\", {\n default: \"Revoke $1\",\n args: [key.name],\n })}\n >\n <Trash2 className=\"size-4\" />\n </Button>\n </SettingsRow>\n ))}\n\n <SettingsRow\n label={tr(\"account.keys.create\", { default: \"Create a key\" })}\n description={tr(\"account.keys.createDescription\", {\n default:\n \"Shown once, at creation. It cannot be recovered afterwards.\",\n })}\n >\n <Button\n variant=\"secondary\"\n size=\"sm\"\n onClick={() => setCreateOpen(true)}\n >\n <Plus className=\"size-4\" />\n {tr(\"account.keys.new\", { default: \"New key\" })}\n </Button>\n </SettingsRow>\n </SettingsSection>\n\n <Dialog open={createOpen} onOpenChange={setCreateOpen}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n {tr(\"account.keys.newTitle\", { default: \"New API key\" })}\n </DialogTitle>\n </DialogHeader>\n <form onSubmit={create} className=\"flex flex-col gap-4\">\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor=\"apiKeyName\">\n {tr(\"account.keys.name\", { default: \"Name\" })}\n </Label>\n <Input\n id=\"apiKeyName\"\n value={name}\n onChange={(event) => setName(event.target.value)}\n placeholder={tr(\"account.keys.namePlaceholder\", {\n default: \"CI pipeline\",\n })}\n required\n />\n </div>\n <div className=\"flex justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={() => setCreateOpen(false)}\n >\n {tr(\"account.keys.cancel\", { default: \"Cancel\" })}\n </Button>\n <Button type=\"submit\" disabled={creating}>\n {tr(\"account.keys.submit\", { default: \"Create\" })}\n </Button>\n </div>\n </form>\n </DialogContent>\n </Dialog>\n\n {/* Deliberately not auto-dismissed: this is the only time the token\n exists in a readable form. */}\n <Dialog\n open={Boolean(freshToken)}\n onOpenChange={(next) => {\n if (!next) {\n setFreshToken(undefined);\n setCopied(false);\n }\n }}\n >\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n {tr(\"account.keys.revealTitle\", { default: \"Copy your key now\" })}\n </DialogTitle>\n </DialogHeader>\n <div className=\"flex flex-col gap-4\">\n <span className=\"text-muted-foreground text-sm\">\n {tr(\"account.keys.revealDescription\", {\n default:\n \"This is the only time it is shown. Store it somewhere safe before closing this dialog.\",\n })}\n </span>\n <code className=\"bg-muted rounded-md border p-3 font-mono text-xs break-all\">\n {freshToken}\n </code>\n <div className=\"flex justify-end gap-2\">\n <Button variant=\"secondary\" onClick={copy}>\n {copied ? (\n <Check className=\"size-4\" />\n ) : (\n <Clipboard className=\"size-4\" />\n )}\n {copied\n ? tr(\"account.keys.copied\", { default: \"Copied\" })\n : tr(\"account.keys.copy\", { default: \"Copy\" })}\n </Button>\n <Button\n onClick={() => {\n setFreshToken(undefined);\n setCopied(false);\n }}\n >\n {tr(\"account.keys.done\", { default: \"Done\" })}\n </Button>\n </div>\n </div>\n </DialogContent>\n </Dialog>\n </>\n );\n};\n\nexport default AccountKeys;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,eAAe,UAA4B;CAC/C,MAAM,MAAM,UAA4B;CACxC,MAAM,KAAK,UAAU,gBAAgB;CACrC,MAAM,SAAS,UAAU;CACzB,MAAM,UAAU,SAAS;CACzB,MAAM,EAAE,OAAO,QAAQ;CAEvB,MAAM,CAAC,MAAM,WAAW,SAAsB,MAAM,WAAW,CAAC,CAAC;CACjE,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,CAAC,MAAM,WAAW,SAAS,EAAE;CACnC,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,YAAY,iBAAiB,SAA6B;CACjE,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAE1C,MAAM,SAAS,OAAO,UAAqB;EACzC,MAAM,eAAe;EACrB,YAAY,IAAI;EAChB,IAAI;GACF,MAAM,UAAe,MAAM,IAAI,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;GAC9D,cAAc,QAAQ,KAAK;GAC3B,QAAQ,MAAO,IAAI,YAAY,CAAkB;GACjD,QAAQ,EAAE;GACV,cAAc,KAAK;EACrB,SAAS,OAAY;GACnB,QAAQ,KACN,OAAO,WACL,GAAG,4BAA4B,EAC7B,SAAS,4BACX,CAAC,GACH,QACF;EACF,UAAU;GACR,YAAY,KAAK;EACnB;CACF;CAEA,MAAM,SAAS,OAAO,QAAmB;EAavC,IAAI,CAAC,MAZY,OAAO,QAAQ;GAC9B,OAAO,GAAG,4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,CAAA,CACL;IACD,CAAA,CAAA;GACO,CAAA,CAAA,EAAA,CAAA;EACT,CAAA;EAIR,oBAAC,QAAD;GACE,MAAM,QAAQ,UAAU;GACxB,eAAe,SAAS;IACtB,IAAI,CAAC,MAAM;KACT,cAAc,KAAA,CAAS;KACvB,UAAU,KAAK;IACjB;GACF;GAEA,UAAA,qBAAC,eAAD,EAAA,UAAA,CACE,oBAAC,cAAD,EAAA,UACE,oBAAC,aAAD,EAAA,UACG,GAAG,4BAA4B,EAAE,SAAS,oBAAoB,CAAC,EACrD,CAAA,EACD,CAAA,GACd,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,oBAAC,QAAD;MAAM,WAAU;MACb,UAAA,GAAG,kCAAkC,EACpC,SACE,yFACJ,CAAC;KACG,CAAA;KACN,oBAAC,QAAD;MAAM,WAAU;MACb,UAAA;KACG,CAAA;KACN,qBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,qBAAC,QAAD;OAAQ,SAAQ;OAAY,SAAS;OAArC,UAAA,CACG,SACC,oBAAC,OAAD,EAAO,WAAU,SAAU,CAAA,IAE3B,oBAAC,WAAD,EAAW,WAAU,SAAU,CAAA,GAEhC,SACG,GAAG,uBAAuB,EAAE,SAAS,SAAS,CAAC,IAC/C,GAAG,qBAAqB,EAAE,SAAS,OAAO,CAAC,CACzC;MACR,CAAA,GAAA,oBAAC,QAAD;OACE,eAAe;QACb,cAAc,KAAA,CAAS;QACvB,UAAU,KAAK;OACjB;OAEC,UAAA,GAAG,qBAAqB,EAAE,SAAS,OAAO,CAAC;MACtC,CAAA,CACL;;IACF;GACQ,CAAA,CAAA,EAAA,CAAA;EACT,CAAA;CACR,EAAA,CAAA;AAEN"}
|
|
1
|
+
{"version":3,"file":"account-keys.js","names":[],"sources":["../../../src/components/account/account-keys.tsx"],"sourcesContent":["import { SettingsRow } from \"@alepha/ui/components/settings/settings-row\";\nimport { SettingsSection } from \"@alepha/ui/components/settings/settings-section\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from \"@alepha/ui/components/ui/dialog\";\nimport { Input } from \"@alepha/ui/components/ui/input\";\nimport { Label } from \"@alepha/ui/components/ui/label\";\nimport { useDialog } from \"@alepha/ui/components/use-dialog/use-dialog\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport type { Infer } from \"alepha\";\nimport type { ApiKeyController, listApiKeyItemSchema } from \"alepha/api/keys\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { useClient, useInject } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { Check, Clipboard, Plus, Trash2 } from \"lucide-react\";\nimport { type FormEvent, useState } from \"react\";\n\n/**\n * Derived from the framework's own response schema rather than restated, so a\n * field added to the endpoint is available here the day it lands — and a\n * field removed is a compile error rather than a blank cell.\n */\ntype ApiKeyRow = Infer<typeof listApiKeyItemSchema>;\n\nexport interface AccountKeysProps {\n apiKeys?: ApiKeyRow[];\n}\n\n/**\n * Your own API keys: mint, see, revoke.\n *\n * The freshly created token is shown **once**, in a dialog that stays open\n * until dismissed, because the server stores only a hash and cannot show it\n * again. That is also why the create form and the reveal are separate steps\n * rather than one inline row — a token that scrolls out of view behind a\n * re-render is gone.\n */\nconst AccountKeys = (props: AccountKeysProps) => {\n const api = useClient<ApiKeyController>();\n const dt = useInject(DateTimeProvider);\n const dialog = useDialog();\n const toaster = useToast();\n const { tr } = useI18n();\n\n const [keys, setKeys] = useState<ApiKeyRow[]>(props.apiKeys ?? []);\n const [createOpen, setCreateOpen] = useState(false);\n const [name, setName] = useState(\"\");\n const [creating, setCreating] = useState(false);\n const [freshToken, setFreshToken] = useState<string | undefined>();\n const [copied, setCopied] = useState(false);\n\n const create = async (event: FormEvent) => {\n event.preventDefault();\n setCreating(true);\n try {\n const created: any = await api.createApiKey({ body: { name } });\n setFreshToken(created.token);\n setKeys(await (api.listApiKeys() as Promise<any>));\n setName(\"\");\n setCreateOpen(false);\n } catch (error: any) {\n toaster.show(\n error?.message ??\n tr(\"account.keys.createError\", {\n default: \"Could not create that key\",\n }),\n \"danger\",\n );\n } finally {\n setCreating(false);\n }\n };\n\n const revoke = async (key: ApiKeyRow) => {\n const ok = await dialog.confirm({\n title: tr(\"account.keys.revokeTitle\", {\n default: \"Revoke $1?\",\n args: [key.name],\n }),\n description: tr(\"account.keys.revokeDescription\", {\n default:\n \"Anything still using this key stops working immediately. This cannot be undone.\",\n }),\n confirmLabel: tr(\"account.keys.revoke\", { default: \"Revoke\" }),\n destructive: true,\n });\n if (!ok) {\n return;\n }\n try {\n await api.revokeMyApiKey({ params: { id: key.id } });\n setKeys((prev) => prev.filter((it) => it.id !== key.id));\n } catch (error: any) {\n toaster.show(\n error?.message ??\n tr(\"account.keys.revokeError\", {\n default: \"Could not revoke that key\",\n }),\n \"danger\",\n );\n }\n };\n\n const copy = async () => {\n if (!freshToken) {\n return;\n }\n await navigator.clipboard.writeText(freshToken);\n setCopied(true);\n };\n\n return (\n <>\n <SettingsSection\n title={tr(\"account.keys.title\", { default: \"API keys\" })}\n description={tr(\"account.keys.description\", {\n default: \"Keys act as you. Revoke any you no longer recognise.\",\n })}\n >\n {keys.map((key) => (\n <SettingsRow\n key={key.id}\n label={key.name}\n description={\n tr(\"account.keys.createdAt\", {\n default: \"…$1 · created $2\",\n args: [key.tokenSuffix, dt.of(key.createdAt).fromNow()],\n }) +\n (key.lastUsedAt\n ? tr(\"account.keys.lastUsedAt\", {\n default: \" · last used $1\",\n args: [dt.of(key.lastUsedAt).fromNow()],\n })\n : tr(\"account.keys.neverUsed\", { default: \" · never used\" }))\n }\n >\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => revoke(key)}\n aria-label={tr(\"account.keys.revokeAria\", {\n default: \"Revoke $1\",\n args: [key.name],\n })}\n >\n <Trash2 className=\"size-4\" />\n </Button>\n </SettingsRow>\n ))}\n\n <SettingsRow\n label={tr(\"account.keys.create\", { default: \"Create a key\" })}\n description={tr(\"account.keys.createDescription\", {\n default:\n \"Shown once, at creation. It cannot be recovered afterwards.\",\n })}\n >\n <Button\n variant=\"secondary\"\n size=\"sm\"\n onClick={() => setCreateOpen(true)}\n >\n <Plus className=\"size-4\" />\n {tr(\"account.keys.new\", { default: \"New key\" })}\n </Button>\n </SettingsRow>\n </SettingsSection>\n\n <Dialog open={createOpen} onOpenChange={setCreateOpen}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n {tr(\"account.keys.newTitle\", { default: \"New API key\" })}\n </DialogTitle>\n </DialogHeader>\n <form onSubmit={create} className=\"flex flex-col gap-4\">\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor=\"apiKeyName\">\n {tr(\"account.keys.name\", { default: \"Name\" })}\n </Label>\n <Input\n id=\"apiKeyName\"\n value={name}\n onChange={(event) => setName(event.target.value)}\n placeholder={tr(\"account.keys.namePlaceholder\", {\n default: \"CI pipeline\",\n })}\n required\n />\n </div>\n {/* `DialogFooter`, not a hand-rolled row: the border-top, the\n tinted band and the rounded bottom live there, and they are\n what every imperative dialog (`useDialog`'s confirm and\n prompt) already looks like. These floated their buttons on\n the body surface instead (feedback #P2143 asked for it\n generically, from Lore's estate dialog). */}\n <DialogFooter>\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={() => setCreateOpen(false)}\n >\n {tr(\"account.keys.cancel\", { default: \"Cancel\" })}\n </Button>\n <Button type=\"submit\" disabled={creating}>\n {tr(\"account.keys.submit\", { default: \"Create\" })}\n </Button>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n\n {/* Deliberately not auto-dismissed: this is the only time the token\n exists in a readable form. */}\n <Dialog\n open={Boolean(freshToken)}\n onOpenChange={(next) => {\n if (!next) {\n setFreshToken(undefined);\n setCopied(false);\n }\n }}\n >\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n {tr(\"account.keys.revealTitle\", { default: \"Copy your key now\" })}\n </DialogTitle>\n </DialogHeader>\n <div className=\"flex flex-col gap-4\">\n <span className=\"text-muted-foreground text-sm\">\n {tr(\"account.keys.revealDescription\", {\n default:\n \"This is the only time it is shown. Store it somewhere safe before closing this dialog.\",\n })}\n </span>\n <code className=\"bg-muted rounded-md border p-3 font-mono text-xs break-all\">\n {freshToken}\n </code>\n <DialogFooter>\n <Button variant=\"secondary\" onClick={copy}>\n {copied ? (\n <Check className=\"size-4\" />\n ) : (\n <Clipboard className=\"size-4\" />\n )}\n {copied\n ? tr(\"account.keys.copied\", { default: \"Copied\" })\n : tr(\"account.keys.copy\", { default: \"Copy\" })}\n </Button>\n <Button\n onClick={() => {\n setFreshToken(undefined);\n setCopied(false);\n }}\n >\n {tr(\"account.keys.done\", { default: \"Done\" })}\n </Button>\n </DialogFooter>\n </div>\n </DialogContent>\n </Dialog>\n </>\n );\n};\n\nexport default AccountKeys;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,eAAe,UAA4B;CAC/C,MAAM,MAAM,UAA4B;CACxC,MAAM,KAAK,UAAU,gBAAgB;CACrC,MAAM,SAAS,UAAU;CACzB,MAAM,UAAU,SAAS;CACzB,MAAM,EAAE,OAAO,QAAQ;CAEvB,MAAM,CAAC,MAAM,WAAW,SAAsB,MAAM,WAAW,CAAC,CAAC;CACjE,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,CAAC,MAAM,WAAW,SAAS,EAAE;CACnC,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,YAAY,iBAAiB,SAA6B;CACjE,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAE1C,MAAM,SAAS,OAAO,UAAqB;EACzC,MAAM,eAAe;EACrB,YAAY,IAAI;EAChB,IAAI;GACF,MAAM,UAAe,MAAM,IAAI,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;GAC9D,cAAc,QAAQ,KAAK;GAC3B,QAAQ,MAAO,IAAI,YAAY,CAAkB;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A,CAAA;IACX;GACQ,CAAA,CAAA,EAAA,CAAA;EACT,CAAA;CACR,EAAA,CAAA;AAEN"}
|
|
@@ -101,10 +101,7 @@ const AccountMfaDialog = (props) => {
|
|
|
101
101
|
}),
|
|
102
102
|
/* @__PURE__ */ jsxs("details", {
|
|
103
103
|
className: "text-muted-foreground text-center text-xs",
|
|
104
|
-
children: [/* @__PURE__ */ jsx("summary", {
|
|
105
|
-
className: "cursor-pointer",
|
|
106
|
-
children: tr("account.mfa.cannotScan", { default: "Cannot scan the code?" })
|
|
107
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
104
|
+
children: [/* @__PURE__ */ jsx("summary", { children: tr("account.mfa.cannotScan", { default: "Cannot scan the code?" }) }), /* @__PURE__ */ jsx("p", {
|
|
108
105
|
className: "mt-2 font-mono break-all",
|
|
109
106
|
children: enrollment.secret
|
|
110
107
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-mfa-dialog.js","names":[],"sources":["../../../src/components/account/account-mfa-dialog.tsx"],"sourcesContent":["import { Alert, AlertDescription } from \"@alepha/ui/components/ui/alert\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogHeader,\n DialogTitle,\n} from \"@alepha/ui/components/ui/dialog\";\nimport {\n InputOTP,\n InputOTPGroup,\n InputOTPSlot,\n} from \"@alepha/ui/components/ui/input-otp\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport type { MyMfaController } from \"alepha/api/users\";\nimport { useClient, useQuery } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { AlertTriangle } from \"lucide-react\";\nimport { useState } from \"react\";\n\n/**\n * What `enrollTotp` hands back: the secret in clear, the `otpauth://` URI,\n * and that URI already rendered as an SVG QR code.\n */\ninterface TotpEnrollment {\n secret: string;\n uri: string;\n qrSvg: string;\n}\n\nexport interface AccountMfaDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /**\n * Called after enrollment completes, so the caller can refresh its status.\n */\n onDone?: () => void | Promise<void>;\n}\n\n/**\n * Enroll an authenticator app: scan, confirm, then write down the recovery\n * codes.\n *\n * The recovery-code step is not a formality and is deliberately hard to\n * skip past. The secret is stored encrypted and the codes hashed, so this\n * dialog is the only moment either can ever be displayed; a user who closes\n * it without keeping the codes has no way back in if they lose the phone,\n * short of an administrator resetting the factor for them.\n */\nexport const AccountMfaDialog = (props: AccountMfaDialogProps) => {\n const api = useClient<MyMfaController>();\n const toaster = useToast();\n const { tr } = useI18n();\n\n const [code, setCode] = useState(\"\");\n const [recoveryCodes, setRecoveryCodes] = useState<string[]>();\n const [submitting, setSubmitting] = useState(false);\n\n /**\n * A fresh enrollment is started each time the dialog opens, and the\n * previous pending one is replaced server-side. `enabled` keys it to\n * `props.open` so nothing is issued for a dialog nobody asked for.\n */\n const { data: enrollment, error } = useQuery<TotpEnrollment>(\n {\n enabled: props.open,\n handler: () => api.enrollTotp() as Promise<TotpEnrollment>,\n },\n [props.open],\n );\n\n /**\n * Closing resets the transient state, so reopening does not flash the\n * previous run's recovery codes at whoever is next at the keyboard.\n */\n const setOpen = (open: boolean) => {\n if (!open) {\n setCode(\"\");\n setRecoveryCodes(undefined);\n }\n props.onOpenChange(open);\n };\n\n const activate = async (value: string) => {\n setSubmitting(true);\n try {\n const result = await api.activateTotp({ body: { code: value } });\n setRecoveryCodes(result.recoveryCodes);\n await props.onDone?.();\n } catch (error: any) {\n setCode(\"\");\n toaster.show(\n error?.message ??\n tr(\"account.mfa.invalidCode\", { default: \"That code is not valid\" }),\n \"danger\",\n );\n } finally {\n setSubmitting(false);\n }\n };\n\n return (\n <Dialog open={props.open} onOpenChange={setOpen}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n {recoveryCodes\n ? tr(\"account.mfa.recoveryTitle\", {\n default: \"Save your recovery codes\",\n })\n : tr(\"account.mfa.setupTitle\", {\n default: \"Set up two-factor authentication\",\n })}\n </DialogTitle>\n </DialogHeader>\n\n {recoveryCodes ? (\n <div className=\"flex flex-col gap-4\">\n <Alert>\n <AlertTriangle className=\"size-4\" />\n <AlertDescription>\n {tr(\"account.mfa.recoveryDescription\", {\n default:\n \"Keep these somewhere safe. Each one works once, and this is the only time they can be shown.\",\n })}\n </AlertDescription>\n </Alert>\n\n <div className=\"bg-muted grid grid-cols-2 gap-2 rounded-lg p-4 font-mono text-sm\">\n {recoveryCodes.map((recovery) => (\n <span key={recovery}>{recovery}</span>\n ))}\n </div>\n\n <Button\n variant=\"secondary\"\n onClick={() => {\n void navigator.clipboard?.writeText(recoveryCodes.join(\"\\n\"));\n toaster.show(\n tr(\"account.mfa.recoveryCopied\", {\n default: \"Recovery codes copied\",\n }),\n \"success\",\n );\n }}\n >\n {tr(\"account.mfa.copyCodes\", { default: \"Copy codes\" })}\n </Button>\n\n <Button onClick={() => setOpen(false)}>\n {tr(\"account.mfa.saved\", { default: \"I have saved them\" })}\n </Button>\n </div>\n ) : (\n <div className=\"flex flex-col gap-4\">\n <p className=\"text-muted-foreground text-sm\">\n {tr(\"account.mfa.setupDescription\", {\n default:\n \"Scan this with your authenticator app, then type the six-digit code it shows.\",\n })}\n </p>\n\n {error && (\n <Alert variant=\"destructive\">\n <AlertTriangle className=\"size-4\" />\n <AlertDescription>\n {tr(\"account.mfa.enrollError\", {\n default:\n \"Could not start the enrollment. Close this and try again.\",\n })}\n </AlertDescription>\n </Alert>\n )}\n\n {enrollment ? (\n <>\n <div\n className=\"mx-auto w-48 rounded-lg bg-white p-3 [&>svg]:w-full\"\n // The QR is generated server-side, from a URI the server\n // built itself. No user input reaches it.\n dangerouslySetInnerHTML={{ __html: enrollment.qrSvg }}\n />\n\n <details className=\"text-muted-foreground text-center text-xs\">\n <summary className=\"cursor-pointer\">\n {tr(\"account.mfa.cannotScan\", {\n default: \"Cannot scan the code?\",\n })}\n </summary>\n <p className=\"mt-2 font-mono break-all\">\n {enrollment.secret}\n </p>\n </details>\n\n <div className=\"flex justify-center\">\n <InputOTP\n maxLength={6}\n value={code}\n disabled={submitting}\n onChange={(value: string) => {\n setCode(value);\n if (value.length === 6) {\n void activate(value);\n }\n }}\n >\n <InputOTPGroup>\n {[0, 1, 2, 3, 4, 5].map((index) => (\n <InputOTPSlot key={index} index={index} />\n ))}\n </InputOTPGroup>\n </InputOTP>\n </div>\n\n <Button\n loading={submitting}\n disabled={code.length !== 6}\n onClick={() => activate(code)}\n >\n {tr(\"account.mfa.turnOn\", { default: \"Turn on\" })}\n </Button>\n </>\n ) : (\n <p className=\"text-muted-foreground text-center text-sm\">\n {tr(\"account.mfa.preparing\", { default: \"Preparing...\" })}\n </p>\n )}\n </div>\n )}\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiDA,MAAa,oBAAoB,UAAiC;CAChE,MAAM,MAAM,UAA2B;CACvC,MAAM,UAAU,SAAS;CACzB,MAAM,EAAE,OAAO,QAAQ;CAEvB,MAAM,CAAC,MAAM,WAAW,SAAS,EAAE;CACnC,MAAM,CAAC,eAAe,oBAAoB,SAAmB;CAC7D,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;;;;;;CAOlD,MAAM,EAAE,MAAM,YAAY,UAAU,SAClC;EACE,SAAS,MAAM;EACf,eAAe,IAAI,WAAW;CAChC,GACA,CAAC,MAAM,IAAI,CACb;;;;;CAMA,MAAM,WAAW,SAAkB;EACjC,IAAI,CAAC,MAAM;GACT,QAAQ,EAAE;GACV,iBAAiB,KAAA,CAAS;EAC5B;EACA,MAAM,aAAa,IAAI;CACzB;CAEA,MAAM,WAAW,OAAO,UAAkB;EACxC,cAAc,IAAI;EAClB,IAAI;GACF,MAAM,SAAS,MAAM,IAAI,aAAa,EAAE,MAAM,EAAE,MAAM,MAAM,EAAE,CAAC;GAC/D,iBAAiB,OAAO,aAAa;GACrC,MAAM,MAAM,SAAS;EACvB,SAAS,OAAY;GACnB,QAAQ,EAAE;GACV,QAAQ,KACN,OAAO,WACL,GAAG,2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AAD,EAAe,WAAU,SAAU,CAAA,GACnC,oBAAC,kBAAD,EAAA,UACG,GAAG,2BAA2B,EAC7B,SACE,4DACJ,CAAC,EACe,CAAA,CACb;;IAGR,aACC,qBAAA,YAAA,EAAA,UAAA;KACE,oBAAC,OAAD;MACE,WAAU;MAGV,yBAAyB,EAAE,QAAQ,WAAW,MAAM;KACrD,CAAA;KAED,qBAAC,WAAD;MAAS,WAAU;MAAnB,UAAA,CACE,oBAAC,WAAD;OAAS,WAAU;OAChB,UAAA,GAAG,0BAA0B,EAC5B,SAAS,wBACX,CAAC;MACM,CAAA,GACT,oBAAC,KAAD;OAAG,WAAU;OACV,UAAA,WAAW;MACX,CAAA,CACI;;KAET,oBAAC,OAAD;MAAK,WAAU;MACb,UAAA,oBAAC,UAAD;OACE,WAAW;OACX,OAAO;OACP,UAAU;OACV,WAAW,UAAkB;QAC3B,QAAQ,KAAK;QACb,IAAI,MAAM,WAAW,GACnB,SAAc,KAAK;OAEvB;OAEA,UAAA,oBAAC,eAAD,EAAA,UACG;QAAC;QAAG;QAAG;QAAG;QAAG;QAAG;OAAC,CAAC,CAAC,KAAK,UACvB,oBAAC,cAAD,EAAiC,MAAQ,GAAtB,KAAsB,CAC1C,EACY,CAAA;MACP,CAAA;KACP,CAAA;KAEL,oBAAC,QAAD;MACE,SAAS;MACT,UAAU,KAAK,WAAW;MAC1B,eAAe,SAAS,IAAI;MAE3B,UAAA,GAAG,sBAAsB,EAAE,SAAS,UAAU,CAAC;KAC1C,CAAA;IACR,EAAA,CAAA,IAEF,oBAAC,KAAD;KAAG,WAAU;KACV,UAAA,GAAG,yBAAyB,EAAE,SAAS,eAAe,CAAC;IACvD,CAAA;GAEF;EAEM,CAAA,CAAA,EAAA,CAAA;CACT,CAAA;AAEZ"}
|
|
1
|
+
{"version":3,"file":"account-mfa-dialog.js","names":[],"sources":["../../../src/components/account/account-mfa-dialog.tsx"],"sourcesContent":["import { Alert, AlertDescription } from \"@alepha/ui/components/ui/alert\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogHeader,\n DialogTitle,\n} from \"@alepha/ui/components/ui/dialog\";\nimport {\n InputOTP,\n InputOTPGroup,\n InputOTPSlot,\n} from \"@alepha/ui/components/ui/input-otp\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport type { MyMfaController } from \"alepha/api/users\";\nimport { useClient, useQuery } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { AlertTriangle } from \"lucide-react\";\nimport { useState } from \"react\";\n\n/**\n * What `enrollTotp` hands back: the secret in clear, the `otpauth://` URI,\n * and that URI already rendered as an SVG QR code.\n */\ninterface TotpEnrollment {\n secret: string;\n uri: string;\n qrSvg: string;\n}\n\nexport interface AccountMfaDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /**\n * Called after enrollment completes, so the caller can refresh its status.\n */\n onDone?: () => void | Promise<void>;\n}\n\n/**\n * Enroll an authenticator app: scan, confirm, then write down the recovery\n * codes.\n *\n * The recovery-code step is not a formality and is deliberately hard to\n * skip past. The secret is stored encrypted and the codes hashed, so this\n * dialog is the only moment either can ever be displayed; a user who closes\n * it without keeping the codes has no way back in if they lose the phone,\n * short of an administrator resetting the factor for them.\n */\nexport const AccountMfaDialog = (props: AccountMfaDialogProps) => {\n const api = useClient<MyMfaController>();\n const toaster = useToast();\n const { tr } = useI18n();\n\n const [code, setCode] = useState(\"\");\n const [recoveryCodes, setRecoveryCodes] = useState<string[]>();\n const [submitting, setSubmitting] = useState(false);\n\n /**\n * A fresh enrollment is started each time the dialog opens, and the\n * previous pending one is replaced server-side. `enabled` keys it to\n * `props.open` so nothing is issued for a dialog nobody asked for.\n */\n const { data: enrollment, error } = useQuery<TotpEnrollment>(\n {\n enabled: props.open,\n handler: () => api.enrollTotp() as Promise<TotpEnrollment>,\n },\n [props.open],\n );\n\n /**\n * Closing resets the transient state, so reopening does not flash the\n * previous run's recovery codes at whoever is next at the keyboard.\n */\n const setOpen = (open: boolean) => {\n if (!open) {\n setCode(\"\");\n setRecoveryCodes(undefined);\n }\n props.onOpenChange(open);\n };\n\n const activate = async (value: string) => {\n setSubmitting(true);\n try {\n const result = await api.activateTotp({ body: { code: value } });\n setRecoveryCodes(result.recoveryCodes);\n await props.onDone?.();\n } catch (error: any) {\n setCode(\"\");\n toaster.show(\n error?.message ??\n tr(\"account.mfa.invalidCode\", { default: \"That code is not valid\" }),\n \"danger\",\n );\n } finally {\n setSubmitting(false);\n }\n };\n\n return (\n <Dialog open={props.open} onOpenChange={setOpen}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n {recoveryCodes\n ? tr(\"account.mfa.recoveryTitle\", {\n default: \"Save your recovery codes\",\n })\n : tr(\"account.mfa.setupTitle\", {\n default: \"Set up two-factor authentication\",\n })}\n </DialogTitle>\n </DialogHeader>\n\n {recoveryCodes ? (\n <div className=\"flex flex-col gap-4\">\n <Alert>\n <AlertTriangle className=\"size-4\" />\n <AlertDescription>\n {tr(\"account.mfa.recoveryDescription\", {\n default:\n \"Keep these somewhere safe. Each one works once, and this is the only time they can be shown.\",\n })}\n </AlertDescription>\n </Alert>\n\n <div className=\"bg-muted grid grid-cols-2 gap-2 rounded-lg p-4 font-mono text-sm\">\n {recoveryCodes.map((recovery) => (\n <span key={recovery}>{recovery}</span>\n ))}\n </div>\n\n <Button\n variant=\"secondary\"\n onClick={() => {\n void navigator.clipboard?.writeText(recoveryCodes.join(\"\\n\"));\n toaster.show(\n tr(\"account.mfa.recoveryCopied\", {\n default: \"Recovery codes copied\",\n }),\n \"success\",\n );\n }}\n >\n {tr(\"account.mfa.copyCodes\", { default: \"Copy codes\" })}\n </Button>\n\n <Button onClick={() => setOpen(false)}>\n {tr(\"account.mfa.saved\", { default: \"I have saved them\" })}\n </Button>\n </div>\n ) : (\n <div className=\"flex flex-col gap-4\">\n <p className=\"text-muted-foreground text-sm\">\n {tr(\"account.mfa.setupDescription\", {\n default:\n \"Scan this with your authenticator app, then type the six-digit code it shows.\",\n })}\n </p>\n\n {error && (\n <Alert variant=\"destructive\">\n <AlertTriangle className=\"size-4\" />\n <AlertDescription>\n {tr(\"account.mfa.enrollError\", {\n default:\n \"Could not start the enrollment. Close this and try again.\",\n })}\n </AlertDescription>\n </Alert>\n )}\n\n {enrollment ? (\n <>\n <div\n className=\"mx-auto w-48 rounded-lg bg-white p-3 [&>svg]:w-full\"\n // The QR is generated server-side, from a URI the server\n // built itself. No user input reaches it.\n dangerouslySetInnerHTML={{ __html: enrollment.qrSvg }}\n />\n\n <details className=\"text-muted-foreground text-center text-xs\">\n <summary>\n {tr(\"account.mfa.cannotScan\", {\n default: \"Cannot scan the code?\",\n })}\n </summary>\n <p className=\"mt-2 font-mono break-all\">\n {enrollment.secret}\n </p>\n </details>\n\n <div className=\"flex justify-center\">\n <InputOTP\n maxLength={6}\n value={code}\n disabled={submitting}\n onChange={(value: string) => {\n setCode(value);\n if (value.length === 6) {\n void activate(value);\n }\n }}\n >\n <InputOTPGroup>\n {[0, 1, 2, 3, 4, 5].map((index) => (\n <InputOTPSlot key={index} index={index} />\n ))}\n </InputOTPGroup>\n </InputOTP>\n </div>\n\n <Button\n loading={submitting}\n disabled={code.length !== 6}\n onClick={() => activate(code)}\n >\n {tr(\"account.mfa.turnOn\", { default: \"Turn on\" })}\n </Button>\n </>\n ) : (\n <p className=\"text-muted-foreground text-center text-sm\">\n {tr(\"account.mfa.preparing\", { default: \"Preparing...\" })}\n </p>\n )}\n </div>\n )}\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiDA,MAAa,oBAAoB,UAAiC;CAChE,MAAM,MAAM,UAA2B;CACvC,MAAM,UAAU,SAAS;CACzB,MAAM,EAAE,OAAO,QAAQ;CAEvB,MAAM,CAAC,MAAM,WAAW,SAAS,EAAE;CACnC,MAAM,CAAC,eAAe,oBAAoB,SAAmB;CAC7D,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;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C,MAAQ,GAAtB,KAAsB,CAC1C,EACY,CAAA;MACP,CAAA;KACP,CAAA;KAEL,oBAAC,QAAD;MACE,SAAS;MACT,UAAU,KAAK,WAAW;MAC1B,eAAe,SAAS,IAAI;MAE3B,UAAA,GAAG,sBAAsB,EAAE,SAAS,UAAU,CAAC;KAC1C,CAAA;IACR,EAAA,CAAA,IAEF,oBAAC,KAAD;KAAG,WAAU;KACV,UAAA,GAAG,yBAAyB,EAAE,SAAS,eAAe,CAAC;IACvD,CAAA;GAEF;EAEM,CAAA,CAAA,EAAA,CAAA;CACT,CAAA;AAEZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-password-dialog.d.ts","sourceRoot":"","sources":["../../../src/components/account/account-password-dialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account-password-dialog.d.ts","sourceRoot":"","sources":["../../../src/components/account/account-password-dialog.tsx"],"names":[],"mappings":"AAkBA,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,OAAO,CAAC;IAEd;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAEtC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,UAAW,0BAA0B,gCAmItE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button } from "../ui/button.js";
|
|
2
2
|
import { useToast } from "../use-toast/use-toast.js";
|
|
3
3
|
import { ControlPassword } from "../control-password/control-password.js";
|
|
4
|
-
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/dialog.js";
|
|
4
|
+
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "../ui/dialog.js";
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { useI18n } from "alepha/react/i18n";
|
|
@@ -102,19 +102,16 @@ const AccountPasswordDialog = (props) => {
|
|
|
102
102
|
autoComplete: "new-password",
|
|
103
103
|
required: true
|
|
104
104
|
}),
|
|
105
|
-
/* @__PURE__ */ jsxs(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
children: title
|
|
116
|
-
})]
|
|
117
|
-
})
|
|
105
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
106
|
+
type: "button",
|
|
107
|
+
variant: "ghost",
|
|
108
|
+
onClick: close,
|
|
109
|
+
children: tr("account.password.cancel", { default: "Cancel" })
|
|
110
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
111
|
+
type: "submit",
|
|
112
|
+
disabled: submitting,
|
|
113
|
+
children: title
|
|
114
|
+
})] })
|
|
118
115
|
]
|
|
119
116
|
})] })
|
|
120
117
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-password-dialog.js","names":[],"sources":["../../../src/components/account/account-password-dialog.tsx"],"sourcesContent":["import { ControlPassword } from \"@alepha/ui/components/control-password/control-password\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogHeader,\n DialogTitle,\n} from \"@alepha/ui/components/ui/dialog\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport type {\n MyIdentityController,\n MyPasswordController,\n} from \"alepha/api/users\";\nimport { useClient } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { type FormEvent, useState } from \"react\";\n\nexport interface AccountPasswordDialogProps {\n open: boolean;\n\n /**\n * Whether the account already has a `credentials` identity. Decides both\n * the copy and — critically — which endpoint is called.\n */\n hasPassword: boolean;\n\n onOpenChange: (open: boolean) => void;\n\n /**\n * Called after a successful change so the caller can refresh its identity\n * list — setting a first password creates one.\n */\n onDone?: () => void | Promise<void>;\n}\n\n/**\n * Set a first password, or change an existing one.\n *\n * ⚠️ **These are two different endpoints and must stay so.**\n * `setMyFirstPassword` takes only the new password and trusts the session,\n * which is defensible when there is nothing to prove knowledge of. Reusing it\n * to *change* a password would make any unattended signed-in browser a full\n * account takeover.\n *\n * `changeMyPassword` verifies the current password and revokes every other\n * session — the usual reason to change a password is believing someone else\n * has it, and leaving their session alive would accomplish nothing. It\n * reports how many it ended, which is why the toast can say so rather than\n * leave the person wondering about their phone.\n */\nexport const AccountPasswordDialog = (props: AccountPasswordDialogProps) => {\n const passwordApi = useClient<MyPasswordController>();\n const identityApi = useClient<MyIdentityController>();\n const toaster = useToast();\n const { tr } = useI18n();\n\n const [currentPassword, setCurrentPassword] = useState(\"\");\n const [password, setPassword] = useState(\"\");\n const [confirmPassword, setConfirmPassword] = useState(\"\");\n const [submitting, setSubmitting] = useState(false);\n\n const close = () => {\n setCurrentPassword(\"\");\n setPassword(\"\");\n setConfirmPassword(\"\");\n props.onOpenChange(false);\n };\n\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n if (password !== confirmPassword) {\n toaster.show(\n tr(\"account.password.mismatch\", {\n default: \"The two passwords do not match\",\n }),\n \"danger\",\n );\n return;\n }\n setSubmitting(true);\n try {\n if (props.hasPassword) {\n const { otherSessionsRevoked } = await passwordApi.changeMyPassword({\n body: { currentPassword, newPassword: password },\n });\n toaster.show(\n otherSessionsRevoked > 0\n ? tr(\"account.password.changedWithSessions\", {\n default: \"Password changed - $1 other session(s) signed out\",\n args: [String(otherSessionsRevoked)],\n })\n : tr(\"account.password.changed\", { default: \"Password changed\" }),\n \"success\",\n );\n } else {\n await identityApi.setMyFirstPassword({ body: { password } });\n toaster.show(\n tr(\"account.password.set\", { default: \"Password set\" }),\n \"success\",\n );\n }\n await props.onDone?.();\n close();\n } catch (error: any) {\n // The realm's password policy and the wrong-current-password refusal\n // both arrive here with messages worth showing verbatim.\n toaster.show(\n error?.message ??\n tr(\"account.password.error\", {\n default: \"Could not save that password\",\n }),\n \"danger\",\n );\n } finally {\n setSubmitting(false);\n }\n };\n\n const title = props.hasPassword\n ? tr(\"account.password.change\", { default: \"Change password\" })\n : tr(\"account.password.setTitle\", { default: \"Set a password\" });\n\n return (\n <Dialog open={props.open} onOpenChange={(next) => !next && close()}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n </DialogHeader>\n <form onSubmit={submit} className=\"flex flex-col gap-4\">\n <span className=\"text-muted-foreground text-sm\">\n {props.hasPassword\n ? tr(\"account.password.changeDescription\", {\n default: \"Every other device will be signed out.\",\n })\n : tr(\"account.password.setDescription\", {\n default:\n \"You will be able to sign in with your password as well as your existing method.\",\n })}\n </span>\n {props.hasPassword ? (\n <ControlPassword\n id=\"currentPassword\"\n label={tr(\"account.password.current\", {\n default: \"Current password\",\n })}\n value={currentPassword}\n onChange={setCurrentPassword}\n autoComplete=\"current-password\"\n required\n />\n ) : null}\n <ControlPassword\n id=\"newPassword\"\n label={tr(\"account.password.new\", { default: \"New password\" })}\n value={password}\n onChange={setPassword}\n autoComplete=\"new-password\"\n required\n />\n <ControlPassword\n id=\"confirmPassword\"\n label={tr(\"account.password.confirm\", {\n default: \"Confirm new password\",\n })}\n value={confirmPassword}\n onChange={setConfirmPassword}\n autoComplete=\"new-password\"\n required\n />\n <
|
|
1
|
+
{"version":3,"file":"account-password-dialog.js","names":[],"sources":["../../../src/components/account/account-password-dialog.tsx"],"sourcesContent":["import { ControlPassword } from \"@alepha/ui/components/control-password/control-password\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from \"@alepha/ui/components/ui/dialog\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport type {\n MyIdentityController,\n MyPasswordController,\n} from \"alepha/api/users\";\nimport { useClient } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { type FormEvent, useState } from \"react\";\n\nexport interface AccountPasswordDialogProps {\n open: boolean;\n\n /**\n * Whether the account already has a `credentials` identity. Decides both\n * the copy and — critically — which endpoint is called.\n */\n hasPassword: boolean;\n\n onOpenChange: (open: boolean) => void;\n\n /**\n * Called after a successful change so the caller can refresh its identity\n * list — setting a first password creates one.\n */\n onDone?: () => void | Promise<void>;\n}\n\n/**\n * Set a first password, or change an existing one.\n *\n * ⚠️ **These are two different endpoints and must stay so.**\n * `setMyFirstPassword` takes only the new password and trusts the session,\n * which is defensible when there is nothing to prove knowledge of. Reusing it\n * to *change* a password would make any unattended signed-in browser a full\n * account takeover.\n *\n * `changeMyPassword` verifies the current password and revokes every other\n * session — the usual reason to change a password is believing someone else\n * has it, and leaving their session alive would accomplish nothing. It\n * reports how many it ended, which is why the toast can say so rather than\n * leave the person wondering about their phone.\n */\nexport const AccountPasswordDialog = (props: AccountPasswordDialogProps) => {\n const passwordApi = useClient<MyPasswordController>();\n const identityApi = useClient<MyIdentityController>();\n const toaster = useToast();\n const { tr } = useI18n();\n\n const [currentPassword, setCurrentPassword] = useState(\"\");\n const [password, setPassword] = useState(\"\");\n const [confirmPassword, setConfirmPassword] = useState(\"\");\n const [submitting, setSubmitting] = useState(false);\n\n const close = () => {\n setCurrentPassword(\"\");\n setPassword(\"\");\n setConfirmPassword(\"\");\n props.onOpenChange(false);\n };\n\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n if (password !== confirmPassword) {\n toaster.show(\n tr(\"account.password.mismatch\", {\n default: \"The two passwords do not match\",\n }),\n \"danger\",\n );\n return;\n }\n setSubmitting(true);\n try {\n if (props.hasPassword) {\n const { otherSessionsRevoked } = await passwordApi.changeMyPassword({\n body: { currentPassword, newPassword: password },\n });\n toaster.show(\n otherSessionsRevoked > 0\n ? tr(\"account.password.changedWithSessions\", {\n default: \"Password changed - $1 other session(s) signed out\",\n args: [String(otherSessionsRevoked)],\n })\n : tr(\"account.password.changed\", { default: \"Password changed\" }),\n \"success\",\n );\n } else {\n await identityApi.setMyFirstPassword({ body: { password } });\n toaster.show(\n tr(\"account.password.set\", { default: \"Password set\" }),\n \"success\",\n );\n }\n await props.onDone?.();\n close();\n } catch (error: any) {\n // The realm's password policy and the wrong-current-password refusal\n // both arrive here with messages worth showing verbatim.\n toaster.show(\n error?.message ??\n tr(\"account.password.error\", {\n default: \"Could not save that password\",\n }),\n \"danger\",\n );\n } finally {\n setSubmitting(false);\n }\n };\n\n const title = props.hasPassword\n ? tr(\"account.password.change\", { default: \"Change password\" })\n : tr(\"account.password.setTitle\", { default: \"Set a password\" });\n\n return (\n <Dialog open={props.open} onOpenChange={(next) => !next && close()}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n </DialogHeader>\n <form onSubmit={submit} className=\"flex flex-col gap-4\">\n <span className=\"text-muted-foreground text-sm\">\n {props.hasPassword\n ? tr(\"account.password.changeDescription\", {\n default: \"Every other device will be signed out.\",\n })\n : tr(\"account.password.setDescription\", {\n default:\n \"You will be able to sign in with your password as well as your existing method.\",\n })}\n </span>\n {props.hasPassword ? (\n <ControlPassword\n id=\"currentPassword\"\n label={tr(\"account.password.current\", {\n default: \"Current password\",\n })}\n value={currentPassword}\n onChange={setCurrentPassword}\n autoComplete=\"current-password\"\n required\n />\n ) : null}\n <ControlPassword\n id=\"newPassword\"\n label={tr(\"account.password.new\", { default: \"New password\" })}\n value={password}\n onChange={setPassword}\n autoComplete=\"new-password\"\n required\n />\n <ControlPassword\n id=\"confirmPassword\"\n label={tr(\"account.password.confirm\", {\n default: \"Confirm new password\",\n })}\n value={confirmPassword}\n onChange={setConfirmPassword}\n autoComplete=\"new-password\"\n required\n />\n <DialogFooter>\n <Button type=\"button\" variant=\"ghost\" onClick={close}>\n {tr(\"account.password.cancel\", { default: \"Cancel\" })}\n </Button>\n <Button type=\"submit\" disabled={submitting}>\n {title}\n </Button>\n </DialogFooter>\n </form>\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,CAAA,EAAA,CAAA;CACT,CAAA;AAEZ"}
|
|
@@ -94,8 +94,9 @@ const AccountProfile = (props) => {
|
|
|
94
94
|
setUploading(false);
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
+
const canEditAvatar = avatarApi.updateMyAvatar.can();
|
|
97
98
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
98
|
-
|
|
99
|
+
canEditAvatar && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SettingsSection, {
|
|
99
100
|
title: tr("account.profile.pictureTitle", { default: "Profile picture" }),
|
|
100
101
|
description: tr("account.profile.pictureDescription", { default: "Shown next to your name wherever you appear." }),
|
|
101
102
|
children: /* @__PURE__ */ jsx(SettingsRow, {
|
|
@@ -108,7 +109,7 @@ const AccountProfile = (props) => {
|
|
|
108
109
|
onClick: () => fileInput.current?.click(),
|
|
109
110
|
disabled: uploading,
|
|
110
111
|
"aria-label": tr("account.profile.avatarChange", { default: "Change avatar" }),
|
|
111
|
-
className: "relative size-14 shrink-0
|
|
112
|
+
className: "relative size-14 shrink-0",
|
|
112
113
|
children: [/* @__PURE__ */ jsx("div", {
|
|
113
114
|
className: "bg-muted size-full overflow-hidden rounded-full border",
|
|
114
115
|
children: /* @__PURE__ */ jsx(FileImage, {
|