fix: reload ctb after save

This commit is contained in:
Bassel Kanso 2024-03-18 11:04:44 +02:00
parent 676c9d44c8
commit 2896c5580a
2 changed files with 11 additions and 3 deletions

View File

@ -41,7 +41,7 @@ export interface DataManagerContextValue {
removeComponentFromDynamicZone: (dzName: string, componentToRemoveIndex: number) => void;
setModifiedData: () => void;
sortedContentTypesList: any[]; // Define the actual type
submitData: (additionalContentTypeData?: Record<string, any>) => void;
submitData: (additionalContentTypeData?: Record<string, any>) => Promise<void>;
updateSchema: (data: Record<string, any>, schemaType: SchemaType, componentUID: UID.Any) => void;
components: Record<UID.Component, Component>;
componentsGroupedByCategory: Record<string, Component[]>;

View File

@ -6,7 +6,7 @@ import has from 'lodash/has';
import isEqual from 'lodash/isEqual';
import upperFirst from 'lodash/upperFirst';
import { useIntl } from 'react-intl';
import { Prompt, useRouteMatch } from 'react-router-dom';
import { Prompt, useRouteMatch, useHistory } from 'react-router-dom';
import { List } from '../../components/List';
import { ListRow } from '../../components/ListRow';
@ -20,6 +20,7 @@ import { LinkToCMSettingsView } from './LinkToCMSettingsView';
/* eslint-disable indent */
const ListView = () => {
const history = useHistory();
const { initialData, modifiedData, isInDevelopmentMode, isInContentTypeView, submitData } =
useDataManager();
const { formatMessage } = useIntl();
@ -49,6 +50,10 @@ const ListView = () => {
const forTarget = isInContentTypeView ? 'contentType' : 'component';
const handleReload = () => {
history.go(0); // Reloads the current page
};
const handleClickAddComponentToDZ = (dynamicZoneTarget?: string) => {
onOpenModalAddComponentsToDZ({ dynamicZoneTarget, targetUid });
};
@ -142,7 +147,10 @@ const ListView = () => {
)}
<Button
startIcon={<Check />}
onClick={() => submitData()}
onClick={async () => {
await submitData();
handleReload();
}}
type="submit"
disabled={isEqual(modifiedData, initialData)}
>