diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7a738d4211..1bc810b753 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -217,7 +217,7 @@ jobs: # find test -type f -name 'e2e.spec.ts' | sort | xargs dirname | xargs -I {} basename {} suite: - _community - # - access-control + - access-control # - admin - auth # - field-error-states diff --git a/packages/next/src/views/Edit/Default/index.tsx b/packages/next/src/views/Edit/Default/index.tsx index 77548e9ed9..78a1604c53 100644 --- a/packages/next/src/views/Edit/Default/index.tsx +++ b/packages/next/src/views/Edit/Default/index.tsx @@ -54,6 +54,7 @@ export const DefaultEditView: React.FC = () => { initialData: data, initialState, isEditing, + onSave: onSaveFromContext, } = useDocumentInfo() const { refreshCookieAsync, user } = useAuth() @@ -118,20 +119,29 @@ export const DefaultEditView: React.FC = () => { void getVersions() void getDocPermissions() - if (!isEditing) { - // Redirect to the same locale if it's been set - const redirectRoute = `${adminRoute}/collections/${collectionSlug}/${json?.doc?.id}${locale ? `?locale=${locale}` : ''}` - router.push(redirectRoute) - } else { - dispatchFormQueryParams({ - type: 'SET', - params: { - uploadEdits: null, - }, + if (typeof onSaveFromContext === 'function') { + void onSaveFromContext({ + ...json, + operation: id ? 'update' : 'create', }) + } else { + if (!isEditing) { + // Redirect to the same locale if it's been set + const redirectRoute = `${adminRoute}/collections/${collectionSlug}/${json?.doc?.id}${locale ? `?locale=${locale}` : ''}` + router.push(redirectRoute) + } else { + dispatchFormQueryParams({ + type: 'SET', + params: { + uploadEdits: null, + }, + }) + } } }, [ + onSaveFromContext, + userSlug, reportUpdate, id, entitySlug,