Skip to content

Commit d188030

Browse files
authored
feat: Remember info panel width and count across browser sessions (parse-community#3031)
1 parent 3f28699 commit d188030

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/dashboard/Data/Browser/DataBrowser.react.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const AGGREGATION_PANEL_AUTO_LOAD_FIRST_ROW = 'aggregationPanelAutoLoadFirstRow'
2626
const AGGREGATION_PANEL_SYNC_SCROLL = 'aggregationPanelSyncScroll';
2727
const AGGREGATION_PANEL_BATCH_NAVIGATE = 'aggregationPanelBatchNavigate';
2828
const AGGREGATION_PANEL_SHOW_CHECKBOX = 'aggregationPanelShowCheckbox';
29+
const AGGREGATION_PANEL_WIDTH = 'aggregationPanelWidth';
30+
const AGGREGATION_PANEL_COUNT = 'aggregationPanelCount';
2931

3032
function formatValueForCopy(value, type) {
3133
if (value === undefined) {
@@ -98,6 +100,10 @@ export default class DataBrowser extends React.Component {
98100
window.localStorage?.getItem(AGGREGATION_PANEL_BATCH_NAVIGATE) !== 'false';
99101
const storedShowPanelCheckbox =
100102
window.localStorage?.getItem(AGGREGATION_PANEL_SHOW_CHECKBOX) !== 'false';
103+
const storedPanelWidth = window.localStorage?.getItem(AGGREGATION_PANEL_WIDTH);
104+
const parsedPanelWidth = storedPanelWidth ? parseInt(storedPanelWidth, 10) : 300;
105+
const storedPanelCount = window.localStorage?.getItem(AGGREGATION_PANEL_COUNT);
106+
const parsedPanelCount = storedPanelCount ? parseInt(storedPanelCount, 10) : 1;
101107
const hasAggregation =
102108
props.classwiseCloudFunctions?.[
103109
`${props.app.applicationId}${props.appName}`
@@ -117,7 +123,7 @@ export default class DataBrowser extends React.Component {
117123
firstSelectedCell: null,
118124
selectedData: [],
119125
prevClassName: props.className,
120-
panelWidth: 300,
126+
panelWidth: parsedPanelWidth,
121127
isResizing: false,
122128
maxWidth: window.innerWidth - 300,
123129
showAggregatedData: true,
@@ -131,7 +137,7 @@ export default class DataBrowser extends React.Component {
131137
prefetchCache: {},
132138
selectionHistory: [],
133139
displayedObjectIds: [], // Array of object IDs currently displayed in the panel
134-
panelCount: 1, // Number of panels to display
140+
panelCount: parsedPanelCount, // Number of panels to display
135141
multiPanelData: {}, // Object mapping objectId to panel data
136142
_objectsToFetch: [], // Temporary field for async fetch handling
137143
loadingObjectIds: new Set(),
@@ -358,6 +364,7 @@ export default class DataBrowser extends React.Component {
358364
isResizing: false,
359365
panelWidth: size.width,
360366
});
367+
window.localStorage?.setItem(AGGREGATION_PANEL_WIDTH, size.width);
361368
}
362369

363370
handleResizeDiv(event, { size }) {
@@ -1148,6 +1155,8 @@ export default class DataBrowser extends React.Component {
11481155
multiPanelData: currentObjectData,
11491156
panelWidth: limitedWidth,
11501157
});
1158+
window.localStorage?.setItem(AGGREGATION_PANEL_COUNT, newPanelCount);
1159+
window.localStorage?.setItem(AGGREGATION_PANEL_WIDTH, limitedWidth);
11511160

11521161
// Fetch missing data asynchronously
11531162
objectsToFetch.forEach((objectId, i) => {
@@ -1169,6 +1178,9 @@ export default class DataBrowser extends React.Component {
11691178

11701179
const newWidth = (prevState.panelWidth / prevState.panelCount) * newPanelCount;
11711180

1181+
window.localStorage?.setItem(AGGREGATION_PANEL_COUNT, newPanelCount);
1182+
window.localStorage?.setItem(AGGREGATION_PANEL_WIDTH, newWidth);
1183+
11721184
return {
11731185
panelCount: newPanelCount,
11741186
displayedObjectIds: newDisplayedObjectIds,

0 commit comments

Comments
 (0)