Fixed an issue where object explorer toolbar button not showing shortcut in the tooltip.#7316

This commit is contained in:
Aditya Toshniwal 2024-06-20 11:31:11 +05:30
parent fedbe550db
commit 9026f46220
2 changed files with 10 additions and 8 deletions

View File

@ -428,7 +428,7 @@ def register_browser_preferences(self):
)
)
ope_new_tab_options = [
open_new_tab_options = [
{'label': gettext('Query Tool'), 'value': 'qt'},
{'label': gettext('Debugger'), 'value': 'debugger'},
{'label': gettext('Schema Diff'), 'value': 'schema_diff'},
@ -436,14 +436,14 @@ def register_browser_preferences(self):
# Allow psq tool to open in new browser tab if ENABLE_PSQL is set to True
if config.ENABLE_PSQL:
ope_new_tab_options.append(
open_new_tab_options.append(
{'label': gettext('PSQL Tool'), 'value': 'psql_tool'})
self.open_in_new_tab = self.preference.register(
'tab_settings', 'new_browser_tab_open',
gettext("Open in new browser tab"), 'select', None,
category_label=PREF_LABEL_OPTIONS,
options=ope_new_tab_options,
options=open_new_tab_options,
help_str=gettext(
'Select Query Tool, Debugger, Schema Diff, ERD Tool '
'or PSQL Tool from the drop-down to set '

View File

@ -7,11 +7,12 @@ import { PgButtonGroup, PgIconButton } from '../components/Buttons';
import _ from 'lodash';
import PropTypes from 'prop-types';
import CustomPropTypes from '../custom_prop_types';
import usePreferences from '../../../preferences/static/js/store';
function ToolbarButton({menuItem, icon, ...props}) {
function ToolbarButton({menuItem, ...props}) {
return (
<PgIconButton title={menuItem?.label??''} icon={icon} {...props} size="xs"
<PgIconButton title={menuItem?.label??''} {...props} size="xs"
disabled={menuItem?.isDisabled??true} onClick={()=>menuItem?.callback()} />
);
}
@ -28,6 +29,7 @@ export default function ObjectExplorerToolbar() {
'search_objects': undefined,
'psql': undefined,
});
const browserPref = usePreferences().getPreferencesForModule('browser');
const pgAdmin = usePgAdmin();
const checkMenuState = ()=>{
const viewMenus = pgAdmin.Browser.MainMenus.
@ -60,10 +62,10 @@ export default function ObjectExplorerToolbar() {
return (
<Box display="flex" alignItems="center" gap="2px">
<PgButtonGroup size="small">
<ToolbarButton icon={<QueryToolIcon />} menuItem={menus['query_tool']} />
<ToolbarButton icon={<ViewDataIcon />} menuItem={menus['view_all_rows_context']} />
<ToolbarButton icon={<QueryToolIcon />} menuItem={menus['query_tool']} shortcut={browserPref?.sub_menu_query_tool} />
<ToolbarButton icon={<ViewDataIcon />} menuItem={menus['view_all_rows_context']} shortcut={browserPref?.sub_menu_view_data} />
<ToolbarButton icon={<RowFilterIcon />} menuItem={menus['view_filtered_rows_context']} />
<ToolbarButton icon={<SearchOutlinedIcon style={{height: '1.4rem'}} />} menuItem={menus['search_objects']} />
<ToolbarButton icon={<SearchOutlinedIcon style={{height: '1.4rem'}} />} menuItem={menus['search_objects']} shortcut={browserPref?.sub_menu_search_objects} />
{!_.isUndefined(menus['psql']) && <ToolbarButton icon={<TerminalIcon />} menuItem={menus['psql']} />}
</PgButtonGroup>
</Box>