Skip to content
Permalink
Browse files

#237 - Correctly invoking the applyToTerm check

  • Loading branch information...
estruyf committed Feb 13, 2019
1 parent 7adfe8a commit 8a897604d6e19c98125fe8f4e54eeefd4dd09638
@@ -24,10 +24,26 @@ export default class TermActionsControl extends React.Component<ITermActionsCont
* componentWillMount lifecycle hook
*/
public componentWillMount(): void {
this.getAvailableActions();
}

/**
* Get the available term actions
*/
private async getAvailableActions(): Promise<void> {
const { term, termActions } = this.props;

// Prepare list of the available actions
const availableActions: ITermAction[] = termActions.actions.filter(async (termAction) => { return await termAction.applyToTerm(term); });
const availableActions: ITermAction[] = [];

if (termActions.actions) {
for (const action of termActions.actions) {
const available = await action.applyToTerm(term);
if (available) {
availableActions.push(action);
}
}
}

this.setState({
availableActions
@@ -463,7 +463,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
};
return updateAction;
},
applyToTerm: () => (true)
applyToTerm: (term: ITerm) => (term && term.Name && term.Name.toLowerCase() === "about us")
},
// new TermLabelAction("Get Labels")
],

0 comments on commit 8a89760

Please sign in to comment.
You can’t perform that action at this time.