@@ -19,6 +19,7 @@ import styles from './Databrowser.scss';
1919import AggregationPanel from '../../../components/AggregationPanel/AggregationPanel' ;
2020
2121const BROWSER_SHOW_ROW_NUMBER = 'browserShowRowNumber' ;
22+ const AGGREGATION_PANEL_VISIBLE = 'aggregationPanelVisible' ;
2223
2324function formatValueForCopy ( value , type ) {
2425 if ( value === undefined ) {
@@ -79,6 +80,12 @@ export default class DataBrowser extends React.Component {
7980 ) ;
8081 const storedRowNumber =
8182 window . localStorage ?. getItem ( BROWSER_SHOW_ROW_NUMBER ) === 'true' ;
83+ const storedPanelVisible =
84+ window . localStorage ?. getItem ( AGGREGATION_PANEL_VISIBLE ) === 'true' ;
85+ const hasAggregation =
86+ props . classwiseCloudFunctions ?. [
87+ `${ props . app . applicationId } ${ props . appName } `
88+ ] ?. [ props . className ] ;
8289
8390 this . state = {
8491 order : order ,
@@ -88,7 +95,7 @@ export default class DataBrowser extends React.Component {
8895 selectedObjectId : undefined ,
8996 simplifiedSchema : this . getSimplifiedSchema ( props . schema , props . className ) ,
9097 allClassesSchema : this . getAllClassesSchema ( props . schema , props . classes ) ,
91- isPanelVisible : false ,
98+ isPanelVisible : storedPanelVisible && ! ! hasAggregation ,
9299 selectedCells : { list : new Set ( ) , rowStart : - 1 , rowEnd : - 1 , colStart : - 1 , colEnd : - 1 } ,
93100 firstSelectedCell : null ,
94101 selectedData : [ ] ,
@@ -157,13 +164,17 @@ export default class DataBrowser extends React.Component {
157164 this . setState ( { order, frozenColumnIndex : - 1 } ) ;
158165 }
159166 if ( props && props . className ) {
160- if (
161- ! props . classwiseCloudFunctions ?. [ `${ props . app . applicationId } ${ props . appName } ` ] ?. [
162- props . className
163- ]
164- ) {
167+ const storedPanelVisible =
168+ window . localStorage ?. getItem ( AGGREGATION_PANEL_VISIBLE ) === 'true' ;
169+ const hasAggregation =
170+ props . classwiseCloudFunctions ?. [
171+ `${ props . app . applicationId } ${ props . appName } `
172+ ] ?. [ props . className ] ;
173+ if ( ! hasAggregation ) {
165174 this . setState ( { isPanelVisible : false } ) ;
166175 this . setState ( { selectedObjectId : undefined } ) ;
176+ } else {
177+ this . setState ( { isPanelVisible : storedPanelVisible } ) ;
167178 }
168179 } else {
169180 this . setState ( { isPanelVisible : false } ) ;
@@ -242,17 +253,26 @@ export default class DataBrowser extends React.Component {
242253 }
243254
244255 togglePanelVisibility ( ) {
245- this . setState ( prevState => ( { isPanelVisible : ! prevState . isPanelVisible } ) ) ;
256+ const newVisibility = ! this . state . isPanelVisible ;
257+ this . setState ( { isPanelVisible : newVisibility } ) ;
258+ try {
259+ window . localStorage ?. setItem (
260+ AGGREGATION_PANEL_VISIBLE ,
261+ newVisibility
262+ ) ;
263+ } catch {
264+ // ignore
265+ }
246266
247- if ( ! this . state . isPanelVisible ) {
267+ if ( ! newVisibility ) {
248268 this . props . setAggregationPanelData ( { } ) ;
249269 this . props . setLoadingInfoPanel ( false ) ;
250270 if ( this . props . errorAggregatedData != { } ) {
251271 this . props . setErrorAggregatedData ( { } ) ;
252272 }
253273 }
254274
255- if ( ! this . state . isPanelVisible && this . state . selectedObjectId ) {
275+ if ( ! newVisibility && this . state . selectedObjectId ) {
256276 if ( this . props . errorAggregatedData != { } ) {
257277 this . props . setErrorAggregatedData ( { } ) ;
258278 }
@@ -285,9 +305,15 @@ export default class DataBrowser extends React.Component {
285305
286306 checkClassNameChange ( prevClassName , className ) {
287307 if ( prevClassName !== className ) {
308+ const storedPanelVisible =
309+ window . localStorage ?. getItem ( AGGREGATION_PANEL_VISIBLE ) === 'true' ;
310+ const hasAggregation =
311+ this . props . classwiseCloudFunctions ?. [
312+ `${ this . props . app . applicationId } ${ this . props . appName } `
313+ ] ?. [ className ] ;
288314 this . setState ( {
289315 prevClassName : className ,
290- isPanelVisible : false ,
316+ isPanelVisible : storedPanelVisible && ! ! hasAggregation ,
291317 selectedObjectId : undefined ,
292318 } ) ;
293319 this . props . setAggregationPanelData ( { } ) ;
0 commit comments