mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
Merge branch 'bugfix/appdef/component-delete-should-maptoid' into bugfix/appdef/viewer-UI-donot-update
This commit is contained in:
commit
2a85e4eab1
3 changed files with 45 additions and 7 deletions
|
|
@ -1379,11 +1379,22 @@ const EditorComponent = (props) => {
|
||||||
|
|
||||||
const newAppDefinition = JSON.parse(JSON.stringify(useEditorStore.getState().appDefinition));
|
const newAppDefinition = JSON.parse(JSON.stringify(useEditorStore.getState().appDefinition));
|
||||||
const currentComponents = newAppDefinition.pages[currentPageId].components;
|
const currentComponents = newAppDefinition.pages[currentPageId].components;
|
||||||
|
const currentDataQueries = useDataQueriesStore.getState().dataQueries;
|
||||||
|
|
||||||
const newComponentDefinition = useResolveStore
|
const newComponentDefinition = useResolveStore
|
||||||
.getState()
|
.getState()
|
||||||
.actions.findAndReplaceReferences(currentComponents, deletedComponentNames);
|
.actions.findAndReplaceReferences(currentComponents, deletedComponentNames);
|
||||||
|
|
||||||
|
const entityReferencesInQuerries = findAllEntityReferences(currentDataQueries, []);
|
||||||
|
|
||||||
|
if (entityReferencesInQuerries.length > 0) {
|
||||||
|
const newDataQueries = useResolveStore
|
||||||
|
.getState()
|
||||||
|
.actions.findAndReplaceReferences(currentDataQueries, deletedComponentNames);
|
||||||
|
|
||||||
|
useDataQueriesStore.getState().actions.setDataQueries(newDataQueries, 'mappingUpdate');
|
||||||
|
}
|
||||||
|
|
||||||
newAppDefinition.pages[currentPageId].components = newComponentDefinition;
|
newAppDefinition.pages[currentPageId].components = newComponentDefinition;
|
||||||
|
|
||||||
useEditorStore.getState().actions.updateEditorState({
|
useEditorStore.getState().actions.updateEditorState({
|
||||||
|
|
|
||||||
|
|
@ -1236,7 +1236,7 @@ export function runQuery(
|
||||||
useResolveStore.getState().actions.addAppSuggestions({
|
useResolveStore.getState().actions.addAppSuggestions({
|
||||||
queries: {
|
queries: {
|
||||||
[queryName]: {
|
[queryName]: {
|
||||||
data: [...finalData],
|
data: finalData,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
import { create, zustandDevTools } from './utils';
|
import { create, findAllEntityReferences, zustandDevTools } from './utils';
|
||||||
import { getDefaultOptions } from './storeHelper';
|
import { getDefaultOptions } from './storeHelper';
|
||||||
import { dataqueryService } from '@/_services';
|
import { dataqueryService } from '@/_services';
|
||||||
// import debounce from 'lodash/debounce';
|
|
||||||
import { useAppDataStore } from '@/_stores/appDataStore';
|
import { useAppDataStore } from '@/_stores/appDataStore';
|
||||||
import { useQueryPanelStore } from '@/_stores/queryPanelStore';
|
import { useQueryPanelStore } from '@/_stores/queryPanelStore';
|
||||||
import { useAppVersionStore } from '@/_stores/appVersionStore';
|
import { useAppVersionStore } from '@/_stores/appVersionStore';
|
||||||
import { runQueries } from '@/_helpers/appUtils';
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { toast } from 'react-hot-toast';
|
import { toast } from 'react-hot-toast';
|
||||||
import _, { isEmpty, throttle } from 'lodash';
|
import _, { isEmpty, throttle } from 'lodash';
|
||||||
|
|
@ -101,10 +99,15 @@ export const useDataQueriesStore = create(
|
||||||
set({ dataQueries });
|
set({ dataQueries });
|
||||||
if (type === 'mappingUpdate') {
|
if (type === 'mappingUpdate') {
|
||||||
const { actions } = useQueryPanelStore.getState();
|
const { actions } = useQueryPanelStore.getState();
|
||||||
actions.setSelectedQuery(null);
|
|
||||||
const queryId = dataQueries[0]?.id;
|
|
||||||
|
|
||||||
actions.setSelectedQuery(queryId);
|
return new Promise((resolve) => {
|
||||||
|
actions.setSelectedQuery(null);
|
||||||
|
resolve();
|
||||||
|
}).then(() => {
|
||||||
|
const queryId = dataQueries[0]?.id;
|
||||||
|
|
||||||
|
actions.setSelectedQuery(queryId);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deleteDataQueries: (queryId) => {
|
deleteDataQueries: (queryId) => {
|
||||||
|
|
@ -138,6 +141,30 @@ export const useDataQueriesStore = create(
|
||||||
}, {}),
|
}, {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const newAppDefinition = JSON.parse(JSON.stringify(useEditorStore.getState().appDefinition));
|
||||||
|
const currentPageId = useEditorStore.getState().currentPageId;
|
||||||
|
const currentComponents = newAppDefinition.pages[currentPageId].components;
|
||||||
|
|
||||||
|
const newComponentDefinition = useResolveStore
|
||||||
|
.getState()
|
||||||
|
.actions.findAndReplaceReferences(currentComponents, [deletedQueryName]);
|
||||||
|
const entityReferencesInQuerries = findAllEntityReferences(get().dataQueries, []);
|
||||||
|
|
||||||
|
if (entityReferencesInQuerries.length > 0) {
|
||||||
|
const newDataQueries = useResolveStore
|
||||||
|
.getState()
|
||||||
|
.actions.findAndReplaceReferences(get().dataQueries, [deletedQueryName]);
|
||||||
|
|
||||||
|
get().actions.setDataQueries(newDataQueries, 'mappingUpdate');
|
||||||
|
}
|
||||||
|
|
||||||
|
newAppDefinition.pages[currentPageId].components = newComponentDefinition;
|
||||||
|
|
||||||
|
useEditorStore.getState().actions.updateEditorState({
|
||||||
|
appDefinition: newAppDefinition,
|
||||||
|
isUpdatingEditorStateInProcess: true,
|
||||||
|
});
|
||||||
|
|
||||||
const referenceManager = useResolveStore.getState().referenceMapper;
|
const referenceManager = useResolveStore.getState().referenceMapper;
|
||||||
referenceManager.delete(queryId);
|
referenceManager.delete(queryId);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue