tachybase_todo/packages/client/src/workflow/triggers/index.tsx
Junyi b59a239a82
Feat: client base entry of plugin workflow ()
* feat(plugin-workflow): add base client entry for workflow

* fix(plugin-workflow): workflow table

* feat: custom ui route ()

* feat(plugin-workflow): add execution table

* refactor(actions): expose utils of actions

* fix(repo): move ".editorconfig" to root

* feat(plugin-workflow): base workflow management able to add node

* fix(plugin-workflow): fix empty workflow

* feat(plugin-workfow): add flow canvas and style

* fix(plugin-workflow): fix type for building

* feat(plugin-workflow): fix add node in branch and add branch ui

* feat(plugin-workflow): add calculation structure to condition config

* fix(plugin-workflow): fix branch line style

* feat(plugin-workflow): remove node with sub-branch

* feat(plugin-workflow): add parallel node type

* fix(plugin-workflow): fix dependency in client

Co-authored-by: chenos <chenlinxh@gmail.com>
2022-03-27 15:51:48 +08:00

95 lines
2.5 KiB
TypeScript

import React from "react";
import { useForm } from "@formily/react";
import { cx } from "@emotion/css";
import { SchemaComponent, useActionContext, useAPIClient, useRecord, useResourceActionContext } from '../../';
import model from './model';
import { nodeCardClass } from "../style";
function useUpdateConfigAction() {
const form = useForm();
const api = useAPIClient();
const record = useRecord();
const ctx = useActionContext();
const { refresh } = useResourceActionContext();
return {
async run() {
await api.resource('workflows', record.id).update({
filterByTk: record.id,
values: {
config: {
...record.config,
...form.values
}
},
});
ctx.setVisible(false);
refresh();
},
};
};
const triggerTypes = {
model
};
export const TriggerConfig = () => {
const { data } = useResourceActionContext();
if (!data) {
return null;
}
const { type, config } = data.data;
const { title, fieldset, scope } = triggerTypes[type];
return (
<div className={cx(nodeCardClass)}>
<h4>{title}</h4>
<SchemaComponent
schema={{
type: 'void',
title: '触发器配置',
'x-component': 'Action.Link',
name: 'drawer',
properties: {
drawer: {
type: 'void',
title: '触发器配置',
'x-component': 'Action.Drawer',
'x-decorator': 'Form',
'x-decorator-props': {
initialValue: config
},
properties: {
...fieldset,
actions: {
type: 'void',
'x-component': 'Action.Drawer.Footer',
properties: {
cancel: {
title: '{{t("Cancel")}}',
'x-component': 'Action',
'x-component-props': {
useAction: '{{ cm.useCancelAction }}',
},
},
submit: {
title: '{{t("Submit")}}',
'x-component': 'Action',
'x-component-props': {
type: 'primary',
useAction: useUpdateConfigAction
}
}
}
}
}
}
}
}}
scope={scope}
/>
</div>
);
}