refactor(plugin-workflow): change reload api to sync, and fix duplicated listening (#2403)
This commit is contained in:
parent
e5f5787175
commit
34ec7388df
@ -4,7 +4,7 @@ import {
|
||||
SchemaComponent,
|
||||
SettingsCenterProvider,
|
||||
} from '@nocobase/client';
|
||||
import { Card } from 'antd';
|
||||
import { Card, Tooltip } from 'antd';
|
||||
import React, { useContext } from 'react';
|
||||
import { ExecutionLink } from './ExecutionLink';
|
||||
import { ExecutionResourceProvider } from './ExecutionResourceProvider';
|
||||
@ -30,6 +30,7 @@ function WorkflowPane() {
|
||||
<SchemaComponent
|
||||
schema={workflowSchema}
|
||||
components={{
|
||||
Tooltip,
|
||||
WorkflowLink,
|
||||
ExecutionResourceProvider,
|
||||
ExecutionLink,
|
||||
|
@ -169,9 +169,13 @@ export const workflowSchema: ISchema = {
|
||||
},
|
||||
},
|
||||
},
|
||||
reload: {
|
||||
sync: {
|
||||
type: 'void',
|
||||
title: `{{t("Reload", { ns: "${NAMESPACE}" })}}`,
|
||||
title: `{{t("Sync", { ns: "${NAMESPACE}" })}}`,
|
||||
'x-decorator': 'Tooltip',
|
||||
'x-decorator-props': {
|
||||
title: `{{ t("Sync enabled status of all workflows from database", { ns: "${NAMESPACE}" }) }}`,
|
||||
},
|
||||
'x-component': 'Action',
|
||||
'x-component-props': {
|
||||
useAction() {
|
||||
@ -179,7 +183,7 @@ export const workflowSchema: ISchema = {
|
||||
const { resource } = useResourceContext();
|
||||
return {
|
||||
async run() {
|
||||
await resource.reload();
|
||||
await resource.sync();
|
||||
message.success(t('Operation succeeded'));
|
||||
},
|
||||
};
|
||||
|
@ -5,7 +5,8 @@ export default {
|
||||
'Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?':
|
||||
'清空执行记录不会重置执行次数,且执行中的也不会被删除,确定要删除所有执行记录吗?',
|
||||
Executed: '已执行',
|
||||
Reload: '重载',
|
||||
Sync: '同步',
|
||||
'Sync enabled status of all workflows from database': '从数据库同步所有工作流的启用状态',
|
||||
'Trigger type': '触发方式',
|
||||
Status: '状态',
|
||||
On: '启用',
|
||||
|
@ -177,7 +177,7 @@ export async function revision(context: Context, next) {
|
||||
await next();
|
||||
}
|
||||
|
||||
export async function reload(context: Context, next) {
|
||||
export async function sync(context: Context, next) {
|
||||
const plugin = context.app.getPlugin('workflow');
|
||||
const repository = utils.getRepositoryFromParams(context);
|
||||
const { filterByTk, filter = {} } = context.action.params;
|
||||
@ -188,10 +188,11 @@ export async function reload(context: Context, next) {
|
||||
});
|
||||
|
||||
workflows.forEach((workflow) => {
|
||||
plugin.toggle(workflow, false);
|
||||
plugin.toggle(workflow);
|
||||
});
|
||||
|
||||
context.status = 205;
|
||||
context.status = 204;
|
||||
|
||||
await next();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user