mirror of
https://github.com/strapi/strapi.git
synced 2025-09-22 06:50:51 +00:00
chore: move stage transition UID to constants
This commit is contained in:
parent
b9a706cb08
commit
ec1176b582
@ -4,6 +4,7 @@
|
||||
module.exports = {
|
||||
WORKFLOW_MODEL_UID: 'admin::workflow',
|
||||
STAGE_MODEL_UID: 'admin::workflow-stage',
|
||||
STAGE_TRANSITION_UID: 'admin::review-workflows.stage.transition',
|
||||
STAGE_DEFAULT_COLOR: '#4945FF',
|
||||
ENTITY_STAGE_ATTRIBUTE: 'strapi_stage',
|
||||
MAX_WORKFLOWS: 200,
|
||||
@ -20,12 +21,12 @@ module.exports = {
|
||||
stages: {
|
||||
populate: {
|
||||
permissions: {
|
||||
fields: ["action", "actionParameters"],
|
||||
fields: ['action', 'actionParameters'],
|
||||
populate: {
|
||||
role: { fields: ["id", "name"] },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
role: { fields: ['id', 'name'] },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -3,7 +3,11 @@
|
||||
const { mapAsync } = require('@strapi/utils');
|
||||
const { getService } = require('../../../utils');
|
||||
const { validateUpdateStageOnEntity } = require('../../../validation/review-workflows');
|
||||
const { STAGE_MODEL_UID, ENTITY_STAGE_ATTRIBUTE } = require('../../../constants/workflows');
|
||||
const {
|
||||
STAGE_MODEL_UID,
|
||||
ENTITY_STAGE_ATTRIBUTE,
|
||||
STAGE_TRANSITION_UID,
|
||||
} = require('../../../constants/workflows');
|
||||
|
||||
/**
|
||||
*
|
||||
@ -97,7 +101,7 @@ module.exports = {
|
||||
|
||||
// Validate if entity stage can be updated
|
||||
const canTransition = stagePermissions.can(
|
||||
'admin::review-workflows.stage.transition',
|
||||
STAGE_TRANSITION_UID,
|
||||
entity[ENTITY_STAGE_ATTRIBUTE]?.id
|
||||
);
|
||||
|
||||
|
@ -6,9 +6,9 @@ const {
|
||||
errors: { ApplicationError },
|
||||
} = require('@strapi/utils');
|
||||
const { getService } = require('../../utils');
|
||||
const { STAGE_TRANSITION_UID } = require('../../constants/workflows');
|
||||
|
||||
// TODO: This should use constants
|
||||
const validActions = ['admin::review-workflows.stage.transition'];
|
||||
const validActions = [STAGE_TRANSITION_UID];
|
||||
|
||||
module.exports = ({ strapi }) => {
|
||||
const roleService = getService('role');
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
const { yup, validateYupSchema } = require('@strapi/utils');
|
||||
const { hasStageAttribute } = require('../utils/review-workflows');
|
||||
const { STAGE_TRANSITION_UID } = require('../constants/workflows');
|
||||
|
||||
const stageObject = yup.object().shape({
|
||||
id: yup.number().integer().min(1),
|
||||
@ -12,7 +13,7 @@ const stageObject = yup.object().shape({
|
||||
permissions: yup.array().of(
|
||||
yup.object().shape({
|
||||
role: yup.number().integer().min(1).required(),
|
||||
action: yup.string().oneOf(['admin::review-workflows.stage.transition']).required(),
|
||||
action: yup.string().oneOf([STAGE_TRANSITION_UID]).required(),
|
||||
actionParameters: yup.object().shape({
|
||||
from: yup.number().integer().min(1).required(),
|
||||
to: yup.number().integer().min(1),
|
||||
|
Loading…
x
Reference in New Issue
Block a user