Skip to content

Commit

Permalink
Show tooltips when icons are disabled.#8449
Browse files Browse the repository at this point in the history
  • Loading branch information
RohitBhati8269 committed Mar 4, 2025
1 parent cf2328d commit a79a8f0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 39 deletions.
45 changes: 15 additions & 30 deletions web/pgadmin/static/js/components/Buttons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,44 +176,29 @@ export const PgIconButton = forwardRef(({icon, title, shortcut, className, split
shortcutTitle = <ShortcutTitle title={title} accesskey={accesskey} shortcut={shortcut}/>;
}

/* Tooltip does not work for disabled items */
if(props.disabled) {
if(color == 'primary') {
return (
<PrimaryButton ref={ref} style={style}
className={['Buttons-iconButton', (splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
accessKey={accesskey} data-label={title || ''} {...props}>
{icon}
</PrimaryButton>
);
} else {
return (
<DefaultButton ref={ref} style={style}
className={['Buttons-iconButton', 'Buttons-iconButtonDefault',(splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
accessKey={accesskey} data-label={title || ''} {...props}>
{icon}
</DefaultButton>
);
}
} else if(color == 'primary') {
if(color == 'primary') {
return (
<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}>
{icon}
</PrimaryButton>
<span>
<PrimaryButton ref={ref} style={style}
className={['Buttons-iconButton', (splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
accessKey={accesskey} data-label={title || ''} {...props}>
{icon}
</PrimaryButton>
</span>
</Tooltip>

);
} else {
return (
<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}>
{icon}
</DefaultButton>
<span>
<DefaultButton ref={ref} style={style}
className={['Buttons-iconButton', 'Buttons-iconButtonDefault',(splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
accessKey={accesskey} data-label={title || ''} {...props}>
{icon}
</DefaultButton>
</span>
</Tooltip>
);
}
Expand Down
17 changes: 12 additions & 5 deletions web/pgadmin/static/js/helpers/ObjectExplorerToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,18 @@ export default function ObjectExplorerToolbar() {
const browserPref = usePreferences().getPreferencesForModule('browser');
const pgAdmin = usePgAdmin();
const checkMenuState = ()=>{
const viewMenus = pgAdmin.Browser.MainMenus.
find((m)=>(m.name=='object'))?.
menuItems?.
find((m)=>(m.name=='view_data'))?.
menu_items;
// Find the 'object' menu and get its menuItems &
// Try to find 'view_data' in the object menu and get its menu_items
let objectMenu = pgAdmin.Browser.MainMenus.find((m) => (m.name == 'object'))?.menuItems;
let viewMenus = objectMenu?.find((m) => (m.name == 'view_data'))?.menu_items;

// If view_data not found in object menu or it doesn't have menu_items
if (_.isUndefined(viewMenus)) {
// Find the 'tools' menu and get its menuItems &
// Try to find 'view_data' in the tools menu and get its menu_items
let toolsMenu = pgAdmin.Browser.MainMenus.find((m) => (m.name == 'tools'))?.menuItems;
viewMenus = toolsMenu?.find((m) => (m.name == 'view_data'))?.menu_items;
}

const toolsMenus = pgAdmin.Browser.MainMenus.
find((m)=>(m.name=='tools'))?.
Expand Down
4 changes: 2 additions & 2 deletions web/pgadmin/tools/sqleditor/static/js/SQLEditorModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class SQLEditor {
data: {
mnuid: 3,
},
applies: ['context', 'object'],
applies: ['context', 'object', 'tools'],
callback: 'showViewData',
enable: this.viewMenuEnabled,
category: 'view_data',
Expand Down Expand Up @@ -154,7 +154,7 @@ export default class SQLEditor {
data: {
mnuid: 4,
},
applies: ['context', 'object'],
applies: ['context', 'object', 'tools'],
callback: 'showFilteredRow',
enable: this.viewMenuEnabled,
category: 'view_data',
Expand Down
4 changes: 2 additions & 2 deletions web/regression/javascript/file_manager/FileManager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('FileManger', ()=>{

await user.click(ctrl.container.querySelector('[name="menu-shared-storage"]'));
await user.click(ctrl.container.querySelector('[data-label="Shared Storage"]'));
expect(ctrl.container.querySelector('button[aria-label="Shared Storage"]')).not.toBeNull();
expect(ctrl.container.querySelector('button[aria-label="Shared Storage"]')).toBeNull();
});

it('Change Storage to My Storage', async ()=>{
Expand All @@ -176,7 +176,7 @@ describe('FileManger', ()=>{

await user.click(ctrl.container.querySelector('[name="menu-shared-storage"]'));
await user.click(ctrl.container.querySelector('[data-label="My Storage"]'));
expect(ctrl.container.querySelector('button[aria-label="My Storage"]')).not.toBeNull();
expect(ctrl.container.querySelector('button[aria-label="My Storage"]')).toBeNull();
});

describe('getComparator', ()=>{
Expand Down

0 comments on commit a79a8f0

Please sign in to comment.