2017-05-12 12:10:46 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
|
//
|
2019-01-02 15:54:12 +05:30
|
|
|
// Copyright (C) 2013 - 2019, The pgAdmin Development Team
|
2017-05-12 12:10:46 +01:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
define(['jquery', 'underscore', 'underscore.string'],
|
|
|
|
|
function ($, _, S) {
|
|
|
|
|
|
|
|
|
|
var check_node_visibility = function (pgBrowser, node_type) {
|
|
|
|
|
if(_.isUndefined(node_type) || _.isNull(node_type)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Target actual node instead of collection.
|
|
|
|
|
// If node is disabled then there is no meaning of
|
|
|
|
|
// adding collection node menu
|
2018-01-12 12:59:51 +05:30
|
|
|
if(S.startsWith(node_type, 'coll-')) {
|
|
|
|
|
node_type = node_type.replace('coll-', '');
|
2017-05-12 12:10:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Exclude non-applicable nodes
|
|
|
|
|
var nodes_not_supported = [
|
2018-01-12 12:59:51 +05:30
|
|
|
'server_group', 'server', 'catalog_object_column',
|
2017-05-12 12:10:46 +01:00
|
|
|
];
|
|
|
|
|
if(_.indexOf(nodes_not_supported, node_type) >= 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-12 12:59:51 +05:30
|
|
|
var preference = pgBrowser.get_preference('browser', 'show_node_'+node_type);
|
2017-05-12 12:10:46 +01:00
|
|
|
|
2017-06-21 17:09:59 +01:00
|
|
|
if (preference) {
|
2018-01-12 12:59:51 +05:30
|
|
|
return preference.value;
|
2017-06-21 17:09:59 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2017-05-12 12:10:46 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2018-01-12 12:59:51 +05:30
|
|
|
};
|
2017-05-12 12:10:46 +01:00
|
|
|
|
2018-01-12 12:59:51 +05:30
|
|
|
return check_node_visibility;
|
|
|
|
|
});
|