mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-04 21:28:34 +08:00
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)
|
||||
.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 {
|
||||
...group,
|
||||
|
@ -3,7 +3,7 @@ export * from './Branch';
|
||||
export * from './FlowContext';
|
||||
export * from './nodes';
|
||||
export { triggers, useTrigger, getTriggersOptions } from './triggers';
|
||||
export { useWorkflowVariableOptions } from './variable';
|
||||
export { useWorkflowVariableOptions, getCollectionFieldOptions } from './variable';
|
||||
|
||||
import { Plugin } from '@nocobase/client';
|
||||
import React from 'react';
|
||||
|
@ -13,14 +13,15 @@ import {
|
||||
useResourceActionContext,
|
||||
} from '@nocobase/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 { useTranslation } from 'react-i18next';
|
||||
import { AddButton } from '../AddButton';
|
||||
import { useFlowContext } from '../FlowContext';
|
||||
import { DrawerDescription } from '../components/DrawerDescription';
|
||||
import { StatusButton } from '../components/StatusButton';
|
||||
import { JobStatusOptionsMap } from '../constants';
|
||||
import { NAMESPACE, lang } from '../locale';
|
||||
import { lang } from '../locale';
|
||||
import useStyles from '../style';
|
||||
import { VariableOption, VariableOptions } from '../variable';
|
||||
import aggregate from './aggregate';
|
||||
@ -36,7 +37,6 @@ import query from './query';
|
||||
import request from './request';
|
||||
import sql from './sql';
|
||||
import update from './update';
|
||||
import { StatusButton } from '../components/StatusButton';
|
||||
|
||||
export interface Instruction {
|
||||
title: string;
|
||||
@ -54,6 +54,7 @@ export interface Instruction {
|
||||
useScopeVariables?(node, options?): VariableOptions;
|
||||
useInitializers?(node): SchemaInitializerItemOptions | null;
|
||||
initializers?: { [key: string]: any };
|
||||
isAvailable?(ctx: object): boolean;
|
||||
}
|
||||
|
||||
export const instructions = new Registry<Instruction>();
|
||||
|
@ -8,7 +8,7 @@ import { useWorkflowVariableOptions } from '../variable';
|
||||
export default {
|
||||
title: `{{t("SQL action", { ns: "${NAMESPACE}" })}}`,
|
||||
type: 'sql',
|
||||
group: 'extended',
|
||||
group: 'collection',
|
||||
description: `{{t("Execute a SQL statement in database.", { ns: "${NAMESPACE}" })}}`,
|
||||
fieldset: {
|
||||
sql: {
|
||||
|
Loading…
Reference in New Issue
Block a user