tachybase_todo/packages/plugins/@nocobase/plugin-workflow/src/client/index.tsx
Junyi 0e7cb9e5cf
refactor(plugin-workflow): split workflow features into plugins (#3115)
* refactor(plugin-workflow): split manual and dynamic calculation into plugins

* refactor(plugin-workflow): move loop to plugin

* refactor(plugin-workflow): move parallel to plugin

* fix(plugin-dynamic-calculation): fix package title

* fix(plugin-workflow): fix plugin name

* refactor(plugin-workflow): move delay to plugin

* refactor(plugin-workflow): simplify exporting names

* refactor(plugin-workflow): move aggregate to plugin

* refactor(plugin-workflow): move sql to plugin

* refactor(plugin-workflow): move reqeust to plugin

* refactor(plugin-workflow): move form trigger to plugin

* refactor(plugin-workflow): move locale to plugins

* fix(plugin-workflow): fix test cases

* fix(plugin-workflow-request): package name typo

* fix(plugin-workflow): remove clean db from testkit

* fix(plugin-workflow-sql): skip independent case

* fix(plugin-workflow-sql): skip independent case

* fix(plugin-workflow-delay): fix test cases

* test(plugin-workflow-delay): fix test cases

* test(plugin-workflow-delay): fix test cases

* test(plugin-workflow-delay): fix test cases

* test(plugin-workflow-delay): fix test cases

* fix(plugin-workflow): fix migration version matching

* test(plugin-workflow): fix test case

* refactor(plugin-workflow): correct exporting of testkit

* fix(plugin-workflow): fix testkit and require module

* refactor(plugin-workflow): add workflow-test package for testing

* test(plugin-workflow): test weird case

* fix(plugin-workflow-test): remove workflow dependency to avoid cycling

* fix(plugin-workflow): fix migration version

* fix(plugin-workflow): fix migration and packages

* fix(plugin-workflow): fix package dependencies

* fix(preset): fix builtin list in preset

* fix(plugin-workflow): add package entry file

* fix(plugin-workflow): fix migrations

* refactor(plugin-workflow): remove require

* fix(plugin-workflow): fix locale namespace

* fix(plugin-workflow): fix merged errors

* fix(plugin-workflow): fix import cycling references

* refactor(plugin-workflow): change instruction and triggers to classes in client

* fix(plugin-workflow): fix migration version
2023-12-07 05:46:58 -08:00

95 lines
3.0 KiB
TypeScript

export * from './Branch';
export * from './FlowContext';
export * from './constants';
export * from './nodes';
export { Trigger, useTrigger } from './triggers';
export * from './variable';
export * from './components';
export * from './utils';
export * from './hooks/useGetAriaLabelOfAddButton';
export { default as useStyles } from './style';
export * from './variable';
export { getCollectionFieldOptions, useWorkflowVariableOptions } from './variable';
import React from 'react';
import { Plugin } from '@nocobase/client';
import { Registry } from '@nocobase/utils/client';
import { ExecutionPage } from './ExecutionPage';
import { WorkflowPage } from './WorkflowPage';
import { WorkflowPane } from './WorkflowPane';
import { Trigger } from './triggers';
import CollectionTrigger from './triggers/collection';
import ScheduleTrigger from './triggers/schedule';
import { Instruction } from './nodes';
import CalculationInstruction from './nodes/calculation';
import ConditionInstruction from './nodes/condition';
import QueryInstruction from './nodes/query';
import CreateInstruction from './nodes/create';
import UpdateInstruction from './nodes/update';
import DestroyInstruction from './nodes/destroy';
import { useTriggerWorkflowsActionProps } from './hooks/useTriggerWorkflowActionProps';
import { getWorkflowDetailPath, getWorkflowExecutionsPath } from './constant';
import { NAMESPACE } from './locale';
export default class extends Plugin {
triggers = new Registry<Trigger>();
instructions = new Registry<Instruction>();
getTriggersOptions = () => {
return Array.from(this.triggers.getEntities()).map(([value, { title, ...options }]) => ({
value,
label: title,
color: 'gold',
options,
}));
};
async load() {
this.addRoutes();
this.addScopes();
this.addComponents();
this.app.pluginSettingsManager.add(NAMESPACE, {
icon: 'PartitionOutlined',
title: `{{t("Workflow", { ns: "${NAMESPACE}" })}}`,
Component: WorkflowPane,
aclSnippet: 'pm.workflow.workflows',
});
this.triggers.register('collection', new CollectionTrigger());
this.triggers.register('schedule', new ScheduleTrigger());
this.instructions.register('calculation', new CalculationInstruction());
this.instructions.register('condition', new ConditionInstruction());
this.instructions.register('query', new QueryInstruction());
this.instructions.register('create', new CreateInstruction());
this.instructions.register('update', new UpdateInstruction());
this.instructions.register('destroy', new DestroyInstruction());
}
addScopes() {
this.app.addScopes({
useTriggerWorkflowsActionProps,
});
}
addComponents() {
this.app.addComponents({
WorkflowPage,
ExecutionPage,
});
}
addRoutes() {
this.app.router.add('admin.workflow.workflows.id', {
path: getWorkflowDetailPath(':id'),
element: <WorkflowPage />,
});
this.app.router.add('admin.workflow.executions.id', {
path: getWorkflowExecutionsPath(':id'),
element: <ExecutionPage />,
});
}
}