diff --git a/node_modules/@strapi/admin/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js b/node_modules/@strapi/admin/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js
index 11e89a5..ebc74c8 100644
--- a/node_modules/@strapi/admin/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js
+++ b/node_modules/@strapi/admin/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js
@@ -247,9 +247,15 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
replace(redirectionLink);
}, [redirectionLink, replace]);
+ const currentContentTypeLayout = get(allLayoutData, ['contentType'], {});
+
+ const hasVersions = useMemo(() => {
+ return get(currentContentTypeLayout, ['pluginOptions', 'versions', 'versioned'], false);
+ }, [currentContentTypeLayout]);
+
const onPost = useCallback(
async (body, trackerProperty) => {
- const endPoint = `${getRequestUrl(`collection-types/${slug}`)}${rawQuery}`;
+ const endPoint = hasVersions ? `/content-versioning/${slug}/save` : `${getRequestUrl(`collection-types/${slug}`)}${rawQuery}`;
try {
// Show a loading button in the EditView/Header.js && lock the app => no navigation
@@ -269,7 +275,13 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
// Enable navigation and remove loaders
dispatch(setStatus('resolved'));
- replace(`/content-manager/collectionType/${slug}/${data.id}${rawQuery}`);
+ if (hasVersions) {
+ replace({
+ pathname: `/content-manager/collectionType/${slug}/${data.id}${rawQuery}`,
+ });
+ } else {
+ replace(`/content-manager/collectionType/${slug}/${data.id}${rawQuery}`);
+ }
return Promise.resolve(data);
} catch (err) {
@@ -322,14 +334,14 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
const onPut = useCallback(
async (body, trackerProperty) => {
- const endPoint = getRequestUrl(`collection-types/${slug}/${id}`);
+ const endPoint = hasVersions ? `/content-versioning/${slug}/save` : getRequestUrl(`collection-types/${slug}/${id}`);
try {
trackUsageRef.current('willEditEntry', trackerProperty);
dispatch(setStatus('submit-pending'));
- const { data } = await axiosInstance.put(endPoint, body);
+ const { data } = hasVersions ? await axiosInstance.post(endPoint, body) : await axiosInstance.put(endPoint, body);
trackUsageRef.current('didEditEntry', { trackerProperty });
toggleNotification({
@@ -341,6 +353,12 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
dispatch(setStatus('resolved'));
+ if (hasVersions) {
+ replace({
+ pathname: `/content-manager/collectionType/${slug}/${data.id}`,
+ });
+ }
+
return Promise.resolve(data);
} catch (err) {
trackUsageRef.current('didNotEditEntry', { error: err, trackerProperty });
diff --git a/node_modules/@strapi/admin/admin/src/content-manager/components/EditViewDataManagerProvider/index.js b/node_modules/@strapi/admin/admin/src/content-manager/components/EditViewDataManagerProvider/index.js
index c8dc356..91ac617 100644
--- a/node_modules/@strapi/admin/admin/src/content-manager/components/EditViewDataManagerProvider/index.js
+++ b/node_modules/@strapi/admin/admin/src/content-manager/components/EditViewDataManagerProvider/index.js
@@ -292,6 +292,12 @@ const EditViewDataManagerProvider = ({
return shouldNotRunValidations ? { status: 'draft' } : {};
}, [hasDraftAndPublish, shouldNotRunValidations]);
+
+ const hasVersions = useMemo(() => {
+ return get(currentContentTypeLayout, ['pluginOptions', 'versions', 'versioned'], false);
+ }, [currentContentTypeLayout]);
+
+
const handleSubmit = useCallback(
async e => {
e.preventDefault();
@@ -515,7 +521,7 @@ const EditViewDataManagerProvider = ({
) : (
<>