From 3bcac26ff925cd0c2d87975c1efcb0f58242db71 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Thu, 26 Oct 2023 12:06:28 +0530 Subject: [PATCH] Fix multiple UI and SonarQube issues found when testing wcDocker changes. #6479 --- .../misc/bgprocess/static/js/Processes.jsx | 2 +- .../misc/statistics/static/js/Statistics.jsx | 1 - .../js/components/PreferencesComponent.jsx | 1 - web/pgadmin/static/bundle/app.js | 15 - web/pgadmin/static/js/BrowserComponent.jsx | 2 +- .../js/Dialogs/ConnectServerContent.jsx | 2 +- .../js/Dialogs/MasterPasswordContent.jsx | 2 +- .../static/js/Dialogs/NamedRestoreContent.jsx | 2 +- .../static/js/Dialogs/RenameTabContent.jsx | 2 +- .../static/js/SchemaView/MappedControl.jsx | 6 +- web/pgadmin/static/js/Theme/index.jsx | 4 + web/pgadmin/static/js/UtilityView.jsx | 2 +- .../static/js/components/ContextMenu.jsx | 2 +- .../js/components/ObjectBreadcrumbs.jsx | 2 +- .../js/helpers/Layout/LayoutIframeTab.jsx | 28 +- .../static/js/helpers/Layout/index.jsx | 81 ++- .../js/helpers/ObjectExplorerToolbar.jsx | 46 +- web/pgadmin/static/js/to_px.js | 6 +- web/pgadmin/static/js/tree/tree.js | 2 +- web/pgadmin/static/js/url_for.js | 39 -- .../components/DebuggerArgumentComponent.jsx | 3 +- .../js/components/ResultGridComponent.jsx | 7 +- .../js/components/QueryToolComponent.jsx | 2 +- .../sqleditor/static/js/sqleditor_title.js | 2 +- .../SchemaView/SchemaDialogViewEdit.spec.js | 27 - .../__mocks__/@material-ui/core.jsx | 5 +- .../javascript/__mocks__/popper.js.js | 10 +- .../javascript/__mocks__/react-data-grid.jsx | 12 +- .../javascript/components/Privilege.spec.js | 2 +- .../erd/ui_components/ERDTool.spec.js | 472 ------------------ web/regression/javascript/setup-jest.js | 2 +- .../tree/pgadmin_tree_state_save_spec.js | 22 - 32 files changed, 120 insertions(+), 693 deletions(-) delete mode 100644 web/regression/javascript/erd/ui_components/ERDTool.spec.js diff --git a/web/pgadmin/misc/bgprocess/static/js/Processes.jsx b/web/pgadmin/misc/bgprocess/static/js/Processes.jsx index 3c6bda8ac..30ea73577 100644 --- a/web/pgadmin/misc/bgprocess/static/js/Processes.jsx +++ b/web/pgadmin/misc/bgprocess/static/js/Processes.jsx @@ -117,7 +117,7 @@ export default function Processes() { /> ) - }, pgAdmin.Browser.stdW.md); + }, pgAdmin.Browser.stdW.md, pgAdmin.Browser.stdH.md); }, []); diff --git a/web/pgadmin/misc/statistics/static/js/Statistics.jsx b/web/pgadmin/misc/statistics/static/js/Statistics.jsx index be2a09377..548a63dca 100644 --- a/web/pgadmin/misc/statistics/static/js/Statistics.jsx +++ b/web/pgadmin/misc/statistics/static/js/Statistics.jsx @@ -157,7 +157,6 @@ function createSingleLineStatistics(data, prettifyFields) { return res; } -// {nodeData, node, treeNodeInfo, isActive, isStale, setIsStale} function Statistics({ nodeData, nodeItem, node, treeNodeInfo, isActive, isStale, setIsStale }) { const classes = useStyles(); const [tableData, setTableData] = React.useState([]); diff --git a/web/pgadmin/preferences/static/js/components/PreferencesComponent.jsx b/web/pgadmin/preferences/static/js/components/PreferencesComponent.jsx index b03676c4f..02aa30c24 100644 --- a/web/pgadmin/preferences/static/js/components/PreferencesComponent.jsx +++ b/web/pgadmin/preferences/static/js/components/PreferencesComponent.jsx @@ -559,7 +559,6 @@ export default function PreferencesComponent({ ...props }) { function () { pgAdmin.Browser.tree.destroy({ success: function () { - // pgAdmin.Browser.initializeBrowserTree(pgAdmin.Browser); return true; }, }); diff --git a/web/pgadmin/static/bundle/app.js b/web/pgadmin/static/bundle/app.js index 48fb830e7..1cacf50e3 100644 --- a/web/pgadmin/static/bundle/app.js +++ b/web/pgadmin/static/bundle/app.js @@ -50,21 +50,6 @@ define('app', [ // Create menus after all modules are initialized. MainMenuFactory.createMainMenus(); - // const menuContainerEle = document.querySelector('#main-menu-container'); - // if(menuContainerEle) { - // ReactDOM.render( - // - // - // , menuContainerEle - // ); - // } - - // ReactDOM.render( - // - // - // , document.querySelector('#object-breadcrumbs') - // ); - ReactDOM.render( diff --git a/web/pgadmin/static/js/BrowserComponent.jsx b/web/pgadmin/static/js/BrowserComponent.jsx index 29e5a636b..077cfa1eb 100644 --- a/web/pgadmin/static/js/BrowserComponent.jsx +++ b/web/pgadmin/static/js/BrowserComponent.jsx @@ -43,7 +43,7 @@ export const defaultTabsData = [ id: BROWSER_PANELS.DASHBOARD, title: gettext('Dashboard'), content: , closable: true, group: 'main' }, { - id: BROWSER_PANELS.PROPERTIES, title: gettext('Properties'), content: , closable: true, + id: BROWSER_PANELS.PROPERTIES, title: gettext('Properties'), content: , closable: true, group: 'main' }, { id: BROWSER_PANELS.SQL, title: gettext('SQL'), content: , closable: true, group: 'main' diff --git a/web/pgadmin/static/js/Dialogs/ConnectServerContent.jsx b/web/pgadmin/static/js/Dialogs/ConnectServerContent.jsx index 1e4cde83a..a99980471 100644 --- a/web/pgadmin/static/js/Dialogs/ConnectServerContent.jsx +++ b/web/pgadmin/static/js/Dialogs/ConnectServerContent.jsx @@ -31,7 +31,7 @@ export default function ConnectServerContent({closeModal, data, onOK, setHeight} const onTextChange = (e, id) => { let val = e; - if(e && e.target) { + if(e?.target) { val = e.target.value; } setFormData((prev)=>({...prev, [id]: val})); diff --git a/web/pgadmin/static/js/Dialogs/MasterPasswordContent.jsx b/web/pgadmin/static/js/Dialogs/MasterPasswordContent.jsx index 585ad066d..eadcbd9d1 100644 --- a/web/pgadmin/static/js/Dialogs/MasterPasswordContent.jsx +++ b/web/pgadmin/static/js/Dialogs/MasterPasswordContent.jsx @@ -34,7 +34,7 @@ export default function MasterPasswordContent({ closeModal, onResetPassowrd, onO const onTextChange = (e, id) => { let val = e; - if (e && e.target) { + if (e?.target) { val = e.target.value; } setFormData((prev) => ({ ...prev, [id]: val })); diff --git a/web/pgadmin/static/js/Dialogs/NamedRestoreContent.jsx b/web/pgadmin/static/js/Dialogs/NamedRestoreContent.jsx index 57c6b60db..8606ca83a 100644 --- a/web/pgadmin/static/js/Dialogs/NamedRestoreContent.jsx +++ b/web/pgadmin/static/js/Dialogs/NamedRestoreContent.jsx @@ -29,7 +29,7 @@ export default function NamedRestoreContent({closeModal, onOK, setHeight}) { const onTextChange = (e, id) => { let val = e; - if(e && e.target) { + if(e?.target) { val = e.target.value; } setFormData((prev)=>({...prev, [id]: val})); diff --git a/web/pgadmin/static/js/Dialogs/RenameTabContent.jsx b/web/pgadmin/static/js/Dialogs/RenameTabContent.jsx index 5c311f970..507105127 100644 --- a/web/pgadmin/static/js/Dialogs/RenameTabContent.jsx +++ b/web/pgadmin/static/js/Dialogs/RenameTabContent.jsx @@ -33,7 +33,7 @@ export default function RenameTabContent({ panelId, panelDocker, closeModal}) { const onTextChange = (e, id) => { let val = e; - if (e && e.target) { + if (e?.target) { val = e.target.value; } setFormData((prev) => ({ ...prev, [id]: val })); diff --git a/web/pgadmin/static/js/SchemaView/MappedControl.jsx b/web/pgadmin/static/js/SchemaView/MappedControl.jsx index 17e4ea387..03b8bbe05 100644 --- a/web/pgadmin/static/js/SchemaView/MappedControl.jsx +++ b/web/pgadmin/static/js/SchemaView/MappedControl.jsx @@ -25,7 +25,7 @@ function MappedFormControlBase({ type, value, id, onChange, className, visible, const name = id; const onTextChange = useCallback((e) => { let val = e; - if(e && e.target) { + if(e?.target) { val = e.target.value; } onChange && onChange(val); @@ -124,7 +124,7 @@ function MappedCellControlBase({ cell, value, id, optionsLoaded, onCellChange, v const name = id; const onTextChange = useCallback((e) => { let val = e; - if (e && e.target) { + if (e?.target) { val = e.target.value; } @@ -133,7 +133,7 @@ function MappedCellControlBase({ cell, value, id, optionsLoaded, onCellChange, v const onRadioChange = useCallback((e) => { let val =e; - if(e && e.target) { + if(e?.target) { val = e.target.checked; } onCellChange && onCellChange(val); diff --git a/web/pgadmin/static/js/Theme/index.jsx b/web/pgadmin/static/js/Theme/index.jsx index 8eeef438e..6b543097a 100644 --- a/web/pgadmin/static/js/Theme/index.jsx +++ b/web/pgadmin/static/js/Theme/index.jsx @@ -320,6 +320,10 @@ function getFinalTheme(baseTheme) { textarea: { fontFamily: 'inherit', }, + iframe: { + margin: 0, + padding: 0, + }, ...pickrOverride(baseTheme), ...uplotOverride(baseTheme), ...rcdockOverride(baseTheme), diff --git a/web/pgadmin/static/js/UtilityView.jsx b/web/pgadmin/static/js/UtilityView.jsx index ed1268ea9..6ea221ffc 100644 --- a/web/pgadmin/static/js/UtilityView.jsx +++ b/web/pgadmin/static/js/UtilityView.jsx @@ -195,7 +195,7 @@ function UtilityViewContent({panelId, schema, treeNodeInfo, actionType, formType onHelp={onHelp} onDataChange={()=>{/*This is intentional (SonarQube)*/}} confirmOnCloseReset={confirmOnReset} - hasSQL={nodeObj?nodeObj.hasSQL:false && (actionType === 'create' || actionType === 'edit')} + hasSQL={nodeObj?.hasSQL && (actionType === 'create' || actionType === 'edit')} getSQLValue={getSQLValue} isTabView={isTabView} disableSqlHelp={sqlHelpUrl == undefined || sqlHelpUrl == ''} diff --git a/web/pgadmin/static/js/components/ContextMenu.jsx b/web/pgadmin/static/js/components/ContextMenu.jsx index 2b64dd978..09258c29c 100644 --- a/web/pgadmin/static/js/components/ContextMenu.jsx +++ b/web/pgadmin/static/js/components/ContextMenu.jsx @@ -34,7 +34,7 @@ export default function ContextMenu({menuItems, position, onClose, label='contex {menuItems.length !=0 && menuItems.map((menuItem, i)=>{ const submenus = menuItem.getMenuItems?.(); if(submenus) { - return + return {submenus.map((submenuItem, si)=>{ return getPgMenuItem(submenuItem, i+'-'+si); })} diff --git a/web/pgadmin/static/js/components/ObjectBreadcrumbs.jsx b/web/pgadmin/static/js/components/ObjectBreadcrumbs.jsx index 3a99f2382..5da83dab1 100644 --- a/web/pgadmin/static/js/components/ObjectBreadcrumbs.jsx +++ b/web/pgadmin/static/js/components/ObjectBreadcrumbs.jsx @@ -13,7 +13,7 @@ const useStyles = makeStyles((theme)=>({ bottom: 0, width: 'auto', maxWidth: '99%', - zIndex: 9999, + zIndex: 1004, padding: '0.25rem 0.5rem', fontSize: '0.95em', color: theme.palette.background.default, diff --git a/web/pgadmin/static/js/helpers/Layout/LayoutIframeTab.jsx b/web/pgadmin/static/js/helpers/Layout/LayoutIframeTab.jsx index da5fcbc32..b097cabf8 100644 --- a/web/pgadmin/static/js/helpers/Layout/LayoutIframeTab.jsx +++ b/web/pgadmin/static/js/helpers/Layout/LayoutIframeTab.jsx @@ -16,6 +16,7 @@ export default function LayoutIframeTab({target, src, children}) { const updatePositionAndSize = () => { if (!selfRef.current) return; const rect = selfRef.current.getBoundingClientRect(); + rect.visibility = selfRef.current.closest('#'+target).style.visibility; // Only update the iframe's position if the position has actually changed if ( @@ -23,13 +24,15 @@ export default function LayoutIframeTab({target, src, children}) { rect.top !== lastKnownPosition.top || rect.left !== lastKnownPosition.left || rect.width !== lastKnownPosition.width || - rect.height !== lastKnownPosition.height + rect.height !== lastKnownPosition.height || + rect.visibility !== lastKnownPosition.visibility ) { iframeTarget.style.position = 'fixed'; // You can adjust this if needed iframeTarget.style.top = `${rect.top}px`; iframeTarget.style.left = `${rect.left}px`; iframeTarget.style.width = `${rect.width}px`; iframeTarget.style.height = `${rect.height}px`; + iframeTarget.style.display = rect.visibility == 'hidden' ? 'none' : ''; lastKnownPosition = rect; } @@ -45,17 +48,18 @@ export default function LayoutIframeTab({target, src, children}) { }, [iframeTarget]); return <> -
- { - if(r) setIframeTarget(r.querySelector('#'+target)); - }} container={document.querySelector('#layout-portal')}> - {src ? -