Skip to content

Commit 7d02410

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 7d02410

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

docs/en_US/release_notes_9_7.rst

Lines changed: 2 additions & 2 deletions
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
************
@@ -47,4 +46,5 @@ Bug fixes
4746
| `Issue #8982 <https://github.com/pgadmin-org/pgadmin4/issues/8982>`_ - Fixed an issue where adding breakpoints caused errors, and stepping out of a nested function removed breakpoints from the parent function.
4847
| `Issue #9007 <https://github.com/pgadmin-org/pgadmin4/issues/9007>`_ - Ensure the scratch pad in the Query Tool is not restored after it is closed.
4948
| `Issue #9008 <https://github.com/pgadmin-org/pgadmin4/issues/9008>`_ - Update the documentation for parameters that require file paths.
50-
| `Issue #9047 <https://github.com/pgadmin-org/pgadmin4/issues/9047>`_ - Fixed an issue where downloading images on the ERD tool was not working in desktop mode.
49+
| `Issue #9047 <https://github.com/pgadmin-org/pgadmin4/issues/9047>`_ - Fixed an issue where downloading images on the ERD tool was not working in desktop mode.
50+
| `Issue #9067 <https://github.com/pgadmin-org/pgadmin4/issues/9067>`_ - Ensure that disabling "Save Application State" in Preferences prevents tool data from being saved and stops it from being restored on application restart.

web/pgadmin/misc/workspaces/static/js/AdHocConnection.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ class AdHocConnectionSchema extends BaseUISchema {
215215
disabled: (state) => state.sid,
216216
},{
217217
id: 'did', label: gettext('Database'), deps: ['sid', 'connected'],
218-
controlProps: {creatable: true},
219218
type: (state) => {
220219
if (state?.sid) {
221220
return {
222221
type: 'select',
222+
controlProps: {creatable: true},
223223
options: () => this.getOtherOptions(
224224
state.sid, 'get_new_connection_database'
225225
),
@@ -238,11 +238,11 @@ class AdHocConnectionSchema extends BaseUISchema {
238238
}
239239
}, {
240240
id: 'user', label: gettext('User'), deps: ['sid', 'connected'],
241-
controlProps: {creatable: true},
242241
type: (state) => {
243242
if (state?.sid) {
244243
return {
245244
type: 'select',
245+
controlProps: {creatable: true},
246246
options: () => this.getOtherOptions(
247247
state.sid, 'get_new_connection_user'
248248
),
@@ -266,9 +266,9 @@ class AdHocConnectionSchema extends BaseUISchema {
266266
}
267267
},{
268268
id: 'role', label: gettext('Role'), deps: ['sid', 'connected'],
269-
controlProps: {creatable: true},
270269
type: (state)=>({
271270
type: 'select',
271+
controlProps: {creatable: true},
272272
options: () => this.getOtherOptions(
273273
state.sid, 'get_new_connection_role'
274274
),

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

Lines changed: 11 additions & 4 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+
layoutDockerObj.saveLayout();
432+
}
433+
saveAppStateRef.current = saveAppState;
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 savedTab = { id: tab.id };
483+
if (saveAppStateRef.current && 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,

0 commit comments

Comments
 (0)