1
0
forked from baron/baron-sso

feat: display UserGroups in the tenant organization tab

This commit is contained in:
2026-03-04 15:21:22 +09:00
parent 539a87e93a
commit 71473b0f6c

View File

@@ -56,9 +56,11 @@ import {
TabsTrigger, TabsTrigger,
} from "../../../components/ui/tabs"; } from "../../../components/ui/tabs";
import { import {
type GroupSummary,
type TenantSummary, type TenantSummary,
type UserSummary, type UserSummary,
createUser, createUser,
fetchGroups,
fetchTenants, fetchTenants,
fetchUsers, fetchUsers,
updateTenant, updateTenant,
@@ -705,7 +707,15 @@ const TenantTreeRow: React.FC<{
variant="ghost" variant="ghost"
size="icon" size="icon"
className="h-8 w-8" className="h-8 w-8"
onClick={() => navigate(`/tenants/${node.id}`)} onClick={() => {
if (node.type === "USER_GROUP") {
// User groups have a different detail path
const baseTenantId = node.tenantId || tenantId;
navigate(`/tenants/${baseTenantId}/organization/${node.id}`);
} else {
navigate(`/tenants/${node.id}`);
}
}}
title={t("ui.common.manage", "관리")} title={t("ui.common.manage", "관리")}
> >
<ArrowRight size={14} /> <ArrowRight size={14} />
@@ -760,6 +770,23 @@ function TenantUserGroupsTab() {
queryFn: () => fetchTenants(1000, 0), queryFn: () => fetchTenants(1000, 0),
}); });
const { data: groupsData, isLoading: isGroupsLoading } = useQuery({
queryKey: ["tenant-groups", tenantId],
queryFn: () => fetchGroups(tenantId),
enabled: !!tenantId,
});
const groupNodes = useMemo(() => {
if (!groupsData) return [];
return groupsData.map((g) => ({
...g,
type: "USER_GROUP",
children: [], // Simplified for now, just a list or separate tree
memberCount: g.members?.length || 0,
recursiveMemberCount: g.members?.length || 0,
})) as unknown as TenantNode[];
}, [groupsData]);
const updateParentMutation = useMutation({ const updateParentMutation = useMutation({
mutationFn: ({ mutationFn: ({
id, id,
@@ -775,10 +802,17 @@ function TenantUserGroupsTab() {
const allTenants = data?.items ?? []; const allTenants = data?.items ?? [];
const { currentBase, subTree } = useMemo( const { currentBase, subTree } = useMemo(() => {
() => buildTenantFullTree(allTenants, tenantId), const tree = buildTenantFullTree(allTenants, tenantId);
[allTenants, tenantId], if (tree.currentBase) {
); // Merge backend-provided UserGroups into the tree as virtual children
tree.currentBase.children = [
...tree.currentBase.children,
...groupNodes,
];
}
return tree;
}, [allTenants, tenantId, groupNodes]);
const handleAdd = (id: string) => const handleAdd = (id: string) =>
updateParentMutation.mutate({ id, parentId: tenantId }); updateParentMutation.mutate({ id, parentId: tenantId });