diff --git a/frontend/src/Editor/Editor.jsx b/frontend/src/Editor/Editor.jsx index 505d284934..ad6ec31dfa 100644 --- a/frontend/src/Editor/Editor.jsx +++ b/frontend/src/Editor/Editor.jsx @@ -19,8 +19,6 @@ import { componentTypes } from './WidgetManager/components'; import { Inspector } from './Inspector/Inspector'; import QueryPanel from './QueryPanel/QueryPanel'; import { - onComponentOptionChanged, - onComponentOptionsChanged, onEvent, onQueryConfirmOrCancel, runQuery, @@ -1402,10 +1400,15 @@ const EditorComponent = (props) => { const updateEntityReferences = (appJson, pageId) => { const currentComponents = appJson?.pages?.[pageId]?.components; + const globalSettings = appJson['globalSettings']; let dataQueries = JSON.parse(JSON.stringify(useDataQueriesStore.getState().dataQueries)); let allEvents = JSON.parse(JSON.stringify(useAppDataStore.getState().events)); + const entittyReferencesInGlobalSettings = findAllEntityReferences(globalSettings, [])?.filter( + (entity) => entity && isValidUUID(entity) + ); + const entityReferencesInComponentDefinitions = findAllEntityReferences(currentComponents, [])?.filter( (entity) => entity && isValidUUID(entity) ); @@ -1420,6 +1423,27 @@ const EditorComponent = (props) => { const manager = useResolveStore.getState().referenceMapper; + if (Array.isArray(entittyReferencesInGlobalSettings) && entittyReferencesInGlobalSettings?.length > 0) { + let newGlobalSettings = JSON.parse(JSON.stringify(globalSettings)); + entittyReferencesInGlobalSettings.forEach((entity) => { + const entityrefExists = manager.has(entity); + + if (entityrefExists) { + const value = manager.get(entity); + newGlobalSettings = dfs(newGlobalSettings, entity, value); + } + }); + + const newAppDefinition = produce(appJson, (draft) => { + draft.globalSettings = newGlobalSettings; + }); + + updateEditorState({ + isUpdatingEditorStateInProcess: false, + appDefinition: newAppDefinition, + }); + } + if (Array.isArray(entityReferencesInComponentDefinitions) && entityReferencesInComponentDefinitions?.length > 0) { let newComponentDefinition = JSON.parse(JSON.stringify(currentComponents)); @@ -1432,7 +1456,8 @@ const EditorComponent = (props) => { } }); - const newAppDefinition = produce(appJson, (draft) => { + const appDefinition = useEditorStore.getState().appDefinition; + const newAppDefinition = produce(appDefinition, (draft) => { draft.pages[pageId].components = newComponentDefinition; });