refactor(plugin-workflow): add isAvailable check for adding node (#2898)
This commit is contained in:
parent
08f213bc16
commit
ab9457c7fc
@ -28,7 +28,11 @@ export function AddButton({ upstream, branchIndex = null }: AddButtonProps) {
|
|||||||
]
|
]
|
||||||
.filter((group) => instructionList.filter((item) => item.group === group.key).length)
|
.filter((group) => instructionList.filter((item) => item.group === group.key).length)
|
||||||
.map((group) => {
|
.map((group) => {
|
||||||
const groupInstructions = instructionList.filter((item) => item.group === group.key);
|
const groupInstructions = instructionList.filter(
|
||||||
|
(item) =>
|
||||||
|
item.group === group.key &&
|
||||||
|
(item.isAvailable ? item.isAvailable({ workflow, upstream, branchIndex }) : true),
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...group,
|
...group,
|
||||||
|
@ -3,7 +3,7 @@ export * from './Branch';
|
|||||||
export * from './FlowContext';
|
export * from './FlowContext';
|
||||||
export * from './nodes';
|
export * from './nodes';
|
||||||
export { triggers, useTrigger, getTriggersOptions } from './triggers';
|
export { triggers, useTrigger, getTriggersOptions } from './triggers';
|
||||||
export { useWorkflowVariableOptions } from './variable';
|
export { useWorkflowVariableOptions, getCollectionFieldOptions } from './variable';
|
||||||
|
|
||||||
import { Plugin } from '@nocobase/client';
|
import { Plugin } from '@nocobase/client';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
@ -13,14 +13,15 @@ import {
|
|||||||
useResourceActionContext,
|
useResourceActionContext,
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import { Registry, parse, str2moment } from '@nocobase/utils/client';
|
import { Registry, parse, str2moment } from '@nocobase/utils/client';
|
||||||
import { Alert, App, Button, Dropdown, Input, Tag, message } from 'antd';
|
import { App, Button, Dropdown, Input, Tag, message } from 'antd';
|
||||||
import React, { useContext, useState } from 'react';
|
import React, { useContext, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { AddButton } from '../AddButton';
|
import { AddButton } from '../AddButton';
|
||||||
import { useFlowContext } from '../FlowContext';
|
import { useFlowContext } from '../FlowContext';
|
||||||
import { DrawerDescription } from '../components/DrawerDescription';
|
import { DrawerDescription } from '../components/DrawerDescription';
|
||||||
|
import { StatusButton } from '../components/StatusButton';
|
||||||
import { JobStatusOptionsMap } from '../constants';
|
import { JobStatusOptionsMap } from '../constants';
|
||||||
import { NAMESPACE, lang } from '../locale';
|
import { lang } from '../locale';
|
||||||
import useStyles from '../style';
|
import useStyles from '../style';
|
||||||
import { VariableOption, VariableOptions } from '../variable';
|
import { VariableOption, VariableOptions } from '../variable';
|
||||||
import aggregate from './aggregate';
|
import aggregate from './aggregate';
|
||||||
@ -36,7 +37,6 @@ import query from './query';
|
|||||||
import request from './request';
|
import request from './request';
|
||||||
import sql from './sql';
|
import sql from './sql';
|
||||||
import update from './update';
|
import update from './update';
|
||||||
import { StatusButton } from '../components/StatusButton';
|
|
||||||
|
|
||||||
export interface Instruction {
|
export interface Instruction {
|
||||||
title: string;
|
title: string;
|
||||||
@ -54,6 +54,7 @@ export interface Instruction {
|
|||||||
useScopeVariables?(node, options?): VariableOptions;
|
useScopeVariables?(node, options?): VariableOptions;
|
||||||
useInitializers?(node): SchemaInitializerItemOptions | null;
|
useInitializers?(node): SchemaInitializerItemOptions | null;
|
||||||
initializers?: { [key: string]: any };
|
initializers?: { [key: string]: any };
|
||||||
|
isAvailable?(ctx: object): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const instructions = new Registry<Instruction>();
|
export const instructions = new Registry<Instruction>();
|
||||||
|
@ -8,7 +8,7 @@ import { useWorkflowVariableOptions } from '../variable';
|
|||||||
export default {
|
export default {
|
||||||
title: `{{t("SQL action", { ns: "${NAMESPACE}" })}}`,
|
title: `{{t("SQL action", { ns: "${NAMESPACE}" })}}`,
|
||||||
type: 'sql',
|
type: 'sql',
|
||||||
group: 'extended',
|
group: 'collection',
|
||||||
description: `{{t("Execute a SQL statement in database.", { ns: "${NAMESPACE}" })}}`,
|
description: `{{t("Execute a SQL statement in database.", { ns: "${NAMESPACE}" })}}`,
|
||||||
fieldset: {
|
fieldset: {
|
||||||
sql: {
|
sql: {
|
||||||
|
Loading…
Reference in New Issue
Block a user