mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -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 MenuItem = pgAdmin.Browser.MenuItem = function(opts) {
|
||||||
var menu_opts = [
|
var menu_opts = [
|
||||||
'name', 'label', 'priority', 'module', 'callback', 'data', 'enable',
|
'name', 'label', 'priority', 'module', 'callback', 'data', 'enable',
|
||||||
'category', 'target', 'url', 'icon'
|
'category', 'target', 'url', 'icon', 'node'
|
||||||
],
|
],
|
||||||
defaults = {
|
defaults = {
|
||||||
url: '#',
|
url: '#',
|
||||||
@ -119,8 +119,20 @@ function(_, S, pgAdmin, $) {
|
|||||||
* Checks this menu enable/disable state based on the selection.
|
* Checks this menu enable/disable state based on the selection.
|
||||||
*/
|
*/
|
||||||
disabled: function(node, item) {
|
disabled: function(node, item) {
|
||||||
if (this.enable == undefined)
|
if (this.enable == undefined) {
|
||||||
return false;
|
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 (_.isBoolean(this.enable)) return !this.enable;
|
||||||
if (_.isFunction(this.enable)) return !this.enable.apply(this.module, [node, item, this.data]);
|
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,
|
target: m.target, icon: m.icon,
|
||||||
enable: (m.enable == '' ? true : (_.isString(m.enable) &&
|
enable: (m.enable == '' ? true : (_.isString(m.enable) &&
|
||||||
m.enable.toLowerCase() == 'false') ?
|
m.enable.toLowerCase() == 'false') ?
|
||||||
false : m.enable)
|
false : m.enable),
|
||||||
|
node: m.node
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user