mirror of
https://github.com/strapi/strapi.git
synced 2025-09-18 13:02:18 +00:00
chore: remove enableReviewWorkflows as it is not necessary anymore
This commit is contained in:
parent
d0af106201
commit
66eb52aab8
@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { set, forEach, pipe, map } = require('lodash/fp');
|
||||
const { mapAsync } = require('@strapi/utils');
|
||||
const { getService } = require('../../utils');
|
||||
const { getVisibleContentTypesUID } = require('../../utils/review-workflows');
|
||||
|
||||
@ -9,10 +8,9 @@ const defaultStages = require('../../constants/default-stages.json');
|
||||
const defaultWorkflow = require('../../constants/default-workflow.json');
|
||||
const { ENTITY_STAGE_ATTRIBUTE } = require('../../constants/workflows');
|
||||
|
||||
const { getDefaultWorkflow } = require('../../utils/review-workflows');
|
||||
const { persistTables, removePersistedTablesWithSuffix } = require('../../utils/persisted-tables');
|
||||
|
||||
async function initDefaultWorkflow({ workflowsService, stagesService, strapi }) {
|
||||
async function initDefaultWorkflow({ workflowsService, stagesService }) {
|
||||
const wfCount = await workflowsService.count();
|
||||
const stagesCount = await stagesService.count();
|
||||
|
||||
@ -25,8 +23,6 @@ async function initDefaultWorkflow({ workflowsService, stagesService, strapi })
|
||||
};
|
||||
|
||||
await workflowsService.create({ data: workflow });
|
||||
// If there is any manually activated RW on content-types, we want to migrate the related entities
|
||||
await enableReviewWorkflow({ strapi })({ contentTypes: strapi.contentTypes });
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,40 +48,6 @@ function extendReviewWorkflowContentTypes({ strapi }) {
|
||||
])(strapi.contentTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the review workflow for the given content types.
|
||||
* @param {Object} strapi - Strapi instance
|
||||
*/
|
||||
function enableReviewWorkflow({ strapi }) {
|
||||
/**
|
||||
* @param {Array<string>} contentTypes - Content type UIDs to enable the review workflow for.
|
||||
* @returns {Promise<void>} - Promise that resolves when the review workflow is enabled.
|
||||
*/
|
||||
return async ({ contentTypes }) => {
|
||||
const defaultWorkflow = await getDefaultWorkflow({ strapi });
|
||||
// This is possible if this is the first start of EE, there won't be any workflow in DB before bootstrap
|
||||
if (!defaultWorkflow) {
|
||||
return;
|
||||
}
|
||||
const firstStage = defaultWorkflow.stages[0];
|
||||
const stagesService = getService('stages', { strapi });
|
||||
|
||||
const updateEntitiesStage = async (contentTypeUID) => {
|
||||
// Update CT entities stage
|
||||
return stagesService.updateEntitiesStage(contentTypeUID, {
|
||||
fromStageId: null,
|
||||
toStageId: firstStage.id,
|
||||
});
|
||||
};
|
||||
|
||||
return pipe([
|
||||
getVisibleContentTypesUID,
|
||||
// Iterate over UIDs to extend the content-type
|
||||
(contentTypesUIDs) => mapAsync(contentTypesUIDs, updateEntitiesStage),
|
||||
])(contentTypes);
|
||||
};
|
||||
}
|
||||
|
||||
function persistStagesJoinTables({ strapi }) {
|
||||
return async ({ contentTypes }) => {
|
||||
const getStageTableToPersist = (contentTypeUID) => {
|
||||
@ -115,7 +77,6 @@ module.exports = ({ strapi }) => {
|
||||
},
|
||||
async register() {
|
||||
extendReviewWorkflowContentTypes({ strapi });
|
||||
strapi.hook('strapi::content-types.afterSync').register(enableReviewWorkflow({ strapi }));
|
||||
strapi.hook('strapi::content-types.afterSync').register(persistStagesJoinTables({ strapi }));
|
||||
},
|
||||
};
|
||||
|
@ -1,11 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { getOr, keys, pickBy, pipe } = require('lodash/fp');
|
||||
const { WORKFLOW_MODEL_UID } = require('../constants/workflows');
|
||||
|
||||
// TODO To be refactored when multiple workflows are added
|
||||
const getDefaultWorkflow = async ({ strapi }) =>
|
||||
strapi.query(WORKFLOW_MODEL_UID).findOne({ populate: ['stages'] });
|
||||
|
||||
const getVisibleContentTypesUID = pipe([
|
||||
// Pick only content-types visible in the content-manager
|
||||
@ -15,6 +10,5 @@ const getVisibleContentTypesUID = pipe([
|
||||
]);
|
||||
|
||||
module.exports = {
|
||||
getDefaultWorkflow,
|
||||
getVisibleContentTypesUID,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user