From 17b1bc0544ec764a0545e3a594c986e9ff552547 Mon Sep 17 00:00:00 2001 From: Manuel <5673677+mtrezza@users.noreply.github.com> Date: Wed, 16 Jul 2025 13:20:08 +0200 Subject: [PATCH 1/2] fix: persist AggregationPanel visibility across sessions --- .../Data/Browser/DataBrowser.react.js | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/dashboard/Data/Browser/DataBrowser.react.js b/src/dashboard/Data/Browser/DataBrowser.react.js index 394c47e025..7b27c3b63e 100644 --- a/src/dashboard/Data/Browser/DataBrowser.react.js +++ b/src/dashboard/Data/Browser/DataBrowser.react.js @@ -19,6 +19,7 @@ import styles from './Databrowser.scss'; import AggregationPanel from '../../../components/AggregationPanel/AggregationPanel'; const BROWSER_SHOW_ROW_NUMBER = 'browserShowRowNumber'; +const AGGREGATION_PANEL_VISIBLE = 'aggregationPanelVisible'; function formatValueForCopy(value, type) { if (value === undefined) { @@ -79,6 +80,12 @@ export default class DataBrowser extends React.Component { ); const storedRowNumber = window.localStorage?.getItem(BROWSER_SHOW_ROW_NUMBER) === 'true'; + const storedPanelVisible = + window.localStorage?.getItem(AGGREGATION_PANEL_VISIBLE) === 'true'; + const hasAggregation = + props.classwiseCloudFunctions?.[ + `${props.app.applicationId}${props.appName}` + ]?.[props.className]; this.state = { order: order, @@ -88,7 +95,7 @@ export default class DataBrowser extends React.Component { selectedObjectId: undefined, simplifiedSchema: this.getSimplifiedSchema(props.schema, props.className), allClassesSchema: this.getAllClassesSchema(props.schema, props.classes), - isPanelVisible: false, + isPanelVisible: storedPanelVisible && !!hasAggregation, selectedCells: { list: new Set(), rowStart: -1, rowEnd: -1, colStart: -1, colEnd: -1 }, firstSelectedCell: null, selectedData: [], @@ -157,13 +164,17 @@ export default class DataBrowser extends React.Component { this.setState({ order, frozenColumnIndex: -1 }); } if (props && props.className) { - if ( - !props.classwiseCloudFunctions?.[`${props.app.applicationId}${props.appName}`]?.[ - props.className - ] - ) { + const storedPanelVisible = + window.localStorage?.getItem(AGGREGATION_PANEL_VISIBLE) === 'true'; + const hasAggregation = + props.classwiseCloudFunctions?.[ + `${props.app.applicationId}${props.appName}` + ]?.[props.className]; + if (!hasAggregation) { this.setState({ isPanelVisible: false }); this.setState({ selectedObjectId: undefined }); + } else { + this.setState({ isPanelVisible: storedPanelVisible }); } } else { this.setState({ isPanelVisible: false }); @@ -242,9 +253,18 @@ export default class DataBrowser extends React.Component { } togglePanelVisibility() { - this.setState(prevState => ({ isPanelVisible: !prevState.isPanelVisible })); + const newVisibility = !this.state.isPanelVisible; + this.setState({ isPanelVisible: newVisibility }); + try { + window.localStorage?.setItem( + AGGREGATION_PANEL_VISIBLE, + newVisibility + ); + } catch { + // ignore + } - if (!this.state.isPanelVisible) { + if (!newVisibility) { this.props.setAggregationPanelData({}); this.props.setLoadingInfoPanel(false); if (this.props.errorAggregatedData != {}) { @@ -252,7 +272,7 @@ export default class DataBrowser extends React.Component { } } - if (!this.state.isPanelVisible && this.state.selectedObjectId) { + if (!newVisibility && this.state.selectedObjectId) { if (this.props.errorAggregatedData != {}) { this.props.setErrorAggregatedData({}); } @@ -285,9 +305,15 @@ export default class DataBrowser extends React.Component { checkClassNameChange(prevClassName, className) { if (prevClassName !== className) { + const storedPanelVisible = + window.localStorage?.getItem(AGGREGATION_PANEL_VISIBLE) === 'true'; + const hasAggregation = + this.props.classwiseCloudFunctions?.[ + `${this.props.app.applicationId}${this.props.appName}` + ]?.[className]; this.setState({ prevClassName: className, - isPanelVisible: false, + isPanelVisible: storedPanelVisible && !!hasAggregation, selectedObjectId: undefined, }); this.props.setAggregationPanelData({}); From 16b480d67465f2c22c469ee97c946d60bbfe231c Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Wed, 16 Jul 2025 13:38:58 +0200 Subject: [PATCH 2/2] Update DataBrowser.react.js --- src/dashboard/Data/Browser/DataBrowser.react.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/dashboard/Data/Browser/DataBrowser.react.js b/src/dashboard/Data/Browser/DataBrowser.react.js index 7b27c3b63e..48e1f66836 100644 --- a/src/dashboard/Data/Browser/DataBrowser.react.js +++ b/src/dashboard/Data/Browser/DataBrowser.react.js @@ -255,14 +255,7 @@ export default class DataBrowser extends React.Component { togglePanelVisibility() { const newVisibility = !this.state.isPanelVisible; this.setState({ isPanelVisible: newVisibility }); - try { - window.localStorage?.setItem( - AGGREGATION_PANEL_VISIBLE, - newVisibility - ); - } catch { - // ignore - } + window.localStorage?.setItem(AGGREGATION_PANEL_VISIBLE, newVisibility); if (!newVisibility) { this.props.setAggregationPanelData({});