mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
fixes app def updates from inspector and containers
This commit is contained in:
parent
ea0ab5b5c7
commit
099337c90b
2 changed files with 17 additions and 52 deletions
|
|
@ -202,13 +202,7 @@ const EditorComponent = (props) => {
|
|||
useEffect(() => {
|
||||
const didAppDefinitionChanged = !_.isEqual(appDefinition, prevAppDefinition.current);
|
||||
|
||||
console.log('---arpit-- appDefinitionChanged [useEffect]', { didAppDefinitionChanged, isSaving });
|
||||
|
||||
if (didAppDefinitionChanged) {
|
||||
console.log('---arpit-- updating [prevAppDefinition] [useEffect]', {
|
||||
prev: prevAppDefinition.current,
|
||||
curr: appDefinition,
|
||||
});
|
||||
prevAppDefinition.current = appDefinition;
|
||||
}
|
||||
|
||||
|
|
@ -309,9 +303,7 @@ const EditorComponent = (props) => {
|
|||
};
|
||||
|
||||
const $componentDidMount = async () => {
|
||||
// console.log('---arpit-- componentDidMounted effect', { appDefinition, currentPageId });
|
||||
window.addEventListener('message', handleMessage);
|
||||
// autoSave();
|
||||
|
||||
await fetchApps(0);
|
||||
await fetchApp(props.params.pageHandle);
|
||||
|
|
@ -629,11 +621,6 @@ const EditorComponent = (props) => {
|
|||
const startingPageId = pages.filter((page) => page.handle === startingPageHandle)[0]?.id;
|
||||
const homePageId = !startingPageHandle || startingPageId === 'null' ? dataDefinition.homePageId : startingPageId;
|
||||
|
||||
console.log('---arpit-- fetching app data', {
|
||||
data,
|
||||
dataDefinition,
|
||||
});
|
||||
|
||||
setCurrentPageId(homePageId);
|
||||
|
||||
updateState({
|
||||
|
|
@ -706,11 +693,6 @@ const EditorComponent = (props) => {
|
|||
};
|
||||
|
||||
const appDefinitionChanged = (newDefinition, opts = {}) => {
|
||||
console.log('--arpit | appDefinitionChanged func() called', {
|
||||
opts,
|
||||
});
|
||||
|
||||
// if (_.isEqual(prevAppDefinition.current, newDefinition)) return;
|
||||
if (config.ENABLE_MULTIPLAYER_EDITING && !opts.skipYmapUpdate) {
|
||||
props.ymap?.set('appDef', {
|
||||
newDefinition,
|
||||
|
|
@ -742,8 +724,6 @@ const EditorComponent = (props) => {
|
|||
const diffPatches = diff(appDefinition, updatedAppDefinition);
|
||||
|
||||
console.log('--arpit | appDefinitionChanged func() | diffPatches', {
|
||||
// appDefinition,
|
||||
// updatedAppDefinition,
|
||||
diffPatches,
|
||||
});
|
||||
|
||||
|
|
@ -905,16 +885,11 @@ const EditorComponent = (props) => {
|
|||
updatedAppDefinition.pages[currentPageId].components[componentDefinition.id].component =
|
||||
componentDefinition.component;
|
||||
|
||||
// // Update the editor state with the new appDefinition
|
||||
updateEditorState({
|
||||
isSaving: true,
|
||||
});
|
||||
|
||||
const diffPatches = diff(appDefinition, updatedAppDefinition);
|
||||
console.log('---arpit [componentDefinitionChanged]', {
|
||||
props,
|
||||
diffPatches,
|
||||
});
|
||||
|
||||
if (!isEmpty(diffPatches)) {
|
||||
// handleAddPatch(diffPatches, diff(updatedAppDefinition, appDefinition));
|
||||
|
|
@ -922,13 +897,13 @@ const EditorComponent = (props) => {
|
|||
}
|
||||
}
|
||||
|
||||
// // Other actions can be performed here if needed, like autoSave, ymap, etc.
|
||||
// // computeComponentState(updatedAppDefinition.pages[currentPageId]?.components);
|
||||
// // autoSave();
|
||||
// // props.ymap?.set('appDef', {
|
||||
// // newDefinition: updatedAppDefinition,
|
||||
// // editingVersionId: props.editingVersion?.id,
|
||||
// // });
|
||||
// Other actions can be performed here if needed, like autoSave, ymap, etc.
|
||||
// computeComponentState(updatedAppDefinition.pages[currentPageId]?.components);
|
||||
// autoSave();
|
||||
// props.ymap?.set('appDef', {
|
||||
// newDefinition: updatedAppDefinition,
|
||||
// editingVersionId: props.editingVersion?.id,
|
||||
// });
|
||||
// }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -36,14 +36,13 @@ export const Inspector = ({
|
|||
const dataQueries = useDataQueries();
|
||||
const component = {
|
||||
id: selectedComponentId,
|
||||
component: allComponents[selectedComponentId].component,
|
||||
component: JSON.parse(JSON.stringify(allComponents[selectedComponentId].component)),
|
||||
layouts: allComponents[selectedComponentId].layouts,
|
||||
parent: allComponents[selectedComponentId].parent,
|
||||
};
|
||||
const currentState = useCurrentState();
|
||||
const [showWidgetDeleteConfirmation, setWidgetDeleteConfirmation] = useState(false);
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [tabHeight, setTabHeight] = React.useState(0);
|
||||
|
||||
const componentNameRef = useRef(null);
|
||||
const [newComponentName, setNewComponentName] = useState(component.component.name);
|
||||
const [inputRef, setInputFocus] = useFocus();
|
||||
|
|
@ -122,7 +121,8 @@ export const Inspector = ({
|
|||
|
||||
function paramUpdated(param, attr, value, paramType) {
|
||||
console.log({ param, attr, value, paramType });
|
||||
let newDefinition = _.cloneDeep(component.component.definition);
|
||||
let newComponent = JSON.parse(JSON.stringify(component));
|
||||
let newDefinition = _.cloneDeep(newComponent.component.definition);
|
||||
let allParams = newDefinition[paramType] || {};
|
||||
const paramObject = allParams[param.name];
|
||||
if (!paramObject) {
|
||||
|
|
@ -145,11 +145,7 @@ export const Inspector = ({
|
|||
allParams[param.name] = value;
|
||||
}
|
||||
newDefinition[paramType] = allParams;
|
||||
let newComponent = _.merge(component, {
|
||||
component: {
|
||||
definition: newDefinition,
|
||||
},
|
||||
});
|
||||
newComponent.component.definition = newDefinition;
|
||||
componentDefinitionChanged(newComponent, { componentPropertyUpdated: true });
|
||||
}
|
||||
|
||||
|
|
@ -212,18 +208,12 @@ export const Inspector = ({
|
|||
}
|
||||
|
||||
function eventsChanged(newEvents, isReordered = false) {
|
||||
let newDefinition;
|
||||
if (isReordered) {
|
||||
newDefinition = JSON.parse(JSON.stringify(component.component));
|
||||
newDefinition.definition.events = newEvents;
|
||||
} else {
|
||||
newDefinition = JSON.parse(JSON.stringify(component.component.definition));
|
||||
newDefinition.events = newEvents;
|
||||
}
|
||||
let newComponent = JSON.parse(JSON.stringify(component));
|
||||
let newDefinition = JSON.parse(JSON.stringify(newComponent.component.definition));
|
||||
|
||||
let newComponent = {
|
||||
...component,
|
||||
};
|
||||
newDefinition.events = newEvents;
|
||||
|
||||
newComponent.component.definition = newDefinition;
|
||||
|
||||
componentDefinitionChanged(newComponent, { eventsChanged: true });
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue