mirror of
https://github.com/strapi/strapi.git
synced 2025-11-05 12:24:35 +00:00
chore: move get CT with RW activated to utils
This commit is contained in:
parent
ddc3c98c25
commit
077631d18b
@ -1,8 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { set, get, forEach, keys, pickBy, pipe } = require('lodash/fp');
|
const { set, forEach, pipe } = require('lodash/fp');
|
||||||
const { mapAsync } = require('@strapi/utils');
|
const { mapAsync } = require('@strapi/utils');
|
||||||
const { getService } = require('../../utils');
|
const { getService } = require('../../utils');
|
||||||
|
const { getContentTypeUIDsWithActivatedReviewWorkflows } = require('../../utils/review-workflows');
|
||||||
|
|
||||||
const defaultStages = require('../../constants/default-stages.json');
|
const defaultStages = require('../../constants/default-stages.json');
|
||||||
const defaultWorkflow = require('../../constants/default-workflow.json');
|
const defaultWorkflow = require('../../constants/default-workflow.json');
|
||||||
@ -13,13 +14,6 @@ const {
|
|||||||
} = require('../../migrations/review-workflows');
|
} = require('../../migrations/review-workflows');
|
||||||
const { getDefaultWorkflow } = require('../../utils/review-workflows');
|
const { getDefaultWorkflow } = require('../../utils/review-workflows');
|
||||||
|
|
||||||
const getContentTypeUIDsWithActivatedReviewWorkflows = pipe([
|
|
||||||
// Pick only content-types with reviewWorkflows options set to true
|
|
||||||
pickBy(get('options.reviewWorkflows')),
|
|
||||||
// Get UIDs
|
|
||||||
keys,
|
|
||||||
]);
|
|
||||||
|
|
||||||
async function initDefaultWorkflow({ workflowsService, stagesService, strapi }) {
|
async function initDefaultWorkflow({ workflowsService, stagesService, strapi }) {
|
||||||
const wfCount = await workflowsService.count();
|
const wfCount = await workflowsService.count();
|
||||||
const stagesCount = await stagesService.count();
|
const stagesCount = await stagesService.count();
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { get, keys, pickBy, pipe } = require('lodash/fp');
|
||||||
const { WORKFLOW_MODEL_UID } = require('../constants/workflows');
|
const { WORKFLOW_MODEL_UID } = require('../constants/workflows');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,7 +20,15 @@ function hasReviewWorkflow({ strapi }, contentType) {
|
|||||||
const getDefaultWorkflow = async ({ strapi }) =>
|
const getDefaultWorkflow = async ({ strapi }) =>
|
||||||
strapi.query(WORKFLOW_MODEL_UID).findOne({ populate: ['stages'] });
|
strapi.query(WORKFLOW_MODEL_UID).findOne({ populate: ['stages'] });
|
||||||
|
|
||||||
|
const getContentTypeUIDsWithActivatedReviewWorkflows = pipe([
|
||||||
|
// Pick only content-types with reviewWorkflows options set to true
|
||||||
|
pickBy(get('options.reviewWorkflows')),
|
||||||
|
// Get UIDs
|
||||||
|
keys,
|
||||||
|
]);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
hasReviewWorkflow,
|
hasReviewWorkflow,
|
||||||
getDefaultWorkflow,
|
getDefaultWorkflow,
|
||||||
|
getContentTypeUIDsWithActivatedReviewWorkflows,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user