From 9354e25d7418c1d692a73db9837ba7dc40349383 Mon Sep 17 00:00:00 2001 From: YANG QIA <2013xile@gmail.com> Date: Thu, 21 Mar 2024 21:09:24 +0800 Subject: [PATCH] fix(acl): role menu loading status (#3787) --- .../plugin-acl/src/client/RolesMenu.tsx | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-acl/src/client/RolesMenu.tsx b/packages/plugins/@nocobase/plugin-acl/src/client/RolesMenu.tsx index 096df14f7..1c4b02db2 100644 --- a/packages/plugins/@nocobase/plugin-acl/src/client/RolesMenu.tsx +++ b/packages/plugins/@nocobase/plugin-acl/src/client/RolesMenu.tsx @@ -18,11 +18,12 @@ export const RolesMenu: React.FC & { Item: React.FC<{ item: any; onEdit: () => void }>; } = () => { const { t } = useACLTranslation(); - const { data, mutate, loading } = useResourceActionContext(); + const { data, mutate } = useResourceActionContext(); const [visible, setVisible] = useState(false); const [record, setRecord] = useState(null); const { role, setRole } = useContext(RolesManagerContext); const [roles, setRoles] = useState([]); + const [loading, setLoading] = useState(false); const api = useAPIClient(); const loadMore = useCallback(async () => { @@ -30,7 +31,7 @@ export const RolesMenu: React.FC & { if (!meta || meta.page >= meta.totalPage) { return; } - + setLoading(true); const res = await api.resource('roles').list({ page: meta.page + 1, pageSize: meta.pageSize, @@ -42,6 +43,7 @@ export const RolesMenu: React.FC & { appends: [], }); mutate(res?.data || {}); + setLoading(false); }, [data]); const { lastItem, setLastItem } = useLoadMoreObserver({ loadMore }); @@ -102,15 +104,12 @@ export const RolesMenu: React.FC & { return ( <> {roles.length ? ( - <> - - {loading && } - + }] : [])]} + selectedKeys={[role?.name]} + onSelect={handleSelect} + /> ) : ( )}