pgadmin4/web/pgadmin/static/js/check_node_visibility.js
Akshay Joshi 9f836f5433 Fixed following code smells reported by SonarQube:
1) Immediately return this expression instead of assigning it to the temporary variable.
 2) Extract this nested ternary operation into an independent statement.
 3) Expected a `for-of` loop instead of a `for` loop with this simple iteration.
2022-01-18 14:49:54 +05:30

43 lines
1.2 KiB
JavaScript

//////////////////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2022, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////////////////
define(['jquery', 'underscore'],
function ($, _) {
return 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
if(node_type.startsWith('coll-')) {
node_type = node_type.replace('coll-', '');
}
// Exclude non-applicable nodes
var nodes_not_supported = [
'server_group', 'server', 'catalog_object_column',
];
if(_.indexOf(nodes_not_supported, node_type) >= 0) {
return true;
}
var preference = pgBrowser.get_preference('browser', 'show_node_'+node_type);
if (preference) {
return preference.value;
}
else {
return true;
}
};
});