mirror of
https://github.com/strapi/strapi.git
synced 2025-08-08 00:37:38 +00:00
Merge pull request #17276 from strapi/feature/review-workflow-multiple-initial-colors
Fix: Make stage theme color retrieval more defensive
This commit is contained in:
commit
5f5c6ec185
@ -174,7 +174,7 @@ export function Stage({
|
|||||||
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
||||||
}, [dragPreviewRef, index]);
|
}, [dragPreviewRef, index]);
|
||||||
|
|
||||||
const { themeColorName } = colorField.value ? getStageColorByHex(colorField.value) : {};
|
const { themeColorName } = getStageColorByHex(colorField.value) ?? {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box ref={composedRef}>
|
<Box ref={composedRef}>
|
||||||
|
@ -19,18 +19,22 @@ const STAGES_FIXTURE = {
|
|||||||
index: 0,
|
index: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ComponentFixture = (props) => {
|
const ComponentFixture = ({
|
||||||
|
// eslint-disable-next-line react/prop-types
|
||||||
|
stages = [
|
||||||
|
{
|
||||||
|
color: STAGE_COLOR_DEFAULT,
|
||||||
|
name: 'something',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
...props
|
||||||
|
}) => {
|
||||||
const store = configureStore([], [reducer]);
|
const store = configureStore([], [reducer]);
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
initialValues: {
|
initialValues: {
|
||||||
stages: [
|
stages,
|
||||||
{
|
|
||||||
color: STAGE_COLOR_DEFAULT,
|
|
||||||
name: 'something',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
validateOnChange: false,
|
validateOnChange: false,
|
||||||
});
|
});
|
||||||
@ -96,4 +100,19 @@ describe('Admin | Settings | Review Workflow | Stage', () => {
|
|||||||
})
|
})
|
||||||
).not.toBeInTheDocument();
|
).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not crash on a custom color code', async () => {
|
||||||
|
const { getByRole } = setup({
|
||||||
|
isOpen: true,
|
||||||
|
canDelete: false,
|
||||||
|
stages: [
|
||||||
|
{
|
||||||
|
color: '#FF4945',
|
||||||
|
name: 'something',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(getByRole('textbox').value).toBe('something');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "In progress",
|
"name": "In progress",
|
||||||
"color": "#FF4945"
|
"color": "#EE5E52"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Reviewed",
|
"name": "Reviewed",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user