diff --git a/web/pgadmin/settings/__init__.py b/web/pgadmin/settings/__init__.py index b91d4efc1..d3b903f82 100644 --- a/web/pgadmin/settings/__init__.py +++ b/web/pgadmin/settings/__init__.py @@ -279,7 +279,7 @@ def save_application_state(): tool_data = fernet.encrypt(json.dumps(data['tool_data']).encode()) connection_info = data['connection_info'] \ if 'connection_info' in data else None - if ('open_file_name' in connection_info and + if (connection_info and 'open_file_name' in connection_info and connection_info['open_file_name']): file_path = get_complete_file_path(connection_info['open_file_name']) connection_info['last_saved_file_hash'] = ( @@ -342,7 +342,7 @@ def get_application_state(): res = [] for row in result: connection_info = row.connection_info - if ('open_file_name' in connection_info and + if (connection_info and 'open_file_name' in connection_info and connection_info['open_file_name']): file_path = get_complete_file_path( connection_info['open_file_name']) diff --git a/web/pgadmin/static/js/ToolErrorView.jsx b/web/pgadmin/static/js/ToolErrorView.jsx index f043b799c..4db6b1126 100644 --- a/web/pgadmin/static/js/ToolErrorView.jsx +++ b/web/pgadmin/static/js/ToolErrorView.jsx @@ -3,8 +3,7 @@ import React from 'react'; import gettext from 'sources/gettext'; import { LAYOUT_EVENTS } from './helpers/Layout'; import { styled } from '@mui/material/styles'; -import { Box } from '@mui/material'; -import { FormHelperText } from '@mui/material'; +import { FormHelperText, Box } from '@mui/material'; import HTMLReactParse from 'html-react-parser'; const StyledBox = styled(Box)(({theme}) => ({ @@ -34,6 +33,4 @@ ToolErrorView.propTypes = { error: PropTypes.string, panelId: PropTypes.string, panelDocker: PropTypes.object, - pgAdmin: PropTypes.object, - toolName: PropTypes.string, }; \ No newline at end of file diff --git a/web/pgadmin/static/js/ToolView.jsx b/web/pgadmin/static/js/ToolView.jsx index aa1947f3e..de6830d0f 100644 --- a/web/pgadmin/static/js/ToolView.jsx +++ b/web/pgadmin/static/js/ToolView.jsx @@ -61,7 +61,8 @@ export default function ToolView({dockerObj}) { let handler = pgAdmin.Browser.getDockerHandler?.(panelId, dockerObj); const deregisterRemove = handler.docker.eventBus.registerListener(LAYOUT_EVENTS.REMOVE, (closePanelId)=>{ deleteToolData(panelId, closePanelId); - deregisterRemove(); + if(panelId == closePanelId){ + deregisterRemove();} }); handler.focus(); diff --git a/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx b/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx index a397257f7..8c3c10281 100644 --- a/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx +++ b/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx @@ -32,8 +32,7 @@ import { ResultGridComponent } from './ResultGridComponent'; import { openSocket, socketApiGet } from '../../../../../static/js/socket_instance'; import { parseApiError } from '../../../../../static/js/api_instance'; import { usePgAdmin } from '../../../../../static/js/PgAdminProvider'; -import { useApplicationState } from '../../../../../settings/static/ApplicationStateProvider'; -import { getToolData } from '../../../../../settings/static/ApplicationStateProvider'; +import { useApplicationState, getToolData } from '../../../../../settings/static/ApplicationStateProvider'; function generateFinalScript(script_array, scriptHeader, script_body) { _.each(Object.keys(script_array).reverse(), function (s) { diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx index 894520061..df59bcf19 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx @@ -348,14 +348,12 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN if(qtState.params.file_deleted == 'false' && qtState.params.is_editor_dirty == 'false'){ // call load file from disk as no fil changes eventBus.current.fireEvent(QUERY_TOOL_EVENTS.LOAD_FILE, qtState.params.open_file_name, qtState.params?.storage); - }else{ - if(qtState.params.file_deleted != 'true'){ - if(qtState.params.external_file_changes == 'true'){ - loadSqlFromLocalStorage = false; - eventBus.current.fireEvent(QUERY_TOOL_EVENTS.WARN_RELOAD_FILE, qtState.params.open_file_name, sqlId); - }else{ - eventBus.current.fireEvent(QUERY_TOOL_EVENTS.LOAD_FILE_DONE, qtState.params.open_file_name, true); - } + }else if(qtState.params.file_deleted != 'true'){ + if(qtState.params.external_file_changes == 'true'){ + loadSqlFromLocalStorage = false; + eventBus.current.fireEvent(QUERY_TOOL_EVENTS.WARN_RELOAD_FILE, qtState.params.open_file_name, sqlId); + }else{ + eventBus.current.fireEvent(QUERY_TOOL_EVENTS.LOAD_FILE_DONE, qtState.params.open_file_name, true); } } } diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx index fd81247a9..141c25cc4 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx @@ -25,9 +25,8 @@ import usePreferences from '../../../../../../preferences/static/js/store'; import { getTitle } from '../../sqleditor_title'; import PropTypes from 'prop-types'; import { MODAL_DIALOGS } from '../QueryToolConstants'; -import { useApplicationState } from '../../../../../../settings/static/ApplicationStateProvider'; +import { useApplicationState, getToolData } from '../../../../../../settings/static/ApplicationStateProvider'; import { useDelayDebounce } from '../../../../../../static/js/custom_hooks'; -import { getToolData } from '../../../../../../settings/static/ApplicationStateProvider'; async function registerAutocomplete(editor, api, transId) { diff --git a/web/regression/feature_utils/locators.py b/web/regression/feature_utils/locators.py index 503fdb07c..5d96c488f 100644 --- a/web/regression/feature_utils/locators.py +++ b/web/regression/feature_utils/locators.py @@ -48,6 +48,22 @@ class NavMenuLocators: maintenance_obj_css = "li[data-label='Maintenance...']" + query_tool_menu_css = "li[data-label='Query Tool']" + + show_system_objects_pref_label_xpath = \ + "//label[contains(text(), 'Show system objects?')]" + + maximize_pref_dialogue_css = "button[data-label='Maximize']" + + specified_pref_node_exp_status = \ + "//*[@id='treeContainer']//div//span[text()='{0}']" + + specified_preference_tree_node = \ + "//*[@id='treeContainer']//div//span[text()='{0}']" \ + + specified_sub_node_of_pref_tree_node = \ + "//*[@id='treeContainer']//div//span[text()='{1}']" + insert_bracket_pair_switch_btn = \ ("//div[label[text()='Insert bracket pairs?']]/" "following-sibling::div//input") diff --git a/web/regression/feature_utils/pgadmin_page.py b/web/regression/feature_utils/pgadmin_page.py index 3e0c442e0..e3f9a6289 100644 --- a/web/regression/feature_utils/pgadmin_page.py +++ b/web/regression/feature_utils/pgadmin_page.py @@ -154,12 +154,13 @@ class PgadminPage: "button[data-label='Tools']")) WebDriverWait(self.driver, 3).until( EC.visibility_of_element_located( - (By.CSS_SELECTOR, "li[data-label='Query Tool']"))) - ActionChains(self.driver).move_to_element( + (By.CSS_SELECTOR, NavMenuLocators.query_tool_menu_css))) + (ActionChains(self.driver).move_to_element( self.driver.find_element( - By.CSS_SELECTOR, "li[data-label='Query Tool']")).perform() + By.CSS_SELECTOR, NavMenuLocators.query_tool_menu_css)) + .perform()) self.click_element(self.find_by_css_selector( - "li[data-label='Query Tool']")) + NavMenuLocators.query_tool_menu_css)) self.driver.switch_to.default_content() WebDriverWait(self.driver, 10).until(