Skip to content

Commit 8a89760

Browse files
committed
#237 - Correctly invoking the applyToTerm check
1 parent 7adfe8a commit 8a89760

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/controls/taxonomyPicker/termActions/TermActionsControl.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,26 @@ export default class TermActionsControl extends React.Component<ITermActionsCont
2424
* componentWillMount lifecycle hook
2525
*/
2626
public componentWillMount(): void {
27+
this.getAvailableActions();
28+
}
29+
30+
/**
31+
* Get the available term actions
32+
*/
33+
private async getAvailableActions(): Promise<void> {
2734
const { term, termActions } = this.props;
2835

2936
// Prepare list of the available actions
30-
const availableActions: ITermAction[] = termActions.actions.filter(async (termAction) => { return await termAction.applyToTerm(term); });
37+
const availableActions: ITermAction[] = [];
38+
39+
if (termActions.actions) {
40+
for (const action of termActions.actions) {
41+
const available = await action.applyToTerm(term);
42+
if (available) {
43+
availableActions.push(action);
44+
}
45+
}
46+
}
3147

3248
this.setState({
3349
availableActions

src/webparts/controlsTest/components/ControlsTest.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
463463
};
464464
return updateAction;
465465
},
466-
applyToTerm: () => (true)
466+
applyToTerm: (term: ITerm) => (term && term.Name && term.Name.toLowerCase() === "about us")
467467
},
468468
// new TermLabelAction("Get Labels")
469469
],

0 commit comments

Comments
 (0)