From b507eb8857baf6f4034732267698aa9ebfea8f9c Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Thu, 26 May 2022 15:31:18 +0530 Subject: [PATCH] Fixed an issue when switching between connections in the Query Tool dropdown, the background and foreground colors should be changed. Fixes #7374 --- docs/en_US/release_notes_6_10.rst | 1 + web/pgadmin/tools/sqleditor/__init__.py | 2 ++ .../static/js/components/QueryToolComponent.jsx | 4 ++++ .../static/js/components/dialogs/NewConnectionDialog.jsx | 9 ++++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/en_US/release_notes_6_10.rst b/docs/en_US/release_notes_6_10.rst index 6c742b12e..8c47292d3 100644 --- a/docs/en_US/release_notes_6_10.rst +++ b/docs/en_US/release_notes_6_10.rst @@ -25,6 +25,7 @@ Bug fixes | `Issue #7368 `_ - Ensure that unwanted APIs should not be getting called for BigAnimal. | `Issue #7372 `_ - Tell Docker to always pull the latest base images when building containers. | `Issue #7373 `_ - Fixed an issue with geometry window zoom mouse scroll not working. + | `Issue #7374 `_ - Fixed an issue when switching between connections in the Query Tool dropdown, the background and foreground colors should be changed. | `Issue #7376 `_ - Fixed an issue where a popup for unsaved changes appears when clicking on the open file button for a blank query editor. | `Issue #7380 `_ - Added support for multi-cell selection in the query tool grid. | `Issue #7383 `_ - Fixed an issue where Preferences are not saved when the dialog is maximized. diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index 20350bdae..af159d75b 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -2061,6 +2061,8 @@ def get_new_connection_data(sgid=None, sid=None): "value": server.serialize['id'], 'image': server_icon_and_background(connected, manager, server), + 'fgcolor': server.serialize['fgcolor'], + 'bgcolor': server.serialize['bgcolor'], 'connected': connected}) msg = "Success" diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx index bc37989a7..5ce227644 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx @@ -514,6 +514,8 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN sid: connectionData.sid, did: connectionData.did, title: connectionData.title, + fgcolor: connectionData.fgcolor, + bgcolor: connectionData.bgcolor, }, connected: respData.data.trans_id ? true : false, obtaining_conn: false, @@ -561,6 +563,8 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN conn_title: getTitle(pgAdmin, null, null, true, data.server_name, data.database_name, data.role || data.user, true), server_name: data.server_name, database_name: data.database_name, + bgcolor: data.bgcolor, + fgcolor: data.fgcolor, is_selected: true, }; diff --git a/web/pgadmin/tools/sqleditor/static/js/components/dialogs/NewConnectionDialog.jsx b/web/pgadmin/tools/sqleditor/static/js/components/dialogs/NewConnectionDialog.jsx index bfecf7535..e9a6589ce 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/dialogs/NewConnectionDialog.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/dialogs/NewConnectionDialog.jsx @@ -124,12 +124,15 @@ class NewConnectionSchema extends BaseUISchema { depChange: (state)=>{ /* Once the option is selected get the name */ /* Force sid to null, and set only if connected */ + let selectedServer = _.find(this.flatServers, (s)=>s.value==state.sid); return { - server_name: _.find(this.flatServers, (s)=>s.value==state.sid)?.label, + server_name: selectedServer?.label, did: null, user: null, role: null, sid: null, + fgcolor: selectedServer?.fgcolor, + bgcolor: selectedServer?.bgcolor, }; }, deferredDepChange: (state, source, topState, actionObj)=>{ @@ -181,6 +184,10 @@ class NewConnectionSchema extends BaseUISchema { id: 'server_name', label: '', type: 'text', visible: false, },{ id: 'database_name', label: '', type: 'text', visible: false, + },{ + id: 'bgcolor', label: '', type: 'text', visible: false, + },{ + id: 'fgcolor', label: '', type: 'text', visible: false, }, ]; }