Replace Alertify alert and confirm with React-based model dialog. Fixes #7053

This commit is contained in:
Akshay Joshi
2021-12-07 18:52:40 +05:30
parent e327066523
commit fd53e4f5f9
62 changed files with 393 additions and 398 deletions

View File

@@ -5,8 +5,8 @@ import { isEmptyString } from 'sources/validators';
import { SCHEMA_STATE_ACTIONS } from '../../../../../../../../../../static/js/SchemaView';
import DataGridViewWithHeaderForm from '../../../../../../../../../../static/js/helpers/DataGridViewWithHeaderForm';
import { getNodeAjaxOptions, getNodeListByName } from '../../../../../../../../../static/js/node_ajax';
import { pgAlertify } from '../../../../../../../../../../static/js/helpers/legacyConnector';
import TableSchema from '../../../../static/js/table.ui';
import Notify from '../../../../../../../../../../static/js/helpers/Notifier';
export function getNodeExclusionConstraintSchema(treeNodeInfo, itemNodeData, pgBrowser, noColumns=false) {
let tableNode = pgBrowser.Nodes['table'];
@@ -275,7 +275,7 @@ export default class ExclusionConstraintSchema extends BaseUISchema {
options: this.fieldOptions.amname,
deferredDepChange: (state, source, topState, actionObj)=>{
return new Promise((resolve)=>{
pgAlertify().confirm(
Notify.confirm(
gettext('Change access method?'),
gettext('Changing access method will clear columns collection'),
function () {

View File

@@ -11,8 +11,8 @@ import gettext from 'sources/gettext';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import { getNodeAjaxOptions, getNodeListByName } from '../../../../../../../../static/js/node_ajax';
import _ from 'lodash';
import { pgAlertify } from 'sources/helpers/legacyConnector';
import { isEmptyString } from 'sources/validators';
import Notify from '../../../../../../../../../static/js/helpers/Notifier';
export function getColumnSchema(nodeObj, treeNodeInfo, itemNodeData) {
return new ColumnSchema(
@@ -296,7 +296,7 @@ export default class IndexSchema extends BaseUISchema {
};
if(state.amname != actionObj.oldState.amname) {
return new Promise((resolve)=>{
pgAlertify().confirm(
Notify.confirm(
gettext('Changing access method will clear columns collection'),
function () {
setColumns(resolve);

View File

@@ -194,7 +194,7 @@ function(
if (!d)
return false;
Alertify.confirm(
Notify.confirm(
gettext('Truncate Table'),
gettext('Are you sure you want to truncate table %s?', d.label),
function (e) {
@@ -238,7 +238,7 @@ function(
if (!d)
return false;
Alertify.confirm(
Notify.confirm(
gettext('Reset statistics'),
gettext('Are you sure you want to reset the statistics for table "%s"?', d._label),
function (e) {
@@ -282,7 +282,7 @@ function(
if (!d)
return false;
Alertify.confirm(
Notify.confirm(
gettext('Detach Partition'),
gettext('Are you sure you want to detach the partition %s?', d._label),
function (e) {

View File

@@ -180,7 +180,7 @@ define('pgadmin.node.table', [
if (!d)
return false;
Alertify.confirm(
Notify.confirm(
gettext('Truncate Table'),
gettext('Are you sure you want to truncate table %s?', d.label),
function (e) {
@@ -228,7 +228,7 @@ define('pgadmin.node.table', [
if (!d)
return false;
Alertify.confirm(
Notify.confirm(
gettext('Reset statistics'),
gettext('Are you sure you want to reset the statistics for table "%s"?', d._label),
function (e) {

View File

@@ -6,7 +6,6 @@ import { isEmptyString } from 'sources/validators';
import PrimaryKeySchema from '../../constraints/index_constraint/static/js/primary_key.ui';
import { SCHEMA_STATE_ACTIONS } from '../../../../../../../../static/js/SchemaView';
import { PartitionKeysSchema, PartitionsSchema } from './partition.utils.ui';
import { pgAlertify } from '../../../../../../../../static/js/helpers/legacyConnector';
import CheckConstraintSchema from '../../constraints/check_constraint/static/js/check_constraint.ui';
import UniqueConstraintSchema from '../../constraints/index_constraint/static/js/unique_constraint.ui';
import { getNodeAjaxOptions, getNodeListByName } from '../../../../../../../static/js/node_ajax';
@@ -15,6 +14,7 @@ import { getNodeVacuumSettingsSchema } from '../../../../../static/js/vacuum.ui'
import { getNodeForeignKeySchema } from '../../constraints/foreign_key/static/js/foreign_key.ui';
import { getNodeExclusionConstraintSchema } from '../../constraints/exclusion_constraint/static/js/exclusion_constraint.ui';
import { getNodePrivilegeRoleSchema } from '../../../../../static/js/privilege.ui';
import Notify from '../../../../../../../../static/js/helpers/Notifier';
export function getNodeTableSchema(treeNodeInfo, itemNodeData, pgBrowser) {
const spcname = ()=>getNodeListByName('tablespace', treeNodeInfo, itemNodeData, {}, (m)=>{
@@ -598,7 +598,7 @@ export default class TableSchema extends BaseUISchema {
group: 'advanced', min_version: 90600,
depChange: (state)=>{
if (state.rlspolicy && this.origData.rlspolicy != state.rlspolicy) {
pgAlertify().alert(
Notify.alert(
gettext('Check Policy?'),
gettext('Please check if any policy exist. If no policy exists for the table, a default-deny policy is used, meaning that no rows are visible or can be modified by other users')
);
@@ -730,7 +730,7 @@ export default class TableSchema extends BaseUISchema {
};
if(!isEmptyString(state.typname) && isEmptyString(actionObj.oldState.typname)) {
return new Promise((resolve)=>{
pgAlertify().confirm(
Notify.confirm(
gettext('Remove column definitions?'),
gettext('Changing \'Of type\' will remove column definitions.'),
function () {

View File

@@ -256,7 +256,7 @@ define('pgadmin.node.mview', [
if (pgBrowser.tree.hasParent(j)) {
j = pgBrowser.tree.parent(j);
} else {
Alertify.alert(gettext('Please select server or child node from tree.'));
Notify.alert(gettext('Please select server or child node from tree.'));
break;
}
}
@@ -275,7 +275,7 @@ define('pgadmin.node.mview', [
dataType: 'json',
}).done(function(res) {
if (!res.success) {
Alertify.alert(
Notify.alert(
gettext('Utility not found'),
res.errormsg
);
@@ -294,7 +294,7 @@ define('pgadmin.node.mview', [
Notify.success(refreshed_res.data.info);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', obj);
} else {
Alertify.alert(
Notify.alert(
gettext('Failed to create materialized view refresh job.'),
refreshed_res.errormsg
);
@@ -306,7 +306,7 @@ define('pgadmin.node.mview', [
);
});
}).fail(function() {
Alertify.alert(
Notify.alert(
gettext('Utility not found'),
gettext('Failed to fetch Utility information')
);

View File

@@ -176,7 +176,7 @@ define('pgadmin.node.database', [
connect(self, d, t, i, true);
return;
}
Alertify.confirm(
Notify.confirm(
gettext('Connection lost'),
gettext('Would you like to reconnect to the database?'),
function() {
@@ -218,7 +218,7 @@ define('pgadmin.node.database', [
d = i ? t.itemData(i) : undefined;
if (d) {
Alertify.confirm(
Notify.confirm(
gettext('Disconnect the database'),
gettext('Are you sure you want to disconnect the database - %s?', d.label),
function() {

View File

@@ -9,8 +9,8 @@
import { getNodeListByName } from '../../../../../../static/js/node_ajax';
import SubscriptionSchema from './subscription.ui';
import getApiInstance from '../../../../../../../static/js/api_instance';
import { pgAlertify } from '../../../../../../../../pgadmin/static/js/helpers/legacyConnector';
import _ from 'lodash';
import Notify from '../../../../../../../static/js/helpers/Notifier';
define('pgadmin.node.subscription', [
'sources/gettext', 'sources/url_for', 'jquery',
@@ -195,12 +195,12 @@ define('pgadmin.node.subscription', [
.then(res=>{
if ((res.data.errormsg === '') && !_.isNull(res.data.data)){
resolve(res.data.data);
pgAlertify().info(
Notify.info(
gettext('Publication fetched successfully.')
);
}else if(!_.isNull(res.data.errormsg) && _.isNull(res.data.data)){
reject(res.data.errormsg);
pgAlertify().alert(
Notify.alert(
gettext('Check connection?'),
gettext(res.data.errormsg)
);

View File

@@ -535,7 +535,7 @@ define('pgadmin.node.role', [
roleOp = roleReassignData.role_op,
confirmBoxTitle = utils.titleize(roleOp);
alertify.confirm(
Notify.confirm(
gettext('%s Objects', confirmBoxTitle),
gettext('Are you sure you wish to %s all the objects owned by the selected role?', roleOp),
function() {
@@ -548,7 +548,7 @@ define('pgadmin.node.role', [
}).catch(function (error) {
try {
const err = error.response.data;
alertify.alert(
Notify.alert(
gettext('Role reassign/drop failed.'),
err.errormsg
);

View File

@@ -284,15 +284,12 @@ define('pgadmin.node.server', [
};
if (notify) {
Alertify.confirm(
Notify.confirm(
gettext('Disconnect server'),
gettext('Are you sure you want to disconnect the server %s?', d.label),
function() { disconnect(); },
function() { return true;}
).set('labels', {
ok: gettext('OK'),
cancel: gettext('Cancel'),
});
function() { return true;},
);
} else {
disconnect();
}
@@ -337,7 +334,7 @@ define('pgadmin.node.server', [
d = i ? t.itemData(i) : undefined;
if (d) {
Alertify.confirm(
Notify.confirm(
gettext('Reload server configuration'),
gettext('Are you sure you want to reload the server configuration on %s?', d.label),
function() {
@@ -358,7 +355,7 @@ define('pgadmin.node.server', [
t.unload(i);
});
},
function() { return true; }
function() { return true; },
);
}
@@ -545,7 +542,7 @@ define('pgadmin.node.server', [
if (res.success) {
// Notify user to update pgpass file
if(is_pgpass_file_used) {
Alertify.alert(
Notify.alert(
gettext('Change Password'),
gettext('Please make sure to disconnect the server'
+ ' and update the new password in the pgpass file'
@@ -666,7 +663,7 @@ define('pgadmin.node.server', [
d = i ? t.itemData(i) : undefined;
if (d) {
Alertify.confirm(
Notify.confirm(
gettext('Clear saved password'),
gettext('Are you sure you want to clear the saved password for server %s?', d.label),
function() {
@@ -703,7 +700,7 @@ define('pgadmin.node.server', [
d = i ? t.itemData(i) : undefined;
if (d) {
Alertify.confirm(
Notify.confirm(
gettext('Clear SSH Tunnel password'),
gettext('Are you sure you want to clear the saved password of SSH Tunnel for server %s?', d.label),
function() {
@@ -790,7 +787,7 @@ define('pgadmin.node.server', [
pgBrowser.Events.on(
'pgadmin:server:connect:cancelled', disconnect
);
Alertify.confirm(
Notify.confirm(
gettext('Connection lost'),
gettext('Would you like to reconnect to the database?'),
function() {

View File

@@ -288,7 +288,7 @@ define('pgadmin.node.tablespace', [
btn_args = this.view.model.toJSON();
btn_args.old_tblspc = d.label;
e.cancel = true;
Alertify.confirm(
Notify.confirm(
gettext('Move objects...'),
gettext(
'Are you sure you wish to move the objects from %s to %s?',

View File

@@ -545,24 +545,20 @@ define('pgadmin.browser', [
}).done((res)=> {
if(res.data.length > 0) {
Alertify.alert(
Notify.alert(
'Warning',
'pgAdmin detected unrecoverable corruption in it\'s SQLite configuration database. ' +
'The database has been backed up and recreated with default settings. '+
'It may be possible to recover data such as query history manually from '+
'the original/corrupt file using a tool such as DB Browser for SQLite if desired.'+
'<br><br>Original file: ' + res.data + '<br>Replacement file: ' +
res.data.substring(0, res.data.length - 14)
)
.set({'closable': true,
'onok': function() {
},
});
res.data.substring(0, res.data.length - 14),
function() {
}
);
}
}).fail(function(xhr, status, error) {
Alertify.alert(error);
Notify.alert(error);
});
},
init_master_password: function() {
@@ -632,7 +628,7 @@ define('pgadmin.browser', [
/* Reset Button */
event.cancel = true;
Alertify.confirm(gettext('Reset Master Password'),
Notify.confirm(gettext('Reset Master Password'),
gettext('This will remove all the saved passwords. This will also remove established connections to '
+ 'the server and you may need to reconnect again. Do you wish to continue?'),
function() {
@@ -642,10 +638,7 @@ define('pgadmin.browser', [
return true;
},
function() {/* If user clicks No */ return true;}
).set('labels', {
ok: gettext('Yes'),
cancel: gettext('No'),
});
);
} else if(event.index == 0) {
/* help Button */
event.cancel = true;

View File

@@ -399,7 +399,7 @@ define([
}
if (sel_rows.length === 0) {
Alertify.alert(gettext('Drop Multiple'),
Notify.alert(gettext('Drop Multiple'),
gettext('Please select at least one object to delete.')
);
return;
@@ -463,7 +463,7 @@ define([
};
if(confirm) {
Alertify.confirm(title, msg, dropAjaxHook, null).show();
Notify.confirm(title, msg, dropAjaxHook, null);
} else {
dropAjaxHook();
}

View File

@@ -7,9 +7,11 @@
//
//////////////////////////////////////////////////////////////
import Notify from '../../../static/js/helpers/Notifier';
define(
['sources/gettext', 'underscore', 'alertify', 'sources/pgadmin'],
function(gettext, _, alertify, pgAdmin) {
['sources/gettext', 'underscore', 'sources/pgadmin'],
function(gettext, _, pgAdmin) {
pgAdmin.Browser = pgAdmin.Browser || {};
_.extend(pgAdmin.Browser, {
@@ -44,7 +46,7 @@ define(
}
text += '</div>';
alertify.alert(
Notify.alert(
title,
text
)

View File

@@ -815,7 +815,7 @@ define('pgadmin.browser.node', [
msg = gettext('Are you sure want to reset the current changes and re-open the panel for %s "%s"?');
}
Alertify.confirm(
Notify.confirm(
gettext('Edit in progress?'),
commonUtils.sprintf(msg, o.label.toLowerCase(), d.label),
function() {
@@ -898,7 +898,7 @@ define('pgadmin.browser.node', [
return;
}
}
Alertify.confirm(title, msg,
Notify.confirm(title, msg,
function() {
$.ajax({
url: obj.generate_url(i, input.url, d, true),
@@ -939,12 +939,8 @@ define('pgadmin.browser.node', [
pgBrowser.report_error(
gettext('Error dropping/removing %s: "%s"', obj.label, objName), errmsg);
});
},
null
).set('labels', {
ok: gettext('Yes'),
cancel: gettext('No'),
}).show();
}
);
},
// Callback for creating script(s) & opening them in Query editor
show_script: function(args, item) {
@@ -1387,7 +1383,7 @@ define('pgadmin.browser.node', [
let confirm_on_properties_close = pgBrowser.get_preferences_for_module('browser').confirm_on_properties_close;
if (confirm_on_properties_close && confirm_close && objview && objview.model) {
if(objview.model.sessChanged()){
Alertify.confirm(
Notify.confirm(
gettext('Warning'),
warn_text,
function() {
@@ -1399,10 +1395,7 @@ define('pgadmin.browser.node', [
function() {
return true;
}
).set('labels', {
ok: gettext('Yes'),
cancel: gettext('No'),
}).show();
);
} else {
return true;
}
@@ -1421,7 +1414,7 @@ define('pgadmin.browser.node', [
let warn_text;
warn_text = gettext(objview.model.warn_text);
if(objview.model.sessChanged()){
Alertify.confirm(
Notify.confirm(
gettext('Warning'),
warn_text,
function() {
@@ -1433,10 +1426,7 @@ define('pgadmin.browser.node', [
function() {
return true;
}
).set('labels', {
ok: gettext('Yes'),
cancel: gettext('No'),
}).show();
);
} else {
return true;
}
@@ -1451,7 +1441,7 @@ define('pgadmin.browser.node', [
objview = $props && $props.data('obj-view');
if (objview && objview.model && !_.isUndefined(objview.model.inform_text) && !_.isNull(objview.model.inform_text)) {
Alertify.alert(
Notify.alert(
gettext('Warning'),
gettext(objview.model.inform_text)
);

View File

@@ -15,7 +15,8 @@ import getApiInstance from 'sources/api_instance';
import {getHelpUrl, getEPASHelpUrl} from 'pgadmin.help';
import SchemaView from 'sources/SchemaView';
import { generateNodeUrl } from './node_ajax';
import Alertify from 'pgadmin.alertifyjs';
import Notify from '../../../static/js/helpers/Notifier';
import gettext from 'sources/gettext';
import 'wcdocker';
@@ -125,7 +126,7 @@ export function getNodeView(nodeType, treeNodeInfo, actionType, itemNodeData, fo
let confirmOnClose = pgAdmin.Browser.get_preferences_for_module('browser').confirm_on_properties_close;
if (warnOnCloseFlag && confirmOnClose) {
if(isDirty){
Alertify.confirm(
Notify.confirm(
gettext('Warning'),
gettext('Changes will be lost. Are you sure you want to close the dialog?'),
function() {
@@ -135,10 +136,7 @@ export function getNodeView(nodeType, treeNodeInfo, actionType, itemNodeData, fo
function() {
return true;
}
).set('labels', {
ok: gettext('Yes'),
cancel: gettext('No'),
}).show();
);
} else {
return true;
}