@jini-ai/user-management 0.7.1 → 0.7.3-next.1
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/CHANGELOG.md +1 -1
- package/README.md +9 -5
- package/dist/admin/adapters/http.js +25 -20
- package/dist/admin/adapters/memory.js +164 -82
- package/dist/admin/auth.module.d.ts +2 -2
- package/dist/admin/auth.module.js +1 -1
- package/dist/admin/conformance/index.js +40 -18
- package/dist/admin/controllers/auth.controller.js +3 -1
- package/dist/admin/controllers/members.controller.js +56 -31
- package/dist/admin/controllers/roles.controller.d.ts +3 -3
- package/dist/admin/controllers/roles.controller.js +188 -122
- package/dist/admin/controllers/users.controller.js +151 -72
- package/dist/admin/members.module.d.ts +2 -2
- package/dist/admin/members.module.js +1 -1
- package/dist/admin/models.d.ts +1 -0
- package/dist/admin/ports.d.ts +3 -0
- package/dist/admin/react/components/DestructiveDialog.d.ts +1 -1
- package/dist/admin/react/components/DestructiveDialog.js +1 -1
- package/dist/admin/react/components/MemberRow.d.ts +3 -1
- package/dist/admin/react/components/MemberRow.js +2 -2
- package/dist/admin/react/components/MembersConfirmation.d.ts +4 -1
- package/dist/admin/react/components/MembersConfirmation.js +2 -2
- package/dist/admin/react/components/PermissionPanel.d.ts +4 -2
- package/dist/admin/react/components/PermissionPanel.js +2 -2
- package/dist/admin/react/components/PolicyRow.d.ts +4 -2
- package/dist/admin/react/components/PolicyRow.js +2 -2
- package/dist/admin/react/components/RoleRow.d.ts +4 -2
- package/dist/admin/react/components/RoleRow.js +2 -2
- package/dist/admin/react/components/UserRow.d.ts +3 -1
- package/dist/admin/react/components/UserRow.js +2 -2
- package/dist/admin/react/components/UsersConfirmation.d.ts +4 -1
- package/dist/admin/react/components/UsersConfirmation.js +2 -2
- package/dist/admin/react/hooks/AuthBinding.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/AuthScope.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/MembersBinding.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/MembersScope.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/PeopleController.hooks.js +6 -4
- package/dist/admin/react/hooks/RolesBinding.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/RolesController.hooks.d.ts +4 -4
- package/dist/admin/react/hooks/RolesController.hooks.js +4 -3
- package/dist/admin/react/hooks/RolesPage.hooks.d.ts +8 -8
- package/dist/admin/react/hooks/RolesScope.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/UsersBinding.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/UsersScope.hooks.d.ts +1 -1
- package/dist/admin/react/index.d.ts +9 -9
- package/dist/admin/react/pages/LoginPage.d.ts +4 -1
- package/dist/admin/react/pages/LoginPage.js +2 -2
- package/dist/admin/react/pages/MembersPage.d.ts +4 -1
- package/dist/admin/react/pages/MembersPage.js +2 -2
- package/dist/admin/react/pages/RolesPage.d.ts +4 -1
- package/dist/admin/react/pages/RolesPage.js +2 -2
- package/dist/admin/react/pages/UsersPage.d.ts +4 -1
- package/dist/admin/react/pages/UsersPage.js +2 -2
- package/dist/admin/react/tabs/AuthTab.d.ts +4 -2
- package/dist/admin/react/tabs/AuthTab.js +2 -2
- package/dist/admin/react/tabs/MembersTab.d.ts +4 -2
- package/dist/admin/react/tabs/MembersTab.js +2 -2
- package/dist/admin/react/tabs/PoliciesTab.d.ts +4 -2
- package/dist/admin/react/tabs/PoliciesTab.js +2 -2
- package/dist/admin/react/tabs/RolesTab.d.ts +4 -2
- package/dist/admin/react/tabs/RolesTab.js +2 -2
- package/dist/admin/react/tabs/UsersTab.d.ts +3 -1
- package/dist/admin/react/tabs/UsersTab.js +2 -2
- package/dist/admin/roles.module.d.ts +2 -2
- package/dist/admin/roles.module.js +1 -1
- package/dist/admin/users.module.d.ts +4 -4
- package/dist/admin/users.module.js +1 -1
- package/dist/react/auth/Login.js +1 -1
- package/dist/react/auth/OwnerRecovery.hooks.d.ts +93 -0
- package/dist/react/auth/OwnerRecovery.hooks.js +105 -0
- package/dist/react/auth/Passkeys.d.ts +8 -3
- package/dist/react/auth/Passkeys.hooks.d.ts +38 -0
- package/dist/react/auth/Passkeys.hooks.js +72 -0
- package/dist/react/auth/Passkeys.js +6 -64
- package/dist/react/auth/TotpSettings.d.ts +5 -2
- package/dist/react/auth/TotpSettings.hooks.d.ts +41 -0
- package/dist/react/auth/TotpSettings.hooks.js +82 -0
- package/dist/react/auth/TotpSettings.js +10 -77
- package/dist/react/auth/hooks/use-login.hooks.d.ts +1 -1
- package/dist/react/auth/hooks/use-login.hooks.js +1 -0
- package/dist/react/errors.d.ts +1 -1
- package/dist/react/errors.js +1 -0
- package/dist/react/index.d.ts +6 -2
- package/dist/react/index.js +3 -1
- package/dist/react/kit.d.ts +91 -0
- package/dist/react/kit.js +63 -0
- package/dist/react/members/Members.d.ts +1 -1
- package/dist/react/members/Members.js +19 -5
- package/dist/react/members/hooks/use-members.hooks.d.ts +1 -1
- package/dist/react/members/hooks/use-members.hooks.js +49 -27
- package/dist/react/members/rules.d.ts +2 -2
- package/dist/react/members/rules.js +1 -0
- package/dist/react/ports.d.ts +2 -0
- package/dist/react/testing.js +47 -22
- package/dist/react/users/ChangeUsernameDialog.d.ts +2 -2
- package/dist/react/users/ChangeUsernameDialog.js +4 -3
- package/dist/react/users/UserRowParts.d.ts +3 -3
- package/dist/react/users/UserRowParts.js +2 -1
- package/dist/react/users/Users.d.ts +3 -3
- package/dist/react/users/Users.js +14 -27
- package/dist/react/users/UsersDialogs.d.ts +7 -0
- package/dist/react/users/UsersDialogs.js +64 -0
- package/dist/react/users/UsersTable.d.ts +118 -0
- package/dist/react/users/UsersTable.js +55 -0
- package/dist/react/users/hooks/use-change-username.hooks.d.ts +1 -1
- package/dist/react/users/hooks/use-change-username.hooks.js +2 -1
- package/dist/react/users/hooks/use-reset-password-fields.hooks.d.ts +8 -0
- package/dist/react/users/hooks/use-reset-password-fields.hooks.js +11 -0
- package/dist/react/users/hooks/use-users-form-state.hooks.d.ts +81 -0
- package/dist/react/users/hooks/use-users-form-state.hooks.js +68 -0
- package/dist/react/users/hooks/use-users-password.hooks.d.ts +24 -0
- package/dist/react/users/hooks/use-users-password.hooks.js +85 -0
- package/dist/react/users/hooks/use-users-roster.hooks.d.ts +42 -0
- package/dist/react/users/hooks/use-users-roster.hooks.js +133 -0
- package/dist/react/users/hooks/use-users-state.hooks.d.ts +102 -0
- package/dist/react/users/hooks/use-users-state.hooks.js +19 -0
- package/dist/react/users/hooks/use-users-status.hooks.d.ts +26 -0
- package/dist/react/users/hooks/use-users-status.hooks.js +97 -0
- package/dist/react/users/hooks/use-users.hooks.d.ts +13 -5
- package/dist/react/users/hooks/use-users.hooks.js +23 -503
- package/dist/react/users/hooks/users-controller.d.ts +14 -0
- package/dist/react/users/hooks/users-controller.js +29 -0
- package/dist/react/users/hooks/users-grant-actions.d.ts +26 -0
- package/dist/react/users/hooks/users-grant-actions.js +124 -0
- package/dist/react/users/rules.d.ts +5 -4
- package/dist/react/users/rules.js +3 -2
- package/dist/server/admin-crud-service.d.ts +2 -2
- package/dist/server/admin-crud-service.js +38 -71
- package/dist/server/agent-tool-input.d.ts +7 -3
- package/dist/server/agent-tool-input.js +47 -14
- package/dist/server/agent-tool-registrations.d.ts +5 -2
- package/dist/server/agent-tool-registrations.js +250 -199
- package/dist/server/agent-tools.d.ts +1 -1
- package/dist/server/auth-service.js +1 -1
- package/dist/server/grant-service.d.ts +8 -0
- package/dist/server/grant-service.js +24 -22
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/link-policy.d.ts +23 -0
- package/dist/server/link-policy.js +30 -0
- package/dist/server/permission-migrations.d.ts +3 -3
- package/dist/server/repo.memory-transactions.js +24 -20
- package/dist/server/repo.memory.d.ts +21 -33
- package/dist/server/repo.memory.js +13 -34
- package/dist/server/seed.d.ts +3 -3
- package/dist/server/seed.js +10 -10
- package/dist/session-bootstrap/ensure.d.ts +13 -0
- package/dist/session-bootstrap/ensure.js +11 -0
- package/dist/session-bootstrap/index.d.ts +5 -0
- package/dist/session-bootstrap/index.js +4 -0
- package/dist/session-bootstrap/loopback.d.ts +14 -0
- package/dist/session-bootstrap/loopback.js +25 -0
- package/dist/session-bootstrap/read-initial.d.ts +25 -0
- package/dist/session-bootstrap/read-initial.js +27 -0
- package/package.json +20 -24
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from "react";
|
|
3
|
-
import { RowMenu, ConfirmDialog } from "
|
|
4
|
-
import { agentHandle } from "@jini-ai/
|
|
5
|
-
import { buildAgentListHandles } from "@jini-ai/ui/panel-kit";
|
|
3
|
+
import { RowMenu, ConfirmDialog, InfoTip, SecretInput } from "../kit.js";
|
|
4
|
+
import { agentHandle, buildAgentListHandles } from "@jini-ai/core/agent-handles";
|
|
6
5
|
import { grantOptionLabel } from "./rules.js";
|
|
7
6
|
import { UserGrantCells, UserNameCell, UserStatusCell, userRowMenuItemsFor } from "./UserRowParts.js";
|
|
8
7
|
import { useUsers } from "./hooks/use-users.hooks.js";
|
|
9
|
-
import {
|
|
10
|
-
import { SecretInput } from "@jini-ai/ui";
|
|
11
|
-
import { useResetPasswordFields } from "./hooks/use-reset-password-fields.hooks.js";
|
|
8
|
+
import { createResetPasswordConfirmHandler, useResetPasswordFields } from "./hooks/use-reset-password-fields.hooks.js";
|
|
12
9
|
import { ChangeUsernameDialog } from "./ChangeUsernameDialog.js";
|
|
10
|
+
import {} from '@jini-ai/core/text';
|
|
13
11
|
/** The "New user" form — extracted from `Users` verbatim; own scope for `formError`/`saving`. */
|
|
14
12
|
function NewUserForm({ username, setUsername, email, setEmail, password, setPassword, saving, formError, onCreate, t }) {
|
|
15
13
|
const passwordInputId = useId();
|
|
@@ -95,28 +93,18 @@ function RevealablePasswordField({ id, label, value, onChange, visible, onToggle
|
|
|
95
93
|
label: `${label} — a credential field, so only a human can fill it`,
|
|
96
94
|
}) })] }));
|
|
97
95
|
}
|
|
98
|
-
/** Resolves `useFields` to the real hook when no override is passed, because ESLint's
|
|
99
|
-
* cyclomatic-complexity rule counts a default parameter value evaluated inside a function's OWN
|
|
100
|
-
* body as one of that function's own branches; a call out to a separately-scoped resolver does
|
|
101
|
-
* not. */
|
|
102
|
-
function resolveResetPasswordFieldsHook(override) {
|
|
103
|
-
return override ?? useResetPasswordFields;
|
|
104
|
-
}
|
|
105
96
|
/** The reset-password dialog — extracted from `Users` verbatim, since extended with the confirm
|
|
106
97
|
* field and both reveal toggles (see this file's header). */
|
|
107
|
-
function UserResetPasswordDialog({ resetPasswordFor, setResetPasswordFor, newPassword, setNewPassword, passwordError, setPasswordError, passwordSaving, confirmResetPassword, t,
|
|
108
|
-
|
|
98
|
+
function UserResetPasswordDialog({ resetPasswordFor, setResetPasswordFor, newPassword, setNewPassword, passwordError, setPasswordError, passwordSaving, confirmResetPassword, t,
|
|
99
|
+
// A `resolveResetPasswordFieldsHook` helper used to do this: it resolved `useFields` to the real
|
|
100
|
+
// hook when no override is passed, because ESLint's cyclomatic-complexity rule counts a default
|
|
101
|
+
// parameter value evaluated inside a function's OWN body as one of that function's own branches;
|
|
102
|
+
// a call out to a separately-scoped resolver does not. The hook-injection gate only accepts a
|
|
103
|
+
// defaulted prop, and with it this dialog is complexity 6 (limit 10), so the default lives here.
|
|
104
|
+
useFields = useResetPasswordFields, }) {
|
|
109
105
|
const fields = useFields({ resetPasswordFor, newPassword });
|
|
110
106
|
const displayedError = fields.mismatch ? t("Passwords do not match.") : passwordError;
|
|
111
|
-
|
|
112
|
-
* `confirmResetPassword`/the server. The inline message below is driven by the same `mismatch`
|
|
113
|
-
* value, so it is already visible by the time a blocked click can happen; there is nothing
|
|
114
|
-
* further to surface here. */
|
|
115
|
-
function handleConfirm() {
|
|
116
|
-
if (fields.mismatch)
|
|
117
|
-
return;
|
|
118
|
-
void confirmResetPassword();
|
|
119
|
-
}
|
|
107
|
+
const handleConfirm = createResetPasswordConfirmHandler({ mismatch: fields.mismatch, confirmResetPassword });
|
|
120
108
|
return (_jsx(ConfirmDialog, { cancelLabel: t("Cancel"), open: resetPasswordFor !== null, agentHandle: "users-reset-password", title: t("Reset password?"), body: resetPasswordFor ? (_jsxs(_Fragment, { children: [_jsxs("p", { children: [t("Set a new password for"), " \"", resetPasswordFor.username, "\".", " ", t("Every active session for this user will be signed out.")] }), _jsx(RevealablePasswordField, { id: "users-reset-password-input", label: t("New password"), value: newPassword, onChange: setNewPassword, visible: fields.showNewPassword, onToggleVisible: fields.toggleShowNewPassword, agentBase: "users-reset-password", t: t }), _jsx(RevealablePasswordField, { id: "users-reset-password-confirm-input", label: t("Confirm new password"), value: fields.confirmPassword, onChange: fields.setConfirmPassword, visible: fields.showConfirmPassword, onToggleVisible: fields.toggleShowConfirmPassword,
|
|
121
109
|
// NOT "users-reset-password-confirm" — that string is already the dialog's own
|
|
122
110
|
// ConfirmDialog Confirm button handle (`agentHandle="users-reset-password"` above,
|
|
@@ -160,12 +148,11 @@ function userManageController({ controller, roles, policies }) {
|
|
|
160
148
|
: null,
|
|
161
149
|
};
|
|
162
150
|
}
|
|
163
|
-
export function Users({ useUsersHook, port, translate: injectedTranslate, queryScope, openOwnPasswordReset, onOwnPasswordResetClosed, passwordResetNotice, renderServerLabel }) {
|
|
151
|
+
export function Users({ useUsersHook = useUsers, port, translate: injectedTranslate, queryScope, openOwnPasswordReset, onOwnPasswordResetClosed, passwordResetNotice, renderServerLabel }) {
|
|
164
152
|
// Widening `useUsers` to `UsersHook` is sound only through the `UsersProps` union: whenever
|
|
165
153
|
// `useUsersHook` is omitted or typed as `useUsers`, `translate` is required, so the default hook
|
|
166
154
|
// never runs without it. TypeScript cannot correlate the two destructured props itself.
|
|
167
|
-
const
|
|
168
|
-
const controller = useSelectedUsersHook({ port, translate: injectedTranslate, queryScope }, {
|
|
155
|
+
const controller = useUsersHook({ port, translate: injectedTranslate, queryScope }, {
|
|
169
156
|
openOwnPasswordReset, onOwnPasswordResetClosed, passwordResetNotice,
|
|
170
157
|
});
|
|
171
158
|
const { users, roles, policies, canGrant, error, formOpen, setFormOpen, username, setUsername, email, setEmail, password, setPassword, saving, formError, onCreate, expandedId, toggleExpanded, toggleSavingId, toggleError, notice, confirmingDisable, setConfirmingDisable, requestDisable, confirmDisable, onToggleStatus, resetPasswordFor, setResetPasswordFor, newPassword, setNewPassword, passwordSaving, passwordError, setPasswordError, openResetPassword, confirmResetPassword, canManageUserTrash, rowCapabilities, ownProfile, renameUserHandler, changeUsername, confirmingDelete, setConfirmingDelete, requestDelete, deleteSaving, confirmDelete, t, translate, } = controller;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useResetPasswordFields } from './hooks/use-reset-password-fields.hooks.js';
|
|
2
|
+
import type { UsersController } from './hooks/use-users.hooks.js';
|
|
3
|
+
export declare function UsersDialogs({ controller: c, useFields }: {
|
|
4
|
+
controller: UsersController;
|
|
5
|
+
useFields?: typeof useResetPasswordFields;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=UsersDialogs.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ConfirmDialog, SecretInput } from '../kit.js';
|
|
3
|
+
import { agentHandle } from '@jini-ai/core/agent-handles';
|
|
4
|
+
import { createResetPasswordConfirmHandler, useResetPasswordFields } from './hooks/use-reset-password-fields.hooks.js';
|
|
5
|
+
import { ChangeUsernameDialog } from './ChangeUsernameDialog.js';
|
|
6
|
+
/** The Disable confirm dialog — extracted from `Users` verbatim. */
|
|
7
|
+
function UserDisableDialog({ confirmingDisable, setConfirmingDisable, toggleSavingId, confirmDisable, t }) {
|
|
8
|
+
return (_jsx(ConfirmDialog, { cancelLabel: t("Cancel"), open: confirmingDisable !== null, agentHandle: "users-disable", title: t("Disable this user?"), body: confirmingDisable ? (_jsxs("p", { children: [t("Disable"), " \"", confirmingDisable.username, "\"? ", t("They will not be able to sign in until re-enabled.")] })) : null, confirmLabel: t("Disable"), tone: "warning", pending: confirmingDisable !== null && toggleSavingId === confirmingDisable.principalId, onConfirm: confirmDisable, onCancel: () => setConfirmingDisable(null) }));
|
|
9
|
+
}
|
|
10
|
+
/** The Delete confirm dialog (delete-user plan v2, 2026-09-24) — mirrors {@link UserDisableDialog}'s
|
|
11
|
+
* shape exactly (own props, own state), naming the Trash rather than a permanent removal since
|
|
12
|
+
* that is what "Delete" now does here (decisions 2/7 of the plan). */
|
|
13
|
+
function UserDeleteDialog({ confirmingDelete, setConfirmingDelete, deleteSaving, confirmDelete, t }) {
|
|
14
|
+
return (_jsx(ConfirmDialog, { cancelLabel: t("Cancel"), open: confirmingDelete !== null, agentHandle: "users-delete", title: t("Delete this user?"), body: confirmingDelete ? (_jsxs("p", { children: [t("Delete"), " \"", confirmingDelete.username, "\"?", " ", t("They will be signed out and moved to the Trash. You can restore them there; they are deleted permanently after 60 days.")] })) : null, confirmLabel: t("Move to trash"), tone: "danger", pending: deleteSaving, onConfirm: confirmDelete, onCancel: () => setConfirmingDelete(null) }));
|
|
15
|
+
}
|
|
16
|
+
/** One password input plus its own independent show/hide toggle. `UserResetPasswordDialog` renders
|
|
17
|
+
* this twice (new password, confirm new password) so each field can be revealed on its own — the
|
|
18
|
+
* whole point of the confirm field is catching a typo by eye, which a single toggle driving both
|
|
19
|
+
* fields would not let the operator do selectively. Follows this file's `GrantSelect` precedent: a
|
|
20
|
+
* shape used by more than one caller gets its own top-level function instead of staying inline
|
|
21
|
+
* twice.
|
|
22
|
+
*
|
|
23
|
+
* The toggle itself is icon-only (standard eye / eye-with-slash convention, per owner request —
|
|
24
|
+
* not a text "Show"/"Hide" link): the accessible name flips between "Show <label>"/"Hide <label>"
|
|
25
|
+
* via `aria-label` (screen reader), which is the one on/off signal a text label would have given
|
|
26
|
+
* (no `aria-pressed` on top: that announced the state twice). The shared stroke icon keeps the
|
|
27
|
+
* open-eye/eye-with-slash convention without duplicating glyphs in this screen.
|
|
28
|
+
*
|
|
29
|
+
* The shared `.jini-secret` wrapper gives the icon its own space: the host's `.field input {
|
|
30
|
+
* width: 100% }` must not make the input fight a sibling toggle for room. */
|
|
31
|
+
function RevealablePasswordField({ id, label, value, onChange, visible, onToggleVisible, agentBase, t }) {
|
|
32
|
+
return (_jsxs("div", { className: "field", children: [_jsx("label", { className: "field-label", htmlFor: id, children: label }), _jsx(SecretInput, { id: id, label: label, toggleLabels: { show: `${t("Show")} ${label}`, hide: `${t("Hide")} ${label}` }, revealed: visible, onRevealedChange: onToggleVisible, toggleAttrs: agentHandle({ handle: `${agentBase}-reveal` }, { role: "button", label: `Show or hide the ${label.toLowerCase()} field's characters` }),
|
|
33
|
+
// `new-password`, not `off` (Chrome ignores `off`): without it Chrome filled a saved
|
|
34
|
+
// login into "New password" only. Kept while revealed as `type="text"`, too.
|
|
35
|
+
autoComplete: "new-password", value: value, onChange: (e) => onChange(e.target.value), style: { flex: "1 1 auto", minWidth: 0 }, ...agentHandle({ handle: agentBase }, {
|
|
36
|
+
role: "field",
|
|
37
|
+
label: `${label} — a credential field, so only a human can fill it`,
|
|
38
|
+
}) })] }));
|
|
39
|
+
}
|
|
40
|
+
/** The reset-password dialog — extracted from `Users` verbatim, since extended with the confirm
|
|
41
|
+
* field and both reveal toggles (see this file's header). */
|
|
42
|
+
function UserResetPasswordDialog({ resetPasswordFor, setResetPasswordFor, newPassword, setNewPassword, passwordError, setPasswordError, passwordSaving, confirmResetPassword, t, useFields = useResetPasswordFields, }) {
|
|
43
|
+
const fields = useFields({ resetPasswordFor, newPassword });
|
|
44
|
+
const displayedError = fields.mismatch ? t("Passwords do not match.") : passwordError;
|
|
45
|
+
const handleConfirm = createResetPasswordConfirmHandler({ mismatch: fields.mismatch, confirmResetPassword });
|
|
46
|
+
return (_jsx(ConfirmDialog, { cancelLabel: t("Cancel"), open: resetPasswordFor !== null, agentHandle: "users-reset-password", title: t("Reset password?"), body: resetPasswordFor ? _jsx(UserResetPasswordBody, { resetPasswordFor: resetPasswordFor, newPassword: newPassword, setNewPassword: setNewPassword, passwordError: passwordError, fields: fields, displayedError: displayedError, t: t }) : null, confirmLabel: t("Reset password"), tone: "warning", pending: passwordSaving, onConfirm: handleConfirm, onCancel: () => {
|
|
47
|
+
setResetPasswordFor(null);
|
|
48
|
+
setNewPassword("");
|
|
49
|
+
setPasswordError(null);
|
|
50
|
+
} }));
|
|
51
|
+
}
|
|
52
|
+
function UserResetPasswordBody({ resetPasswordFor, newPassword, setNewPassword, passwordError, fields, displayedError, t }) {
|
|
53
|
+
return (_jsxs(_Fragment, { children: [_jsxs("p", { children: [t("Set a new password for"), " \"", resetPasswordFor.username, "\".", " ", t("Every active session for this user will be signed out.")] }), _jsx(RevealablePasswordField, { id: "users-reset-password-input", label: t("New password"), value: newPassword, onChange: setNewPassword, visible: fields.showNewPassword, onToggleVisible: fields.toggleShowNewPassword, agentBase: "users-reset-password", t: t }), _jsx(RevealablePasswordField, { id: "users-reset-password-confirm-input", label: t("Confirm new password"), value: fields.confirmPassword, onChange: fields.setConfirmPassword, visible: fields.showConfirmPassword, onToggleVisible: fields.toggleShowConfirmPassword,
|
|
54
|
+
// NOT "users-reset-password-confirm" — that string is already the dialog's own
|
|
55
|
+
// ConfirmDialog Confirm button handle (`agentHandle="users-reset-password"` above,
|
|
56
|
+
// `-confirm` sub-handle). Two elements answering to the same handle is a
|
|
57
|
+
// page-authoring bug the page driver refuses to resolve (see
|
|
58
|
+
// `dom-page-driver.ts`'s `ambiguousHandleError`), so this field gets its own name.
|
|
59
|
+
agentBase: "users-reset-password-retype", t: t }), fields.mismatch || passwordError ? (_jsx("p", { className: "save-error", role: "alert", children: displayedError })) : null] }));
|
|
60
|
+
}
|
|
61
|
+
export function UsersDialogs({ controller: c, useFields }) {
|
|
62
|
+
return _jsxs(_Fragment, { children: [_jsx(UserDisableDialog, { confirmingDisable: c.confirmingDisable, setConfirmingDisable: c.setConfirmingDisable, toggleSavingId: c.toggleSavingId, confirmDisable: c.confirmDisable, t: c.t }), _jsx(UserDeleteDialog, { confirmingDelete: c.confirmingDelete, setConfirmingDelete: c.setConfirmingDelete, deleteSaving: c.deleteSaving, confirmDelete: c.confirmDelete, t: c.t }), _jsx(UserResetPasswordDialog, { resetPasswordFor: c.resetPasswordFor, setResetPasswordFor: c.setResetPasswordFor, newPassword: c.newPassword, setNewPassword: c.setNewPassword, passwordError: c.passwordError, setPasswordError: c.setPasswordError, passwordSaving: c.passwordSaving, confirmResetPassword: c.confirmResetPassword, t: c.t, ...(useFields ? { useFields } : {}) }), c.changeUsername ? _jsx(ChangeUsernameDialog, { controller: c.changeUsername, translate: c.t }) : null] });
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=UsersDialogs.js.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import type { Translate } from '@jini-ai/core/text';
|
|
3
|
+
import type { AdminIdentityUser, AdminRole, AdminPolicy } from '../models.js';
|
|
4
|
+
import { type UserAccountCapabilities } from './rules.js';
|
|
5
|
+
import type { UsersController } from './hooks/use-users.hooks.js';
|
|
6
|
+
import type { UsersProps } from './Users.js';
|
|
7
|
+
/** The subset of `AdminRole`/`AdminPolicy` a grant `<select>` actually renders. Named rather than
|
|
8
|
+
* taking the full records, so the shared control below cannot come to depend on anything a role has
|
|
9
|
+
* and a policy does not. */
|
|
10
|
+
export interface GrantOption {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
isBuiltin: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** One "pick something, then grant it to this user" control. Both grants on the Manage panel are
|
|
16
|
+
* this same shape, which is what lets them share {@link GrantSelect} instead of being two
|
|
17
|
+
* near-identical blocks whose props had to be threaded separately. */
|
|
18
|
+
export interface GrantSelectController {
|
|
19
|
+
options: GrantOption[];
|
|
20
|
+
/** The id currently selected in the `<select>`, or `""` for the placeholder row. */
|
|
21
|
+
pendingId: string;
|
|
22
|
+
setPendingId: Dispatch<SetStateAction<string>>;
|
|
23
|
+
submit: (required: {
|
|
24
|
+
principalId: string;
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Everything the expanded "Manage" panel needs, as one object.
|
|
29
|
+
*
|
|
30
|
+
* Replaces the fifteen loose state/setter/callback props this panel used to take and `UserRow` used
|
|
31
|
+
* to relay through an `Omit<UserManagePanelProps, "principalId">` rest spread. The grouping is by
|
|
32
|
+
* interaction, not by convenience: the email editor and the two grants are three independent
|
|
33
|
+
* controls that happen to share one error line and one in-flight flag, and saying so in the type is
|
|
34
|
+
* what lets a test build a Manage panel without also standing up a row, a table, and a page.
|
|
35
|
+
*/
|
|
36
|
+
export interface UserManageController {
|
|
37
|
+
/** The one error line the whole panel shares — any of the three writes can set it. */
|
|
38
|
+
error: string | null;
|
|
39
|
+
/** Shared by both grants: the panel issues one grant at a time. */
|
|
40
|
+
saving: boolean;
|
|
41
|
+
email: {
|
|
42
|
+
value: string;
|
|
43
|
+
set: Dispatch<SetStateAction<string>>;
|
|
44
|
+
saving: boolean;
|
|
45
|
+
save: (required: {
|
|
46
|
+
principalId: string;
|
|
47
|
+
}) => Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
/** `null` when the caller may not read roles/policies (`UsersController.canGrant`): no grant controls. */
|
|
50
|
+
roleGrant: GrantSelectController | null;
|
|
51
|
+
policyGrant: GrantSelectController | null;
|
|
52
|
+
}
|
|
53
|
+
export interface UserManagePanelProps {
|
|
54
|
+
principalId: string;
|
|
55
|
+
manage: UserManageController;
|
|
56
|
+
t: (key: string) => string;
|
|
57
|
+
/** The table's column count, so the panel row spans it exactly (fewer without Roles/Policies). */
|
|
58
|
+
colSpan?: number;
|
|
59
|
+
}
|
|
60
|
+
/** The expanded "Manage" row's contents (email edit, role/policy grant forms).
|
|
61
|
+
*
|
|
62
|
+
* Exported so a test can drive it with a hand-built {@link UserManageController} — the seam only
|
|
63
|
+
* counts as one if something other than `Users` can supply it. */
|
|
64
|
+
export declare function UserManagePanel({ principalId, manage, t, colSpan }: UserManagePanelProps): import("react").JSX.Element;
|
|
65
|
+
/** A user row's own affordances — expand/collapse and the three menu actions. Distinct from
|
|
66
|
+
* {@link UserManageController}, which describes what the expanded panel does once it is open. */
|
|
67
|
+
export interface UserRowActionsController {
|
|
68
|
+
expandedId: string | null;
|
|
69
|
+
toggleExpanded: (user: AdminIdentityUser) => void;
|
|
70
|
+
/** Which row has a status write in flight — drives that row's disabled menu item only. */
|
|
71
|
+
savingId: string | null;
|
|
72
|
+
requestDisable: (user: AdminIdentityUser) => void;
|
|
73
|
+
toggleStatus: (user: AdminIdentityUser) => Promise<void>;
|
|
74
|
+
openResetPassword: (user: AdminIdentityUser) => void;
|
|
75
|
+
renameUserHandler?: UsersController["renameUserHandler"];
|
|
76
|
+
/** Delete-user plan v2 (2026-09-24): whether the row's `RowMenu` should carry a "Delete" item at
|
|
77
|
+
* all — see `use-users.hooks.ts`'s `canManageUserTrash` doc comment for where this comes from. */
|
|
78
|
+
canDelete: boolean;
|
|
79
|
+
rowCapabilities?: (user: AdminIdentityUser) => UserAccountCapabilities;
|
|
80
|
+
requestDelete: (user: AdminIdentityUser) => void;
|
|
81
|
+
}
|
|
82
|
+
export interface UserRowProps {
|
|
83
|
+
user: AdminIdentityUser;
|
|
84
|
+
isOwn?: boolean;
|
|
85
|
+
roleById: ReadonlyMap<string, AdminRole>;
|
|
86
|
+
policyById: ReadonlyMap<string, AdminPolicy>;
|
|
87
|
+
/** Whether the Roles/Policies cells render — see {@link UsersTableProps.showGrants}. */
|
|
88
|
+
showGrants: boolean;
|
|
89
|
+
actions: UserRowActionsController;
|
|
90
|
+
manage: UserManageController;
|
|
91
|
+
/** This row's own distinct handle base — computed once, across every rendered row, by
|
|
92
|
+
* `UsersTable` (via `buildAgentListHandles`); see `Taxonomy.tsx`'s `NewTermForm.agentBase` for
|
|
93
|
+
* why a per-instance uniqueness search does not work here. */
|
|
94
|
+
agentBase: string;
|
|
95
|
+
t: (key: string) => string;
|
|
96
|
+
translate: Translate;
|
|
97
|
+
renderServerLabel?: UsersProps["renderServerLabel"];
|
|
98
|
+
}
|
|
99
|
+
export interface UsersTableProps {
|
|
100
|
+
users: AdminIdentityUser[];
|
|
101
|
+
ownPrincipalId?: string | undefined;
|
|
102
|
+
/** The full records, for the Roles/Policies label columns. The grant selects get their own
|
|
103
|
+
* `options` through `manage`, so neither consumer has to reach into the other's props. */
|
|
104
|
+
roles: AdminRole[];
|
|
105
|
+
policies: AdminPolicy[];
|
|
106
|
+
/** `UsersController.canGrant`: without `role.manage` there are no names to resolve grant ids
|
|
107
|
+
* against, so the Roles/Policies columns are left out rather than showing raw ids. */
|
|
108
|
+
showGrants: boolean;
|
|
109
|
+
actions: UserRowActionsController;
|
|
110
|
+
manage: UserManageController;
|
|
111
|
+
t: (key: string) => string;
|
|
112
|
+
translate: Translate;
|
|
113
|
+
renderServerLabel?: UsersProps["renderServerLabel"];
|
|
114
|
+
}
|
|
115
|
+
/** The users table, or the empty state. Builds the role/policy lookup maps once per render rather
|
|
116
|
+
* than once per row. */
|
|
117
|
+
export declare function UsersTable({ users, ownPrincipalId, roles, policies, showGrants, actions, manage, t, translate, renderServerLabel }: UsersTableProps): import("react").JSX.Element;
|
|
118
|
+
//# sourceMappingURL=UsersTable.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { agentHandle, buildAgentListHandles } from '@jini-ai/core/agent-handles';
|
|
3
|
+
import { RowMenu, InfoTip } from '../kit.js';
|
|
4
|
+
import { grantOptionLabel } from './rules.js';
|
|
5
|
+
import { UserGrantCells, UserNameCell, UserStatusCell, userRowMenuItemsFor } from './UserRowParts.js';
|
|
6
|
+
/** The select-plus-button both grants render. */
|
|
7
|
+
function GrantSelect({ principalId, label, placeholder, submitLabel, grant, saving, agentBase, t }) {
|
|
8
|
+
return (_jsxs("label", { children: [label, _jsxs("span", { className: "editor-actions", children: [_jsxs("select", { value: grant.pendingId, onChange: (e) => grant.setPendingId(e.target.value), ...agentHandle({ handle: `${agentBase}-select` }, {
|
|
9
|
+
role: "field",
|
|
10
|
+
label: `${label} — set with page.select_option, not click`,
|
|
11
|
+
}), children: [_jsx("option", { value: "", children: placeholder }), grant.options.map((option) => (_jsxs("option", { value: option.id, children: [grantOptionLabel({ option, translate: t }), option.isBuiltin ? ` ${t("(built-in)")}` : ""] }, option.id)))] }), _jsx("button", { type: "button", disabled: !grant.pendingId || saving, onClick: () => grant.submit({ principalId }), ...agentHandle({ handle: `${agentBase}-submit` }, { role: "button", label: `${submitLabel} the selected option to this user` }), children: saving ? t("Saving…") : submitLabel })] })] }));
|
|
12
|
+
}
|
|
13
|
+
/** The expanded "Manage" row's contents (email edit, role/policy grant forms).
|
|
14
|
+
*
|
|
15
|
+
* Exported so a test can drive it with a hand-built {@link UserManageController} — the seam only
|
|
16
|
+
* counts as one if something other than `Users` can supply it. */
|
|
17
|
+
export function UserManagePanel({ principalId, manage, t, colSpan = 6 }) {
|
|
18
|
+
return (_jsx("tr", { children: _jsx("td", { colSpan: colSpan, children: _jsxs("div", { className: "notice integrations-form", children: [manage.error ? _jsx("span", { className: "save-error", children: manage.error }) : null, _jsx(UserManageEmailEditor, { principalId: principalId, manage: manage, t: t }), manage.roleGrant ? (_jsx(GrantSelect, { principalId: principalId, label: t("Assign role"), placeholder: t("Select a role…"), submitLabel: t("Assign"), grant: manage.roleGrant, saving: manage.saving, agentBase: "user-manage-role", t: t })) : null, manage.policyGrant ? (_jsx(GrantSelect, { principalId: principalId, label: t("Attach policy"), placeholder: t("Select a policy…"), submitLabel: t("Attach"), grant: manage.policyGrant, saving: manage.saving, agentBase: "user-manage-policy", t: t })) : null] }) }) }));
|
|
19
|
+
}
|
|
20
|
+
/** One user's row plus its optional expanded "Manage" row. `key` lives on the `<UserRow>` element at
|
|
21
|
+
* the call site, not inside here, since this is no longer the array-mapping callback itself. */
|
|
22
|
+
function UserRow({ user, isOwn, roleById, policyById, showGrants, actions, manage, agentBase, t, translate, renderServerLabel }) {
|
|
23
|
+
const expanded = actions.expandedId === user.principalId;
|
|
24
|
+
return (_jsxs(_Fragment, { children: [_jsxs("tr", { "aria-current": isOwn ? "true" : undefined, children: [_jsx(UserNameCell, { user: user, isOwn: isOwn, expanded: expanded, onToggle: actions.toggleExpanded, agentBase: agentBase, t: t }), _jsx("td", { children: user.email ?? _jsx("span", { className: "muted-cell", children: "\u2014" }) }), _jsx(UserStatusCell, { status: user.status, t: t, renderServerLabel: renderServerLabel }), showGrants ? (_jsx(UserGrantCells, { user: user, roleById: roleById, policyById: policyById, t: t, translate: translate, renderServerLabel: renderServerLabel })) : null, _jsx("td", { children: _jsx(RowMenu, { triggerLabel: `${t("Actions for user")} "${user.username}"`, agentHandle: `${agentBase}-menu`, items: userRowMenuItemsFor({ user, actions, translate }) }) })] }), expanded ? (_jsx(UserManagePanel, { principalId: user.principalId, manage: manage, t: t, colSpan: showGrants ? 6 : 4 })) : null] }));
|
|
25
|
+
}
|
|
26
|
+
/** The users table, or the empty state. Builds the role/policy lookup maps once per render rather
|
|
27
|
+
* than once per row. */
|
|
28
|
+
export function UsersTable({ users, ownPrincipalId, roles, policies, showGrants, actions, manage, t, translate, renderServerLabel }) {
|
|
29
|
+
if (users.length === 0) {
|
|
30
|
+
return (_jsx("div", { className: "card", children: _jsxs("div", { className: "empty-state", children: [_jsx("p", { children: t("No users yet.") }), _jsx("p", { className: "page-description", children: t("Create your first operator account to get started.") })] }) }));
|
|
31
|
+
}
|
|
32
|
+
// Not `useMemo`d: computed after the empty-state early return above, so a `useMemo` here would
|
|
33
|
+
// need hoisting above it to keep hook order stable across renders — same constraint `Media.tsx`
|
|
34
|
+
// documents for its own post-early-return computation. Not worth that indirection: these three
|
|
35
|
+
// maps/handles are a single O(n) pass each over one operator's own users/roles/policies (already
|
|
36
|
+
// built once per render rather than once per row, per this function's own doc comment above).
|
|
37
|
+
const roleById = new Map(roles.map((role) => [role.id, role]));
|
|
38
|
+
const policyById = new Map(policies.map((policy) => [policy.id, policy]));
|
|
39
|
+
// Principal ids are stable and unique, so they disambiguate one row's Manage toggle from
|
|
40
|
+
// another's — same reasoning as every other list on this workstream.
|
|
41
|
+
const rowHandles = buildAgentListHandles({ prefix: "users-row", ids: users.map((user) => user.principalId) });
|
|
42
|
+
return (_jsx("div", { className: "table-scroll", children: _jsxs("table", { className: "list-table", children: [_jsx(UsersTableHeader, { showGrants: showGrants, t: t }), _jsx("tbody", { children: users.map((user, index) => (_jsx(UserRow, { user: user, isOwn: user.principalId === ownPrincipalId, roleById: roleById, policyById: policyById, showGrants: showGrants, actions: actions, manage: manage, agentBase: rowHandles[index], t: t, translate: translate, renderServerLabel: renderServerLabel }, user.principalId))) })] }) }));
|
|
43
|
+
}
|
|
44
|
+
function UsersTableHeader({ showGrants, t }) {
|
|
45
|
+
return (_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t("Username") }), _jsx("th", { children: t("Email") }), _jsx("th", { children: t("Status") }), showGrants ? (_jsxs(_Fragment, { children: [_jsxs("th", { "data-label": t("Roles"), children: [t("Roles"), _jsx(InfoTip, { triggerLabel: t("About roles"), label: [
|
|
46
|
+
t("• Owner — full control, including users and site keys."),
|
|
47
|
+
t("• Admin — manage content, settings, site keys, and roles within their permissions."),
|
|
48
|
+
t("• Editor — edit, publish, and delete content; upload, edit, and trash media; switch themes."),
|
|
49
|
+
t("• Viewer — read content, changes, and plugin information."),
|
|
50
|
+
].join("\n") })] }), _jsx("th", { children: t("Policies") })] })) : null, _jsx("th", { children: t("More") })] }) }));
|
|
51
|
+
}
|
|
52
|
+
function UserManageEmailEditor({ principalId, manage, t }) {
|
|
53
|
+
return (_jsxs("label", { children: [t("Email"), _jsxs("span", { className: "editor-actions", children: [_jsx("input", { type: "email", value: manage.email.value, onChange: (e) => manage.email.set(e.target.value), placeholder: t("(none)"), ...agentHandle({ handle: "user-manage-email" }, { role: "field", label: "This user's email address" }) }), _jsx("button", { type: "button", disabled: manage.email.saving, onClick: () => manage.email.save({ principalId }), ...agentHandle({ handle: "user-manage-email-save" }, { role: "button", label: "Save this user's email address" }), children: manage.email.saving ? t("Saving…") : t("Save email") })] })] }));
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=UsersTable.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Dispatch, type SetStateAction } from "react";
|
|
2
|
-
import { type Translate } from "@jini-ai/ui/panel-kit";
|
|
3
2
|
import type { AdminIdentityUser } from "../../models.js";
|
|
4
3
|
import type { UsersPort } from "../../ports.js";
|
|
4
|
+
import { type Translate } from '@jini-ai/core/text';
|
|
5
5
|
export interface ChangeUsernameController {
|
|
6
6
|
target: AdminIdentityUser | null;
|
|
7
7
|
username: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useRef, useState } from "react";
|
|
2
|
-
import { useFetchMutation } from "
|
|
2
|
+
import { useFetchMutation } from "../../kit.js";
|
|
3
3
|
import { describeApiError, KEYS } from "../rules.js";
|
|
4
|
+
import {} from '@jini-ai/core/text';
|
|
4
5
|
/** Shared rename dialog lifecycle: guard, write through the existing user port, invalidate list.
|
|
5
6
|
* Failures retain the target/draft and the server's actual reason; duplicate submits are refused.
|
|
6
7
|
* @complexity O(1) client state and one PATCH per submission. No credential/session effects.
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { AdminIdentityUser } from "../../models.js";
|
|
2
|
+
/** Blocks the reset entirely when the two fields disagree — a mismatch never reaches
|
|
3
|
+
* `confirmResetPassword`/the server. The inline message below is driven by the same `mismatch`
|
|
4
|
+
* value, so it is already visible by the time a blocked click can happen; there is nothing
|
|
5
|
+
* further to surface here. */
|
|
6
|
+
export declare function createResetPasswordConfirmHandler({ mismatch, confirmResetPassword }: {
|
|
7
|
+
mismatch: boolean;
|
|
8
|
+
confirmResetPassword: () => Promise<void>;
|
|
9
|
+
}, _options?: Record<string, never>): () => void;
|
|
2
10
|
/**
|
|
3
11
|
* @file The reset-password dialog's own confirm-field and reveal-toggle state — client-side only,
|
|
4
12
|
* never sent to the server (`use-users.hooks.ts`'s `resetPasswordMutation` still posts only
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
+
/** Blocks the reset entirely when the two fields disagree — a mismatch never reaches
|
|
3
|
+
* `confirmResetPassword`/the server. The inline message below is driven by the same `mismatch`
|
|
4
|
+
* value, so it is already visible by the time a blocked click can happen; there is nothing
|
|
5
|
+
* further to surface here. */
|
|
6
|
+
export function createResetPasswordConfirmHandler({ mismatch, confirmResetPassword }, _options = {}) {
|
|
7
|
+
return () => {
|
|
8
|
+
if (mismatch)
|
|
9
|
+
return;
|
|
10
|
+
void confirmResetPassword();
|
|
11
|
+
};
|
|
12
|
+
}
|
|
2
13
|
/**
|
|
3
14
|
* Owns the "Confirm new password" field and both fields' independent reveal toggles.
|
|
4
15
|
*
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { AdminIdentityUser } from "../../models.js";
|
|
2
|
+
import type { UsersDependencies } from "./use-users.hooks.js";
|
|
3
|
+
import { useAsyncAction as useAsyncActionDefault, useFetchMutation as useFetchMutationDefault } from "../../kit.js";
|
|
4
|
+
export declare function useUsersCreationState({ port, queryScope }: Pick<UsersDependencies, 'port' | 'queryScope'>, { useAsyncAction, useFetchMutation }?: {
|
|
5
|
+
useAsyncAction?: typeof useAsyncActionDefault;
|
|
6
|
+
useFetchMutation?: typeof useFetchMutationDefault;
|
|
7
|
+
}): {
|
|
8
|
+
formOpen: boolean;
|
|
9
|
+
setFormOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
10
|
+
username: string;
|
|
11
|
+
setUsername: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
12
|
+
email: string;
|
|
13
|
+
setEmail: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
14
|
+
password: string;
|
|
15
|
+
setPassword: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
16
|
+
createUser: import("../../kit.js").AsyncActionState;
|
|
17
|
+
createUserMutation: import("@jini-ai/ui").MutationResult<{
|
|
18
|
+
username: string;
|
|
19
|
+
password: string;
|
|
20
|
+
email: string | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
user: AdminIdentityUser;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
export declare function useUsersGrantState({ port, queryScope }: Pick<UsersDependencies, 'port' | 'queryScope'>, { useFetchMutation }?: {
|
|
26
|
+
useFetchMutation?: typeof useFetchMutationDefault;
|
|
27
|
+
}): {
|
|
28
|
+
expandedId: string | null;
|
|
29
|
+
setExpandedId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
30
|
+
toggleGenerationRef: import("react").RefObject<number>;
|
|
31
|
+
pendingRoleId: string;
|
|
32
|
+
setPendingRoleId: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
33
|
+
pendingPolicyId: string;
|
|
34
|
+
setPendingPolicyId: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
35
|
+
grantSaving: boolean;
|
|
36
|
+
setGrantSaving: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
37
|
+
grantError: string | null;
|
|
38
|
+
setGrantError: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
39
|
+
assignRoleMutation: import("@jini-ai/ui").MutationResult<{
|
|
40
|
+
principalId: string;
|
|
41
|
+
roleId: string;
|
|
42
|
+
}, {
|
|
43
|
+
assignment: unknown;
|
|
44
|
+
}>;
|
|
45
|
+
attachPolicyMutation: import("@jini-ai/ui").MutationResult<{
|
|
46
|
+
principalId: string;
|
|
47
|
+
policyId: string;
|
|
48
|
+
}, {
|
|
49
|
+
attachment: unknown;
|
|
50
|
+
}>;
|
|
51
|
+
editEmail: string;
|
|
52
|
+
setEditEmail: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
53
|
+
updateEmailMutation: import("@jini-ai/ui").MutationResult<{
|
|
54
|
+
principalId: string;
|
|
55
|
+
email: string;
|
|
56
|
+
}, {
|
|
57
|
+
user: AdminIdentityUser;
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
export declare function useUsersStatusState({ port, queryScope }: Pick<UsersDependencies, 'port' | 'queryScope'>, { useAsyncAction, useFetchMutation }?: {
|
|
61
|
+
useAsyncAction?: typeof useAsyncActionDefault;
|
|
62
|
+
useFetchMutation?: typeof useFetchMutationDefault;
|
|
63
|
+
}): {
|
|
64
|
+
toggleSavingId: string | null;
|
|
65
|
+
setToggleSavingId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
66
|
+
toggleError: string | null;
|
|
67
|
+
setToggleError: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
68
|
+
notice: string | null;
|
|
69
|
+
setNotice: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
70
|
+
toggleStatusMutation: import("@jini-ai/ui").MutationResult<AdminIdentityUser, {
|
|
71
|
+
user: AdminIdentityUser;
|
|
72
|
+
}>;
|
|
73
|
+
confirmingDisable: AdminIdentityUser | null;
|
|
74
|
+
setConfirmingDisable: import("react").Dispatch<import("react").SetStateAction<AdminIdentityUser | null>>;
|
|
75
|
+
resetPasswordFor: AdminIdentityUser | null;
|
|
76
|
+
setResetPasswordFor: import("react").Dispatch<import("react").SetStateAction<AdminIdentityUser | null>>;
|
|
77
|
+
newPassword: string;
|
|
78
|
+
setNewPassword: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
79
|
+
resetPassword: import("../../kit.js").AsyncActionState;
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=use-users-form-state.hooks.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useRef, useState } from "react";
|
|
2
|
+
import { KEYS } from "../rules.js";
|
|
3
|
+
import { useAsyncAction as useAsyncActionDefault, useFetchMutation as useFetchMutationDefault } from "../../kit.js";
|
|
4
|
+
export function useUsersCreationState({ port, queryScope }, { useAsyncAction = useAsyncActionDefault, useFetchMutation = useFetchMutationDefault } = {}) {
|
|
5
|
+
const [formOpen, setFormOpen] = useState(false);
|
|
6
|
+
const [username, setUsername] = useState("");
|
|
7
|
+
const [email, setEmail] = useState("");
|
|
8
|
+
const [password, setPassword] = useState("");
|
|
9
|
+
const createUser = useAsyncAction();
|
|
10
|
+
const createUserMutation = useFetchMutation({
|
|
11
|
+
run: ({ input }) => port.createUser({ username: input.username, password: input.password }, { email: input.email })
|
|
12
|
+
}, {
|
|
13
|
+
invalidates: [[queryScope, ...KEYS.list]],
|
|
14
|
+
});
|
|
15
|
+
return { formOpen, setFormOpen, username, setUsername, email, setEmail, password, setPassword, createUser, createUserMutation };
|
|
16
|
+
}
|
|
17
|
+
export function useUsersGrantState({ port, queryScope }, { useFetchMutation = useFetchMutationDefault } = {}) {
|
|
18
|
+
const [expandedId, setExpandedId] = useState(null);
|
|
19
|
+
// Bumped once per `toggleExpanded` call, regardless of which panel — `runGrantMutation` (a
|
|
20
|
+
// top-level function, outside this closure's re-render cycle) reads this to tell whether the
|
|
21
|
+
// operator switched panels AT ALL while its own grant was in flight. See that function's own doc
|
|
22
|
+
// comment for why this counts switches rather than comparing against `expandedId`'s value.
|
|
23
|
+
const toggleGenerationRef = useRef(0);
|
|
24
|
+
const [pendingRoleId, setPendingRoleId] = useState("");
|
|
25
|
+
const [pendingPolicyId, setPendingPolicyId] = useState("");
|
|
26
|
+
const [grantSaving, setGrantSaving] = useState(false);
|
|
27
|
+
const [grantError, setGrantError] = useState(null);
|
|
28
|
+
const assignRoleMutation = useFetchMutation({
|
|
29
|
+
run: ({ input }) => port.assignRole(input)
|
|
30
|
+
}, {
|
|
31
|
+
invalidates: [[queryScope, ...KEYS.list]],
|
|
32
|
+
});
|
|
33
|
+
const attachPolicyMutation = useFetchMutation({
|
|
34
|
+
run: ({ input }) => port.attachPolicy(input)
|
|
35
|
+
}, {
|
|
36
|
+
invalidates: [[queryScope, ...KEYS.list]],
|
|
37
|
+
});
|
|
38
|
+
const [editEmail, setEditEmail] = useState("");
|
|
39
|
+
const updateEmailMutation = useFetchMutation({
|
|
40
|
+
run: ({ input }) => port.updateUser({ principalId: input.principalId }, { email: input.email })
|
|
41
|
+
}, {
|
|
42
|
+
invalidates: [[queryScope, ...KEYS.list]],
|
|
43
|
+
});
|
|
44
|
+
return { expandedId, setExpandedId, toggleGenerationRef, pendingRoleId, setPendingRoleId, pendingPolicyId, setPendingPolicyId, grantSaving, setGrantSaving, grantError, setGrantError, assignRoleMutation, attachPolicyMutation, editEmail, setEditEmail, updateEmailMutation };
|
|
45
|
+
}
|
|
46
|
+
export function useUsersStatusState({ port, queryScope }, { useAsyncAction = useAsyncActionDefault, useFetchMutation = useFetchMutationDefault } = {}) {
|
|
47
|
+
const [toggleSavingId, setToggleSavingId] = useState(null);
|
|
48
|
+
const [toggleError, setToggleError] = useState(null);
|
|
49
|
+
const [notice, setNotice] = useState(null);
|
|
50
|
+
const toggleStatusMutation = useFetchMutation({
|
|
51
|
+
run: ({ input: user }) => (user.status === "active" ? port.disableUser({ principalId: user.principalId }) : port.enableUser({ principalId: user.principalId }))
|
|
52
|
+
}, {
|
|
53
|
+
invalidates: [[queryScope, ...KEYS.list]],
|
|
54
|
+
});
|
|
55
|
+
// Disable now confirms via a `RowMenu` item -> `ConfirmDialog` modal (replacing the in-place
|
|
56
|
+
// two-click `ConfirmButton`, which has no menu-item equivalent — same migration the host app's src/features/posts/Posts.tsx and
|
|
57
|
+
// packages/admin/src/redirects/react/pages/RedirectsPage.tsx already made). `null` when the dialog is closed.
|
|
58
|
+
const [confirmingDisable, setConfirmingDisable] = useState(null);
|
|
59
|
+
// Reset password moved out of the expanded "Manage" panel into its own `RowMenu` item, which
|
|
60
|
+
// opens this dialog (it needs a text field, so it's a `ConfirmDialog` with an input in the body,
|
|
61
|
+
// not a plain confirm). Kept open on failure (unlike the delete-style dialogs above, which close
|
|
62
|
+
// either way) so a failed attempt doesn't discard the password the operator just typed.
|
|
63
|
+
const [resetPasswordFor, setResetPasswordFor] = useState(null);
|
|
64
|
+
const [newPassword, setNewPassword] = useState("");
|
|
65
|
+
const resetPassword = useAsyncAction();
|
|
66
|
+
return { toggleSavingId, setToggleSavingId, toggleError, setToggleError, notice, setNotice, toggleStatusMutation, confirmingDisable, setConfirmingDisable, resetPasswordFor, setResetPasswordFor, newPassword, setNewPassword, resetPassword };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=use-users-form-state.hooks.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AdminIdentityUser } from "../../models.js";
|
|
2
|
+
import type { UsersPort } from "../../ports.js";
|
|
3
|
+
import type { UsersController, UsersOptions } from "./use-users.hooks.js";
|
|
4
|
+
import type { useUsersState } from "./use-users-state.hooks.js";
|
|
5
|
+
import { useFetchMutation as useFetchMutationDefault } from "../../kit.js";
|
|
6
|
+
export declare function useUsersPasswordLink({ users, ownPrincipalId, ownProfile, resetPasswordFor }: ReturnType<typeof useUsersState>, { openOwnPasswordReset, onOwnPasswordResetClosed, openResetPassword }: UsersOptions & {
|
|
7
|
+
openResetPassword: UsersController['openResetPassword'];
|
|
8
|
+
}): void;
|
|
9
|
+
export declare function useUsersResetMutation({ port }: {
|
|
10
|
+
port: UsersPort;
|
|
11
|
+
}, { useFetchMutation }?: {
|
|
12
|
+
useFetchMutation?: typeof useFetchMutationDefault;
|
|
13
|
+
}): import("@jini-ai/ui").MutationResult<{
|
|
14
|
+
principalId: string;
|
|
15
|
+
password: string;
|
|
16
|
+
}, void>;
|
|
17
|
+
export declare function createUsersOpenResetAction({ state }: {
|
|
18
|
+
state: ReturnType<typeof useUsersState>;
|
|
19
|
+
}, _optional?: Record<string, never>): (user: AdminIdentityUser) => void;
|
|
20
|
+
export declare function createUsersConfirmResetAction({ state, resetPasswordMutation }: {
|
|
21
|
+
state: ReturnType<typeof useUsersState>;
|
|
22
|
+
resetPasswordMutation: ReturnType<typeof useUsersResetMutation>;
|
|
23
|
+
}, { passwordResetNotice }?: Pick<UsersOptions, 'passwordResetNotice'>): () => Promise<void>;
|
|
24
|
+
//# sourceMappingURL=use-users-password.hooks.d.ts.map
|