mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-09 23:54:09 -06:00
Enhance the logic to change the label from 'Delete/Drop' to 'Remove' for the server and server group node. Fixes #4923
This commit is contained in:
parent
ac2bd5e6ee
commit
d476343b99
@ -33,6 +33,7 @@ Bug fixes
|
||||
| `Issue #4818 <https://redmine.postgresql.org/issues/4818>`_ - Fix server connection drops out issue in query tool.
|
||||
| `Issue #4836 <https://redmine.postgresql.org/issues/4836>`_ - Updated the json file name from 'servers.json' to 'pgadmin4/servers.json' in the container deployment section of the documentation.
|
||||
| `Issue #4878 <https://redmine.postgresql.org/issues/4878>`_ - Ensure that the superuser should be able to create role, as the superuser overrides all the access restrictions.
|
||||
| `Issue #4923 <https://redmine.postgresql.org/issues/4923>`_ - Enhance the logic to change the label from 'Delete/Drop' to 'Remove' for the server and server group node.
|
||||
| `Issue #4925 <https://redmine.postgresql.org/issues/4925>`_ - Shown some text on process watcher till the initial logs are loaded.
|
||||
| `Issue #4926 <https://redmine.postgresql.org/issues/4926>`_ - Fix VPN network disconnect issue where pgAdmin4 hangs on expanding the Servers node.
|
||||
| `Issue #4930 <https://redmine.postgresql.org/issues/4930>`_ - Fix main window tab navigation accessibility issue.
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user