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