Skip to content

Commit 0beb765

Browse files
committed
fix validation toast notification for workflow
1 parent 2d89cc7 commit 0beb765

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/actions/editorialWorkflow.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { selectFields } from 'Reducers/collections';
88
import { status, EDITORIAL_WORKFLOW } from 'Constants/publishModes';
99
import { EditorialWorkflowError } from "ValueObjects/errors";
1010
import { loadEntry } from './entries';
11+
import ValidationErrorTypes from 'Constants/validationErrorTypes';
1112

1213
const { notifSend } = notifActions;
1314

@@ -261,9 +262,22 @@ export function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
261262
return async (dispatch, getState) => {
262263
const state = getState();
263264
const entryDraft = state.entryDraft;
265+
const fieldsErrors = entryDraft.get('fieldsErrors');
264266

265267
// Early return if draft contains validation errors
266-
if (!entryDraft.get('fieldsErrors').isEmpty()) return Promise.reject();
268+
if (!fieldsErrors.isEmpty()) {
269+
const hasPresenceErrors = fieldsErrors
270+
.some(errors => errors.some(error => error.type && error.type === ValidationErrorTypes.PRESENCE));
271+
272+
if (hasPresenceErrors) {
273+
dispatch(notifSend({
274+
message: 'Oops, you\'ve missed a required field. Please complete before saving.',
275+
kind: 'danger',
276+
dismissAfter: 8000,
277+
}));
278+
}
279+
return Promise.reject()
280+
}
267281

268282
const backend = currentBackend(state.config);
269283
const transactionID = uuid();
@@ -289,7 +303,6 @@ export function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
289303
assetProxies.toJS(),
290304
state.integrations,
291305
];
292-
293306
try {
294307
const newSlug = await persistAction.call(...persistCallArgs);
295308
dispatch(notifSend({

0 commit comments

Comments
 (0)