Merge pull request #16482 from strapi/feautre/rw-colors

This commit is contained in:
Marc 2023-04-26 13:43:43 +02:00 committed by GitHub
commit 6fc31d84bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -270,10 +270,25 @@ describeOnCondition(edition === 'EE')('Review workflows', () => {
];
});
test("It should assign a default color to stages if they don't have one", async () => {
await requests.admin.put(`/admin/review-workflows/workflows/${testWorkflow.id}/stages`, {
body: {
data: [defaultStage, { id: secondStage.id, name: 'new_name', color: '#000000' }],
},
});
const workflowRes = await requests.admin.get(
`/admin/review-workflows/workflows/${testWorkflow.id}?populate=*`
);
expect(workflowRes.status).toBe(200);
expect(workflowRes.body.data.stages[0].color).toBe('#4945FF');
expect(workflowRes.body.data.stages[1].color).toBe('#000000');
});
test("It shouldn't be available for public", async () => {
const stagesRes = await requests.public.put(
`/admin/review-workflows/workflows/${testWorkflow.id}/stages`,
stagesUpdateData
{ body: { data: stagesUpdateData } }
);
const workflowRes = await requests.public.get(
`/admin/review-workflows/workflows/${testWorkflow.id}`

View File

@ -24,6 +24,11 @@ module.exports = {
type: 'string',
configurable: false,
},
color: {
type: 'string',
configurable: false,
default: '#4945FF',
},
workflow: {
type: 'relation',
target: 'admin::workflow',

View File

@ -5,6 +5,7 @@ const { yup, validateYupSchema } = require('@strapi/utils');
const stageObject = yup.object().shape({
id: yup.number().integer().min(1),
name: yup.string().max(255).required(),
color: yup.string().matches(/^#(?:[0-9a-fA-F]{3}){1,2}$/i), // hex color
});
const validateUpdateStagesSchema = yup