mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 23:57:32 +00:00
Remove layout prop in favor of useSelector
This commit is contained in:
parent
53166af4fe
commit
90975c5d93
@ -1,6 +1,6 @@
|
||||
import React, { Suspense, memo } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import get from 'lodash/get';
|
||||
import { useSelector } from 'react-redux';
|
||||
import {
|
||||
CheckPermissions,
|
||||
LoadingIndicatorPage,
|
||||
@ -34,21 +34,21 @@ const cmPermissions = permissions.contentManager;
|
||||
const ctbPermissions = [{ action: 'plugin::content-type-builder.read', subject: null }];
|
||||
|
||||
/* eslint-disable react/no-array-index-key */
|
||||
const EditView = ({
|
||||
allowedActions,
|
||||
isSingleType,
|
||||
goBack,
|
||||
layout,
|
||||
slug,
|
||||
id,
|
||||
origin,
|
||||
userPermissions,
|
||||
}) => {
|
||||
const EditView = ({ allowedActions, isSingleType, goBack, slug, id, origin, userPermissions }) => {
|
||||
const { trackUsage } = useTracking();
|
||||
const { formatMessage } = useIntl();
|
||||
const { createActionAllowedFields, readActionAllowedFields, updateActionAllowedFields } =
|
||||
getFieldsActionMatchingPermissions(userPermissions, slug);
|
||||
|
||||
const { layout, formattedContentTypeLayout } = useSelector((state) => {
|
||||
const layout = state['content-manager_editViewLayoutManager'].currentLayout;
|
||||
|
||||
return {
|
||||
layout,
|
||||
formattedContentTypeLayout: createAttributesLayout(layout?.contentType ?? {}),
|
||||
};
|
||||
});
|
||||
|
||||
const configurationPermissions = isSingleType
|
||||
? cmPermissions.singleTypesConfigurations
|
||||
: cmPermissions.collectionTypesConfigurations;
|
||||
@ -57,7 +57,6 @@ const EditView = ({
|
||||
const configurationsURL = `/content-manager/${
|
||||
isSingleType ? 'singleType' : 'collectionType'
|
||||
}/${slug}/configurations/edit`;
|
||||
const currentContentTypeLayoutData = get(layout, ['contentType'], {});
|
||||
|
||||
const DataManagementWrapper = isSingleType ? SingleTypeFormWrapper : CollectionTypeFormWrapper;
|
||||
|
||||
@ -68,8 +67,6 @@ const EditView = ({
|
||||
});
|
||||
};
|
||||
|
||||
const formattedContentTypeLayout = createAttributesLayout(currentContentTypeLayoutData);
|
||||
|
||||
return (
|
||||
<DataManagementWrapper allLayoutData={layout} slug={slug} id={id} origin={origin}>
|
||||
{({
|
||||
@ -256,16 +253,6 @@ EditView.propTypes = {
|
||||
canCreate: PropTypes.bool.isRequired,
|
||||
canDelete: PropTypes.bool.isRequired,
|
||||
}).isRequired,
|
||||
layout: PropTypes.shape({
|
||||
components: PropTypes.object.isRequired,
|
||||
contentType: PropTypes.shape({
|
||||
uid: PropTypes.string.isRequired,
|
||||
settings: PropTypes.object.isRequired,
|
||||
metadatas: PropTypes.object.isRequired,
|
||||
options: PropTypes.object.isRequired,
|
||||
attributes: PropTypes.object.isRequired,
|
||||
}).isRequired,
|
||||
}).isRequired,
|
||||
id: PropTypes.string,
|
||||
isSingleType: PropTypes.bool,
|
||||
goBack: PropTypes.func.isRequired,
|
||||
|
||||
@ -30,7 +30,7 @@ const EditViewLayoutManager = ({ layout, ...rest }) => {
|
||||
return <LoadingIndicatorPage />;
|
||||
}
|
||||
|
||||
return <Permissions {...rest} layout={currentLayout} userPermissions={permissions} />;
|
||||
return <Permissions {...rest} userPermissions={permissions} />;
|
||||
};
|
||||
|
||||
EditViewLayoutManager.propTypes = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user