mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed the following code smells:
1) useState call is not destructured into value + setter pair. 2) A fragment with only one child is redundant. 3) Unnecessary '.apply()' and '.call()'. 4) Expected the Promise rejection reason to be an Error.
This commit is contained in:
@@ -87,7 +87,7 @@ export default class MainMenuFactory {
|
||||
if (options.module && 'callbacks' in options.module && options.module.callbacks[options.callback]) {
|
||||
options.module.callbacks[options.callback].apply(options.module, [options.data, pgAdmin.Browser.tree?.selected()]);
|
||||
} else if (options?.module?.[options.callback]) {
|
||||
options.module[options.callback].apply(options.module, [options.data, pgAdmin.Browser.tree?.selected()]);
|
||||
options.module[options.callback](options.data, pgAdmin.Browser.tree?.selected());
|
||||
} else if (options?.callback) {
|
||||
options.callback(options);
|
||||
} else if (options.url != '#') {
|
||||
@@ -117,7 +117,7 @@ export default class MainMenuFactory {
|
||||
let selectedNode=pgAdmin.Browser.tree.selected();
|
||||
let flag=!_.isUndefined(selectedNodeFromNodes.showMenu);
|
||||
if(flag){
|
||||
var showMenu = selectedNodeFromNodes.showMenu(d, selectedNode);
|
||||
let showMenu = selectedNodeFromNodes.showMenu(d, selectedNode);
|
||||
return {flag:showMenu?false:flag,showMenu};
|
||||
} else{
|
||||
return {flag,showMenu:undefined};
|
||||
|
||||
@@ -1697,7 +1697,7 @@ define('pgadmin.browser', [
|
||||
load: true,
|
||||
};
|
||||
ctx.success = function() {
|
||||
this.b._refreshNode.call(this.b, this, this.d);
|
||||
this.b._refreshNode(this, this.d);
|
||||
}.bind(ctx);
|
||||
findNode(__ctx.i, d, ctx);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ define('pgadmin.browser.node', [
|
||||
},
|
||||
enable: _.isFunction(self.canEdit) ?
|
||||
function() {
|
||||
return !!(self.canEdit.apply(self, arguments));
|
||||
return !!(self.canEdit(arguments));
|
||||
} : (!!self.canEdit),
|
||||
}]);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ define('pgadmin.browser.node', [
|
||||
},
|
||||
enable: _.isFunction(self.canDrop) ?
|
||||
function() {
|
||||
return !!(self.canDrop.apply(self, arguments));
|
||||
return !!(self.canDrop(arguments));
|
||||
} : (!!self.canDrop),
|
||||
}]);
|
||||
|
||||
@@ -177,7 +177,7 @@ define('pgadmin.browser.node', [
|
||||
},
|
||||
enable: _.isFunction(self.canDropCascade) ?
|
||||
function() {
|
||||
return self.canDropCascade.apply(self, arguments);
|
||||
return self.canDropCascade(arguments);
|
||||
} : (!!self.canDropCascade),
|
||||
}]);
|
||||
}
|
||||
@@ -386,7 +386,7 @@ define('pgadmin.browser.node', [
|
||||
const onSave = (newNodeData)=>{
|
||||
// Clear the cache for this node now.
|
||||
setTimeout(()=>{
|
||||
this.clear_cache.apply(this, item);
|
||||
this.clear_cache(item);
|
||||
}, 0);
|
||||
try {
|
||||
pgBrowser.Events.trigger(
|
||||
@@ -416,7 +416,7 @@ define('pgadmin.browser.node', [
|
||||
const onSave = (newNodeData)=>{
|
||||
// Clear the cache for this node now.
|
||||
setTimeout(()=>{
|
||||
this.clear_cache.apply(this, item);
|
||||
this.clear_cache(item);
|
||||
}, 0);
|
||||
try {
|
||||
pgBrowser.Events.trigger(
|
||||
@@ -446,7 +446,7 @@ define('pgadmin.browser.node', [
|
||||
|
||||
// Clear the cache for this node now.
|
||||
setTimeout(()=>{
|
||||
this.clear_cache.apply(this, item);
|
||||
this.clear_cache(item);
|
||||
}, 0);
|
||||
|
||||
pgBrowser.Events.trigger(
|
||||
@@ -530,7 +530,7 @@ define('pgadmin.browser.node', [
|
||||
title = gettext('Delete CASCADE %s?', obj.label);
|
||||
|
||||
if (!(_.isFunction(obj.canDropCascade) ?
|
||||
obj.canDropCascade.apply(obj, [d, i]) : obj.canDropCascade)) {
|
||||
obj.canDropCascade(d, i) : obj.canDropCascade)) {
|
||||
pgAdmin.Browser.notifier.error(
|
||||
gettext('The %s "%s" cannot be dropped.', obj.label, d.label),
|
||||
10000
|
||||
@@ -547,7 +547,7 @@ define('pgadmin.browser.node', [
|
||||
}
|
||||
|
||||
if (!(_.isFunction(obj.canDrop) ?
|
||||
obj.canDrop.apply(obj, [d, i]) : obj.canDrop)) {
|
||||
obj.canDrop(d, i) : obj.canDrop)) {
|
||||
pgAdmin.Browser.notifier.error(
|
||||
gettext('The %s "%s" cannot be dropped/removed.', obj.label, d.label),
|
||||
10000
|
||||
@@ -745,7 +745,7 @@ define('pgadmin.browser.node', [
|
||||
removed: function(item) {
|
||||
let self = this;
|
||||
setTimeout(function() {
|
||||
self.clear_cache.apply(self, item);
|
||||
self.clear_cache(item);
|
||||
}, 0);
|
||||
},
|
||||
refresh: function(cmd, _item) {
|
||||
|
||||
@@ -144,10 +144,10 @@ export function getNodeListById(nodeObj, treeNodeInfo, itemNodeData, params={},
|
||||
_.each(rows, function(r) {
|
||||
if (filter(r)) {
|
||||
let l = (_.isFunction(nodeObj['node_label']) ?
|
||||
(nodeObj['node_label']).apply(nodeObj, [r]) :
|
||||
nodeObj['node_label'](r) :
|
||||
r.label),
|
||||
image = (_.isFunction(nodeObj['node_image']) ?
|
||||
(nodeObj['node_image']).apply(nodeObj, [r]) :
|
||||
nodeObj['node_image'](r) :
|
||||
(nodeObj['node_image'] || ('icon-' + nodeObj.type)));
|
||||
|
||||
res.push({
|
||||
@@ -175,10 +175,10 @@ export function getNodeListByName(node, treeNodeInfo, itemNodeData, params={}, f
|
||||
_.each(rows, function(r) {
|
||||
if (filter(r)) {
|
||||
let l = (_.isFunction(nodeObj['node_label']) ?
|
||||
(nodeObj['node_label']).apply(nodeObj, [r]) :
|
||||
nodeObj['node_label'](r) :
|
||||
r.label),
|
||||
image = (_.isFunction(nodeObj['node_image']) ?
|
||||
(nodeObj['node_image']).apply(nodeObj, [r]) :
|
||||
nodeObj['node_image'](r) :
|
||||
(nodeObj['node_image'] || ('icon-' + nodeObj.type)));
|
||||
|
||||
res.push({
|
||||
|
||||
Reference in New Issue
Block a user