Honour the node type (if provided) in the menu item, and disable it on

any other nodes.
This commit is contained in:
Ashesh Vashi 2016-05-25 01:15:07 +05:30
parent d20db0f43e
commit 748497916e
2 changed files with 17 additions and 4 deletions

View File

@ -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]);

View File

@ -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 {