mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 19:04:38 +00:00
feat(review-workflows): add default workflow
This commit is contained in:
parent
2ef020de1c
commit
e661450b01
9
packages/core/admin/ee/server/bootstrap.js
vendored
9
packages/core/admin/ee/server/bootstrap.js
vendored
@ -25,11 +25,16 @@ const SSO_ACTIONS = [
|
||||
];
|
||||
|
||||
module.exports = async () => {
|
||||
const { actionProvider } = getService('permission');
|
||||
|
||||
if (features.isEnabled('sso')) {
|
||||
const { actionProvider } = getService('permission');
|
||||
await actionProvider.registerMany(SSO_ACTIONS);
|
||||
}
|
||||
|
||||
if (features.isEnabled('review-workflows')) {
|
||||
const { bootstrap: rwBootstrap } = getService('review-workflows');
|
||||
|
||||
await rwBootstrap();
|
||||
}
|
||||
|
||||
await executeCEBootstrap();
|
||||
};
|
||||
|
||||
11
packages/core/admin/ee/server/constants/default-stages.json
Normal file
11
packages/core/admin/ee/server/constants/default-stages.json
Normal file
@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
"name": "To do"
|
||||
},
|
||||
{
|
||||
"name": "In progress"
|
||||
},
|
||||
{
|
||||
"name": "Done"
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"uid": "cjld2cjxh0000qzrmn831i7rn"
|
||||
}
|
||||
@ -5,4 +5,5 @@ module.exports = {
|
||||
role: require('./role'),
|
||||
workflows: require('./review-workflows/workflows'),
|
||||
stages: require('./review-workflows/stages'),
|
||||
'review-workflows': require('./review-workflows/review-workflows'),
|
||||
};
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
const { WORKFLOW_MODEL_UID, STAGE_MODEL_UID } = require('../../constants/workflows');
|
||||
|
||||
module.exports = ({ strapi }) => ({
|
||||
async bootstrap() {
|
||||
const wfCount = await strapi.entityService.count(WORKFLOW_MODEL_UID);
|
||||
const stagesCount = await strapi.entityService.count(STAGE_MODEL_UID);
|
||||
|
||||
if (wfCount + stagesCount === 0) {
|
||||
const defaultStages = require('../../constants/default-stages.json');
|
||||
const defaultWorkflow = require('../../constants/default-workflow.json');
|
||||
|
||||
await strapi.query('admin::workflow-stage').createMany({ data: defaultStages });
|
||||
|
||||
const stages = await strapi
|
||||
.query('admin::workflow-stage')
|
||||
.findMany({ limit: 3, select: ['id'] });
|
||||
|
||||
const workflow = {
|
||||
...defaultWorkflow,
|
||||
stages: {
|
||||
connect: [
|
||||
{
|
||||
id: stages[0].id,
|
||||
position: {
|
||||
start: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: stages[1].id,
|
||||
position: {
|
||||
after: stages[0].id,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: stages[2].id,
|
||||
position: {
|
||||
after: stages[1].id,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
await strapi.query('admin::workflow').create({ data: workflow });
|
||||
}
|
||||
},
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user