Skip to content

Commit 5073998

Browse files
Ensure that disabling "Save Application State" in Preferences prevents tool data from being saved and stops it from being restored on application restart.pgadmin-org#9067
1 parent ecb652c commit 5073998

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

docs/en_US/release_notes_9_7.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ New features
2424
| `Issue #6456 <https://github.com/pgadmin-org/pgadmin4/issues/6456>`_ - Added GENERIC_PLAN, MEMORY, SERIALIZE option to EXPLAIN/EXPLAIN ANALYZE command.
2525
| `Issue #8917 <https://github.com/pgadmin-org/pgadmin4/issues/8917>`_ - Add support for server tag-based filtering in the Object Explorer.
2626
| `Issue #8931 <https://github.com/pgadmin-org/pgadmin4/issues/8931>`_ - Added support for builtin locale provider while creating Collation.
27-
| `Issue #8935 <https://github.com/pgadmin-org/pgadmin4/issues/8935>`_ - Added all new connection string parameters introduced in PostgreSQL 16 and later.
2827
2928
Housekeeping
3029
************

web/pgadmin/static/js/helpers/Layout/index.jsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ export default function Layout({groups, noContextGroups, getLayoutInstance, layo
396396
const layoutDockerObj = React.useMemo(()=>new LayoutDocker(layoutId, props.defaultLayout, resetToTabPanel, noContextGroups), []);
397397
const prefStore = usePreferences();
398398
const dynamicTabsStyleRef = useRef();
399+
const saveAppStateRef = useRef(prefStore?.getPreferencesForModule('misc')?.save_app_state);
399400
const { deleteToolData } = useApplicationState();
400401

401402
useEffect(()=>{
@@ -411,6 +412,8 @@ export default function Layout({groups, noContextGroups, getLayoutInstance, layo
411412

412413
useEffect(()=>{
413414
const dynamicTabs = prefStore.getPreferencesForModule('browser')?.dynamic_tabs;
415+
const saveAppState = prefStore?.getPreferencesForModule('misc')?.save_app_state;
416+
414417
// Add a class to set max width for non dynamic Tabs
415418
if(!dynamicTabs && !dynamicTabsStyleRef.current) {
416419
const css = '.dock-tab:not(div.dock-tab-active) { max-width: 180px; }',
@@ -423,6 +426,12 @@ export default function Layout({groups, noContextGroups, getLayoutInstance, layo
423426
dynamicTabsStyleRef.current.remove();
424427
dynamicTabsStyleRef.current = null;
425428
}
429+
430+
if(!saveAppState && saveAppStateRef.current){
431+
saveAppStateRef.current = saveAppState;
432+
layoutDockerObj.saveLayout();
433+
}
434+
426435
}, [prefStore]);
427436

428437
const getTabMenuItems = (panelId)=>{
@@ -470,10 +479,8 @@ export default function Layout({groups, noContextGroups, getLayoutInstance, layo
470479
const saveTab = (tab) => {
471480
// 'tab' here is the full TabData object, potentially with 'title', 'content', etc.
472481
// We only want to save the 'id' and any custom properties needed by loadTab.
473-
const savedTab = {
474-
id: tab.id,
475-
};
476-
if (tab.metaData && !BROWSER_PANELS.DEBUGGER_TOOL.includes(tab.id.split('_')[0])) {
482+
const saveAppState = prefStore?.getPreferencesForModule('misc')?.save_app_state;
483+
if (saveAppState && tab.metaData && !BROWSER_PANELS.DEBUGGER_TOOL.includes(tab.id.split('_')[0])) {
477484
// add custom properties that were part of the original TabBase
478485
const updatedMetaData = {
479486
...tab.metaData,
@@ -485,9 +492,13 @@ export default function Layout({groups, noContextGroups, getLayoutInstance, layo
485492
},
486493
restore: true,
487494
};
488-
savedTab.metaData = updatedMetaData;
495+
return {
496+
id: tab.id,
497+
metaData: updatedMetaData
498+
};
499+
}else{
500+
return {id: tab.id};
489501
}
490-
return savedTab;
491502
};
492503

493504
const flatDefaultLayout = useMemo(()=>{

0 commit comments

Comments
 (0)