Skip to content

Commit

Permalink
Fix an issue where view/edit tool is not opening in workspace layout.
Browse files Browse the repository at this point in the history
Fixed few other theme related issues.
  • Loading branch information
adityatoshniwal committed Dec 17, 2024
1 parent eef20dc commit e84f4cd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
31 changes: 23 additions & 8 deletions web/pgadmin/misc/workspaces/static/js/WorkspaceToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { styled } from '@mui/material/styles';
import { WORKSPACES } from '../../../../browser/static/js/constants';
import { useWorkspace } from './WorkspaceProvider';
import { LAYOUT_EVENTS } from '../../../../static/js/helpers/Layout';
import gettext from 'sources/gettext';

const StyledWorkspaceButton = styled(PgIconButton)(({theme}) => ({
'&.Buttons-iconButtonDefault': {
Expand All @@ -28,10 +29,16 @@ const StyledWorkspaceButton = styled(PgIconButton)(({theme}) => ({
borderRadius: 0,
padding: '8px 6px',
height: '40px',
backgroundColor: theme.palette.background.default,
'&:hover': {
borderColor: 'transparent',
},
'&.active': {
borderRightColor: theme.otherVars.activeBorder,
backgroundColor: theme.otherVars.tree.bgSelected,
borderRightColor: theme.palette.primary.main,
},
'&.Mui-disabled': {
backgroundColor: theme.palette.background.default,
borderRightColor: 'transparent',
}
},
Expand Down Expand Up @@ -87,6 +94,14 @@ WorkspaceButton.propTypes = {
value: PropTypes.string
};

const Root = styled('div')(({theme}) => ({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
...theme.mixins.panelBorder.top,
...theme.mixins.panelBorder.right,
}));

export default function WorkspaceToolbar() {
const [menus, setMenus] = useState({
'settings': undefined,
Expand All @@ -107,15 +122,15 @@ export default function WorkspaceToolbar() {
}, []);

return (
<Box style={{borderTop: '1px solid #dde0e6', borderRight: '1px solid #dde0e6'}} display="flex" flexDirection="column" alignItems="center" gap="2px">
<WorkspaceButton icon={<AccountTreeRoundedIcon />} value={WORKSPACES.DEFAULT} />
<WorkspaceButton icon={<QueryToolIcon />} value={WORKSPACES.QUERY_TOOL} />
<WorkspaceButton icon={<TerminalRoundedIcon style={{height: '1.4rem'}}/>} value={WORKSPACES.PSQL_TOOL} />
<WorkspaceButton icon={<SchemaDiffIcon />} value={WORKSPACES.SCHEMA_DIFF_TOOL} />
<Root>
<WorkspaceButton icon={<AccountTreeRoundedIcon />} value={WORKSPACES.DEFAULT} title={gettext('Default Workspace')} tooltipPlacement="right" />
<WorkspaceButton icon={<QueryToolIcon />} value={WORKSPACES.QUERY_TOOL} title={gettext('Query Tool Workspace')} tooltipPlacement="right" />
<WorkspaceButton icon={<TerminalRoundedIcon style={{height: '1.4rem'}}/>} value={WORKSPACES.PSQL_TOOL} title={gettext('PSQL Tool Workspace')} tooltipPlacement="right" />
<WorkspaceButton icon={<SchemaDiffIcon />} value={WORKSPACES.SCHEMA_DIFF_TOOL} title={gettext('Schema Diff Workspace')} tooltipPlacement="right" />
<Box marginTop="auto">
<WorkspaceButton icon={<SettingsIcon />} menuItem={menus['settings']} />
<WorkspaceButton icon={<SettingsIcon />} menuItem={menus['settings']} title={gettext('Preferences')} tooltipPlacement="right" />
</Box>
</Box>
</Root>
);
}

2 changes: 1 addition & 1 deletion web/pgadmin/static/img/fonticon/compare.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions web/pgadmin/static/js/components/Buttons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ DefaultButton.propTypes = {


/* pgAdmin Icon button, takes Icon component as input */
export const PgIconButton = forwardRef(({icon, title, shortcut, className, splitButton, style, color, accesskey, isDropdown, ...props}, ref)=>{
export const PgIconButton = forwardRef(({icon, title, shortcut, className, splitButton, style, color, accesskey, isDropdown, tooltipPlacement, ...props}, ref)=>{
let shortcutTitle = null;
if(accesskey || shortcut) {
shortcutTitle = <ShortcutTitle title={title} accesskey={accesskey} shortcut={shortcut}/>;
Expand All @@ -192,7 +192,7 @@ export const PgIconButton = forwardRef(({icon, title, shortcut, className, split
}
} else if(color == 'primary') {
return (
<Tooltip title={shortcutTitle || title || ''} aria-label={title || ''} enterDelay={isDropdown ? 1500 : undefined}>
<Tooltip title={shortcutTitle || title || ''} aria-label={title || ''} enterDelay={isDropdown ? 1500 : undefined} placement={tooltipPlacement}>
<PrimaryButton ref={ref} style={style}
className={['Buttons-iconButton', (splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
accessKey={accesskey} data-label={title || ''} {...props}>
Expand All @@ -203,7 +203,7 @@ export const PgIconButton = forwardRef(({icon, title, shortcut, className, split
);
} else {
return (
<Tooltip title={shortcutTitle || title || ''} aria-label={title || ''} enterDelay={isDropdown ? 1500 : undefined}>
<Tooltip title={shortcutTitle || title || ''} aria-label={title || ''} enterDelay={isDropdown ? 1500 : undefined} placement={tooltipPlacement}>
<DefaultButton ref={ref} style={style}
className={['Buttons-iconButton', 'Buttons-iconButtonDefault',(splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
accessKey={accesskey} data-label={title || ''} {...props}>
Expand All @@ -225,6 +225,7 @@ PgIconButton.propTypes = {
disabled: PropTypes.bool,
splitButton: PropTypes.bool,
isDropdown: PropTypes.bool,
tooltipPlacement: PropTypes.string,
};

export const PgButtonGroup = forwardRef(({children, ...props}, ref)=>{
Expand Down
9 changes: 5 additions & 4 deletions web/pgadmin/tools/sqleditor/static/js/SQLEditorModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,22 +213,23 @@ export default class SQLEditor {
let browser_preferences = usePreferences.getState().getPreferencesForModule('browser');
let open_new_tab = browser_preferences.new_browser_tab_open;
const [icon, tooltip] = panelTitleFunc.getQueryToolIcon(panel_title, is_query_tool);
let selectedNodeInfo = pgAdmin.Browser.tree.getTreeNodeHierarchy(
pgAdmin.Browser.tree.selected()
);

pgAdmin.Browser.Events.trigger(
'pgadmin:tool:show',
`${BROWSER_PANELS.QUERY_TOOL}_${trans_id}`,
panel_url,
{...params, title: _.escape(panel_title.replace('\\', '\\\\'))},
{...params, title: _.escape(panel_title.replace('\\', '\\\\')), selectedNodeInfo: JSON.stringify(selectedNodeInfo)},
{title: panel_title, icon: icon, tooltip: tooltip, renamable: true},
Boolean(open_new_tab?.includes('qt'))
);
return true;
}

async loadComponent(container, params) {
let selectedNodeInfo = pgWindow.pgAdmin.Browser.tree.getTreeNodeHierarchy(
pgWindow.pgAdmin.Browser.tree.selected()
);
const selectedNodeInfo = params.selectedNodeInfo ? JSON.parse(params.selectedNodeInfo) : params.selectedNodeInfo;
pgAdmin.Browser.keyboardNavigation.init();
await listenPreferenceBroadcast();
const root = ReactDOM.createRoot(container);
Expand Down

0 comments on commit e84f4cd

Please sign in to comment.