mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 14:04:28 +00:00
fix: add condition check to node.canPerformAction
This commit is contained in:
parent
a93fe0df71
commit
6fc61693ed
@ -15,6 +15,7 @@ import {
|
|||||||
NodeStatus,
|
NodeStatus,
|
||||||
CompositeValue,
|
CompositeValue,
|
||||||
GlobalEvent,
|
GlobalEvent,
|
||||||
|
ComponentAction,
|
||||||
} from '@ali/lowcode-types';
|
} from '@ali/lowcode-types';
|
||||||
import { compatStage } from '@ali/lowcode-utils';
|
import { compatStage } from '@ali/lowcode-utils';
|
||||||
import { SettingTopEntry } from '@ali/lowcode-designer';
|
import { SettingTopEntry } from '@ali/lowcode-designer';
|
||||||
@ -863,10 +864,17 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
/**
|
/**
|
||||||
* 是否可执行某action
|
* 是否可执行某action
|
||||||
*/
|
*/
|
||||||
canPerformAction(action: string): boolean {
|
canPerformAction(actionName: string): boolean {
|
||||||
const availableActions =
|
const availableActions =
|
||||||
this.componentMeta?.availableActions?.map((action) => action.name) || [];
|
this.componentMeta?.availableActions?.filter((action: ComponentAction) => {
|
||||||
return availableActions.indexOf(action) >= 0;
|
const { condition } = action;
|
||||||
|
return typeof condition === 'function' ?
|
||||||
|
condition(this) !== false :
|
||||||
|
condition !== false;
|
||||||
|
})
|
||||||
|
.map((action: ComponentAction) => action.name) || [];
|
||||||
|
|
||||||
|
return availableActions.indexOf(actionName) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======= compatible apis ====
|
// ======= compatible apis ====
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user