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