();
+ setLastItem(ref);
+
+ setRoles((prev) => prev.concat(data.data));
+ }, [data, setLastItem]);
+
+ const items = useMemo(
+ () =>
+ roles.map((item: any, index: number) => ({
+ key: item.name,
+ label:
+ index === roles.length - 1 ? (
+
+ {
+ setVisible(true);
+ setRecord(item);
+ }}
+ />
+
+ ) : (
+ {
+ setVisible(true);
+ setRecord(item);
+ }}
+ />
+ ),
+ })),
+ [roles, lastItem],
+ );
return (
<>
- {items.length ? (
-
+ {roles.length ? (
+ <>
+
+ {loading && }
+ >
) : (
)}
@@ -92,12 +135,15 @@ RolesMenu.Item = function DepartmentTreeItem({ item, onEdit }) {
deleteDepartment();
}
};
+ const title = Schema.compile(item.title, { t });
return (
- {Schema.compile(item.title, { t })}
+
+ {title}
+
diff --git a/packages/plugins/@nocobase/plugin-acl/src/client/hooks/load-more-observer.ts b/packages/plugins/@nocobase/plugin-acl/src/client/hooks/load-more-observer.ts
new file mode 100644
index 000000000..7bc5e5bbf
--- /dev/null
+++ b/packages/plugins/@nocobase/plugin-acl/src/client/hooks/load-more-observer.ts
@@ -0,0 +1,45 @@
+import React, { useCallback, useEffect, useRef, useState } from 'react';
+
+export const useLoadMoreObserver = ({
+ loadMore,
+}: {
+ loadMore: () => void; // callback
+}) => {
+ const [lastItem, setLastItem] = useState>(null);
+ const observer = useRef(null);
+ const observeExposure = useCallback(
+ (lastItem: React.RefObject) => {
+ if (!lastItem) {
+ return;
+ }
+ observer.current && observer.current.disconnect();
+ observer.current = new IntersectionObserver((entries) => {
+ entries.forEach((entry) => {
+ if (entry.target !== lastItem.current) {
+ return;
+ }
+ if (entry.isIntersecting) {
+ observer.current && observer.current.unobserve(lastItem.current);
+ loadMore();
+ }
+ });
+ });
+
+ lastItem.current && observer.current && observer.current.observe(lastItem.current);
+ },
+ [loadMore],
+ );
+
+ useEffect(() => {
+ observeExposure(lastItem);
+
+ return () => {
+ observer.current && observer.current.disconnect();
+ };
+ }, [lastItem, observeExposure]);
+
+ return {
+ lastItem,
+ setLastItem,
+ };
+};
From f385c34c72a3aa190448c29dfadbc081239182e1 Mon Sep 17 00:00:00 2001
From: katherinehhh
Date: Thu, 21 Mar 2024 16:32:51 +0800
Subject: [PATCH 18/18] fix: filter does not allow passing empty objects
(#3780)
---
packages/core/client/src/block-provider/BlockProvider.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/core/client/src/block-provider/BlockProvider.tsx b/packages/core/client/src/block-provider/BlockProvider.tsx
index 483d48b20..da97a5c09 100644
--- a/packages/core/client/src/block-provider/BlockProvider.tsx
+++ b/packages/core/client/src/block-provider/BlockProvider.tsx
@@ -349,7 +349,7 @@ export const useParamsFromRecord = () => {
if (record.__collection && collectionField && !['oho', 'm2o', 'obo'].includes(collectionField.interface)) {
obj['targetCollection'] = record.__collection;
}
- if (!filterByTk) {
+ if (!filterByTk && Object.keys(filter).length > 0) {
obj['filter'] = filter;
}
return obj;