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