Skip to content

Commit 7b3827a

Browse files
committed
Add | Configure action for specific members
1 parent 36d9a0d commit 7b3827a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/actions/ActionPicker.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ function ActionPicker({ disabled, kind, arity, selectedKey, onAction, dataType }
5252

5353
const [containerState] = useContainerContext();
5454

55+
const { selectedItems } = containerState;
56+
5557
const frame = useRef(null);
5658

5759
useEffect(() => {
@@ -70,7 +72,14 @@ function ActionPicker({ disabled, kind, arity, selectedKey, onAction, dataType }
7072
)
7173
).forEach(
7274
action => {
73-
if (!action.onlyFor || action.onlyFor.find(criteria => match(dataType, criteria))) {
75+
if (
76+
(!action.onlyFor || action.onlyFor.find(criteria => match(dataType, criteria))) &&
77+
(!action.onlyForMembers || (
78+
selectedItems.length === 1 && action.onlyForMembers.find(
79+
criteria => match(selectedItems[0], criteria)
80+
)
81+
))
82+
) {
7483
if (
7584
action.onlyFor || !config.crud || !action.crud || (
7685
!action.crud.find(op => config.crud.indexOf(op) === -1)
@@ -88,7 +97,7 @@ function ActionPicker({ disabled, kind, arity, selectedKey, onAction, dataType }
8897
} else {
8998
setState({ actions: [] });
9099
}
91-
}, [dataType, arity, kind]);
100+
}, [dataType, arity, kind, selectedItems]);
92101

93102
useResizeObserver(frame, entry => setState({ width: Math.floor(entry.contentRect.width) }));
94103

0 commit comments

Comments
 (0)