mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 08:46:39 -06:00
Honour the node type (if provided) in the menu item, and disable it on
any other nodes.
This commit is contained in:
parent
d20db0f43e
commit
748497916e
@ -9,7 +9,7 @@ function(_, S, pgAdmin, $) {
|
||||
var MenuItem = pgAdmin.Browser.MenuItem = function(opts) {
|
||||
var menu_opts = [
|
||||
'name', 'label', 'priority', 'module', 'callback', 'data', 'enable',
|
||||
'category', 'target', 'url', 'icon'
|
||||
'category', 'target', 'url', 'icon', 'node'
|
||||
],
|
||||
defaults = {
|
||||
url: '#',
|
||||
@ -119,8 +119,20 @@ function(_, S, pgAdmin, $) {
|
||||
* Checks this menu enable/disable state based on the selection.
|
||||
*/
|
||||
disabled: function(node, item) {
|
||||
if (this.enable == undefined)
|
||||
return false;
|
||||
if (this.enable == undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.node) {
|
||||
if (!node) {
|
||||
return true;
|
||||
}
|
||||
if (_.isArray(this.node) ? (
|
||||
_.indexOf(this.node, node) == -1
|
||||
) : (this.node != node._type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (_.isBoolean(this.enable)) return !this.enable;
|
||||
if (_.isFunction(this.enable)) return !this.enable.apply(this.module, [node, item, this.data]);
|
||||
|
@ -591,7 +591,8 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
|
||||
target: m.target, icon: m.icon,
|
||||
enable: (m.enable == '' ? true : (_.isString(m.enable) &&
|
||||
m.enable.toLowerCase() == 'false') ?
|
||||
false : m.enable)
|
||||
false : m.enable),
|
||||
node: m.node
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user