@@ -52,6 +52,8 @@ function ActionPicker({ disabled, kind, arity, selectedKey, onAction, dataType }
52
52
53
53
const [ containerState ] = useContainerContext ( ) ;
54
54
55
+ const { selectedItems } = containerState ;
56
+
55
57
const frame = useRef ( null ) ;
56
58
57
59
useEffect ( ( ) => {
@@ -70,7 +72,14 @@ function ActionPicker({ disabled, kind, arity, selectedKey, onAction, dataType }
70
72
)
71
73
) . forEach (
72
74
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
+ ) {
74
83
if (
75
84
action . onlyFor || ! config . crud || ! action . crud || (
76
85
! action . crud . find ( op => config . crud . indexOf ( op ) === - 1 )
@@ -88,7 +97,7 @@ function ActionPicker({ disabled, kind, arity, selectedKey, onAction, dataType }
88
97
} else {
89
98
setState ( { actions : [ ] } ) ;
90
99
}
91
- } , [ dataType , arity , kind ] ) ;
100
+ } , [ dataType , arity , kind , selectedItems ] ) ;
92
101
93
102
useResizeObserver ( frame , entry => setState ( { width : Math . floor ( entry . contentRect . width ) } ) ) ;
94
103
0 commit comments