From 291ed9bb7d2e5362fab236cb831ce798adb6a955 Mon Sep 17 00:00:00 2001 From: Leonardo <leomilho@gmail.com> Date: Tue, 23 Jul 2024 16:36:58 +0200 Subject: [PATCH] fix(viz): don't override viz settings if already set from savestate --- .../paohvis/components/HyperRangeBlock.tsx | 4 ++-- libs/shared/lib/vis/visualizations/paohvis/paohvis.tsx | 10 ++++++++-- .../lib/vis/visualizations/tablevis/tablevis.tsx | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libs/shared/lib/vis/visualizations/paohvis/components/HyperRangeBlock.tsx b/libs/shared/lib/vis/visualizations/paohvis/components/HyperRangeBlock.tsx index 4a75d8308..06c49d327 100644 --- a/libs/shared/lib/vis/visualizations/paohvis/components/HyperRangeBlock.tsx +++ b/libs/shared/lib/vis/visualizations/paohvis/components/HyperRangeBlock.tsx @@ -4,7 +4,7 @@ import { LinesHyperEdges, PaohvisDataPaginated, RowInformation } from '../types' interface HyperEdgeRangesBlockProps { dataModel: PaohvisDataPaginated; - dataLinesHyperedges: LinesHyperEdges[]; + dataLinesHyperEdges: LinesHyperEdges[]; rowHeight: number; yOffset: number; rowLabelColumnWidth: number; @@ -28,7 +28,7 @@ interface HyperEdgeRangesBlockProps { export const HyperEdgeRangesBlock: React.FC<HyperEdgeRangesBlockProps> = ({ dataModel, - dataLinesHyperedges, + dataLinesHyperEdges: dataLinesHyperedges, rowHeight, yOffset, rowLabelColumnWidth, diff --git a/libs/shared/lib/vis/visualizations/paohvis/paohvis.tsx b/libs/shared/lib/vis/visualizations/paohvis/paohvis.tsx index af58aef15..14ff4f739 100644 --- a/libs/shared/lib/vis/visualizations/paohvis/paohvis.tsx +++ b/libs/shared/lib/vis/visualizations/paohvis/paohvis.tsx @@ -882,7 +882,7 @@ export const PaohVis = ({ data, graphMetadata, schema, settings, updateSettings <HyperEdgeRangesBlock dataModel={dataModel} - dataLinesHyperedges={lineHyperEdges} + dataLinesHyperEdges={lineHyperEdges} rowHeight={settings.rowHeight} yOffset={computedSizesSvg.colWidth} rowLabelColumnWidth={widthTotalRowInformation} @@ -943,7 +943,13 @@ const PaohSettings = ({ settings, graphMetadata, updateSettings }: Visualization }, [settings.columnNode, graphMetadata]); useEffect(() => { - if (graphMetadata && graphMetadata.nodes && graphMetadata.nodes.labels.length > 1) { + if ( + graphMetadata && + graphMetadata.nodes && + graphMetadata.nodes.labels.length > 1 && + settings.rowNode === '' && + settings.columnNode === '' + ) { updateSettings({ rowNode: graphMetadata.nodes.labels[0], columnNode: graphMetadata.nodes.labels[1] }); } }, [graphMetadata]); diff --git a/libs/shared/lib/vis/visualizations/tablevis/tablevis.tsx b/libs/shared/lib/vis/visualizations/tablevis/tablevis.tsx index b6b51faae..6121b4c12 100644 --- a/libs/shared/lib/vis/visualizations/tablevis/tablevis.tsx +++ b/libs/shared/lib/vis/visualizations/tablevis/tablevis.tsx @@ -30,7 +30,7 @@ export const TableVis = ({ data, schema, settings, updateSettings, graphMetadata const searchResults = useSearchResultData(); const ref = useRef<HTMLDivElement>(null); useEffect(() => { - if (graphMetadata != undefined) { + if (graphMetadata != undefined && settings.displayEntity === '') { if (!graphMetadata.nodes.labels.includes(settings.displayEntity)) { updateSettings({ displayEntity: graphMetadata.nodes.labels[0], @@ -116,7 +116,7 @@ export const TableVis = ({ data, schema, settings, updateSettings, graphMetadata const TableSettings = ({ settings, graphMetadata, updateSettings }: VisualizationSettingsPropTypes<TableProps>) => { useEffect(() => { - if (graphMetadata && graphMetadata.nodes && graphMetadata.nodes.labels.length > 0) { + if (graphMetadata && graphMetadata.nodes && graphMetadata.nodes.labels.length > 0 && settings.displayEntity === '') { updateSettings({ displayEntity: graphMetadata.nodes.labels[0] }); } }, [graphMetadata]); @@ -137,7 +137,7 @@ const TableSettings = ({ settings, graphMetadata, updateSettings }: Visualizatio }, [settings.displayEntity, graphMetadata]); useEffect(() => { - if (graphMetadata && graphMetadata.nodes && graphMetadata.nodes.labels.length > 0) { + if (graphMetadata && graphMetadata.nodes && graphMetadata.nodes.labels.length > 0 && settings.displayAttributes.length === 0) { updateSettings({ displayAttributes: selectedNodeAttributes }); } }, [selectedNodeAttributes, graphMetadata]); -- GitLab