@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
import { ITermAction , ITermActionsControlProps , ITermActionsControlState , TermActionsDisplayMode , TermActionsDisplayStyle } from './ITermsActions' ;
3
3
import { DropdownTermAction } from './DropdownTermAction' ;
4
4
import ButtonTermAction from './ButtonTermAction' ;
5
+ import { find } from 'office-ui-fabric-react/lib/Utilities' ;
5
6
6
7
export default class TermActionsControl extends React . Component < ITermActionsControlProps , ITermActionsControlState > {
7
8
@@ -38,7 +39,7 @@ export default class TermActionsControl extends React.Component<ITermActionsCont
38
39
39
40
if ( termActions . actions ) {
40
41
for ( const action of termActions . actions ) {
41
- const available = await action . applyToTerm ( term , this . props . termActionCallback ) ;
42
+ const available = await action . applyToTerm ( term , this . props . termActionCallback , this . setActionVisibility ) ;
42
43
if ( available ) {
43
44
availableActions . push ( action ) ;
44
45
}
@@ -50,6 +51,20 @@ export default class TermActionsControl extends React.Component<ITermActionsCont
50
51
} ) ;
51
52
}
52
53
54
+ /**
55
+ * Sets the visibility of a certain action
56
+ * @param isHidden
57
+ */
58
+ private setActionVisibility ( actionId : string , isHidden : boolean ) {
59
+ this . setState ( ( prevState : ITermActionsControlState ) => {
60
+ const action = find ( prevState . availableActions , a => a . id === actionId ) ;
61
+ action . hidden = isHidden ;
62
+ return {
63
+ availableActions : prevState . availableActions
64
+ } ;
65
+ } ) ;
66
+ }
67
+
53
68
/**
54
69
* Default React render method
55
70
*/
0 commit comments