@jini-ai/user-management 0.7.2 → 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 -7
- 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,99 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
* pair, run one mutation, do a success-only side effect, and clear saving in a `finally` — the
|
|
9
|
-
* "whole-hook" complexity view (brief §2) rolls every closure inside a hook into one score, so two
|
|
10
|
-
* near-identical blocks count against `useUsers` even though `grantError`/`grantSaving` are
|
|
11
|
-
* deliberately NOT a fit for `useAsyncAction` (see that file's own header: shared across three
|
|
12
|
-
* handlers on purpose, not one action's own slot — `onSaveEmail` is the third, kept separate below
|
|
13
|
-
* since it tracks its OWN `emailSaving`). Reproducing the shared-state shape as a local top-level
|
|
14
|
-
* helper — rather than importing the generic primitive — collapses the two call sites without
|
|
15
|
-
* forcing that mismatch onto them. `mutate` itself `invalidates: [KEYS.list]`, replacing the
|
|
16
|
-
* pre-migration `reload()` call this helper used to make explicitly.
|
|
17
|
-
*
|
|
18
|
-
* `onSuccess` (2026-09-05 fix, same bug class as `use-roles.hooks.ts`'s `onSaveRole`/
|
|
19
|
-
* `onWritePermission`): nothing gates opening a DIFFERENT user's Manage panel
|
|
20
|
-
* (`toggleExpanded`) while a grant for the previously expanded one is still in flight, and
|
|
21
|
-
* `onSuccess` clears `pendingRoleId`/`pendingPolicyId` — a shared field, not keyed by principal.
|
|
22
|
-
* `toggleGenerationRef` (bumped once per `toggleExpanded` call, regardless of which panel — see
|
|
23
|
-
* that function) lets a stale grant tell whether the operator switched panels at ALL while it was
|
|
24
|
-
* in flight, independent of which principal is currently expanded: comparing against the panel's
|
|
25
|
-
* OWN identity would wrongly refuse a grant issued before any panel was ever expanded (a
|
|
26
|
-
* legitimate, already-certified call shape), where `expandedId` never gets set to begin with.
|
|
27
|
-
* `onSuccess` is skipped only when a switch actually happened since this call started — otherwise
|
|
28
|
-
* a stale grant's success would erase a NEW, unrelated selection the operator has since made for
|
|
29
|
-
* the panel they actually have open now. */
|
|
30
|
-
async function runGrantMutation({ toggleGenerationRef, mutate, onSuccess, setGrantSaving, setGrantError, describeError }) {
|
|
31
|
-
// Read synchronously, before the first `await` — the same instant both callers used to read and
|
|
32
|
-
// pass in themselves, so this is still the generation this call STARTED under.
|
|
33
|
-
const generationAtStart = toggleGenerationRef.current;
|
|
34
|
-
setGrantSaving(true);
|
|
35
|
-
setGrantError(null);
|
|
36
|
-
try {
|
|
37
|
-
await mutate();
|
|
38
|
-
if (toggleGenerationRef.current === generationAtStart)
|
|
39
|
-
onSuccess();
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
// Same generation check as the success branch above (C8, plan-access.md §8, N3): a stale
|
|
43
|
-
// failure must not paint onto a DIFFERENT user's panel the operator has since opened.
|
|
44
|
-
if (toggleGenerationRef.current === generationAtStart)
|
|
45
|
-
setGrantError(describeError(e));
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
// Guarded the same way — a stale call's `finally` must not clear a NEWER call's own saving
|
|
49
|
-
// flag. `toggleExpanded` resets `grantSaving` itself when it bumps the generation, so a panel
|
|
50
|
-
// switch still leaves the new panel un-stuck even though this skip means THIS call no longer
|
|
51
|
-
// clears it.
|
|
52
|
-
if (toggleGenerationRef.current === generationAtStart)
|
|
53
|
-
setGrantSaving(false);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Roles and policies for the grant controls, or `null` when the server refuses them with 403 (the
|
|
58
|
-
* caller lacks `role.manage`). Any other failure still rejects, so a real outage keeps surfacing as
|
|
59
|
-
* the screen's load error.
|
|
60
|
-
*
|
|
61
|
-
* @complexity O(1) requests (two, concurrent).
|
|
62
|
-
*/
|
|
63
|
-
async function loadGrantOptions(port) {
|
|
64
|
-
try {
|
|
65
|
-
const [r, p] = await Promise.all([port.listRoles({}), port.listPolicies({})]);
|
|
66
|
-
return { roles: r.roles, policies: p.policies };
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
if (e && typeof e === "object" && "status" in e && e.status === 403)
|
|
70
|
-
return null;
|
|
71
|
-
throw e;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* The combined read split into the controller's list fields: all `null` (and `canGrant` false)
|
|
76
|
-
* until the read settles, then `[]` roles/policies with `canGrant` false when `loadGrantOptions`
|
|
77
|
-
* reported a 403. Pure so `useUsers` stays a flat wiring list.
|
|
78
|
-
*/
|
|
79
|
-
function selectUsersList({ data }) {
|
|
80
|
-
if (!data)
|
|
81
|
-
return { users: null, roles: null, policies: null, canGrant: false };
|
|
82
|
-
const grantOptions = data.grantOptions;
|
|
83
|
-
return { users: data.users, roles: grantOptions?.roles ?? [], policies: grantOptions?.policies ?? [], canGrant: grantOptions != null };
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* The signed-in caller as the row-level permission checks see it: their own roster row (`null`
|
|
87
|
-
* while `me()` or the roster is unsettled, or when the caller is not in it), whether that row is an
|
|
88
|
-
* owner, and the role lookup both checks share. Computed once per render rather than once per row.
|
|
89
|
-
*
|
|
90
|
-
* @complexity O(users + roles) per render.
|
|
91
|
-
*/
|
|
92
|
-
function selectCaller({ users, roles, ownPrincipalId }) {
|
|
93
|
-
const roleMap = new Map((roles ?? []).map(role => [role.id, role]));
|
|
94
|
-
const ownProfile = users?.find(user => user.principalId === ownPrincipalId) ?? null;
|
|
95
|
-
return { roleMap, ownProfile, callerIsOwner: ownProfile !== null && isOwnerAccount({ user: ownProfile, roles: roleMap }) };
|
|
96
|
-
}
|
|
1
|
+
import { useUsersState as useUsersStateDefault } from "./use-users-state.hooks.js";
|
|
2
|
+
import { useUsersPasswordLink as useUsersPasswordLinkDefault, useUsersResetMutation as useUsersResetMutationDefault } from "./use-users-password.hooks.js";
|
|
3
|
+
import { createUsersOpenResetAction, createUsersConfirmResetAction } from "./use-users-password.hooks.js";
|
|
4
|
+
import { createUsersCreateAction, createUsersPanelActions, createUsersGrantActions } from "./users-grant-actions.js";
|
|
5
|
+
import { useUsersDeletion as useUsersDeletionDefault } from "./use-users-status.hooks.js";
|
|
6
|
+
import { createUsersToggleAction, createUsersDisableActions } from "./use-users-status.hooks.js";
|
|
7
|
+
import { createUsersController } from "./users-controller.js";
|
|
97
8
|
/**
|
|
98
9
|
* Everything the Users screen does — full state, effects, and every server write, as one hook so
|
|
99
10
|
* `Users.tsx` stays a pure render of whatever this returns. See this file's header for the
|
|
@@ -102,412 +13,21 @@ function selectCaller({ users, roles, ownPrincipalId }) {
|
|
|
102
13
|
* @param deps - Injected collaborators; production callers get these from {@link useWiredUsers}.
|
|
103
14
|
* @returns The full `UsersController` the view renders from — see that interface for every field.
|
|
104
15
|
*/
|
|
105
|
-
export function useUsers({ port, translate, queryScope }, { openOwnPasswordReset = false, onOwnPasswordResetClosed, passwordResetNotice, } = {}) {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
const { users, roles, policies, canGrant } = selectUsersList({ data: list.data });
|
|
123
|
-
const error = list.error ? describeError(list.error, translate("failed to load users")) : null;
|
|
124
|
-
const [formOpen, setFormOpen] = useState(false);
|
|
125
|
-
const [username, setUsername] = useState("");
|
|
126
|
-
const [email, setEmail] = useState("");
|
|
127
|
-
const [password, setPassword] = useState("");
|
|
128
|
-
const createUser = useAsyncAction();
|
|
129
|
-
const createUserMutation = useFetchMutation({
|
|
130
|
-
run: ({ input }) => port.createUser({ username: input.username, password: input.password }, { email: input.email })
|
|
131
|
-
}, {
|
|
132
|
-
invalidates: [[queryScope, ...KEYS.list]],
|
|
133
|
-
});
|
|
134
|
-
const [expandedId, setExpandedId] = useState(null);
|
|
135
|
-
// Bumped once per `toggleExpanded` call, regardless of which panel — `runGrantMutation` (a
|
|
136
|
-
// top-level function, outside this closure's re-render cycle) reads this to tell whether the
|
|
137
|
-
// operator switched panels AT ALL while its own grant was in flight. See that function's own doc
|
|
138
|
-
// comment for why this counts switches rather than comparing against `expandedId`'s value.
|
|
139
|
-
const toggleGenerationRef = useRef(0);
|
|
140
|
-
const [pendingRoleId, setPendingRoleId] = useState("");
|
|
141
|
-
const [pendingPolicyId, setPendingPolicyId] = useState("");
|
|
142
|
-
const [grantSaving, setGrantSaving] = useState(false);
|
|
143
|
-
const [grantError, setGrantError] = useState(null);
|
|
144
|
-
const assignRoleMutation = useFetchMutation({
|
|
145
|
-
run: ({ input }) => port.assignRole(input)
|
|
146
|
-
}, {
|
|
147
|
-
invalidates: [[queryScope, ...KEYS.list]],
|
|
148
|
-
});
|
|
149
|
-
const attachPolicyMutation = useFetchMutation({
|
|
150
|
-
run: ({ input }) => port.attachPolicy(input)
|
|
151
|
-
}, {
|
|
152
|
-
invalidates: [[queryScope, ...KEYS.list]],
|
|
153
|
-
});
|
|
154
|
-
const [editEmail, setEditEmail] = useState("");
|
|
155
|
-
const updateEmailMutation = useFetchMutation({
|
|
156
|
-
run: ({ input }) => port.updateUser({ principalId: input.principalId }, { email: input.email })
|
|
157
|
-
}, {
|
|
158
|
-
invalidates: [[queryScope, ...KEYS.list]],
|
|
159
|
-
});
|
|
160
|
-
const [toggleSavingId, setToggleSavingId] = useState(null);
|
|
161
|
-
const [toggleError, setToggleError] = useState(null);
|
|
162
|
-
const [notice, setNotice] = useState(null);
|
|
163
|
-
const toggleStatusMutation = useFetchMutation({
|
|
164
|
-
run: ({ input: user }) => (user.status === "active" ? port.disableUser({ principalId: user.principalId }) : port.enableUser({ principalId: user.principalId }))
|
|
165
|
-
}, {
|
|
166
|
-
invalidates: [[queryScope, ...KEYS.list]],
|
|
167
|
-
});
|
|
168
|
-
// Disable now confirms via a `RowMenu` item -> `ConfirmDialog` modal (replacing the in-place
|
|
169
|
-
// two-click `ConfirmButton`, which has no menu-item equivalent — same migration Posts.tsx/
|
|
170
|
-
// Redirects.tsx already made). `null` when the dialog is closed.
|
|
171
|
-
const [confirmingDisable, setConfirmingDisable] = useState(null);
|
|
172
|
-
// Reset password moved out of the expanded "Manage" panel into its own `RowMenu` item, which
|
|
173
|
-
// opens this dialog (it needs a text field, so it's a `ConfirmDialog` with an input in the body,
|
|
174
|
-
// not a plain confirm). Kept open on failure (unlike the delete-style dialogs above, which close
|
|
175
|
-
// either way) so a failed attempt doesn't discard the password the operator just typed.
|
|
176
|
-
const [resetPasswordFor, setResetPasswordFor] = useState(null);
|
|
177
|
-
const [newPassword, setNewPassword] = useState("");
|
|
178
|
-
const resetPassword = useAsyncAction();
|
|
179
|
-
/** The signed-in caller's own principal id (password-banner plan, 2026-09-24 Slice 3), from
|
|
180
|
-
* `port.me()`. `null` until that call settles, or forever if it fails — both are treated as
|
|
181
|
-
* "unknown", which the deep-link effect below and `confirmResetPassword`'s notice branch both
|
|
182
|
-
* already handle as "not a self-reset".
|
|
183
|
-
*
|
|
184
|
-
* Fetched unconditionally (not gated on `openOwnPasswordReset`) — a deliberate choice, not an
|
|
185
|
-
* oversight: it makes the "sign in again" notice below correct for ANY self-reset, including an
|
|
186
|
-
* admin resetting their OWN row from the ordinary row-menu (no deep link involved), not just the
|
|
187
|
-
* one opened via `/users/change-password`. One extra `me()` call per screen load is cheaper than
|
|
188
|
-
* threading two different notice code paths for what is, to the operator, the same event. */
|
|
189
|
-
const [ownPrincipalId, setOwnPrincipalId] = useState(null);
|
|
190
|
-
const [effectivePermissions, setEffectivePermissions] = useState([]);
|
|
191
|
-
// `canManageUserTrash` (delete-user plan v2, Slice 4): resolved by this SAME one-shot `me()` call
|
|
192
|
-
// rather than a second request — see `UsersController.canManageUserTrash`'s own doc comment.
|
|
193
|
-
const [canManageUserTrash, setCanManageUserTrash] = useState(false);
|
|
194
|
-
useEffect(() => {
|
|
195
|
-
let cancelled = false;
|
|
196
|
-
portRef.current
|
|
197
|
-
.me({})
|
|
198
|
-
.then((res) => {
|
|
199
|
-
if (!cancelled) {
|
|
200
|
-
setOwnPrincipalId(res.user.id);
|
|
201
|
-
setEffectivePermissions(res.effectivePermissions ?? []);
|
|
202
|
-
setCanManageUserTrash(res.canManageUserTrash);
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
.catch(() => {
|
|
206
|
-
// Best-effort, see `ownPrincipalId`'s own doc comment above — a failure just means the
|
|
207
|
-
// deep link can't auto-open and self-resets fall back to the per-username notice.
|
|
208
|
-
// `canManageUserTrash` stays `false`, the same "unknown means no affordance" default.
|
|
209
|
-
});
|
|
210
|
-
return () => {
|
|
211
|
-
cancelled = true;
|
|
212
|
-
};
|
|
213
|
-
}, []);
|
|
214
|
-
const { roleMap, ownProfile, callerIsOwner } = selectCaller({ users, roles, ownPrincipalId });
|
|
215
|
-
function rowCapabilities(user) {
|
|
216
|
-
return userAccountCapabilities({ user, callerPrincipalId: ownPrincipalId, callerIsOwner, canManageUserTrash, roles: roleMap });
|
|
217
|
-
}
|
|
218
|
-
function canRenameUser(user) {
|
|
219
|
-
if (user.canRename === false)
|
|
220
|
-
return false;
|
|
221
|
-
if (!ownPrincipalId || (!effectivePermissions.includes("*") && !effectivePermissions.includes("user.manage")))
|
|
222
|
-
return false;
|
|
223
|
-
// Server-supplied owner flags remain authoritative when role.manage is unavailable.
|
|
224
|
-
const targetIsOwner = user.isOwner ?? (user.roleIds.some(id => !roleMap.has(id)) || isOwnerAccount({ user, roles: roleMap }));
|
|
225
|
-
return !targetIsOwner || callerIsOwner;
|
|
226
|
-
}
|
|
227
|
-
const changeUsername = useChangeUsername({ port, queryScope, translate, canRename: canRenameUser });
|
|
228
|
-
const canRenameOwnProfile = ownProfile !== null && canRenameUser(ownProfile);
|
|
229
|
-
/** Profile and row actions enter the same guarded dialog; the view only renders affordances. */
|
|
230
|
-
function openOwnRename() {
|
|
231
|
-
if (ownProfile)
|
|
232
|
-
changeUsername.open({ user: ownProfile });
|
|
233
|
-
}
|
|
234
|
-
function renameUserHandler({ user }, _options = {}) {
|
|
235
|
-
return canRenameUser(user) ? (target) => changeUsername.open({ user: target }) : undefined;
|
|
236
|
-
}
|
|
237
|
-
/** Guards the one-shot deep-link auto-open effect below so it fires at most once per mount, even
|
|
238
|
-
* as `users`/`ownPrincipalId` keep changing identity across the renders it's waiting on (list
|
|
239
|
-
* reloads, `me()` settling). Separate from {@link openedViaDeepLinkRef}, which tracks a DIFFERENT
|
|
240
|
-
* question ("should closing the dialog navigate away") over the dialog's own open/close lifetime
|
|
241
|
-
* — this one is "has the auto-open already been attempted", which must stay true forever once it
|
|
242
|
-
* fires, including after the dialog this effect opened has since been closed. */
|
|
243
|
-
const deepLinkAttemptedRef = useRef(false);
|
|
244
|
-
/** Set true exactly when this effect opens the dialog, cleared by the close-effect below the first
|
|
245
|
-
* time it observes `resetPasswordFor` go back to `null`. Read there to decide whether to navigate
|
|
246
|
-
* — an operator resetting a DIFFERENT row's password from the ordinary row menu, or cancelling a
|
|
247
|
-
* normal reset, must not also get shoved to `/users`. */
|
|
248
|
-
const openedViaDeepLinkRef = useRef(false);
|
|
249
|
-
useEffect(() => {
|
|
250
|
-
// `ownProfile` is derived from exactly `users`/`ownPrincipalId` (see `selectCaller`), so it is
|
|
251
|
-
// `null` until both have settled and the caller's own row is in the roster.
|
|
252
|
-
if (!openOwnPasswordReset || deepLinkAttemptedRef.current || !ownProfile)
|
|
253
|
-
return;
|
|
254
|
-
deepLinkAttemptedRef.current = true;
|
|
255
|
-
openedViaDeepLinkRef.current = true;
|
|
256
|
-
openResetPassword(ownProfile);
|
|
257
|
-
}, [openOwnPasswordReset, users, ownPrincipalId]);
|
|
258
|
-
useEffect(() => {
|
|
259
|
-
if (resetPasswordFor !== null || !openedViaDeepLinkRef.current)
|
|
260
|
-
return;
|
|
261
|
-
openedViaDeepLinkRef.current = false;
|
|
262
|
-
onOwnPasswordResetClosed?.();
|
|
263
|
-
}, [resetPasswordFor, onOwnPasswordResetClosed]);
|
|
264
|
-
// No `invalidates` — matches the pre-migration `confirmResetPassword`, which never called
|
|
265
|
-
// `reload()` either (a password reset changes nothing the users table shows).
|
|
266
|
-
const resetPasswordMutation = useFetchMutation({
|
|
267
|
-
run: ({ input }) => port.resetUserPassword(input),
|
|
268
|
-
});
|
|
269
|
-
async function onCreate(e) {
|
|
270
|
-
e.preventDefault();
|
|
271
|
-
await createUser.run({ action: async () => {
|
|
272
|
-
await createUserMutation.mutate({ input: { username, password, email: email || undefined } });
|
|
273
|
-
setUsername("");
|
|
274
|
-
setEmail("");
|
|
275
|
-
setPassword("");
|
|
276
|
-
setFormOpen(false);
|
|
277
|
-
}, describeError: (e) => describeError(e, translate("failed to create user")) });
|
|
278
|
-
}
|
|
279
|
-
function toggleExpanded(user) {
|
|
280
|
-
setGrantError(null);
|
|
281
|
-
// A still-in-flight grant for the panel being LEFT can no longer clear this itself
|
|
282
|
-
// (`runGrantMutation`'s `finally` now skips a stale call's own generation) — reset it here so
|
|
283
|
-
// the newly opened panel never inherits a stuck "saving" indicator from the old one.
|
|
284
|
-
setGrantSaving(false);
|
|
285
|
-
setPendingRoleId("");
|
|
286
|
-
setPendingPolicyId("");
|
|
287
|
-
setEditEmail(user.email ?? "");
|
|
288
|
-
toggleGenerationRef.current += 1;
|
|
289
|
-
setExpandedId((current) => (current === user.principalId ? null : user.principalId));
|
|
290
|
-
}
|
|
291
|
-
async function onAssignRole({ principalId }) {
|
|
292
|
-
if (!pendingRoleId)
|
|
293
|
-
return;
|
|
294
|
-
await runGrantMutation({
|
|
295
|
-
toggleGenerationRef,
|
|
296
|
-
mutate: () => assignRoleMutation.mutate({ input: { principalId, roleId: pendingRoleId } }),
|
|
297
|
-
onSuccess: () => setPendingRoleId(""),
|
|
298
|
-
setGrantSaving,
|
|
299
|
-
setGrantError,
|
|
300
|
-
describeError: (e) => describeError(e, translate("failed to assign role")),
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
async function onAttachPolicy({ principalId }) {
|
|
304
|
-
if (!pendingPolicyId)
|
|
305
|
-
return;
|
|
306
|
-
await runGrantMutation({
|
|
307
|
-
toggleGenerationRef,
|
|
308
|
-
mutate: () => attachPolicyMutation.mutate({ input: { principalId, policyId: pendingPolicyId } }),
|
|
309
|
-
onSuccess: () => setPendingPolicyId(""),
|
|
310
|
-
setGrantSaving,
|
|
311
|
-
setGrantError,
|
|
312
|
-
describeError: (e) => describeError(e, translate("failed to attach policy")),
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
// `onSaveEmail` was left out of the `runGrantMutation` fold above on purpose: it tracks its OWN
|
|
316
|
-
// `emailSaving` flag rather than the shared `grantSaving` `onAssignRole`/`onAttachPolicy` use, so
|
|
317
|
-
// routing it through the same helper would mean passing a no-op in place of `setGrantSaving` —
|
|
318
|
-
// extraction for the sake of a shared call site, not a shared shape. Left hand-rolled; `emailSaving`
|
|
319
|
-
// now derives from `updateEmailMutation.status` since (unlike `grantSaving`) it was already this
|
|
320
|
-
// one mutation's own dedicated flag.
|
|
321
|
-
async function onSaveEmail({ principalId }) {
|
|
322
|
-
setGrantError(null);
|
|
323
|
-
try {
|
|
324
|
-
await updateEmailMutation.mutate({ input: { principalId, email: editEmail } });
|
|
325
|
-
}
|
|
326
|
-
catch (e) {
|
|
327
|
-
setGrantError(describeError(e, translate("failed to update email")));
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
const emailSaving = updateEmailMutation.status === "pending";
|
|
331
|
-
/** Opens the reset-password dialog for `user` — the `RowMenu` item's `onSelect`. Guards against
|
|
332
|
-
* opening a second one while a toggle or a previous reset is still in flight, same discipline
|
|
333
|
-
* Redirects.tsx uses for its own `RowMenu` items (no per-item `disabled` on `RowMenu` itself). */
|
|
334
|
-
function openResetPassword(user) {
|
|
335
|
-
if (!rowCapabilities(user).canResetPassword)
|
|
336
|
-
return;
|
|
337
|
-
if (toggleSavingId || resetPassword.saving)
|
|
338
|
-
return;
|
|
339
|
-
resetPassword.setError(null);
|
|
340
|
-
setNewPassword("");
|
|
341
|
-
setResetPasswordFor(user);
|
|
342
|
-
}
|
|
343
|
-
async function confirmResetPassword() {
|
|
344
|
-
if (!resetPasswordFor || !newPassword || !rowCapabilities(resetPasswordFor).canResetPassword)
|
|
345
|
-
return;
|
|
346
|
-
// Dialog stays open on failure (unlike the Disable/Delete-style dialogs elsewhere in this app,
|
|
347
|
-
// which close either way) — closing would discard the password the operator just typed for no
|
|
348
|
-
// reason; there's nothing sensitive left on screen once they retry or cancel. `resetPasswordFor`/
|
|
349
|
-
// `newPassword` are therefore only cleared in the success path below, never as a `finally`.
|
|
350
|
-
await resetPassword.run({ action: async () => {
|
|
351
|
-
await resetPasswordMutation.mutate({ input: { principalId: resetPasswordFor.principalId, password: newPassword } });
|
|
352
|
-
// A self-reset (own row, deep-linked or from the ordinary row menu — see `ownPrincipalId`'s
|
|
353
|
-
// own doc comment) gets the "sign in again" notice instead of the per-username one: the reset
|
|
354
|
-
// just revoked the CALLER'S OWN session, so the next request 401s and `App.hooks.tsx` sends
|
|
355
|
-
// them to the login screen — the generic notice naming a DIFFERENT user would be misleading
|
|
356
|
-
// here, since it's actually their own sign-in that just ended.
|
|
357
|
-
setNotice(resetPasswordFor.principalId === ownPrincipalId
|
|
358
|
-
? translate("Password changed. Sign in again with your new password.")
|
|
359
|
-
: passwordResetNotice?.({ username: resetPasswordFor.username }) ?? interpolate({
|
|
360
|
-
template: translate('Password reset for "{username}" — every active session for this user was revoked.'),
|
|
361
|
-
vars: { username: resetPasswordFor.username },
|
|
362
|
-
}));
|
|
363
|
-
setResetPasswordFor(null);
|
|
364
|
-
setNewPassword("");
|
|
365
|
-
}, describeError: (e) => describeError(e, translate("failed to reset password")) });
|
|
366
|
-
}
|
|
367
|
-
/** `setToggleSavingId`'s `finally` reset (2026-09-05 fix, same bug class as
|
|
368
|
-
* `use-roles.hooks.ts`'s `onSaveRole`/`runRowDelete`) is a functional update keyed on THIS call's
|
|
369
|
-
* own `principalId`: Enable fires with no confirmation gate, so two calls — on different users —
|
|
370
|
-
* can genuinely overlap, and an unconditional reset would clear the busy indicator (which
|
|
371
|
-
* `openResetPassword` below reads to refuse opening while a toggle is in flight) out from under a
|
|
372
|
-
* still-in-flight, unrelated toggle. */
|
|
373
|
-
async function onToggleStatus(user) {
|
|
374
|
-
const capabilities = rowCapabilities(user);
|
|
375
|
-
if (user.status === "active" ? !capabilities.canDisable : !capabilities.canEnable)
|
|
376
|
-
return;
|
|
377
|
-
setToggleSavingId(user.principalId);
|
|
378
|
-
setToggleError(null);
|
|
379
|
-
try {
|
|
380
|
-
await toggleStatusMutation.mutate({ input: user });
|
|
381
|
-
}
|
|
382
|
-
catch (e) {
|
|
383
|
-
setToggleError(describeError(e, translate("failed to change status")));
|
|
384
|
-
}
|
|
385
|
-
finally {
|
|
386
|
-
setToggleSavingId((current) => (current === user.principalId ? null : current));
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
/** Opens the Disable confirm dialog for `user` — the `RowMenu` "Disable" item's `onSelect` when
|
|
390
|
-
* the user is currently active. Was an inline closure inside the old `rowMenuItems`; named here
|
|
391
|
-
* now that the item builder itself moved to `rules.ts` and needs a callback to hand it. */
|
|
392
|
-
function requestDisable(user) {
|
|
393
|
-
if (!rowCapabilities(user).canDisable)
|
|
394
|
-
return;
|
|
395
|
-
setToggleError(null);
|
|
396
|
-
setConfirmingDisable(user);
|
|
397
|
-
}
|
|
398
|
-
/** Confirms the Disable that `RowMenu`'s "Disable" item asked about. Closes the dialog either
|
|
399
|
-
* way (matching Posts.tsx/Redirects.tsx's own Disable/Delete `ConfirmDialog` convention) — a
|
|
400
|
-
* failure surfaces via `toggleError` above the table, not by leaving the modal open.
|
|
401
|
-
*
|
|
402
|
-
* 2026-09-05 fix, same bug class as `use-roles.hooks.ts`'s `runRowDelete`: `setConfirmingDisable`
|
|
403
|
-
* is exposed directly on the controller, so nothing at the hook level stops the operator opening
|
|
404
|
-
* a DIFFERENT user's Disable confirmation while this one's toggle is still in flight. The close
|
|
405
|
-
* below only clears it when it still names the SAME user this call started for — otherwise a
|
|
406
|
-
* stale toggle's settlement would silently dismiss a newer, still-undecided confirmation. */
|
|
407
|
-
async function confirmDisable() {
|
|
408
|
-
if (!confirmingDisable)
|
|
409
|
-
return;
|
|
410
|
-
const user = confirmingDisable;
|
|
411
|
-
await onToggleStatus(user);
|
|
412
|
-
setConfirmingDisable((current) => (current?.principalId === user.principalId ? null : current));
|
|
413
|
-
}
|
|
414
|
-
// Delete-user plan v2 (2026-09-24), Slice 4 — mirrors Disable's request/confirm pair above with
|
|
415
|
-
// its OWN state (see `confirmingDelete`'s own doc comment for why not shared). `deleteUserMutation`
|
|
416
|
-
// invalidates `KEYS.list` like every other write on this screen; the route already filters a newly
|
|
417
|
-
// trashed principal out of `listUsers()`, so the row disappears on the next render with no extra
|
|
418
|
-
// client-side bookkeeping.
|
|
419
|
-
const deleteUserMutation = useFetchMutation({
|
|
420
|
-
run: ({ input: principalId }) => port.deleteUser({ principalId })
|
|
421
|
-
}, {
|
|
422
|
-
invalidates: [[queryScope, ...KEYS.list]],
|
|
423
|
-
});
|
|
424
|
-
const [confirmingDelete, setConfirmingDelete] = useState(null);
|
|
425
|
-
function requestDelete(user) {
|
|
426
|
-
if (!rowCapabilities(user).canDelete)
|
|
427
|
-
return;
|
|
428
|
-
setToggleError(null);
|
|
429
|
-
setConfirmingDelete(user);
|
|
430
|
-
}
|
|
431
|
-
/** Confirms the Delete that `RowMenu`'s "Delete" item asked about. Closes the dialog either way
|
|
432
|
-
* (matching `confirmDisable`'s and Posts.tsx/Redirects.tsx's own Delete `ConfirmDialog`
|
|
433
|
-
* convention) — a failure surfaces via `toggleError` above the table, not by leaving the modal
|
|
434
|
-
* open. Same stale-call guard as `confirmDisable`: only clears `confirmingDelete` when it still
|
|
435
|
-
* names the SAME user this call started for. */
|
|
436
|
-
async function confirmDelete() {
|
|
437
|
-
if (!confirmingDelete || !rowCapabilities(confirmingDelete).canDelete)
|
|
438
|
-
return;
|
|
439
|
-
const user = confirmingDelete;
|
|
440
|
-
try {
|
|
441
|
-
await deleteUserMutation.mutate({ input: user.principalId });
|
|
442
|
-
}
|
|
443
|
-
catch (e) {
|
|
444
|
-
setToggleError(describeError(e, translate("failed to delete user")));
|
|
445
|
-
}
|
|
446
|
-
setConfirmingDelete((current) => (current?.principalId === user.principalId ? null : current));
|
|
447
|
-
}
|
|
448
|
-
return {
|
|
449
|
-
users,
|
|
450
|
-
roles,
|
|
451
|
-
policies,
|
|
452
|
-
canGrant,
|
|
453
|
-
error,
|
|
454
|
-
formOpen,
|
|
455
|
-
setFormOpen,
|
|
456
|
-
username,
|
|
457
|
-
setUsername,
|
|
458
|
-
email,
|
|
459
|
-
setEmail,
|
|
460
|
-
password,
|
|
461
|
-
setPassword,
|
|
462
|
-
saving: createUser.saving,
|
|
463
|
-
formError: createUser.error,
|
|
464
|
-
onCreate,
|
|
465
|
-
expandedId,
|
|
466
|
-
toggleExpanded,
|
|
467
|
-
pendingRoleId,
|
|
468
|
-
setPendingRoleId,
|
|
469
|
-
pendingPolicyId,
|
|
470
|
-
setPendingPolicyId,
|
|
471
|
-
grantSaving,
|
|
472
|
-
grantError,
|
|
473
|
-
onAssignRole,
|
|
474
|
-
onAttachPolicy,
|
|
475
|
-
editEmail,
|
|
476
|
-
setEditEmail,
|
|
477
|
-
emailSaving,
|
|
478
|
-
onSaveEmail,
|
|
479
|
-
toggleSavingId,
|
|
480
|
-
toggleError,
|
|
481
|
-
notice,
|
|
482
|
-
confirmingDisable,
|
|
483
|
-
setConfirmingDisable,
|
|
484
|
-
requestDisable,
|
|
485
|
-
confirmDisable,
|
|
486
|
-
onToggleStatus,
|
|
487
|
-
resetPasswordFor,
|
|
488
|
-
setResetPasswordFor,
|
|
489
|
-
newPassword,
|
|
490
|
-
setNewPassword,
|
|
491
|
-
passwordSaving: resetPassword.saving,
|
|
492
|
-
passwordError: resetPassword.error,
|
|
493
|
-
setPasswordError: resetPassword.setError,
|
|
494
|
-
openResetPassword,
|
|
495
|
-
confirmResetPassword,
|
|
496
|
-
canManageUserTrash,
|
|
497
|
-
rowCapabilities,
|
|
498
|
-
ownProfile,
|
|
499
|
-
canRenameUser,
|
|
500
|
-
canRenameOwnProfile,
|
|
501
|
-
openOwnRename,
|
|
502
|
-
renameUserHandler,
|
|
503
|
-
changeUsername,
|
|
504
|
-
confirmingDelete,
|
|
505
|
-
setConfirmingDelete,
|
|
506
|
-
requestDelete,
|
|
507
|
-
deleteSaving: deleteUserMutation.status === "pending",
|
|
508
|
-
confirmDelete,
|
|
509
|
-
t: translate,
|
|
510
|
-
translate,
|
|
511
|
-
};
|
|
16
|
+
export function useUsers({ port, translate, queryScope }, { openOwnPasswordReset = false, onOwnPasswordResetClosed, passwordResetNotice, useUsersState = useUsersStateDefault, useUsersPasswordLink = useUsersPasswordLinkDefault, useUsersResetMutation = useUsersResetMutationDefault, useUsersDeletion = useUsersDeletionDefault, } = {}) {
|
|
17
|
+
const state = useUsersState({ port, translate, queryScope });
|
|
18
|
+
const openResetPassword = createUsersOpenResetAction({ state });
|
|
19
|
+
useUsersPasswordLink(state, { openOwnPasswordReset, onOwnPasswordResetClosed, openResetPassword });
|
|
20
|
+
const resetPasswordMutation = useUsersResetMutation({ port });
|
|
21
|
+
const onCreate = createUsersCreateAction({ state });
|
|
22
|
+
const panelActions = createUsersPanelActions({ state });
|
|
23
|
+
const grantActions = createUsersGrantActions({ state });
|
|
24
|
+
const confirmResetPassword = createUsersConfirmResetAction({ state, resetPasswordMutation }, { passwordResetNotice });
|
|
25
|
+
const onToggleStatus = createUsersToggleAction({ state });
|
|
26
|
+
const disableActions = createUsersDisableActions({ state, onToggleStatus });
|
|
27
|
+
const deletion = useUsersDeletion({ state });
|
|
28
|
+
return createUsersController({ state, actions: {
|
|
29
|
+
onCreate, ...panelActions, ...grantActions, openResetPassword, confirmResetPassword,
|
|
30
|
+
onToggleStatus, ...disableActions, ...deletion,
|
|
31
|
+
} });
|
|
512
32
|
}
|
|
513
33
|
//# sourceMappingURL=use-users.hooks.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UsersController } from "./use-users.hooks.js";
|
|
2
|
+
import type { useUsersState } from "./use-users-state.hooks.js";
|
|
3
|
+
import type { createUsersPanelActions, createUsersGrantActions } from "./users-grant-actions.js";
|
|
4
|
+
import type { createUsersDisableActions, useUsersDeletion } from "./use-users-status.hooks.js";
|
|
5
|
+
export declare function createUsersController({ state, actions }: {
|
|
6
|
+
state: ReturnType<typeof useUsersState>;
|
|
7
|
+
actions: ReturnType<typeof createUsersPanelActions> & ReturnType<typeof createUsersGrantActions> & ReturnType<typeof createUsersDisableActions> & ReturnType<typeof useUsersDeletion> & {
|
|
8
|
+
onCreate: UsersController['onCreate'];
|
|
9
|
+
openResetPassword: UsersController['openResetPassword'];
|
|
10
|
+
confirmResetPassword: UsersController['confirmResetPassword'];
|
|
11
|
+
onToggleStatus: UsersController['onToggleStatus'];
|
|
12
|
+
};
|
|
13
|
+
}, _optional?: Record<string, never>): UsersController;
|
|
14
|
+
//# sourceMappingURL=users-controller.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function createUsersController({ state, actions }, _optional = {}) {
|
|
2
|
+
const { users, roles, policies, canGrant, error, formOpen, setFormOpen, username, setUsername, email, setEmail, password, setPassword, createUser, expandedId, pendingRoleId, setPendingRoleId, pendingPolicyId, setPendingPolicyId, grantSaving, grantError, editEmail, setEditEmail, toggleSavingId, toggleError, notice, confirmingDisable, setConfirmingDisable, resetPasswordFor, setResetPasswordFor, newPassword, setNewPassword, resetPassword, canManageUserTrash, rowCapabilities, ownProfile, canRenameUser, canRenameOwnProfile, openOwnRename, renameUserHandler, changeUsername, translate, } = state;
|
|
3
|
+
const { onCreate, toggleExpanded, onAssignRole, onAttachPolicy, emailSaving, onSaveEmail, requestDisable, confirmDisable, onToggleStatus, openResetPassword, confirmResetPassword, confirmingDelete, setConfirmingDelete, requestDelete, deleteUserMutation, confirmDelete, } = actions;
|
|
4
|
+
return {
|
|
5
|
+
users, roles, policies, canGrant, error,
|
|
6
|
+
formOpen, setFormOpen, username, setUsername,
|
|
7
|
+
email, setEmail, password, setPassword,
|
|
8
|
+
saving: createUser.saving,
|
|
9
|
+
formError: createUser.error,
|
|
10
|
+
onCreate,
|
|
11
|
+
expandedId, toggleExpanded, pendingRoleId, setPendingRoleId,
|
|
12
|
+
pendingPolicyId, setPendingPolicyId, grantSaving, grantError,
|
|
13
|
+
onAssignRole, onAttachPolicy,
|
|
14
|
+
editEmail, setEditEmail, emailSaving, onSaveEmail,
|
|
15
|
+
toggleSavingId, toggleError, notice,
|
|
16
|
+
confirmingDisable, setConfirmingDisable, requestDisable, confirmDisable, onToggleStatus,
|
|
17
|
+
resetPasswordFor, setResetPasswordFor, newPassword, setNewPassword,
|
|
18
|
+
passwordSaving: resetPassword.saving,
|
|
19
|
+
passwordError: resetPassword.error,
|
|
20
|
+
setPasswordError: resetPassword.setError,
|
|
21
|
+
openResetPassword, confirmResetPassword,
|
|
22
|
+
canManageUserTrash, rowCapabilities, ownProfile, canRenameUser,
|
|
23
|
+
canRenameOwnProfile, openOwnRename, renameUserHandler, changeUsername,
|
|
24
|
+
confirmingDelete, setConfirmingDelete, requestDelete,
|
|
25
|
+
deleteSaving: deleteUserMutation.status === "pending", confirmDelete,
|
|
26
|
+
t: translate, translate,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=users-controller.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FormEvent } from "react";
|
|
2
|
+
import type { AdminIdentityUser } from "../../models.js";
|
|
3
|
+
import type { useUsersState } from "./use-users-state.hooks.js";
|
|
4
|
+
export declare function createUsersCreateAction({ state }: {
|
|
5
|
+
state: ReturnType<typeof useUsersState>;
|
|
6
|
+
}, _optional?: Record<string, never>): (e: FormEvent) => Promise<void>;
|
|
7
|
+
export declare function createUsersPanelActions({ state }: {
|
|
8
|
+
state: ReturnType<typeof useUsersState>;
|
|
9
|
+
}, _optional?: Record<string, never>): {
|
|
10
|
+
toggleExpanded: (user: AdminIdentityUser) => void;
|
|
11
|
+
onSaveEmail: ({ principalId }: {
|
|
12
|
+
principalId: string;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
emailSaving: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function createUsersGrantActions({ state }: {
|
|
17
|
+
state: ReturnType<typeof useUsersState>;
|
|
18
|
+
}, _optional?: Record<string, never>): {
|
|
19
|
+
onAssignRole: ({ principalId }: {
|
|
20
|
+
principalId: string;
|
|
21
|
+
}) => Promise<void>;
|
|
22
|
+
onAttachPolicy: ({ principalId }: {
|
|
23
|
+
principalId: string;
|
|
24
|
+
}) => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=users-grant-actions.d.ts.map
|