mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
- Move pgadmin4-treeview to pgAdmin main repo.
- Use react based context menu for browser tree. #5615. - Fix feature tests failure.
This commit is contained in:
@@ -80,34 +80,8 @@ export default class MainMenuFactory {
|
||||
});
|
||||
}
|
||||
|
||||
static getContextMenu(menuList, item, node) {
|
||||
static getContextMenu(menuList) {
|
||||
Menu.sortMenus(menuList);
|
||||
|
||||
let ctxMenus = {};
|
||||
let ctxIndex = 1;
|
||||
menuList.forEach(ctx => {
|
||||
let ctx_uid = _.uniqueId('ctx_');
|
||||
let sub_ctx_item = {};
|
||||
ctx.checkAndSetDisabled(node, item);
|
||||
if (ctx.getMenuItems()) {
|
||||
// Menu.sortMenus(ctx.getMenuItems());
|
||||
ctx.getMenuItems().forEach((c) => {
|
||||
c.checkAndSetDisabled(node, item);
|
||||
if (!c.isDisabled) {
|
||||
sub_ctx_item[ctx_uid + _.uniqueId('_sub_')] = c.getContextItem(c.label, c.isDisabled);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!ctx.isDisabled) {
|
||||
if(ctx.type == 'separator') {
|
||||
ctxMenus[ctx_uid + '_' + ctx.priority + '_' + + ctxIndex + '_sep'] = '----';
|
||||
} else {
|
||||
ctxMenus[ctx_uid + '_' + ctx.priority + '_' + + ctxIndex + '_itm'] = ctx.getContextItem(ctx.label, ctx.isDisabled, sub_ctx_item);
|
||||
}
|
||||
}
|
||||
ctxIndex++;
|
||||
});
|
||||
|
||||
return ctxMenus;
|
||||
return menuList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ define('pgadmin.browser', [
|
||||
let menuItemList = obj.getMenuList('object', item, d);
|
||||
objectMenu && MainMenuFactory.refreshMainMenuItems(objectMenu, menuItemList);
|
||||
let ctxMenuList = obj.getMenuList('context', item, d, true);
|
||||
obj.BrowserContextMenu = MainMenuFactory.getContextMenu(ctxMenuList, item, d);
|
||||
obj.BrowserContextMenu = MainMenuFactory.getContextMenu(ctxMenuList);
|
||||
} else {
|
||||
objectMenu && MainMenuFactory.refreshMainMenuItems(objectMenu, [
|
||||
MainMenuFactory.createMenuItem({
|
||||
@@ -564,30 +564,6 @@ define('pgadmin.browser', [
|
||||
obj?.editor?.refresh();
|
||||
}, 10);
|
||||
|
||||
// Build the treeview context menu
|
||||
$('#tree').contextMenu({
|
||||
selector: '.file-entry',
|
||||
autoHide: false,
|
||||
build: function(element) {
|
||||
let item = obj.tree.itemFrom(element),
|
||||
context_menu = {};
|
||||
|
||||
if(item) obj.tree.select(item);
|
||||
context_menu = obj.BrowserContextMenu;
|
||||
|
||||
return {
|
||||
autoHide: false,
|
||||
items: context_menu,
|
||||
};
|
||||
},
|
||||
events: {
|
||||
hide: function() {
|
||||
// Return focus to the tree
|
||||
obj.keyboardNavigation.bindLeftTree();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Register scripts and add menus
|
||||
pgBrowser.utils.registerScripts(this);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import * as commonUtils from '../../../static/js/utils';
|
||||
import dialogTabNavigator from '../../../static/js/dialog_tab_navigator';
|
||||
import * as keyboardFunc from 'sources/keyboard_shortcuts';
|
||||
import pgWindow from 'sources/window';
|
||||
import gettext from 'sources/gettext';
|
||||
|
||||
const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
|
||||
@@ -130,10 +131,27 @@ _.extend(pgBrowser.keyboardNavigation, {
|
||||
},
|
||||
bindMainMenu: function(event, combo) {
|
||||
const shortcut_obj = this.keyboardShortcut;
|
||||
if (combo === shortcut_obj.file_shortcut) $('#mnu_file a.dropdown-toggle').dropdown('toggle');
|
||||
if (combo === shortcut_obj.object_shortcut) $('#mnu_obj a.dropdown-toggle').first().dropdown('toggle');
|
||||
if (combo === shortcut_obj.tools_shortcut) $('#mnu_tools a.dropdown-toggle').dropdown('toggle');
|
||||
if (combo === shortcut_obj.help_shortcut) $('#mnu_help a.dropdown-toggle').dropdown('toggle');
|
||||
let menuLabel = null;
|
||||
switch (combo) {
|
||||
case shortcut_obj.file_shortcut:
|
||||
menuLabel = gettext('File');
|
||||
break;
|
||||
case shortcut_obj.object_shortcut:
|
||||
menuLabel = gettext('Object');
|
||||
break;
|
||||
case shortcut_obj.tools_shortcut:
|
||||
menuLabel = gettext('Tools');
|
||||
break;
|
||||
case shortcut_obj.help_shortcut:
|
||||
menuLabel = gettext('Help');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(menuLabel) {
|
||||
document.querySelector(`#main-menu-container button[data-label="${menuLabel}"]`)?.click();
|
||||
}
|
||||
},
|
||||
bindRightPanel: function(event, combo) {
|
||||
let allPanels = pgAdmin.Browser.docker.findPanels();
|
||||
|
||||
Reference in New Issue
Block a user