@@ -2,6 +2,7 @@ import * as React from 'react';
22import { ITermAction , ITermActionsControlProps , ITermActionsControlState , TermActionsDisplayMode , TermActionsDisplayStyle } from './ITermsActions' ;
33import { DropdownTermAction } from './DropdownTermAction' ;
44import ButtonTermAction from './ButtonTermAction' ;
5+ import { find } from 'office-ui-fabric-react/lib/Utilities' ;
56
67export default class TermActionsControl extends React . Component < ITermActionsControlProps , ITermActionsControlState > {
78
@@ -38,7 +39,7 @@ export default class TermActionsControl extends React.Component<ITermActionsCont
3839
3940 if ( termActions . actions ) {
4041 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 ) ;
4243 if ( available ) {
4344 availableActions . push ( action ) ;
4445 }
@@ -50,6 +51,20 @@ export default class TermActionsControl extends React.Component<ITermActionsCont
5051 } ) ;
5152 }
5253
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+
5368 /**
5469 * Default React render method
5570 */
0 commit comments