mirror of
https://github.com/strapi/strapi.git
synced 2025-12-02 18:13:16 +00:00
Settings: Allow stages to be added even if the workflow doesn't have any yet
This commit is contained in:
parent
3db0779f8f
commit
932664a61f
@ -90,7 +90,7 @@ export function ReviewWorkflowsPage() {
|
|||||||
</Loader>
|
</Loader>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{formik.values?.stages && <Stages stages={formik.values.stages} />}
|
<Stages stages={formik.values?.stages} />
|
||||||
</ContentLayout>
|
</ContentLayout>
|
||||||
</Form>
|
</Form>
|
||||||
</FormikProvider>
|
</FormikProvider>
|
||||||
|
|||||||
@ -70,6 +70,7 @@ Stages.propTypes = {
|
|||||||
stages: PropTypes.arrayOf(
|
stages: PropTypes.arrayOf(
|
||||||
PropTypes.shape({
|
PropTypes.shape({
|
||||||
id: PropTypes.number,
|
id: PropTypes.number,
|
||||||
|
__temp_key__: PropTypes.number,
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
|||||||
@ -56,13 +56,16 @@ export function reducer(state = initialState, action) {
|
|||||||
case ACTION_ADD_STAGE: {
|
case ACTION_ADD_STAGE: {
|
||||||
const { currentWorkflow } = state.clientState;
|
const { currentWorkflow } = state.clientState;
|
||||||
|
|
||||||
draft.clientState.currentWorkflow.data.stages = [
|
if (!currentWorkflow.data) {
|
||||||
...currentWorkflow.data.stages,
|
draft.clientState.currentWorkflow.data = {
|
||||||
{
|
stages: [],
|
||||||
...payload,
|
};
|
||||||
__temp_key__: currentWorkflow.data.stages.length + 1,
|
}
|
||||||
},
|
|
||||||
];
|
draft.clientState.currentWorkflow.data.stages.push({
|
||||||
|
...payload,
|
||||||
|
__temp_key__: (currentWorkflow.data?.stages?.length ?? 0) + 1,
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,6 +133,38 @@ describe('Admin | Settings | Review Workflows | reducer', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('ACTION_ADD_STAGE when there are not stages yet', () => {
|
||||||
|
const action = {
|
||||||
|
type: ACTION_ADD_STAGE,
|
||||||
|
payload: { name: 'something' },
|
||||||
|
};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
status: expect.any(String),
|
||||||
|
serverState: expect.any(Object),
|
||||||
|
clientState: {
|
||||||
|
currentWorkflow: { data: null, isDirty: false },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(reducer(state, action)).toStrictEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
clientState: expect.objectContaining({
|
||||||
|
currentWorkflow: expect.objectContaining({
|
||||||
|
data: expect.objectContaining({
|
||||||
|
stages: expect.arrayContaining([
|
||||||
|
{
|
||||||
|
__temp_key__: 1,
|
||||||
|
name: 'something',
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('ACTION_UPDATE_STAGE', () => {
|
test('ACTION_UPDATE_STAGE', () => {
|
||||||
const action = {
|
const action = {
|
||||||
type: ACTION_UPDATE_STAGE,
|
type: ACTION_UPDATE_STAGE,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user