tachybase_todo/packages/plugins/@nocobase/plugin-workflow-manual/src/server/Plugin.ts
Junyi f7b62ed42b
fix(plugin-workflow): fix sql transaction and locale (#3444)
* fix(plugin-workflow): fix sql transaction and locale

* fix(plugin-workflow): fix locale
2024-01-27 09:37:40 +08:00

44 lines
1.1 KiB
TypeScript

import { Plugin } from '@nocobase/server';
import actions from '@nocobase/actions';
import { HandlerType } from '@nocobase/resourcer';
import WorkflowPlugin, { JOB_STATUS } from '@nocobase/plugin-workflow';
import path from 'path';
import { submit } from './actions';
import ManualInstruction from './ManualInstruction';
export default class extends Plugin {
async load() {
await this.importCollections(path.resolve(__dirname, 'collections'));
this.app.resource({
name: 'users_jobs',
actions: {
list: {
filter: {
$or: [
{
'workflow.enabled': true,
},
{
'workflow.enabled': false,
status: {
$ne: JOB_STATUS.PENDING,
},
},
],
},
handler: actions.list as HandlerType,
},
submit,
},
});
this.app.acl.allow('users_jobs', ['list', 'get', 'submit'], 'loggedIn');
const workflowPlugin = this.app.pm.get(WorkflowPlugin) as WorkflowPlugin;
workflowPlugin.registerInstruction('manual', ManualInstruction);
}
}