Skip to content

Commit a79a8f0

Browse files
Show tooltips when icons are disabled.#8449
1 parent cf2328d commit a79a8f0

File tree

4 files changed

+31
-39
lines changed

4 files changed

+31
-39
lines changed

web/pgadmin/static/js/components/Buttons.jsx

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -176,44 +176,29 @@ export const PgIconButton = forwardRef(({icon, title, shortcut, className, split
176176
shortcutTitle = <ShortcutTitle title={title} accesskey={accesskey} shortcut={shortcut}/>;
177177
}
178178

179-
/* Tooltip does not work for disabled items */
180-
if(props.disabled) {
181-
if(color == 'primary') {
182-
return (
183-
<PrimaryButton ref={ref} style={style}
184-
className={['Buttons-iconButton', (splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
185-
accessKey={accesskey} data-label={title || ''} {...props}>
186-
{icon}
187-
</PrimaryButton>
188-
);
189-
} else {
190-
return (
191-
<DefaultButton ref={ref} style={style}
192-
className={['Buttons-iconButton', 'Buttons-iconButtonDefault',(splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
193-
accessKey={accesskey} data-label={title || ''} {...props}>
194-
{icon}
195-
</DefaultButton>
196-
);
197-
}
198-
} else if(color == 'primary') {
179+
if(color == 'primary') {
199180
return (
200181
<Tooltip title={shortcutTitle || title || ''} aria-label={title || ''} enterDelay={isDropdown ? 1500 : undefined} placement={tooltipPlacement}>
201-
<PrimaryButton ref={ref} style={style}
202-
className={['Buttons-iconButton', (splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
203-
accessKey={accesskey} data-label={title || ''} {...props}>
204-
{icon}
205-
</PrimaryButton>
182+
<span>
183+
<PrimaryButton ref={ref} style={style}
184+
className={['Buttons-iconButton', (splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
185+
accessKey={accesskey} data-label={title || ''} {...props}>
186+
{icon}
187+
</PrimaryButton>
188+
</span>
206189
</Tooltip>
207190

208191
);
209192
} else {
210193
return (
211194
<Tooltip title={shortcutTitle || title || ''} aria-label={title || ''} enterDelay={isDropdown ? 1500 : undefined} placement={tooltipPlacement}>
212-
<DefaultButton ref={ref} style={style}
213-
className={['Buttons-iconButton', 'Buttons-iconButtonDefault',(splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
214-
accessKey={accesskey} data-label={title || ''} {...props}>
215-
{icon}
216-
</DefaultButton>
195+
<span>
196+
<DefaultButton ref={ref} style={style}
197+
className={['Buttons-iconButton', 'Buttons-iconButtonDefault',(splitButton ? 'Buttons-splitButton' : ''), className].join(' ')}
198+
accessKey={accesskey} data-label={title || ''} {...props}>
199+
{icon}
200+
</DefaultButton>
201+
</span>
217202
</Tooltip>
218203
);
219204
}

web/pgadmin/static/js/helpers/ObjectExplorerToolbar.jsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@ export default function ObjectExplorerToolbar() {
4242
const browserPref = usePreferences().getPreferencesForModule('browser');
4343
const pgAdmin = usePgAdmin();
4444
const checkMenuState = ()=>{
45-
const viewMenus = pgAdmin.Browser.MainMenus.
46-
find((m)=>(m.name=='object'))?.
47-
menuItems?.
48-
find((m)=>(m.name=='view_data'))?.
49-
menu_items;
45+
// Find the 'object' menu and get its menuItems &
46+
// Try to find 'view_data' in the object menu and get its menu_items
47+
let objectMenu = pgAdmin.Browser.MainMenus.find((m) => (m.name == 'object'))?.menuItems;
48+
let viewMenus = objectMenu?.find((m) => (m.name == 'view_data'))?.menu_items;
49+
50+
// If view_data not found in object menu or it doesn't have menu_items
51+
if (_.isUndefined(viewMenus)) {
52+
// Find the 'tools' menu and get its menuItems &
53+
// Try to find 'view_data' in the tools menu and get its menu_items
54+
let toolsMenu = pgAdmin.Browser.MainMenus.find((m) => (m.name == 'tools'))?.menuItems;
55+
viewMenus = toolsMenu?.find((m) => (m.name == 'view_data'))?.menu_items;
56+
}
5057

5158
const toolsMenus = pgAdmin.Browser.MainMenus.
5259
find((m)=>(m.name=='tools'))?.

web/pgadmin/tools/sqleditor/static/js/SQLEditorModule.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export default class SQLEditor {
115115
data: {
116116
mnuid: 3,
117117
},
118-
applies: ['context', 'object'],
118+
applies: ['context', 'object', 'tools'],
119119
callback: 'showViewData',
120120
enable: this.viewMenuEnabled,
121121
category: 'view_data',
@@ -154,7 +154,7 @@ export default class SQLEditor {
154154
data: {
155155
mnuid: 4,
156156
},
157-
applies: ['context', 'object'],
157+
applies: ['context', 'object', 'tools'],
158158
callback: 'showFilteredRow',
159159
enable: this.viewMenuEnabled,
160160
category: 'view_data',

web/regression/javascript/file_manager/FileManager.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe('FileManger', ()=>{
162162

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

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

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

182182
describe('getComparator', ()=>{

0 commit comments

Comments
 (0)