Fix the SonarQube issues and issues reported during testing. #3319

pull/8838/head^2
Yogesh Mahajan 2025-06-13 13:14:36 +05:30 committed by GitHub
parent 22fd919220
commit 67c18cb082
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 34 additions and 23 deletions

View File

@ -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'])

View File

@ -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,
};

View File

@ -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();

View File

@ -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) {

View File

@ -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);
}
}
}

View File

@ -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) {

View File

@ -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")

View File

@ -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(