public inbox for [email protected]
help / color / mirror / Atom feedFrom: Khushboo Vashi <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin 4][Patch] - RM #4923 - Enhancement for RM#3279
Date: Mon, 2 Dec 2019 17:15:45 +0530
Message-ID: <CAFOhELc=b2dTemodbmQjW5UbXB_L=p5sPpcV0XaB6JyFAV3Hdg@mail.gmail.com> (raw)
Hi,
Please find the attached patch to fix the RM #4923 - Enhancement for
RM#3279.
Earlier we had *Delete/Drop* label in the context menu to remove the server
which was not appropriate, so we have changed it to *Remove Server*, but
the approach taken was not generic, which has been fixed in this patch.
Apart from that, the Server Group drop label has been changed to 'Remove
Server Group' in this patch as requested in the RM.
Thanks,
Khushboo
Attachments:
[application/octet-stream] RM_4923.patch (5.8K, 3-RM_4923.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/server.js b/web/pgadmin/browser/server_groups/servers/static/js/server.js
index 843794d53..8d6361378 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/server.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/server.js
@@ -58,6 +58,8 @@ define('pgadmin.node.server', [
dialogHelp: url_for('help.static', {'filename': 'server_dialog.html'}),
label: gettext('Server'),
canDrop: true,
+ dropAsRemove: true,
+ dropPriority: 5,
hasStatistics: true,
hasCollectiveStatistics: true,
can_expand: function(d) {
diff --git a/web/pgadmin/browser/server_groups/static/js/server_group.js b/web/pgadmin/browser/server_groups/static/js/server_group.js
index 62daa3d5b..8457db658 100644
--- a/web/pgadmin/browser/server_groups/static/js/server_group.js
+++ b/web/pgadmin/browser/server_groups/static/js/server_group.js
@@ -70,6 +70,7 @@ define('pgadmin.node.server_group', [
},
}),
canDrop: function(itemData) { return itemData.can_delete; },
+ dropAsRemove: true,
canDelete: function(i) {
var s = pgAdmin.Browser.tree.siblings(i, true);
diff --git a/web/pgadmin/browser/static/js/node.js b/web/pgadmin/browser/static/js/node.js
index fbce346f0..e7e80c8d7 100644
--- a/web/pgadmin/browser/static/js/node.js
+++ b/web/pgadmin/browser/static/js/node.js
@@ -28,10 +28,6 @@ define('pgadmin.browser.node', [
F1: 112,
};
- const REMOVE_SERVER_PRIORITY = 5;
- const REMOVE_SERVER_LABEL = 'Remove Server';
- const SERVER = 'server';
-
// It has already been defined.
// Avoid running this script again.
if (pgBrowser.Node)
@@ -146,8 +142,8 @@ define('pgadmin.browser.node', [
module: self,
applies: ['object', 'context'],
callback: 'delete_obj',
- priority: self.get_menu_item_priority(self.type, 2),
- label: self.change_menu_label(self.type, gettext('Delete/Drop')),
+ priority: self.dropPriority,
+ label: (self.dropAsRemove) ? gettext('Remove %s', self.label) : gettext('Delete/Drop'),
data: {
'url': 'drop',
},
@@ -539,6 +535,14 @@ define('pgadmin.browser.node', [
* Override this, when a node is not deletable.
*/
canDropCascade: false,
+ /*********************************************************************************
+ dropAsRemove should be true in case, Drop object label needs to be replaced by Remove
+ */
+ dropAsRemove: false,
+ /******************************************************************************
+ dropPriority is set to 2 by default, override it when change is required
+ */
+ dropPriority: 2,
// List of common callbacks - that can be used for different
// operations!
callbacks: {
@@ -748,7 +752,10 @@ define('pgadmin.browser.node', [
obj = pgBrowser.Nodes[d._type];
var objName = d.label;
- var msg, title;
+ var msg, title, drop_label;
+
+ if (obj.dropAsRemove) drop_label = 'Remove'; else drop_label = 'Drop';
+
if (input.url == 'delete') {
msg = gettext('Are you sure you want to drop %s "%s" and all the objects that depend on it?',
@@ -764,31 +771,15 @@ define('pgadmin.browser.node', [
return;
}
} else {
- var remove_drop_text;
- if(obj.type === SERVER) {
- remove_drop_text = 'Remove';
- }
- else {
- remove_drop_text = 'DROP';
- }
-
- msg = gettext('Are you sure you want to %s %s "%s"?', remove_drop_text.toLowerCase(), obj.label.toLowerCase(), d.label);
- title = gettext('%s %s?', remove_drop_text, obj.label);
+ msg = gettext('Are you sure you want to %s %s "%s"?', drop_label.toLowerCase(), obj.label.toLowerCase(), d.label);
+ title = gettext('%s %s?', drop_label, obj.label);
if (!(_.isFunction(obj.canDrop) ?
obj.canDrop.apply(obj, [d, i]) : obj.canDrop)) {
- if(obj.type === SERVER) {
- Alertify.error(
- gettext('The %s "%s" cannot be removed.', obj.label, d.label),
- 10
- );
- }
- else {
- Alertify.error(
- gettext('The %s "%s" cannot be dropped.', obj.label, d.label),
- 10
- );
- }
+ Alertify.error(
+ gettext('The %s "%s" cannot be dropped/removed.', obj.label, d.label),
+ 10
+ );
return;
}
}
@@ -817,14 +808,9 @@ define('pgadmin.browser.node', [
console.warn(e.stack || e);
}
}
- if(obj.type === SERVER) {
- pgBrowser.report_error(
- gettext('Error removing %s: "%s"', obj.label, objName), msg);
- }
- else {
- pgBrowser.report_error(
- gettext('Error dropping %s: "%s"', obj.label, objName), msg);
- }
+ pgBrowser.report_error(
+ gettext('Error dropping/removing %s: "%s"', obj.label, objName), msg);
+
});
},
null).show();
@@ -1829,18 +1815,6 @@ define('pgadmin.browser.node', [
return this.parent_type;
}
},
- get_menu_item_priority: function(type, default_priority) { //downgrade Remove Server priority in menus only for Servers
- if(type && type === SERVER) {
- return REMOVE_SERVER_PRIORITY;
- }
- return default_priority;
- },
- change_menu_label: function(type, default_label) { //change Delete/Drop menu option to Remove Server
- if(type && type === SERVER) {
- return gettext(REMOVE_SERVER_LABEL);
- }
- return default_label;
- },
});
return pgAdmin.Browser.Node;
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [pgAdmin 4][Patch] - RM #4923 - Enhancement for RM#3279
In-Reply-To: <CAFOhELc=b2dTemodbmQjW5UbXB_L=p5sPpcV0XaB6JyFAV3Hdg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox