hazo_auth 4.5.1 → 4.5.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/user_management/index.tsx"],"names":[],"mappings":"AA0DA,4CAA4C;AAC5C,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4DAA4D;IAC5D,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,cAAc,EAAE,CAAC;CACvC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/user_management/index.tsx"],"names":[],"mappings":"AA0DA,4CAA4C;AAC5C,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4DAA4D;IAC5D,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,cAAc,EAAE,CAAC;CACvC,CAAC;AA8BF;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,SAAS,EAAE,YAAoB,EAAE,mBAA2B,EAAE,gBAAwB,EAAE,kBAAuB,EAAE,EAAE,yBAAyB,2CAi8ClL"}
|
|
@@ -73,6 +73,8 @@ export function UserManagementLayout({ className, hrbacEnabled = false, multiTen
|
|
|
73
73
|
const [selectedUser, setSelectedUser] = useState(null);
|
|
74
74
|
const [usersActionLoading, setUsersActionLoading] = useState(false);
|
|
75
75
|
const [userTypeUpdateLoading, setUserTypeUpdateLoading] = useState(false);
|
|
76
|
+
const [orgUpdateLoading, setOrgUpdateLoading] = useState(false);
|
|
77
|
+
const [availableOrgs, setAvailableOrgs] = useState([]);
|
|
76
78
|
// Tab 3: Permissions state
|
|
77
79
|
const [permissions, setPermissions] = useState([]);
|
|
78
80
|
const [permissionsLoading, setPermissionsLoading] = useState(true);
|
|
@@ -112,6 +114,29 @@ export function UserManagementLayout({ className, hrbacEnabled = false, multiTen
|
|
|
112
114
|
}
|
|
113
115
|
void loadUsers();
|
|
114
116
|
}, [showUsersTab, loadUsers]);
|
|
117
|
+
// Load organizations (only if multi-tenancy is enabled and user has permission)
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (!multiTenancyEnabled || !showUsersTab) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const loadOrgs = async () => {
|
|
123
|
+
try {
|
|
124
|
+
const response = await fetch(`${apiBasePath}/org_management/orgs`);
|
|
125
|
+
const data = await response.json();
|
|
126
|
+
if (data.success && Array.isArray(data.orgs)) {
|
|
127
|
+
setAvailableOrgs(data.orgs.map((org) => ({
|
|
128
|
+
id: org.id,
|
|
129
|
+
name: org.name,
|
|
130
|
+
})));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
// Silently fail - orgs dropdown will just be empty
|
|
135
|
+
console.error("Failed to load organizations:", error);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
void loadOrgs();
|
|
139
|
+
}, [multiTenancyEnabled, showUsersTab, apiBasePath]);
|
|
115
140
|
// Load permissions (only if user has permission)
|
|
116
141
|
useEffect(() => {
|
|
117
142
|
if (!showPermissionsTab) {
|
|
@@ -263,6 +288,41 @@ export function UserManagementLayout({ className, hrbacEnabled = false, multiTen
|
|
|
263
288
|
setUserTypeUpdateLoading(false);
|
|
264
289
|
}
|
|
265
290
|
};
|
|
291
|
+
// Handle org change
|
|
292
|
+
const handleOrgChange = async (newOrgId) => {
|
|
293
|
+
if (!selectedUser)
|
|
294
|
+
return;
|
|
295
|
+
setOrgUpdateLoading(true);
|
|
296
|
+
try {
|
|
297
|
+
const response = await fetch(`${apiBasePath}/user_management/users`, {
|
|
298
|
+
method: "PATCH",
|
|
299
|
+
headers: {
|
|
300
|
+
"Content-Type": "application/json",
|
|
301
|
+
},
|
|
302
|
+
body: JSON.stringify({
|
|
303
|
+
user_id: selectedUser.id,
|
|
304
|
+
org_id: newOrgId || null,
|
|
305
|
+
}),
|
|
306
|
+
});
|
|
307
|
+
const data = await response.json();
|
|
308
|
+
if (data.success) {
|
|
309
|
+
toast.success("Organization updated successfully");
|
|
310
|
+
// Update local state
|
|
311
|
+
setSelectedUser(Object.assign(Object.assign({}, selectedUser), { org_id: newOrgId || null }));
|
|
312
|
+
// Reload users list to get updated root_org_id from server
|
|
313
|
+
await loadUsers();
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
toast.error(data.error || "Failed to update organization");
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
toast.error("Failed to update organization");
|
|
321
|
+
}
|
|
322
|
+
finally {
|
|
323
|
+
setOrgUpdateLoading(false);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
266
326
|
// Handle migrate permissions
|
|
267
327
|
const handleMigratePermissions = async () => {
|
|
268
328
|
var _a, _b;
|
|
@@ -552,7 +612,7 @@ export function UserManagementLayout({ className, hrbacEnabled = false, multiTen
|
|
|
552
612
|
minute: "2-digit",
|
|
553
613
|
second: "2-digit",
|
|
554
614
|
timeZoneName: "short",
|
|
555
|
-
}) })) : (_jsx("span", { className: "text-muted-foreground", children: "-" })) })] }), userTypesEnabled && (_jsxs("div", { className: "cls_user_management_user_detail_field_user_type flex flex-col gap-2", children: [_jsx(Label, { className: "cls_user_management_user_detail_label font-semibold", children: "User Type" }), _jsxs("div", { className: "cls_user_management_user_detail_user_type_value flex items-center gap-2", children: [_jsxs(Select, { value: selectedUser.user_type || "", onValueChange: (value) => handleUserTypeChange(value), disabled: userTypeUpdateLoading, children: [_jsx(SelectTrigger, { className: "w-48", children: _jsx(SelectValue, { placeholder: "Select user type" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "", children: "None" }), availableUserTypes.map((type) => (_jsx(SelectItem, { value: type.key, children: type.label }, type.key)))] })] }), userTypeUpdateLoading && (_jsx(Loader2, { className: "h-4 w-4 animate-spin text-muted-foreground" }))] })] }))] })) }), _jsx(DialogFooter, { className: "cls_user_management_user_detail_dialog_footer", children: _jsx(Button, { onClick: () => setUserDetailDialogOpen(false), variant: "outline", className: "cls_user_management_user_detail_dialog_close", children: "Close" }) })] }) }), _jsx(Dialog, { open: assignRolesDialogOpen, onOpenChange: setAssignRolesDialogOpen, children: _jsxs(DialogContent, { className: "cls_user_management_assign_roles_dialog max-w-4xl max-h-[80vh] overflow-y-auto", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Assign Roles to User" }), _jsxs(DialogDescription, { children: ["Select roles to assign to ", (selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.name) || (selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.email_address), ". Check the roles you want to assign, then click Save."] })] }), _jsx("div", { className: "cls_user_management_assign_roles_dialog_content py-4", children: _jsx(RolesMatrix, { add_button_enabled: false, role_name_selection_enabled: true, permissions_read_only: true, show_save_cancel: true, user_id: selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.id, onSave: (data) => {
|
|
615
|
+
}) })) : (_jsx("span", { className: "text-muted-foreground", children: "-" })) })] }), userTypesEnabled && (_jsxs("div", { className: "cls_user_management_user_detail_field_user_type flex flex-col gap-2", children: [_jsx(Label, { className: "cls_user_management_user_detail_label font-semibold", children: "User Type" }), _jsxs("div", { className: "cls_user_management_user_detail_user_type_value flex items-center gap-2", children: [_jsxs(Select, { value: selectedUser.user_type || "", onValueChange: (value) => handleUserTypeChange(value), disabled: userTypeUpdateLoading, children: [_jsx(SelectTrigger, { className: "w-48", children: _jsx(SelectValue, { placeholder: "Select user type" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "", children: "None" }), availableUserTypes.map((type) => (_jsx(SelectItem, { value: type.key, children: type.label }, type.key)))] })] }), userTypeUpdateLoading && (_jsx(Loader2, { className: "h-4 w-4 animate-spin text-muted-foreground" }))] })] })), multiTenancyEnabled && (_jsxs("div", { className: "cls_user_management_user_detail_field_org flex flex-col gap-2", children: [_jsx(Label, { className: "cls_user_management_user_detail_label font-semibold", children: "Organization" }), _jsxs("div", { className: "cls_user_management_user_detail_org_value flex items-center gap-2", children: [_jsxs(Select, { value: selectedUser.org_id || "", onValueChange: (value) => handleOrgChange(value), disabled: orgUpdateLoading, children: [_jsx(SelectTrigger, { className: "w-64", children: _jsx(SelectValue, { placeholder: "Select organization" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "", children: "None" }), availableOrgs.map((org) => (_jsx(SelectItem, { value: org.id, children: org.name }, org.id)))] })] }), orgUpdateLoading && (_jsx(Loader2, { className: "h-4 w-4 animate-spin text-muted-foreground" }))] })] }))] })) }), _jsx(DialogFooter, { className: "cls_user_management_user_detail_dialog_footer", children: _jsx(Button, { onClick: () => setUserDetailDialogOpen(false), variant: "outline", className: "cls_user_management_user_detail_dialog_close", children: "Close" }) })] }) }), _jsx(Dialog, { open: assignRolesDialogOpen, onOpenChange: setAssignRolesDialogOpen, children: _jsxs(DialogContent, { className: "cls_user_management_assign_roles_dialog max-w-4xl max-h-[80vh] overflow-y-auto", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Assign Roles to User" }), _jsxs(DialogDescription, { children: ["Select roles to assign to ", (selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.name) || (selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.email_address), ". Check the roles you want to assign, then click Save."] })] }), _jsx("div", { className: "cls_user_management_assign_roles_dialog_content py-4", children: _jsx(RolesMatrix, { add_button_enabled: false, role_name_selection_enabled: true, permissions_read_only: true, show_save_cancel: true, user_id: selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.id, onSave: (data) => {
|
|
556
616
|
// Data is already saved by RolesMatrix component
|
|
557
617
|
console.log("User roles saved:", data);
|
|
558
618
|
// Refresh users list to show updated roles
|