From 4e9762f170d9e6bbde19da56739d3a559dbb3204 Mon Sep 17 00:00:00 2001 From: Arpit Date: Mon, 9 Oct 2023 16:11:03 +0530 Subject: [PATCH] fixes: column data generated from restapi does not render correct columns in viewer (#7695) --- frontend/src/Editor/EditorFunc.jsx | 12 +++++++++++- frontend/src/_stores/utils.js | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/frontend/src/Editor/EditorFunc.jsx b/frontend/src/Editor/EditorFunc.jsx index b255d604ff..105bc73446 100644 --- a/frontend/src/Editor/EditorFunc.jsx +++ b/frontend/src/Editor/EditorFunc.jsx @@ -55,7 +55,7 @@ import { useDataQueries, useDataQueriesStore } from '@/_stores/dataQueriesStore' import { useAppVersionStore, useAppVersionActions, useAppVersionState } from '@/_stores/appVersionStore'; import { useQueryPanelStore } from '@/_stores/queryPanelStore'; import { useCurrentStateStore, useCurrentState } from '@/_stores/currentStateStore'; -import { computeAppDiff, computeComponentPropertyDiff, resetAllStores } from '@/_stores/utils'; +import { computeAppDiff, computeComponentPropertyDiff, isParamFromTableColumn, resetAllStores } from '@/_stores/utils'; import { setCookie } from '@/_helpers/cookie'; import { shallow } from 'zustand/shallow'; import { useEditorActions, useEditorState, useEditorStore } from '@/_stores/editorStore'; @@ -801,6 +801,16 @@ const EditorComponent = (props) => { updateAppDefinitionDiff(diffPatches); + const isParamDiffFromTableColumn = opts?.containerChanges + ? isParamFromTableColumn(diffPatches, updatedAppDefinition) + : false; + + if (isParamDiffFromTableColumn) { + opts.componentDefinitionChanged = true; + opts.isParamFromTableColumn = true; + delete opts.containerChanges; + } + updateState({ appDiffOptions: opts, }); diff --git a/frontend/src/_stores/utils.js b/frontend/src/_stores/utils.js index 58349d0699..99d9afff27 100644 --- a/frontend/src/_stores/utils.js +++ b/frontend/src/_stores/utils.js @@ -95,6 +95,14 @@ function updateValueInJson(json, path, value) { return json; } +export function isParamFromTableColumn(appDiff, definition) { + const path = generatePath(appDiff, 'columns') || generatePath(appDiff, 'actions'); + + const value2 = getValueFromJson(definition, path); + + return value2 !== undefined; +} + export const computeComponentPropertyDiff = (appDiff, definition, opts) => { if (!opts?.isParamFromTableColumn) { return appDiff;