mirror of
https://github.com/strapi/strapi.git
synced 2025-09-21 14:31:16 +00:00
Fix mutate content types hook
This commit is contained in:
parent
f721091221
commit
227f5cdfcc
@ -23,13 +23,13 @@ const makeSelectModelAndComponentSchemas = () =>
|
||||
schemas: [...components, ...models],
|
||||
}));
|
||||
|
||||
const makeSelectFieldSizes = () => createSelector(selectAppDomain(), (state) => state.fieldSizes);
|
||||
const selectFieldSizes = createSelector(selectAppDomain(), (state) => state.fieldSizes);
|
||||
|
||||
export default makeSelectApp;
|
||||
export {
|
||||
makeSelectModelAndComponentSchemas,
|
||||
makeSelectModelLinks,
|
||||
makeSelectModels,
|
||||
makeSelectFieldSizes,
|
||||
selectFieldSizes,
|
||||
selectAppDomain,
|
||||
};
|
||||
|
@ -44,24 +44,27 @@ const useContentManagerInitData = () => {
|
||||
})
|
||||
);
|
||||
|
||||
const { authorizedContentTypeLinks, authorizedSingleTypeLinks } = await getContentTypeLinks({
|
||||
const unmutatedContentTypeLinks = await getContentTypeLinks({
|
||||
models,
|
||||
userPermissions: allPermissions,
|
||||
toggleNotification,
|
||||
});
|
||||
|
||||
const { ctLinks } = runHookWaterfall(MUTATE_COLLECTION_TYPES_LINKS, {
|
||||
ctLinks: authorizedContentTypeLinks,
|
||||
const { ctLinks: authorizedCollectionTypeLinks } = runHookWaterfall(
|
||||
MUTATE_COLLECTION_TYPES_LINKS,
|
||||
{
|
||||
ctLinks: unmutatedContentTypeLinks.authorizedCollectionTypeLinks,
|
||||
models,
|
||||
});
|
||||
const { stLinks } = runHookWaterfall(MUTATE_SINGLE_TYPES_LINKS, {
|
||||
stLinks: authorizedSingleTypeLinks,
|
||||
}
|
||||
);
|
||||
const { stLinks: authorizedSingleTypeLinks } = runHookWaterfall(MUTATE_SINGLE_TYPES_LINKS, {
|
||||
stLinks: unmutatedContentTypeLinks.authorizedSingleTypeLinks,
|
||||
models,
|
||||
});
|
||||
|
||||
const actionToDispatch = setInitData({
|
||||
authorizedCollectionTypeLinks: ctLinks,
|
||||
authorizedSingleTypeLinks: stLinks,
|
||||
authorizedCollectionTypeLinks,
|
||||
authorizedSingleTypeLinks,
|
||||
contentTypeSchemas: models,
|
||||
components,
|
||||
fieldSizes,
|
||||
|
@ -6,7 +6,7 @@ import { useSelector, shallowEqual } from 'react-redux';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { useLayoutDnd } from '../../../hooks';
|
||||
import { createPossibleMainFieldsForModelsAndComponents, getInputProps } from '../utils';
|
||||
import { makeSelectModelAndComponentSchemas, makeSelectFieldSizes } from '../../App/selectors';
|
||||
import { makeSelectModelAndComponentSchemas, selectFieldSizes } from '../../App/selectors';
|
||||
import getTrad from '../../../utils/getTrad';
|
||||
import GenericInput from './GenericInput';
|
||||
|
||||
@ -25,9 +25,8 @@ const ModalForm = ({ onMetaChange, onSizeChange }) => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { modifiedData, selectedField, attributes, fieldForm } = useLayoutDnd();
|
||||
const schemasSelector = useMemo(makeSelectModelAndComponentSchemas, []);
|
||||
const fieldSizesSelector = useMemo(makeSelectFieldSizes, []);
|
||||
const { schemas } = useSelector((state) => schemasSelector(state), shallowEqual);
|
||||
const fieldSizes = useSelector((state) => fieldSizesSelector(state));
|
||||
const fieldSizes = useSelector(selectFieldSizes);
|
||||
|
||||
const formToDisplay = useMemo(() => {
|
||||
if (!selectedField) {
|
||||
|
@ -35,7 +35,7 @@ import ModalForm from './components/FormModal';
|
||||
import LayoutDndProvider from '../../components/LayoutDndProvider';
|
||||
import { unformatLayout } from './utils/layout';
|
||||
import putCMSettingsEV from './utils/api';
|
||||
import { makeSelectFieldSizes } from '../App/selectors';
|
||||
import { selectFieldSizes } from '../App/selectors';
|
||||
|
||||
const EditSettingsView = ({ mainLayout, components, isContentTypeView, slug, updateLayout }) => {
|
||||
const [reducerState, dispatch] = useReducer(reducer, initialState, () =>
|
||||
@ -51,8 +51,7 @@ const EditSettingsView = ({ mainLayout, components, isContentTypeView, slug, upd
|
||||
const { formatMessage } = useIntl();
|
||||
const modelName = get(mainLayout, ['info', 'displayName'], '');
|
||||
const attributes = get(modifiedData, ['attributes'], {});
|
||||
const fieldSizesSelector = useMemo(makeSelectFieldSizes, []);
|
||||
const fieldSizes = useSelector((state) => fieldSizesSelector(state));
|
||||
const fieldSizes = useSelector(selectFieldSizes);
|
||||
|
||||
const entryTitleOptions = Object.keys(attributes).filter((attr) => {
|
||||
const type = get(attributes, [attr, 'type'], '');
|
||||
|
Loading…
x
Reference in New Issue
Block a user