hazo_auth 10.18.3 → 10.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli-src/lib/utils/password_validator.ts +12 -5
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/config/email_verification_field_config.js +18 -15
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/hooks/use_email_verification.js +12 -9
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/index.js +6 -3
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.js +11 -8
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +8 -5
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/index.js +6 -3
- package/dist/components/layouts/login/config/login_field_config.d.ts.map +1 -1
- package/dist/components/layouts/login/config/login_field_config.js +14 -11
- package/dist/components/layouts/login/hooks/use_login_form.d.ts.map +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.js +7 -4
- package/dist/components/layouts/login/index.d.ts.map +1 -1
- package/dist/components/layouts/login/index.js +11 -8
- package/dist/components/layouts/my_settings/components/connected_accounts_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/connected_accounts_section.js +7 -4
- package/dist/components/layouts/my_settings/components/danger_zone_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/danger_zone_section.js +8 -5
- package/dist/components/layouts/my_settings/components/set_password_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/set_password_section.js +20 -13
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.js +9 -6
- package/dist/components/layouts/otp/index.d.ts.map +1 -1
- package/dist/components/layouts/otp/index.js +4 -1
- package/dist/components/layouts/register/config/register_field_config.d.ts.map +1 -1
- package/dist/components/layouts/register/config/register_field_config.js +20 -17
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +8 -5
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +11 -8
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts +1 -1
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/config/reset_password_field_config.js +14 -11
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.js +13 -10
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/index.js +7 -4
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/already_logged_in_guard.js +4 -1
- package/dist/components/layouts/shared/components/facebook_sign_in_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/facebook_sign_in_button.js +5 -2
- package/dist/components/layouts/shared/components/form_action_buttons.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/form_action_buttons.js +4 -1
- package/dist/components/layouts/shared/components/google_sign_in_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/google_sign_in_button.js +5 -2
- package/dist/components/layouts/shared/components/logout_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/logout_button.js +7 -4
- package/dist/components/layouts/shared/components/oauth_divider.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/oauth_divider.js +4 -1
- package/dist/components/layouts/shared/components/password_field.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/password_field.js +4 -1
- package/dist/components/layouts/shared/components/unauthorized_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/unauthorized_guard.js +6 -3
- package/dist/components/layouts/shared/config/layout_customization.d.ts +5 -0
- package/dist/components/layouts/shared/config/layout_customization.d.ts.map +1 -1
- package/dist/components/layouts/shared/config/layout_customization.js +14 -0
- package/dist/components/layouts/shared/utils/validation.d.ts +4 -0
- package/dist/components/layouts/shared/utils/validation.d.ts.map +1 -1
- package/dist/components/layouts/shared/utils/validation.js +18 -6
- package/dist/components/layouts/user_management/components/roles_matrix.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/roles_matrix.js +22 -17
- package/dist/components/layouts/user_management/components/scope_hierarchy_tab.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/scope_hierarchy_tab.js +29 -26
- package/dist/components/layouts/user_management/components/user_scopes_tab.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/user_scopes_tab.js +27 -19
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.d.ts +2 -1
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.js +64 -21
- package/dist/components/layouts/user_management/index.d.ts.map +1 -1
- package/dist/components/layouts/user_management/index.js +48 -42
- package/dist/components/otp/OTPRequestForm.d.ts.map +1 -1
- package/dist/components/otp/OTPRequestForm.js +8 -5
- package/dist/components/otp/OTPVerifyForm.d.ts.map +1 -1
- package/dist/components/otp/OTPVerifyForm.js +10 -7
- package/dist/components/permission_denied_dialog.client.d.ts.map +1 -1
- package/dist/components/permission_denied_dialog.client.js +12 -9
- package/dist/lib/utils/password_validator.d.ts.map +1 -1
- package/dist/lib/utils/password_validator.js +5 -5
- package/dist/locales/en.json +383 -0
- package/dist/server/routes/library_photos.d.ts +2 -2
- package/dist/server/routes/set_password.js +1 -1
- package/dist/strings/default_strings.d.ts.map +1 -1
- package/dist/strings/default_strings.js +14 -11
- package/package.json +22 -17
|
@@ -14,6 +14,9 @@ import { Plus, Loader2, CircleCheck, CircleX, Pencil } from "lucide-react";
|
|
|
14
14
|
import { toast } from "sonner";
|
|
15
15
|
import { Avatar, AvatarImage, AvatarFallback } from "../../../ui/avatar.js";
|
|
16
16
|
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
17
|
+
import en from "../../../../locales/en.json" with { type: "json" };
|
|
18
|
+
import { createPackageT } from "hazo_core/i18n";
|
|
19
|
+
const t = createPackageT("hazo_auth", en);
|
|
17
20
|
// section: component
|
|
18
21
|
/**
|
|
19
22
|
* Roles matrix component - reusable internal component for roles-permissions management
|
|
@@ -49,7 +52,7 @@ export function RolesMatrix({ add_button_enabled = true, role_name_selection_ena
|
|
|
49
52
|
const roles_response = await fetch(`${apiBasePath}/user_management/roles`);
|
|
50
53
|
const roles_data = await roles_response.json();
|
|
51
54
|
if (!roles_data.success) {
|
|
52
|
-
toast.error("
|
|
55
|
+
toast.error(t("roles_matrix.toast.load_failed"));
|
|
53
56
|
setLoading(false);
|
|
54
57
|
return;
|
|
55
58
|
}
|
|
@@ -142,7 +145,7 @@ export function RolesMatrix({ add_button_enabled = true, role_name_selection_ena
|
|
|
142
145
|
setOriginalRoles(original_roles);
|
|
143
146
|
}
|
|
144
147
|
catch (error) {
|
|
145
|
-
toast.error("
|
|
148
|
+
toast.error(t("roles_matrix.toast.load_failed"));
|
|
146
149
|
}
|
|
147
150
|
finally {
|
|
148
151
|
setLoading(false);
|
|
@@ -181,12 +184,12 @@ export function RolesMatrix({ add_button_enabled = true, role_name_selection_ena
|
|
|
181
184
|
// Handle add role
|
|
182
185
|
const handleAddRole = () => {
|
|
183
186
|
if (!newRoleName.trim()) {
|
|
184
|
-
toast.error("
|
|
187
|
+
toast.error(t("roles_matrix.toast.role_name_required"));
|
|
185
188
|
return;
|
|
186
189
|
}
|
|
187
190
|
// Check if role name already exists
|
|
188
191
|
if (roles.some((r) => r.role_name.toLowerCase() === newRoleName.trim().toLowerCase())) {
|
|
189
|
-
toast.error("
|
|
192
|
+
toast.error(t("roles_matrix.toast.role_exists"));
|
|
190
193
|
return;
|
|
191
194
|
}
|
|
192
195
|
setRoles((prev) => [
|
|
@@ -199,7 +202,7 @@ export function RolesMatrix({ add_button_enabled = true, role_name_selection_ena
|
|
|
199
202
|
]);
|
|
200
203
|
setNewRoleName("");
|
|
201
204
|
setIsAddDialogOpen(false);
|
|
202
|
-
toast.success("
|
|
205
|
+
toast.success(t("roles_matrix.toast.role_added"));
|
|
203
206
|
};
|
|
204
207
|
// Handle cancel - reset to original database state
|
|
205
208
|
const handleCancel = () => {
|
|
@@ -211,7 +214,7 @@ export function RolesMatrix({ add_button_enabled = true, role_name_selection_ena
|
|
|
211
214
|
permissions: new Set(role.permissions),
|
|
212
215
|
}));
|
|
213
216
|
setRoles(reset_roles);
|
|
214
|
-
toast.info("
|
|
217
|
+
toast.info(t("roles_matrix.toast.changes_cancelled"));
|
|
215
218
|
// Call onCancel callback if provided (e.g., to close dialog)
|
|
216
219
|
if (onCancel) {
|
|
217
220
|
onCancel();
|
|
@@ -249,14 +252,14 @@ export function RolesMatrix({ add_button_enabled = true, role_name_selection_ena
|
|
|
249
252
|
});
|
|
250
253
|
const data = await response.json();
|
|
251
254
|
if (data.success) {
|
|
252
|
-
toast.success("
|
|
255
|
+
toast.success(t("roles_matrix.toast.user_roles_update_success"));
|
|
253
256
|
// Update original state to reflect saved changes
|
|
254
257
|
const updated_original_roles = originalRoles.map((role) => (Object.assign(Object.assign({}, role), { selected: role.role_id !== undefined && selected_role_ids.includes(role.role_id) })));
|
|
255
258
|
setOriginalRoles(updated_original_roles);
|
|
256
259
|
setUserRoleIds(selected_role_ids);
|
|
257
260
|
}
|
|
258
261
|
else {
|
|
259
|
-
toast.error(data.error || "
|
|
262
|
+
toast.error(data.error || t("roles_matrix.toast.user_roles_update_failed"));
|
|
260
263
|
}
|
|
261
264
|
}
|
|
262
265
|
else {
|
|
@@ -275,7 +278,7 @@ export function RolesMatrix({ add_button_enabled = true, role_name_selection_ena
|
|
|
275
278
|
});
|
|
276
279
|
const data = await response.json();
|
|
277
280
|
if (data.success) {
|
|
278
|
-
toast.success("
|
|
281
|
+
toast.success(t("roles_matrix.toast.save_success"));
|
|
279
282
|
// Reload data to get updated role IDs
|
|
280
283
|
const reload_response = await fetch(`${apiBasePath}/user_management/roles`);
|
|
281
284
|
const reload_data = await reload_response.json();
|
|
@@ -297,12 +300,12 @@ export function RolesMatrix({ add_button_enabled = true, role_name_selection_ena
|
|
|
297
300
|
}
|
|
298
301
|
}
|
|
299
302
|
else {
|
|
300
|
-
toast.error(data.error || "
|
|
303
|
+
toast.error(data.error || t("roles_matrix.toast.save_failed"));
|
|
301
304
|
}
|
|
302
305
|
}
|
|
303
306
|
}
|
|
304
307
|
catch (error) {
|
|
305
|
-
toast.error(user_id ? "
|
|
308
|
+
toast.error(user_id ? t("roles_matrix.toast.user_roles_update_failed") : t("roles_matrix.toast.save_failed"));
|
|
306
309
|
}
|
|
307
310
|
finally {
|
|
308
311
|
setSaving(false);
|
|
@@ -371,29 +374,31 @@ export function RolesMatrix({ add_button_enabled = true, role_name_selection_ena
|
|
|
371
374
|
};
|
|
372
375
|
// Number of permission tags to show before truncating
|
|
373
376
|
const MAX_VISIBLE_TAGS = 4;
|
|
374
|
-
return (_jsxs("div", { className: `cls_roles_matrix flex flex-col gap-4 w-full ${className || ""}`, children: [user_id && userInfo && (_jsxs("div", { className: "cls_roles_matrix_user_info flex items-center gap-4 p-4 border rounded-lg bg-muted/50", children: [_jsxs(Avatar, { className: "cls_roles_matrix_user_avatar h-12 w-12", children: [_jsx(AvatarImage, { src: userInfo.profile_picture_url || undefined, alt: userInfo.name ? `Profile picture of ${userInfo.name}` : "Profile picture", className: "cls_roles_matrix_user_avatar_image" }), _jsx(AvatarFallback, { className: "cls_roles_matrix_user_avatar_fallback bg-slate-200 text-slate-600", children: getUserInitials(userInfo.name, userInfo.email_address) })] }), _jsxs("div", { className: "cls_roles_matrix_user_info_details flex flex-col", children: [_jsx("span", { className: "cls_roles_matrix_user_name font-semibold text-lg", children: userInfo.name || userInfo.email_address }), userInfo.name && (_jsx("span", { className: "cls_roles_matrix_user_email text-sm text-muted-foreground", children: userInfo.email_address }))] })] })), _jsx("div", { className: "cls_roles_matrix_header flex items-center justify-between", children: _jsx("div", { className: "cls_roles_matrix_header_left", children: add_button_enabled && (_jsxs(Button, { onClick: () => setIsAddDialogOpen(true), variant: "default", size: "sm", className: "cls_roles_matrix_add_button", children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), "
|
|
377
|
+
return (_jsxs("div", { className: `cls_roles_matrix flex flex-col gap-4 w-full ${className || ""}`, children: [user_id && userInfo && (_jsxs("div", { className: "cls_roles_matrix_user_info flex items-center gap-4 p-4 border rounded-lg bg-muted/50", children: [_jsxs(Avatar, { className: "cls_roles_matrix_user_avatar h-12 w-12", children: [_jsx(AvatarImage, { src: userInfo.profile_picture_url || undefined, alt: userInfo.name ? `Profile picture of ${userInfo.name}` : "Profile picture", className: "cls_roles_matrix_user_avatar_image" }), _jsx(AvatarFallback, { className: "cls_roles_matrix_user_avatar_fallback bg-slate-200 text-slate-600", children: getUserInitials(userInfo.name, userInfo.email_address) })] }), _jsxs("div", { className: "cls_roles_matrix_user_info_details flex flex-col", children: [_jsx("span", { className: "cls_roles_matrix_user_name font-semibold text-lg", children: userInfo.name || userInfo.email_address }), userInfo.name && (_jsx("span", { className: "cls_roles_matrix_user_email text-sm text-muted-foreground", children: userInfo.email_address }))] })] })), _jsx("div", { className: "cls_roles_matrix_header flex items-center justify-between", children: _jsx("div", { className: "cls_roles_matrix_header_left", children: add_button_enabled && (_jsxs(Button, { onClick: () => setIsAddDialogOpen(true), variant: "default", size: "sm", className: "cls_roles_matrix_add_button", children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), t("roles_matrix.add_role_button")] })) }) }), _jsx("div", { className: "cls_roles_matrix_table_container border rounded-lg overflow-auto w-full", children: _jsxs(Table, { className: "cls_roles_matrix_table w-full", children: [_jsx(TableHeader, { className: "cls_roles_matrix_table_header", children: _jsxs(TableRow, { className: "cls_roles_matrix_table_header_row", children: [role_name_selection_enabled && (_jsx(TableHead, { className: "cls_roles_matrix_table_header_role_checkbox w-12" })), _jsx(TableHead, { className: "cls_roles_matrix_table_header_role_name w-48", children: t("roles_matrix.table.role_name_header") }), _jsx(TableHead, { className: "cls_roles_matrix_table_header_permissions", children: t("roles_matrix.table.permissions_header") }), !permissions_read_only && (_jsx(TableHead, { className: "cls_roles_matrix_table_header_actions w-24 text-center", children: t("roles_matrix.table.actions_header") }))] }) }), _jsx(TableBody, { className: "cls_roles_matrix_table_body", children: roles.length === 0 ? (_jsx(TableRow, { className: "cls_roles_matrix_table_row_empty", children: _jsx(TableCell, { colSpan: role_name_selection_enabled ? 4 : 3, className: "text-center text-muted-foreground py-8", children: t("roles_matrix.table.empty") }) })) : (roles.map((role, role_index) => {
|
|
375
378
|
const permission_array = Array.from(role.permissions);
|
|
376
379
|
const is_expanded = expandedRoles.has(role_index);
|
|
377
380
|
const visible_permissions = is_expanded
|
|
378
381
|
? permission_array
|
|
379
382
|
: permission_array.slice(0, MAX_VISIBLE_TAGS);
|
|
380
383
|
const remaining_count = permission_array.length - MAX_VISIBLE_TAGS;
|
|
381
|
-
return (_jsxs(TableRow, { className: "cls_roles_matrix_table_row", children: [role_name_selection_enabled && (_jsx(TableCell, { className: "cls_roles_matrix_table_cell_role_checkbox text-center", children: _jsx("div", { className: "cls_roles_matrix_role_checkbox_wrapper flex items-center justify-center", children: _jsx(Checkbox, { checked: role.selected, onCheckedChange: () => handleRoleSelectionToggle(role_index), className: "cls_roles_matrix_role_checkbox" }) }) })), _jsx(TableCell, { className: "cls_roles_matrix_table_cell_role_name font-medium", children: role.role_name }), _jsx(TableCell, { className: "cls_roles_matrix_table_cell_permissions", children: _jsx("div", { className: "cls_roles_matrix_permission_tags flex flex-wrap items-center gap-1.5", children: permission_array.length === 0 ? (_jsx("span", { className: "text-muted-foreground text-sm italic", children: "
|
|
384
|
+
return (_jsxs(TableRow, { className: "cls_roles_matrix_table_row", children: [role_name_selection_enabled && (_jsx(TableCell, { className: "cls_roles_matrix_table_cell_role_checkbox text-center", children: _jsx("div", { className: "cls_roles_matrix_role_checkbox_wrapper flex items-center justify-center", children: _jsx(Checkbox, { checked: role.selected, onCheckedChange: () => handleRoleSelectionToggle(role_index), className: "cls_roles_matrix_role_checkbox" }) }) })), _jsx(TableCell, { className: "cls_roles_matrix_table_cell_role_name font-medium", children: role.role_name }), _jsx(TableCell, { className: "cls_roles_matrix_table_cell_permissions", children: _jsx("div", { className: "cls_roles_matrix_permission_tags flex flex-wrap items-center gap-1.5", children: permission_array.length === 0 ? (_jsx("span", { className: "text-muted-foreground text-sm italic", children: t("roles_matrix.table.no_permissions") })) : (_jsxs(_Fragment, { children: [visible_permissions.map((perm_name) => (_jsx("span", { className: "cls_roles_matrix_permission_tag bg-blue-100 text-blue-700 px-2 py-0.5 rounded text-xs font-medium", title: getPermissionDescription(perm_name) || perm_name, children: perm_name }, perm_name))), remaining_count > 0 && !is_expanded && (_jsx("span", { className: "cls_roles_matrix_permission_tag_more bg-slate-100 text-slate-600 px-2 py-0.5 rounded text-xs font-medium cursor-pointer hover:bg-slate-200", onClick: () => {
|
|
382
385
|
if (permissions_read_only) {
|
|
383
386
|
handleToggleExpandedPermissions(role_index);
|
|
384
387
|
}
|
|
385
388
|
else {
|
|
386
389
|
handleOpenEditPermissions(role_index);
|
|
387
390
|
}
|
|
388
|
-
}, title: permissions_read_only
|
|
389
|
-
|
|
391
|
+
}, title: permissions_read_only
|
|
392
|
+
? t("roles_matrix.table.expand_title", { count: String(permission_array.length) })
|
|
393
|
+
: t("roles_matrix.table.edit_title", { count: String(permission_array.length) }), children: t("roles_matrix.table.more_tag", { count: String(remaining_count) }) })), is_expanded && remaining_count > 0 && (_jsx("span", { className: "cls_roles_matrix_permission_tag_collapse bg-slate-100 text-slate-600 px-2 py-0.5 rounded text-xs font-medium cursor-pointer hover:bg-slate-200", onClick: () => handleToggleExpandedPermissions(role_index), title: t("roles_matrix.table.collapse_title"), children: t("roles_matrix.table.show_less") }))] })) }) }), !permissions_read_only && (_jsx(TableCell, { className: "cls_roles_matrix_table_cell_actions text-center", children: _jsx(Button, { onClick: () => handleOpenEditPermissions(role_index), variant: "ghost", size: "sm", className: "cls_roles_matrix_edit_button h-8 w-8 p-0", title: t("roles_matrix.table.edit_permissions_title"), children: _jsx(Pencil, { className: "h-4 w-4" }) }) }))] }, role_index));
|
|
394
|
+
})) })] }) }), show_save_cancel && (_jsxs("div", { className: "cls_roles_matrix_footer flex items-center justify-end gap-2", children: [_jsx(Button, { onClick: handleSave, disabled: saving, variant: "default", size: "sm", className: "cls_roles_matrix_save_button", children: saving ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }), t("roles_matrix.footer.saving")] })) : (_jsxs(_Fragment, { children: [_jsx(CircleCheck, { className: "h-4 w-4 mr-2" }), t("shared.save_button")] })) }), _jsxs(Button, { onClick: handleCancel, variant: "outline", size: "sm", className: "cls_roles_matrix_cancel_button", children: [_jsx(CircleX, { className: "h-4 w-4 mr-2" }), t("shared.cancel_button")] })] })), _jsx(Dialog, { open: isAddDialogOpen, onOpenChange: setIsAddDialogOpen, children: _jsxs(DialogContent, { className: "cls_roles_matrix_add_dialog", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: t("roles_matrix.add_dialog.title") }), _jsx(DialogDescription, { children: t("roles_matrix.add_dialog.description") })] }), _jsx("div", { className: "cls_roles_matrix_add_dialog_content flex flex-col gap-4 py-4", children: _jsxs("div", { className: "cls_roles_matrix_add_dialog_field flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "role_name", className: "cls_roles_matrix_add_dialog_label", children: t("roles_matrix.add_dialog.name_label") }), _jsx(Input, { id: "role_name", value: newRoleName, onChange: (e) => setNewRoleName(e.target.value), placeholder: t("roles_matrix.add_dialog.name_placeholder"), className: "cls_roles_matrix_add_dialog_input", onKeyDown: (e) => {
|
|
390
395
|
if (e.key === "Enter") {
|
|
391
396
|
handleAddRole();
|
|
392
397
|
}
|
|
393
|
-
} })] }) }), _jsxs(DialogFooter, { className: "cls_roles_matrix_add_dialog_footer", children: [_jsx(Button, { onClick: handleAddRole, variant: "default", className: "cls_roles_matrix_add_dialog_save", children: "
|
|
398
|
+
} })] }) }), _jsxs(DialogFooter, { className: "cls_roles_matrix_add_dialog_footer", children: [_jsx(Button, { onClick: handleAddRole, variant: "default", className: "cls_roles_matrix_add_dialog_save", children: t("roles_matrix.add_role_button") }), _jsx(Button, { onClick: () => {
|
|
394
399
|
setIsAddDialogOpen(false);
|
|
395
400
|
setNewRoleName("");
|
|
396
|
-
}, variant: "outline", className: "cls_roles_matrix_add_dialog_cancel", children: "
|
|
401
|
+
}, variant: "outline", className: "cls_roles_matrix_add_dialog_cancel", children: t("shared.cancel_button") })] })] }) }), _jsx(Dialog, { open: editPermissionsDialogOpen, onOpenChange: setEditPermissionsDialogOpen, children: _jsxs(DialogContent, { className: "cls_roles_matrix_edit_permissions_dialog max-w-lg max-h-[80vh] flex flex-col", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: t("roles_matrix.edit_permissions_dialog.title", { role_name: editingRoleIndex !== null ? (((_a = roles[editingRoleIndex]) === null || _a === void 0 ? void 0 : _a.role_name) || "") : "" }) }), _jsx(DialogDescription, { children: t("roles_matrix.edit_permissions_dialog.description") })] }), _jsxs("div", { className: "cls_roles_matrix_edit_permissions_actions flex items-center gap-2 py-2 border-b", children: [_jsx(Button, { onClick: handleSelectAllPermissions, variant: "outline", size: "sm", className: "cls_roles_matrix_select_all_button", children: t("roles_matrix.edit_permissions_dialog.select_all") }), _jsx(Button, { onClick: handleUnselectAllPermissions, variant: "outline", size: "sm", className: "cls_roles_matrix_unselect_all_button", children: t("roles_matrix.edit_permissions_dialog.unselect_all") })] }), _jsx("div", { className: "cls_roles_matrix_edit_permissions_list flex-1 overflow-y-auto py-2 min-h-0", children: _jsx("div", { className: "flex flex-col gap-3", children: permissionsWithDescriptions.map((perm) => {
|
|
397
402
|
var _a;
|
|
398
403
|
const is_checked = editingRoleIndex !== null && ((_a = roles[editingRoleIndex]) === null || _a === void 0 ? void 0 : _a.permissions.has(perm.permission_name));
|
|
399
404
|
return (_jsxs("div", { className: "cls_roles_matrix_permission_item flex items-start gap-3 p-2 rounded hover:bg-muted/50 cursor-pointer", onClick: () => editingRoleIndex !== null && handlePermissionToggle(editingRoleIndex, perm.permission_name), children: [_jsx(Checkbox, { checked: is_checked, onCheckedChange: () => editingRoleIndex !== null && handlePermissionToggle(editingRoleIndex, perm.permission_name), className: "cls_roles_matrix_permission_checkbox mt-0.5" }), _jsxs("div", { className: "cls_roles_matrix_permission_info flex flex-col gap-0.5", children: [_jsx("span", { className: "cls_roles_matrix_permission_name font-medium text-sm", children: perm.permission_name }), perm.description && (_jsx("span", { className: "cls_roles_matrix_permission_description text-xs text-muted-foreground italic", children: perm.description }))] })] }, perm.permission_name));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope_hierarchy_tab.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/scope_hierarchy_tab.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scope_hierarchy_tab.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/scope_hierarchy_tab.tsx"],"names":[],"mappings":"AAmDA,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AA6GF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,GACV,EAAE,sBAAsB,+BAofxB"}
|
|
@@ -16,6 +16,9 @@ import { BrandingEditor } from "../../scope_management/components/branding_edito
|
|
|
16
16
|
import { toast } from "sonner";
|
|
17
17
|
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
18
18
|
import { use_hazo_auth } from "../../shared/hooks/use_hazo_auth.js";
|
|
19
|
+
import en from "../../../../locales/en.json" with { type: "json" };
|
|
20
|
+
import { createPackageT } from "hazo_core/i18n";
|
|
21
|
+
const t = createPackageT("hazo_auth", en);
|
|
19
22
|
// section: helpers
|
|
20
23
|
// Convert ScopeTreeNode to TreeDataItem format
|
|
21
24
|
function convertToTreeData(nodes, onEdit, onDelete, onAddChild, onBranding) {
|
|
@@ -30,16 +33,16 @@ function convertToTreeData(nodes, onEdit, onDelete, onAddChild, onBranding) {
|
|
|
30
33
|
actions: (_jsxs("div", { className: "flex items-center gap-1", children: [isRootScope && (_jsx(Button, { variant: "ghost", size: "sm", className: "h-6 w-6 p-0", onClick: (e) => {
|
|
31
34
|
e.stopPropagation();
|
|
32
35
|
onBranding(node);
|
|
33
|
-
}, title: "
|
|
36
|
+
}, title: t("scope_hierarchy.tab.manage_branding_title"), children: _jsx(Palette, { className: "h-3 w-3" }) })), _jsx(Button, { variant: "ghost", size: "sm", className: "h-6 w-6 p-0", onClick: (e) => {
|
|
34
37
|
e.stopPropagation();
|
|
35
38
|
onAddChild(node);
|
|
36
|
-
}, title: "
|
|
39
|
+
}, title: t("scope_hierarchy.tab.add_child_title"), children: _jsx(Plus, { className: "h-3 w-3" }) }), _jsx(Button, { variant: "ghost", size: "sm", className: "h-6 w-6 p-0", onClick: (e) => {
|
|
37
40
|
e.stopPropagation();
|
|
38
41
|
onEdit(node);
|
|
39
|
-
}, title: "
|
|
42
|
+
}, title: t("scope_hierarchy.tab.edit_title"), children: _jsx(Edit, { className: "h-3 w-3" }) }), _jsx(Button, { variant: "ghost", size: "sm", className: "h-6 w-6 p-0 text-destructive hover:text-destructive", onClick: (e) => {
|
|
40
43
|
e.stopPropagation();
|
|
41
44
|
onDelete(node);
|
|
42
|
-
}, title: "
|
|
45
|
+
}, title: t("scope_hierarchy.tab.delete_title"), children: _jsx(Trash2, { className: "h-3 w-3" }) })] })),
|
|
43
46
|
};
|
|
44
47
|
if (hasChildren) {
|
|
45
48
|
item.children = convertToTreeData(node.children, onEdit, onDelete, onAddChild, onBranding);
|
|
@@ -87,12 +90,12 @@ export function ScopeHierarchyTab({ className, }) {
|
|
|
87
90
|
setTree(data.tree || []);
|
|
88
91
|
}
|
|
89
92
|
else {
|
|
90
|
-
toast.error(data.error || "
|
|
93
|
+
toast.error(data.error || t("scope_hierarchy.toast.load_failed"));
|
|
91
94
|
setTree([]);
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
97
|
catch (error) {
|
|
95
|
-
toast.error("
|
|
98
|
+
toast.error(t("scope_hierarchy.toast.load_failed"));
|
|
96
99
|
setTree([]);
|
|
97
100
|
}
|
|
98
101
|
finally {
|
|
@@ -144,11 +147,11 @@ export function ScopeHierarchyTab({ className, }) {
|
|
|
144
147
|
// Create scope
|
|
145
148
|
const handleCreateScope = async () => {
|
|
146
149
|
if (!newName.trim()) {
|
|
147
|
-
toast.error("
|
|
150
|
+
toast.error(t("scope_hierarchy.toast.name_required"));
|
|
148
151
|
return;
|
|
149
152
|
}
|
|
150
153
|
if (!newLevel.trim()) {
|
|
151
|
-
toast.error("
|
|
154
|
+
toast.error(t("scope_hierarchy.toast.level_required"));
|
|
152
155
|
return;
|
|
153
156
|
}
|
|
154
157
|
setActionLoading(true);
|
|
@@ -165,7 +168,7 @@ export function ScopeHierarchyTab({ className, }) {
|
|
|
165
168
|
});
|
|
166
169
|
const data = await response.json();
|
|
167
170
|
if (data.success) {
|
|
168
|
-
toast.success("
|
|
171
|
+
toast.success(t("scope_hierarchy.toast.create_success"));
|
|
169
172
|
setAddDialogOpen(false);
|
|
170
173
|
setNewName("");
|
|
171
174
|
setNewLevel("");
|
|
@@ -173,11 +176,11 @@ export function ScopeHierarchyTab({ className, }) {
|
|
|
173
176
|
await loadTree();
|
|
174
177
|
}
|
|
175
178
|
else {
|
|
176
|
-
toast.error(data.error || "
|
|
179
|
+
toast.error(data.error || t("scope_hierarchy.toast.create_failed"));
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
catch (error) {
|
|
180
|
-
toast.error("
|
|
183
|
+
toast.error(t("scope_hierarchy.toast.create_failed"));
|
|
181
184
|
}
|
|
182
185
|
finally {
|
|
183
186
|
setActionLoading(false);
|
|
@@ -188,11 +191,11 @@ export function ScopeHierarchyTab({ className, }) {
|
|
|
188
191
|
if (!selectedScope)
|
|
189
192
|
return;
|
|
190
193
|
if (!editName.trim()) {
|
|
191
|
-
toast.error("
|
|
194
|
+
toast.error(t("scope_hierarchy.toast.name_required"));
|
|
192
195
|
return;
|
|
193
196
|
}
|
|
194
197
|
if (!editLevel.trim()) {
|
|
195
|
-
toast.error("
|
|
198
|
+
toast.error(t("scope_hierarchy.toast.level_required"));
|
|
196
199
|
return;
|
|
197
200
|
}
|
|
198
201
|
setActionLoading(true);
|
|
@@ -209,7 +212,7 @@ export function ScopeHierarchyTab({ className, }) {
|
|
|
209
212
|
});
|
|
210
213
|
const data = await response.json();
|
|
211
214
|
if (data.success) {
|
|
212
|
-
toast.success("
|
|
215
|
+
toast.success(t("scope_hierarchy.toast.update_success"));
|
|
213
216
|
setEditDialogOpen(false);
|
|
214
217
|
setSelectedScope(null);
|
|
215
218
|
setEditName("");
|
|
@@ -217,11 +220,11 @@ export function ScopeHierarchyTab({ className, }) {
|
|
|
217
220
|
await loadTree();
|
|
218
221
|
}
|
|
219
222
|
else {
|
|
220
|
-
toast.error(data.error || "
|
|
223
|
+
toast.error(data.error || t("scope_hierarchy.toast.update_failed"));
|
|
221
224
|
}
|
|
222
225
|
}
|
|
223
226
|
catch (error) {
|
|
224
|
-
toast.error("
|
|
227
|
+
toast.error(t("scope_hierarchy.toast.update_failed"));
|
|
225
228
|
}
|
|
226
229
|
finally {
|
|
227
230
|
setActionLoading(false);
|
|
@@ -241,17 +244,17 @@ export function ScopeHierarchyTab({ className, }) {
|
|
|
241
244
|
});
|
|
242
245
|
const data = await response.json();
|
|
243
246
|
if (data.success) {
|
|
244
|
-
toast.success("
|
|
247
|
+
toast.success(t("scope_hierarchy.toast.delete_success"));
|
|
245
248
|
setDeleteDialogOpen(false);
|
|
246
249
|
setSelectedScope(null);
|
|
247
250
|
await loadTree();
|
|
248
251
|
}
|
|
249
252
|
else {
|
|
250
|
-
toast.error(data.error || "
|
|
253
|
+
toast.error(data.error || t("scope_hierarchy.toast.delete_failed"));
|
|
251
254
|
}
|
|
252
255
|
}
|
|
253
256
|
catch (error) {
|
|
254
|
-
toast.error("
|
|
257
|
+
toast.error(t("scope_hierarchy.toast.delete_failed"));
|
|
255
258
|
}
|
|
256
259
|
finally {
|
|
257
260
|
setActionLoading(false);
|
|
@@ -265,15 +268,15 @@ export function ScopeHierarchyTab({ className, }) {
|
|
|
265
268
|
const handleSelectChange = (item) => {
|
|
266
269
|
setSelectedItem(item);
|
|
267
270
|
};
|
|
268
|
-
return (_jsxs("div", { className: `cls_scope_hierarchy_tab flex flex-col gap-4 w-full ${className || ""}`, children: [_jsxs("div", { className: "cls_scope_hierarchy_header flex items-center justify-between gap-4 flex-wrap", children: [_jsx("div", { className: "cls_scope_hierarchy_header_left flex items-center gap-4", children: _jsxs(Button, { variant: "outline", size: "sm", onClick: () => void loadTree(), disabled: loading, children: [_jsx(RefreshCw, { className: `h-4 w-4 mr-2 ${loading ? "animate-spin" : ""}` }), "
|
|
269
|
-
?
|
|
270
|
-
: "
|
|
271
|
-
?
|
|
272
|
-
: "
|
|
271
|
+
return (_jsxs("div", { className: `cls_scope_hierarchy_tab flex flex-col gap-4 w-full ${className || ""}`, children: [_jsxs("div", { className: "cls_scope_hierarchy_header flex items-center justify-between gap-4 flex-wrap", children: [_jsx("div", { className: "cls_scope_hierarchy_header_left flex items-center gap-4", children: _jsxs(Button, { variant: "outline", size: "sm", onClick: () => void loadTree(), disabled: loading, children: [_jsx(RefreshCw, { className: `h-4 w-4 mr-2 ${loading ? "animate-spin" : ""}` }), t("scope_hierarchy.tab.refresh_button")] }) }), _jsx("div", { className: "cls_scope_hierarchy_header_right", children: _jsxs(Button, { onClick: handleAddRootScope, variant: "default", size: "sm", children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), t("scope_hierarchy.tab.add_root_button")] }) })] }), loading || authResult.loading ? (_jsx("div", { className: "cls_scope_hierarchy_loading flex items-center justify-center p-8", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-slate-400" }) })) : tree.length === 0 ? (_jsxs("div", { className: "cls_scope_hierarchy_empty flex flex-col items-center justify-center p-8 border rounded-lg border-dashed", children: [_jsx(FolderTree, { className: "h-12 w-12 text-muted-foreground mb-4" }), _jsx("p", { className: "text-muted-foreground text-center mb-4", children: t("scope_hierarchy.tab.empty_message") }), _jsxs(Button, { onClick: handleAddRootScope, variant: "outline", size: "sm", children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), t("scope_hierarchy.tab.create_first_button")] })] })) : (_jsx("div", { className: "cls_scope_hierarchy_tree_container border rounded-lg overflow-auto w-full min-h-[300px]", children: _jsx(TreeView, { data: treeData, expandAll: true, defaultNodeIcon: Building2, defaultLeafIcon: Building2, onSelectChange: handleSelectChange, className: "w-full" }) })), (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.scopeData) && (_jsxs("div", { className: "cls_scope_hierarchy_selected_info p-4 border rounded-lg bg-muted/50", children: [_jsx("h4", { className: "font-medium mb-2", children: t("scope_hierarchy.tab.selected_scope_heading") }), _jsxs("div", { className: "grid grid-cols-2 gap-2 text-sm", children: [_jsxs("div", { children: [_jsx("span", { className: "text-muted-foreground", children: t("scope_hierarchy.tab.name_label") }), " ", selectedItem.scopeData.name] }), _jsxs("div", { children: [_jsx("span", { className: "text-muted-foreground", children: t("scope_hierarchy.tab.level_label") }), " ", selectedItem.scopeData.level] }), _jsxs("div", { className: "col-span-2", children: [_jsx("span", { className: "text-muted-foreground", children: t("scope_hierarchy.tab.id_label") }), " ", _jsx("span", { className: "font-mono text-xs", children: selectedItem.scopeData.id })] }), selectedItem.scopeData.parent_id && (_jsxs("div", { className: "col-span-2", children: [_jsx("span", { className: "text-muted-foreground", children: t("scope_hierarchy.tab.parent_id_label") }), " ", _jsx("span", { className: "font-mono text-xs", children: selectedItem.scopeData.parent_id })] }))] })] })), _jsx(Dialog, { open: addDialogOpen, onOpenChange: setAddDialogOpen, children: _jsxs(DialogContent, { className: "cls_scope_hierarchy_add_dialog", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: addParentScope
|
|
272
|
+
? t("scope_hierarchy.tab.add_dialog.title_child", { parent: addParentScope.name })
|
|
273
|
+
: t("scope_hierarchy.tab.add_dialog.title_root") }), _jsx(DialogDescription, { children: addParentScope
|
|
274
|
+
? t("scope_hierarchy.tab.add_dialog.description_child", { parent: addParentScope.name })
|
|
275
|
+
: t("scope_hierarchy.tab.add_dialog.description_root") })] }), _jsxs("div", { className: "flex flex-col gap-4 py-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "new_scope_name", children: t("scope_hierarchy.tab.add_dialog.name_label") }), _jsx(Input, { id: "new_scope_name", value: newName, onChange: (e) => setNewName(e.target.value), placeholder: t("scope_hierarchy.tab.add_dialog.name_placeholder") })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "new_scope_level", children: t("scope_hierarchy.tab.add_dialog.level_label") }), _jsx(Input, { id: "new_scope_level", value: newLevel, onChange: (e) => setNewLevel(e.target.value), placeholder: t("scope_hierarchy.tab.add_dialog.level_placeholder") }), _jsx("p", { className: "text-xs text-muted-foreground", children: t("scope_hierarchy.tab.add_dialog.level_help") })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { onClick: handleCreateScope, disabled: actionLoading, variant: "default", children: actionLoading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }), t("scope_hierarchy.tab.add_dialog.creating")] })) : (_jsxs(_Fragment, { children: [_jsx(CircleCheck, { className: "h-4 w-4 mr-2" }), t("scope_hierarchy.tab.add_dialog.create_button")] })) }), _jsxs(Button, { onClick: () => setAddDialogOpen(false), variant: "outline", children: [_jsx(CircleX, { className: "h-4 w-4 mr-2" }), t("shared.cancel_button")] })] })] }) }), _jsx(Dialog, { open: editDialogOpen, onOpenChange: setEditDialogOpen, children: _jsxs(DialogContent, { className: "cls_scope_hierarchy_edit_dialog", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: t("scope_hierarchy.tab.edit_dialog.title") }), _jsx(DialogDescription, { children: t("scope_hierarchy.tab.edit_dialog.description", { name: (selectedScope === null || selectedScope === void 0 ? void 0 : selectedScope.name) || "" }) })] }), _jsxs("div", { className: "flex flex-col gap-4 py-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "edit_scope_name", children: t("scope_hierarchy.tab.add_dialog.name_label") }), _jsx(Input, { id: "edit_scope_name", value: editName, onChange: (e) => setEditName(e.target.value), placeholder: t("scope_hierarchy.tab.edit_dialog.name_placeholder") })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "edit_scope_level", children: t("scope_hierarchy.tab.add_dialog.level_label") }), _jsx(Input, { id: "edit_scope_level", value: editLevel, onChange: (e) => setEditLevel(e.target.value), placeholder: t("scope_hierarchy.tab.edit_dialog.level_placeholder") })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { onClick: handleUpdateScope, disabled: actionLoading, variant: "default", children: actionLoading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }), t("scope_hierarchy.tab.edit_dialog.saving")] })) : (_jsxs(_Fragment, { children: [_jsx(CircleCheck, { className: "h-4 w-4 mr-2" }), t("scope_hierarchy.tab.edit_dialog.save_button")] })) }), _jsxs(Button, { onClick: () => {
|
|
273
276
|
setEditDialogOpen(false);
|
|
274
277
|
setSelectedScope(null);
|
|
275
|
-
}, variant: "outline", children: [_jsx(CircleX, { className: "h-4 w-4 mr-2" }), "
|
|
278
|
+
}, variant: "outline", children: [_jsx(CircleX, { className: "h-4 w-4 mr-2" }), t("shared.cancel_button")] })] })] }) }), _jsx(AlertDialog, { open: deleteDialogOpen, onOpenChange: setDeleteDialogOpen, children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: t("scope_hierarchy.tab.delete_dialog.title") }), _jsx(AlertDialogDescription, { children: t("scope_hierarchy.tab.delete_dialog.description", { name: (selectedScope === null || selectedScope === void 0 ? void 0 : selectedScope.name) || "" }) })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogAction, { onClick: handleDeleteScope, disabled: actionLoading, children: actionLoading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }), t("scope_hierarchy.tab.delete_dialog.deleting")] })) : (t("scope_hierarchy.tab.delete_dialog.confirm")) }), _jsx(AlertDialogCancel, { onClick: () => {
|
|
276
279
|
setDeleteDialogOpen(false);
|
|
277
280
|
setSelectedScope(null);
|
|
278
|
-
}, children: "
|
|
281
|
+
}, children: t("shared.cancel_button") })] })] }) }), brandingScope && (_jsx(BrandingEditor, { scopeId: brandingScope.id, scopeName: brandingScope.name, isOpen: brandingDialogOpen, onClose: closeBrandingDialog }))] }));
|
|
279
282
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user_scopes_tab.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/user_scopes_tab.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user_scopes_tab.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/user_scopes_tab.tsx"],"names":[],"mappings":"AAgEA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAkEF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,kBAAkB,+BA0jB9D"}
|
|
@@ -17,6 +17,9 @@ import { TreeView } from "../../../ui/tree-view.js";
|
|
|
17
17
|
import { Loader2, Plus, Trash2, Search, CircleCheck, CircleX, ChevronRight, Building2, FolderTree, } from "lucide-react";
|
|
18
18
|
import { toast } from "sonner";
|
|
19
19
|
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
20
|
+
import en from "../../../../locales/en.json" with { type: "json" };
|
|
21
|
+
import { createPackageT } from "hazo_core/i18n";
|
|
22
|
+
const t = createPackageT("hazo_auth", en);
|
|
20
23
|
// Convert ScopeTreeNode to TreeDataItem format for selection
|
|
21
24
|
function convertToTreeData(nodes) {
|
|
22
25
|
return nodes.map((node) => {
|
|
@@ -75,11 +78,11 @@ export function UserScopesTab({ className }) {
|
|
|
75
78
|
setUsers(data.users || []);
|
|
76
79
|
}
|
|
77
80
|
else {
|
|
78
|
-
toast.error(data.error || "
|
|
81
|
+
toast.error(data.error || t("user_management.toast.load_users_failed"));
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
catch (error) {
|
|
82
|
-
toast.error("
|
|
85
|
+
toast.error(t("user_management.toast.load_users_failed"));
|
|
83
86
|
}
|
|
84
87
|
finally {
|
|
85
88
|
setUsersLoading(false);
|
|
@@ -107,11 +110,11 @@ export function UserScopesTab({ className }) {
|
|
|
107
110
|
setInheritedScopeIds(data.inherited_scope_ids || []);
|
|
108
111
|
}
|
|
109
112
|
else {
|
|
110
|
-
toast.error(data.error || "
|
|
113
|
+
toast.error(data.error || t("user_scopes.toast.load_user_scopes_failed"));
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
catch (error) {
|
|
114
|
-
toast.error("
|
|
117
|
+
toast.error(t("user_scopes.toast.load_user_scopes_failed"));
|
|
115
118
|
}
|
|
116
119
|
finally {
|
|
117
120
|
setScopesLoading(false);
|
|
@@ -202,11 +205,11 @@ export function UserScopesTab({ className }) {
|
|
|
202
205
|
// Handle add scope
|
|
203
206
|
const handleAddScope = async () => {
|
|
204
207
|
if (!selectedUser || !(selectedTreeItem === null || selectedTreeItem === void 0 ? void 0 : selectedTreeItem.scopeData)) {
|
|
205
|
-
toast.error("
|
|
208
|
+
toast.error(t("user_scopes.toast.select_scope_required"));
|
|
206
209
|
return;
|
|
207
210
|
}
|
|
208
211
|
if (!selectedRoleId) {
|
|
209
|
-
toast.error("
|
|
212
|
+
toast.error(t("user_scopes.toast.select_role_required"));
|
|
210
213
|
return;
|
|
211
214
|
}
|
|
212
215
|
const scope = selectedTreeItem.scopeData;
|
|
@@ -223,18 +226,18 @@ export function UserScopesTab({ className }) {
|
|
|
223
226
|
});
|
|
224
227
|
const data = await response.json();
|
|
225
228
|
if (data.success) {
|
|
226
|
-
toast.success("
|
|
229
|
+
toast.success(t("user_scopes.toast.assign_success"));
|
|
227
230
|
setAddDialogOpen(false);
|
|
228
231
|
setSelectedTreeItem(undefined);
|
|
229
232
|
setSelectedRoleId("");
|
|
230
233
|
await loadUserScopes();
|
|
231
234
|
}
|
|
232
235
|
else {
|
|
233
|
-
toast.error(data.error || "
|
|
236
|
+
toast.error(data.error || t("user_scopes.toast.assign_failed"));
|
|
234
237
|
}
|
|
235
238
|
}
|
|
236
239
|
catch (error) {
|
|
237
|
-
toast.error("
|
|
240
|
+
toast.error(t("user_scopes.toast.assign_failed"));
|
|
238
241
|
}
|
|
239
242
|
finally {
|
|
240
243
|
setActionLoading(false);
|
|
@@ -255,35 +258,40 @@ export function UserScopesTab({ className }) {
|
|
|
255
258
|
});
|
|
256
259
|
const data = await response.json();
|
|
257
260
|
if (data.success) {
|
|
258
|
-
toast.success("
|
|
261
|
+
toast.success(t("user_scopes.toast.remove_success"));
|
|
259
262
|
setDeleteDialogOpen(false);
|
|
260
263
|
setScopeToDelete(null);
|
|
261
264
|
await loadUserScopes();
|
|
262
265
|
}
|
|
263
266
|
else {
|
|
264
|
-
toast.error(data.error || "
|
|
267
|
+
toast.error(data.error || t("user_scopes.toast.remove_failed"));
|
|
265
268
|
}
|
|
266
269
|
}
|
|
267
270
|
catch (error) {
|
|
268
|
-
toast.error("
|
|
271
|
+
toast.error(t("user_scopes.toast.remove_failed"));
|
|
269
272
|
}
|
|
270
273
|
finally {
|
|
271
274
|
setActionLoading(false);
|
|
272
275
|
}
|
|
273
276
|
};
|
|
274
|
-
return (_jsxs("div", { className: `cls_user_scopes_tab flex flex-col lg:flex-row gap-4 w-full min-h-[500px] ${className || ""}`, children: [_jsxs("div", { className: "cls_user_scopes_users_panel w-full lg:w-1/3 flex flex-col border rounded-lg", children: [_jsxs("div", { className: "cls_user_scopes_users_header p-4 border-b bg-muted/30", children: [_jsx("h3", { className: "font-semibold mb-2", children: "
|
|
275
|
-
?
|
|
276
|
-
: "
|
|
277
|
+
return (_jsxs("div", { className: `cls_user_scopes_tab flex flex-col lg:flex-row gap-4 w-full min-h-[500px] ${className || ""}`, children: [_jsxs("div", { className: "cls_user_scopes_users_panel w-full lg:w-1/3 flex flex-col border rounded-lg", children: [_jsxs("div", { className: "cls_user_scopes_users_header p-4 border-b bg-muted/30", children: [_jsx("h3", { className: "font-semibold mb-2", children: t("user_scopes.tab.select_user_heading") }), _jsxs("div", { className: "relative", children: [_jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }), _jsx(Input, { value: userSearch, onChange: (e) => setUserSearch(e.target.value), placeholder: t("user_scopes.tab.search_placeholder"), className: "pl-8" })] })] }), _jsx("div", { className: "cls_user_scopes_users_list flex-1 overflow-auto", children: usersLoading ? (_jsx("div", { className: "flex items-center justify-center p-8", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-slate-400" }) })) : filteredUsers.length === 0 ? (_jsx("div", { className: "text-center text-muted-foreground p-8", children: t("user_scopes.tab.no_users_found") })) : (_jsx("div", { className: "divide-y", children: filteredUsers.map((user) => (_jsxs("div", { className: `cls_user_scopes_user_item flex items-center gap-3 p-3 cursor-pointer hover:bg-muted/50 transition-colors ${(selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.id) === user.id ? "bg-muted" : ""}`, onClick: () => setSelectedUser(user), children: [_jsxs(Avatar, { className: "h-8 w-8", children: [_jsx(AvatarImage, { src: user.profile_picture_url || undefined }), _jsx(AvatarFallback, { className: "bg-slate-200 text-slate-600 text-xs", children: getUserInitials(user) })] }), _jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("p", { className: "text-sm font-medium truncate", children: user.name || user.email_address }), user.name && (_jsx("p", { className: "text-xs text-muted-foreground truncate", children: user.email_address }))] }), (selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.id) === user.id && (_jsx(ChevronRight, { className: "h-4 w-4 text-muted-foreground" }))] }, user.id))) })) })] }), _jsxs("div", { className: "cls_user_scopes_assignments_panel w-full lg:w-2/3 flex flex-col border rounded-lg", children: [_jsxs("div", { className: "cls_user_scopes_assignments_header p-4 border-b bg-muted/30 flex items-center justify-between", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-semibold", children: selectedUser
|
|
278
|
+
? t("user_scopes.tab.scopes_for", { user: selectedUser.name || selectedUser.email_address })
|
|
279
|
+
: t("user_scopes.tab.select_user_prompt") }), selectedUser && inheritedScopeIds.length > 0 && (_jsx("p", { className: "text-xs text-muted-foreground mt-1", children: t("user_scopes.tab.inherited_scopes", { count: inheritedScopeIds.length }) }))] }), selectedUser && (_jsxs(Button, { onClick: () => {
|
|
277
280
|
setSelectedTreeItem(undefined);
|
|
278
281
|
setAddDialogOpen(true);
|
|
279
|
-
}, variant: "default", size: "sm", children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), "
|
|
282
|
+
}, variant: "default", size: "sm", children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), t("user_scopes.tab.add_scope_button")] }))] }), _jsx("div", { className: "cls_user_scopes_assignments_content flex-1 overflow-auto", children: !selectedUser ? (_jsx("div", { className: "flex items-center justify-center h-full text-muted-foreground", children: t("user_scopes.tab.no_user_selected") })) : scopesLoading ? (_jsx("div", { className: "flex items-center justify-center h-full", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-slate-400" }) })) : userScopes.length === 0 ? (_jsxs("div", { className: "flex flex-col items-center justify-center h-full gap-4 text-muted-foreground", children: [_jsx("p", { children: t("user_scopes.tab.no_scopes_assigned") }), _jsxs(Button, { onClick: () => {
|
|
280
283
|
setSelectedTreeItem(undefined);
|
|
281
284
|
setAddDialogOpen(true);
|
|
282
|
-
}, variant: "outline", size: "sm", children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), "
|
|
285
|
+
}, variant: "outline", size: "sm", children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), t("user_scopes.tab.assign_first_scope")] })] })) : (_jsxs(Table, { className: "w-full", children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: t("user_scopes.tab.table.scope_name") }), _jsx(TableHead, { children: t("user_scopes.tab.table.level") }), _jsx(TableHead, { children: t("user_scopes.tab.table.scope_id") }), _jsx(TableHead, { children: t("user_scopes.tab.table.assigned") }), _jsx(TableHead, { className: "text-right w-[80px]", children: t("user_scopes.tab.table.actions") })] }) }), _jsx(TableBody, { children: userScopes.map((scope) => (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-medium", children: scope.scope_name || t("user_scopes.tab.table.unknown") }), _jsx(TableCell, { className: "text-sm", children: scope.level || "-" }), _jsxs(TableCell, { className: "font-mono text-xs text-muted-foreground", children: [scope.scope_id.substring(0, 8), "..."] }), _jsx(TableCell, { className: "text-sm text-muted-foreground", children: new Date(scope.created_at).toLocaleDateString() }), _jsx(TableCell, { className: "text-right", children: _jsx(Button, { onClick: () => {
|
|
283
286
|
setScopeToDelete(scope);
|
|
284
287
|
setDeleteDialogOpen(true);
|
|
285
|
-
}, variant: "outline", size: "sm", className: "text-destructive", children: _jsx(Trash2, { className: "h-4 w-4" }) }) })] }, scope.scope_id))) })] })) })] }), _jsx(Dialog, { open: addDialogOpen, onOpenChange: setAddDialogOpen, children: _jsxs(DialogContent, { className: "cls_user_scopes_add_dialog sm:max-w-[500px]", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children:
|
|
288
|
+
}, variant: "outline", size: "sm", className: "text-destructive", children: _jsx(Trash2, { className: "h-4 w-4" }) }) })] }, scope.scope_id))) })] })) })] }), _jsx(Dialog, { open: addDialogOpen, onOpenChange: setAddDialogOpen, children: _jsxs(DialogContent, { className: "cls_user_scopes_add_dialog sm:max-w-[500px]", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: t("user_scopes.tab.add_dialog.title") }), _jsx(DialogDescription, { children: t("user_scopes.tab.add_dialog.description", {
|
|
289
|
+
user: (selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.name) || (selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.email_address) || "",
|
|
290
|
+
}) })] }), _jsxs("div", { className: "flex flex-col gap-4 py-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: t("user_scopes.tab.add_dialog.select_scope_label") }), treeLoading ? (_jsx("div", { className: "flex items-center justify-center p-8 border rounded-lg", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-slate-400" }) })) : scopeTree.length === 0 ? (_jsxs("div", { className: "flex flex-col items-center justify-center p-6 border rounded-lg border-dashed", children: [_jsx(FolderTree, { className: "h-8 w-8 text-muted-foreground mb-2" }), _jsx("p", { className: "text-sm text-muted-foreground text-center", children: t("user_scopes.tab.add_dialog.no_scopes") })] })) : (_jsx("div", { className: "border rounded-lg max-h-[300px] overflow-auto", children: _jsx(TreeView, { data: treeData, expandAll: true, defaultNodeIcon: Building2, defaultLeafIcon: Building2, onSelectChange: handleTreeSelectChange, initialSelectedItemId: selectedTreeItem === null || selectedTreeItem === void 0 ? void 0 : selectedTreeItem.id, className: "w-full" }) }))] }), (selectedTreeItem === null || selectedTreeItem === void 0 ? void 0 : selectedTreeItem.scopeData) && (_jsxs("div", { className: "p-3 border rounded-lg bg-muted/50", children: [_jsxs("p", { className: "text-sm", children: [_jsx("span", { className: "font-medium", children: t("user_scopes.tab.add_dialog.selected_prefix") }), " ", selectedTreeItem.scopeData.name] }), _jsxs("p", { className: "text-xs text-muted-foreground", children: [selectedTreeItem.scopeData.level, " - ID: ", selectedTreeItem.scopeData.id.substring(0, 8), "..."] })] })), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: t("user_scopes.tab.add_dialog.assign_role_label") }), rolesLoading ? (_jsxs("div", { className: "flex items-center gap-2 p-2 text-sm text-muted-foreground", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin" }), t("user_scopes.tab.add_dialog.loading_roles")] })) : roles.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: t("user_scopes.tab.add_dialog.no_roles") })) : (_jsxs(Select, { value: selectedRoleId, onValueChange: setSelectedRoleId, children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, { placeholder: t("user_scopes.tab.add_dialog.select_role_placeholder") }) }), _jsx(SelectContent, { children: roles.map((role) => (_jsxs(SelectItem, { value: role.id, children: [role.name, role.description && (_jsxs("span", { className: "text-muted-foreground ml-2", children: ["- ", role.description] }))] }, role.id))) })] }))] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { onClick: handleAddScope, disabled: actionLoading || !(selectedTreeItem === null || selectedTreeItem === void 0 ? void 0 : selectedTreeItem.scopeData) || !selectedRoleId, variant: "default", children: actionLoading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }), t("user_scopes.tab.add_dialog.assigning")] })) : (_jsxs(_Fragment, { children: [_jsx(CircleCheck, { className: "h-4 w-4 mr-2" }), t("user_scopes.tab.add_dialog.assign_button")] })) }), _jsxs(Button, { onClick: () => setAddDialogOpen(false), variant: "outline", children: [_jsx(CircleX, { className: "h-4 w-4 mr-2" }), t("shared.cancel_button")] })] })] }) }), _jsx(AlertDialog, { open: deleteDialogOpen, onOpenChange: setDeleteDialogOpen, children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: t("user_scopes.tab.delete_dialog.title") }), _jsx(AlertDialogDescription, { children: t("user_scopes.tab.delete_dialog.description", {
|
|
291
|
+
scope: (scopeToDelete === null || scopeToDelete === void 0 ? void 0 : scopeToDelete.scope_name) || (scopeToDelete === null || scopeToDelete === void 0 ? void 0 : scopeToDelete.scope_id.substring(0, 8)) || "",
|
|
292
|
+
user: (selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.name) || (selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.email_address) || "",
|
|
293
|
+
}) })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogAction, { onClick: handleRemoveScope, disabled: actionLoading, children: actionLoading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }), t("user_scopes.tab.delete_dialog.removing")] })) : (t("user_scopes.tab.delete_dialog.confirm")) }), _jsx(AlertDialogCancel, { onClick: () => {
|
|
286
294
|
setDeleteDialogOpen(false);
|
|
287
295
|
setScopeToDelete(null);
|
|
288
|
-
}, children: "
|
|
296
|
+
}, children: t("shared.cancel_button") })] })] }) })] }));
|
|
289
297
|
}
|
|
@@ -9,7 +9,8 @@ export interface UserSignupStatsCardsProps {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Total + rolling-window signup cards (All time, 7d, 30d, 3mo, 6mo, YTD) each
|
|
12
|
-
* with % change vs the prior equal period, plus a
|
|
12
|
+
* with % change vs the prior equal period, plus a larger interactive YTD
|
|
13
|
+
* monthly bar chart with axes, gridlines, and hover tooltips.
|
|
13
14
|
* Computes everything client-side from the already-loaded users list.
|
|
14
15
|
*/
|
|
15
16
|
export declare function UserSignupStatsCards({ users, now, className }: UserSignupStatsCardsProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user_signup_stats_cards.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/user_signup_stats_cards.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user_signup_stats_cards.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/user_signup_stats_cards.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAOjD,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,aAAa,CAAC;QAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IACrD,8DAA8D;IAC9D,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA2ND;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,yBAAyB,qBAaxF"}
|