tachybase_todo/packages/plugins/@tachybase/plugin-workflow-notice/src/server/plugin.ts
bai.zixv a298f4ddf0 feat/workflow-notice (#1037)
![image](/attachments/9c701f22-f743-40a4-895c-d40fb170a3a3)
![image](/attachments/04e3e2c6-0545-4230-b7e5-fd0d00add727)

1. 可能有一些遗留问题, 比如工作流状态同步显示的问题, 以及后续需要配置.
2. 目前没有时间仔细核对, 需要先做其他事情

Reviewed-on: daoyoucloud/tachybase#1037
Co-authored-by: bai.zixv <bai.zixv@foxmail.com>
Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
2024-05-28 09:52:08 +08:00

50 lines
1.4 KiB
TypeScript

import WorkflowPlugin from '@tachybase/plugin-workflow';
import { Plugin } from '@tachybase/server';
import path from 'path';
import { NOTICE_INSTRUCTION_NAMESPACE } from '../common/constants';
import NoticeInstruction from './NoticeInstruction';
import { init } from './actions';
import { COLLECTION_WORKFLOWS_NAME } from './collections/workflowNotice';
import { COLLECTION_NOTICE_NAME } from '../common/constants';
export class PluginWorkflowNoticeServer extends Plugin {
workflow;
async afterAdd() {}
async beforeLoad() {
this.app.on('afterLoadPlugin', (plugin) => {
if (!(plugin instanceof WorkflowPlugin)) {
return;
}
this.workflow = plugin;
plugin.instructions.register(NOTICE_INSTRUCTION_NAMESPACE, new NoticeInstruction(plugin));
});
}
async load() {
const { db } = this;
db.addMigrations({
namespace: NOTICE_INSTRUCTION_NAMESPACE,
directory: path.resolve(__dirname, 'migrations'),
context: {
plugin: this,
},
});
await db.import({
directory: path.resolve(__dirname, 'collections'),
});
init(this);
this.app.acl.allow(COLLECTION_WORKFLOWS_NAME, ['listWorkflowNoticeFlows'], 'loggedIn');
this.app.acl.allow(COLLECTION_NOTICE_NAME, ['get', 'list', 'listCentralized', 'submit'], 'loggedIn');
}
async install() {}
async afterEnable() {}
async afterDisable() {}
async remove() {}
}
export default PluginWorkflowNoticeServer;