Replaced alertifyjs notifiers with React-based notistack. Fixes #7004

This commit is contained in:
Akshay Joshi
2021-12-02 16:05:52 +05:30
parent 0f9b9b9dcf
commit c6424e3897
61 changed files with 584 additions and 641 deletions

View File

@@ -16,6 +16,7 @@ Housekeeping
| `Issue #6088 <https://redmine.postgresql.org/issues/6088>`_ - Replace Flask-BabelEx with Flask-Babel.
| `Issue #6984 <https://redmine.postgresql.org/issues/6984>`_ - Port Backup Global, Backup Server, and Backup object dialog in React.
| `Issue #7004 <https://redmine.postgresql.org/issues/7004>`_ - Replaced alertifyjs notifiers with React-based notistack.
| `Issue #7010 <https://redmine.postgresql.org/issues/7010>`_ - Upgrade Flask to version 2.
Bug fixes

View File

@@ -134,6 +134,7 @@
"moment-timezone": "^0.5.33",
"mousetrap": "^1.6.3",
"notificar": "^1.0.1",
"notistack": "^1.0.10",
"path-fx": "^2.0.0",
"pathfinding": "^0.4.18",
"paths-js": "^0.4.9",

View File

@@ -9,16 +9,15 @@
import { getNodeListByName } from '../../../../../../../../static/js/node_ajax';
import CompoundTriggerSchema from './compound_trigger.ui';
import Notify from '../../../../../../../../../static/js/helpers/Notifier';
define('pgadmin.node.compound_trigger', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'sources/pgadmin', 'pgadmin.browser',
'pgadmin.backform', 'pgadmin.alertifyjs',
'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform',
'pgadmin.node.schema.dir/schema_child_tree_node',
'pgadmin.browser.collection',
], function(
gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, alertify,
SchemaChildTreeNode
gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, SchemaChildTreeNode
) {
if (!pgBrowser.Nodes['coll-compound_trigger']) {
@@ -121,7 +120,7 @@ define('pgadmin.node.compound_trigger', [
})
.done(function(res) {
if (res.success == 1) {
alertify.success(res.info);
Notify.success(res.info);
t.removeIcon(i);
data.icon = 'icon-compound_trigger';
t.addIcon(i, {icon: data.icon});
@@ -135,7 +134,7 @@ define('pgadmin.node.compound_trigger', [
}
})
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
},
@@ -159,7 +158,7 @@ define('pgadmin.node.compound_trigger', [
})
.done(function(res) {
if (res.success == 1) {
alertify.success(res.info);
Notify.success(res.info);
t.removeIcon(i);
data.icon = 'icon-compound_trigger-bad';
t.addIcon(i, {icon: data.icon});
@@ -173,7 +172,7 @@ define('pgadmin.node.compound_trigger', [
}
})
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error, gettext('Disable compound trigger failed'));
Notify.pgRespErrorNotify(xhr, error, gettext('Disable compound trigger failed'));
t.unload(i);
});
},

View File

@@ -8,13 +8,14 @@
//////////////////////////////////////////////////////////////
import CheckConstraintSchema from './check_constraint.ui';
import Notify from '../../../../../../../../../../static/js/helpers/Notifier';
// Check Constraint Module: Node
define('pgadmin.node.check_constraint', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
'sources/pgadmin', 'pgadmin.browser',
'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection',
], function(gettext, url_for, $, _, pgAdmin, pgBrowser, alertify, schemaChildTreeNode) {
], function(gettext, url_for, $, _, pgAdmin, pgBrowser, schemaChildTreeNode) {
// Check Constraint Node
if (!pgBrowser.Nodes['check_constraint']) {
@@ -74,7 +75,7 @@ define('pgadmin.node.check_constraint', [
})
.done(function(res) {
if (res.success == 1) {
alertify.success(res.info);
Notify.success(res.info);
t.removeIcon(i);
data.valid = true;
data.icon = 'icon-check_constraint';
@@ -84,7 +85,7 @@ define('pgadmin.node.check_constraint', [
}
})
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}

View File

@@ -8,13 +8,13 @@
//////////////////////////////////////////////////////////////
import { getNodeForeignKeySchema } from './foreign_key.ui';
import Notify from '../../../../../../../../../../static/js/helpers/Notifier';
define('pgadmin.node.foreign_key', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone',
'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
'pgadmin.browser.collection',
'sources/pgadmin', 'pgadmin.browser', 'pgadmin.browser.collection',
], function(
gettext, url_for, $, _, Backbone, pgAdmin, pgBrowser, Alertify
gettext, url_for, $, _, Backbone, pgAdmin, pgBrowser
) {
// Extend the browser's node class for foreign key node
if (!pgBrowser.Nodes['foreign_key']) {
@@ -71,7 +71,7 @@ define('pgadmin.node.foreign_key', [
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
t.removeIcon(i);
data.valid = true;
data.icon = 'icon-foreign_key';
@@ -81,7 +81,7 @@ define('pgadmin.node.foreign_key', [
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}

View File

@@ -8,6 +8,7 @@
//////////////////////////////////////////////////////////////
import { getNodePartitionTableSchema } from './partition.ui';
import Notify from '../../../../../../../../../static/js/helpers/Notifier';
define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
@@ -159,7 +160,7 @@ function(
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
t.unload(i);
t.setInode(i);
t.deselect(i);
@@ -169,7 +170,7 @@ function(
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
},
@@ -207,7 +208,7 @@ function(
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
t.removeIcon(i);
data.icon = 'icon-partition';
t.addIcon(i, {icon: data.icon});
@@ -221,7 +222,7 @@ function(
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}},
@@ -249,7 +250,7 @@ function(
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
t.removeIcon(i);
data.icon = 'icon-partition';
t.addIcon(i, {icon: data.icon});
@@ -263,7 +264,7 @@ function(
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}
@@ -292,7 +293,7 @@ function(
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
var n = t.next(i);
if (!n) {
n = t.prev(i);
@@ -307,7 +308,7 @@ function(
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
}
},

View File

@@ -7,13 +7,13 @@
//
//////////////////////////////////////////////////////////////
import RuleSchema from './rule.ui';
import Notify from '../../../../../../../../../static/js/helpers/Notifier';
define('pgadmin.node.rule', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform',
'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.alertifyjs',
], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, SchemaChildTreeNode, alertify) {
'pgadmin.node.schema.dir/schema_child_tree_node',
], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, SchemaChildTreeNode) {
/**
Create and add a rule collection into nodes
@@ -145,7 +145,7 @@ define('pgadmin.node.rule', [
dataType: 'json',
})
.done(function() {
alertify.success('Rule updated.');
Notify.success('Rule updated.');
t.removeIcon(i);
data.icon = 'icon-rule';
t.addIcon(i, {icon: data.icon});
@@ -158,7 +158,7 @@ define('pgadmin.node.rule', [
}, 10);
})
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
},
@@ -181,7 +181,7 @@ define('pgadmin.node.rule', [
dataType: 'json',
})
.done(function() {
alertify.success('Rule updated');
Notify.success('Rule updated');
t.removeIcon(i);
data.icon = 'icon-rule-bad';
t.addIcon(i, {icon: data.icon});
@@ -194,7 +194,7 @@ define('pgadmin.node.rule', [
}, 10);
})
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error, gettext('Disable rule failed'));
Notify.pgRespErrorNotify(xhr, error, gettext('Disable rule failed'));
t.unload(i);
});
},

View File

@@ -9,14 +9,14 @@
import axios from 'axios';
export function disableTriggers(tree, alertify, generateUrl, args) {
return setTriggers(tree, alertify, generateUrl, args, {is_enable_trigger: 'D' });
export function disableTriggers(tree, Notify, generateUrl, args) {
return setTriggers(tree, Notify, generateUrl, args, {is_enable_trigger: 'D' });
}
export function enableTriggers(tree, alertify, generateUrl, args) {
return setTriggers(tree, alertify, generateUrl, args, {is_enable_trigger: 'O' });
export function enableTriggers(tree, Notify, generateUrl, args) {
return setTriggers(tree, Notify, generateUrl, args, {is_enable_trigger: 'O' });
}
function setTriggers(tree, alertify, generateUrl, args, params) {
function setTriggers(tree, Notify, generateUrl, args, params) {
const treeNode = retrieveTreeNode(args, tree);
if (!treeNode || treeNode.getData() === null || treeNode.getData() === undefined)
@@ -28,7 +28,7 @@ function setTriggers(tree, alertify, generateUrl, args, params) {
)
.then((res) => {
if (res.data.success === 1) {
alertify.success(res.data.info);
Notify.success(res.data.info);
treeNode.reload(tree);
}
})
@@ -36,7 +36,7 @@ function setTriggers(tree, alertify, generateUrl, args, params) {
try {
const err = xhr.response.data;
if (err.success === 0) {
alertify.error(err.errormsg);
Notify.error(err.errormsg);
}
} catch (e) {
console.warn(e.stack || e);

View File

@@ -8,6 +8,7 @@
//////////////////////////////////////////////////////////////
import { getNodeTableSchema } from './table.ui';
import Notify from '../../../../../../../../static/js/helpers/Notifier';
define('pgadmin.node.table', [
'pgadmin.tables.js/enable_disable_triggers',
@@ -141,7 +142,7 @@ define('pgadmin.node.table', [
enable_triggers_on_table: function(args) {
tableFunctions.enableTriggers(
pgBrowser.tree,
Alertify,
Notify,
this.generate_url.bind(this),
args
);
@@ -150,7 +151,7 @@ define('pgadmin.node.table', [
disable_triggers_on_table: function(args) {
tableFunctions.disableTriggers(
pgBrowser.tree,
Alertify,
Notify,
this.generate_url.bind(this),
args
);
@@ -193,7 +194,7 @@ define('pgadmin.node.table', [
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
t.removeIcon(i);
data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
t.addIcon(i, {icon: data.icon});
@@ -206,11 +207,11 @@ define('pgadmin.node.table', [
}, 10);
}
if (res.success == 2) {
Alertify.error(res.info, 0);
Notify.error(res.info, 0);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}
@@ -239,7 +240,7 @@ define('pgadmin.node.table', [
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
t.removeIcon(i);
data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
t.addIcon(i, {icon: data.icon});
@@ -253,7 +254,7 @@ define('pgadmin.node.table', [
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}
@@ -280,7 +281,7 @@ define('pgadmin.node.table', [
type:'GET',
})
.done(function(res) {
Alertify.success(res.info);
Notify.success(res.info);
d.rows_cnt = res.data.total_rows;
t.unload(i);
t.setInode(i);
@@ -290,7 +291,7 @@ define('pgadmin.node.table', [
}, 10);
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
},

View File

@@ -8,16 +8,15 @@
//////////////////////////////////////////////////////////////
import { getNodeListByName, getNodeAjaxOptions } from '../../../../../../../../static/js/node_ajax';
import TriggerSchema from './trigger.ui';
import Notify from '../../../../../../../../../static/js/helpers/Notifier';
define('pgadmin.node.trigger', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'sources/pgadmin', 'pgadmin.browser',
'pgadmin.backform', 'pgadmin.alertifyjs',
'pgadmin.node.schema.dir/schema_child_tree_node',
'pgadmin.backform', 'pgadmin.node.schema.dir/schema_child_tree_node',
'pgadmin.browser.collection',
], function(
gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, alertify,
SchemaChildTreeNode
gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, SchemaChildTreeNode
) {
if (!pgBrowser.Nodes['coll-trigger']) {
@@ -116,7 +115,7 @@ define('pgadmin.node.trigger', [
})
.done(function(res) {
if (res.success == 1) {
alertify.success(res.info);
Notify.success(res.info);
t.removeIcon(i);
data.icon = 'icon-trigger';
t.addIcon(i, {icon: data.icon});
@@ -130,7 +129,7 @@ define('pgadmin.node.trigger', [
}
})
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
},
@@ -154,7 +153,7 @@ define('pgadmin.node.trigger', [
})
.done(function(res) {
if (res.success == 1) {
alertify.success(res.info);
Notify.success(res.info);
t.removeIcon(i);
data.icon = 'icon-trigger-bad';
t.addIcon(i, {icon: data.icon});
@@ -168,7 +167,7 @@ define('pgadmin.node.trigger', [
}
})
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error, gettext('Disable trigger failed'));
Notify.pgRespErrorNotify(xhr, error, gettext('Disable trigger failed'));
t.unload(i);
});
},

View File

@@ -11,6 +11,7 @@ import MViewSchema from './mview.ui';
import { getNodeListByName } from '../../../../../../../static/js/node_ajax';
import { getNodePrivilegeRoleSchema } from '../../../../../static/js/privilege.ui';
import { getNodeVacuumSettingsSchema } from '../../../../../static/js/vacuum.ui';
import Notify from '../../../../../../../../static/js/helpers/Notifier';
define('pgadmin.node.mview', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
@@ -290,7 +291,7 @@ define('pgadmin.node.mview', [
.done(function(refreshed_res) {
if (refreshed_res.data && refreshed_res.data.status) {
//Do nothing as we are creating the job and exiting from the main dialog
Alertify.success(refreshed_res.data.info);
Notify.success(refreshed_res.data.info);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', obj);
} else {
Alertify.alert(
@@ -300,7 +301,7 @@ define('pgadmin.node.mview', [
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(
Notify.pgRespErrorNotify(
xhr, error, gettext('Failed to create materialized view refresh job.')
);
});

View File

@@ -11,6 +11,7 @@ import { getNodeAjaxOptions, getNodeListByName } from '../../../../../static/js/
import { getNodePrivilegeRoleSchema } from '../../../static/js/privilege.ui';
import { getNodeVariableSchema } from '../../../static/js/variable.ui';
import DatabaseSchema from './database.ui';
import Notify from '../../../../../../static/js/helpers/Notifier';
define('pgadmin.node.database', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
@@ -232,7 +233,7 @@ define('pgadmin.node.database', [
if(res.data.info_prefix) {
res.info = `${_.escape(res.data.info_prefix)} - ${res.info}`;
}
Alertify.success(res.info);
Notify.success(res.info);
t.removeIcon(i);
data.connected = false;
data.icon = 'icon-database-not-connected';
@@ -244,7 +245,7 @@ define('pgadmin.node.database', [
} else {
try {
Alertify.error(res.errormsg);
Notify.error(res.errormsg);
} catch (e) {
console.warn(e.stack || e);
}
@@ -252,7 +253,7 @@ define('pgadmin.node.database', [
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
},
@@ -428,7 +429,7 @@ define('pgadmin.node.database', [
function(error) {
tree.setInode(_item);
tree.addIcon(_item, {icon: 'icon-database-not-connected'});
Alertify.pgNotifier(error, xhr, gettext('Connect to database.'));
Notify.pgNotifier(error, xhr, gettext('Connect to database.'));
}
);
} else {
@@ -437,7 +438,7 @@ define('pgadmin.node.database', [
tree.addIcon(_item, {icon: 'icon-database-not-connected'});
}
Alertify.pgNotifier('error', xhr, error, function(msg) {
Notify.pgNotifier('error', xhr, error, function(msg) {
setTimeout(function() {
if (msg == 'CRYPTKEY_SET') {
connect_to_database(_model, _data, _tree, _item, _wasConnected);
@@ -472,9 +473,9 @@ define('pgadmin.node.database', [
res.info = `${_.escape(res.data.info_prefix)} - ${res.info}`;
}
if(res.data.already_connected) {
Alertify.info(res.info);
Notify.info(res.info);
} else {
Alertify.success(res.info);
Notify.success(res.info);
}
obj.trigger('connected', obj, _item, _data);
pgBrowser.Events.trigger(

View File

@@ -10,12 +10,13 @@
import { getNodeAjaxOptions } from '../../../../../static/js/node_ajax';
import PgaJobSchema from './pga_job.ui';
import { getNodePgaJobStepSchema } from '../../steps/static/js/pga_jobstep.ui';
import Notify from '../../../../../../static/js/helpers/Notifier';
define('pgadmin.node.pga_job', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
'sources/pgadmin', 'pgadmin.browser',
'pgadmin.node.pga_jobstep', 'pgadmin.node.pga_schedule',
], function(gettext, url_for, $, _, pgAdmin, pgBrowser, alertify) {
], function(gettext, url_for, $, _, pgAdmin, pgBrowser) {
if (!pgBrowser.Nodes['coll-pga_job']) {
pgBrowser.Nodes['coll-pga_job'] =
@@ -125,7 +126,7 @@ define('pgadmin.node.pga_job', [
// now.
.done(function() { t.unload(i); })
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}

View File

@@ -10,6 +10,7 @@ import RoleSchema from './role.ui';
import { getNodeVariableSchema } from '../../../static/js/variable.ui';
import { getNodeListByName } from '../../../../../static/js/node_ajax';
import { getMembershipSchema } from '../../../static/js/membership.ui';
import Notify from '../../../../../../static/js/helpers/Notifier';
define('pgadmin.node.role', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
@@ -543,7 +544,7 @@ define('pgadmin.node.role', [
roleReassignData
).then(function (response) {
if(response.data)
alertify.success(response.data.info);
Notify.success(response.data.info);
}).catch(function (error) {
try {
const err = error.response.data;

View File

@@ -9,6 +9,7 @@
import { getNodeListById } from '../../../../static/js/node_ajax';
import ServerSchema from './server.ui';
import Notify from '../../../../../static/js/helpers/Notifier';
define('pgadmin.node.server', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone',
@@ -252,7 +253,7 @@ define('pgadmin.node.server', [
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
d = t.itemData(i);
t.removeIcon(i);
d.connected = false;
@@ -269,7 +270,7 @@ define('pgadmin.node.server', [
}
else {
try {
Alertify.error(res.errormsg);
Notify.error(res.errormsg);
} catch (e) {
console.warn(e.stack || e);
}
@@ -277,7 +278,7 @@ define('pgadmin.node.server', [
}
}})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
};
@@ -346,14 +347,14 @@ define('pgadmin.node.server', [
})
.done(function(res) {
if (res.data.status) {
Alertify.success(res.data.result);
Notify.success(res.data.result);
}
else {
Alertify.error(res.data.result);
Notify.error(res.data.result);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
},
@@ -387,15 +388,15 @@ define('pgadmin.node.server', [
data:{ 'value': JSON.stringify(value) },
})
.done(function(res) {
Alertify.success(res.data.result, 10);
Notify.success(res.data.result, 10000);
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
} else {
evt.cancel = true;
Alertify.error( gettext('Please enter a valid name.'), 10);
Notify.error(gettext('Please enter a valid name.'), 10000);
}
},
// We will execute this function when user clicks on the Cancel
@@ -552,14 +553,14 @@ define('pgadmin.node.server', [
);
}
Alertify.success(res.info);
Notify.success(res.info);
self.close();
} else {
Alertify.error(res.errormsg);
Notify.error(res.errormsg);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
}
},
@@ -579,7 +580,7 @@ define('pgadmin.node.server', [
Alertify.changeServerPassword(d).resizeTo('40%','52%');
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
}
@@ -604,7 +605,7 @@ define('pgadmin.node.server', [
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
t.itemData(i).wal_pause=res.data.wal_pause;
t.unload(i);
t.setInode(i);
@@ -616,7 +617,7 @@ define('pgadmin.node.server', [
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
},
@@ -639,7 +640,7 @@ define('pgadmin.node.server', [
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
t.itemData(i).wal_pause=res.data.wal_pause;
t.unload(i);
t.setInode(i);
@@ -651,7 +652,7 @@ define('pgadmin.node.server', [
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
},
@@ -675,15 +676,15 @@ define('pgadmin.node.server', [
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
t.itemData(i).is_password_saved=res.data.is_password_saved;
}
else {
Alertify.error(res.info);
Notify.error(res.info);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
},
function() { return true; }
@@ -712,15 +713,15 @@ define('pgadmin.node.server', [
})
.done(function(res) {
if (res.success == 1) {
Alertify.success(res.info);
Notify.success(res.info);
t.itemData(i).is_tunnel_password_saved=res.data.is_tunnel_password_saved;
}
else {
Alertify.error(res.info);
Notify.error(res.info);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
},
function() { return true; }
@@ -826,7 +827,7 @@ define('pgadmin.node.server', [
tree.unload(item);
tree.setInode(item);
tree.addIcon(item, {icon: 'icon-shared-server-not-connected'});
Alertify.info('Please enter the server details to connect to the server. This server is a shared server.');
Notify.info('Please enter the server details to connect to the server. This server is a shared server.');
}else{
data.is_connecting = false;
tree.unload(item);
@@ -865,11 +866,11 @@ define('pgadmin.node.server', [
},
function() {
tree.addIcon(_item, {icon: 'icon-server-not-connected'});
Alertify.pgNotifier('Connection error', xhr, gettext('Connect to server.'));
Notify.pgNotifier('Connection error', xhr, gettext('Connect to server.'));
}
);
} else {
Alertify.pgNotifier('error', xhr, error, function(msg) {
Notify.pgNotifier('error', xhr, error, function(msg) {
setTimeout(function() {
if (msg == 'CRYPTKEY_SET') {
connect_to_server(_node, _data, _tree, _item, _wasConnected);
@@ -899,13 +900,13 @@ define('pgadmin.node.server', [
serverInfo[_data._id] = _.extend({}, _data);
if (_data.version < 90500) {
Alertify.warning(gettext('You have connected to a server version that is older ' +
Notify.warning(gettext('You have connected to a server version that is older ' +
'than is supported by pgAdmin. This may cause pgAdmin to break in strange and ' +
'unpredictable ways. Or a plague of frogs. Either way, you have been warned!') +
'<br /><br />' +
res.info, 0);
res.info, null);
} else {
Alertify.success(res.info);
Notify.success(res.info);
}
obj.trigger('connected', obj, _item, _data);
@@ -1089,7 +1090,7 @@ define('pgadmin.node.server', [
serverInfo[data._id] = _.extend({}, data);
if(data.errmsg) {
Alertify.error(data.errmsg);
Notify.error(data.errmsg);
}
}
})
@@ -1100,7 +1101,7 @@ define('pgadmin.node.server', [
}else{
tree.addIcon(item, {icon: 'icon-server-not-connected'});
}
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
};
}

View File

@@ -11,6 +11,7 @@ import { getNodeListByName } from '../../../../../static/js/node_ajax';
import { getNodePrivilegeRoleSchema } from '../../../static/js/privilege.ui';
import { getNodeVariableSchema } from '../../../static/js/variable.ui';
import TablespaceSchema from './tablespace.ui';
import Notify from '../../../../../../static/js/helpers/Notifier';
define('pgadmin.node.tablespace', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone',
@@ -301,14 +302,14 @@ define('pgadmin.node.tablespace', [
})
.done(function(res) {
if (res.success) {
Alertify.success(res.info);
Notify.success(res.info);
self.close();
} else {
Alertify.error(res.errormsg);
Notify.error(res.errormsg);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
},
function() {

View File

@@ -8,6 +8,7 @@
//////////////////////////////////////////////////////////////
import { generateNodeUrl } from './node_ajax';
import Notify from '../../../static/js/helpers/Notifier';
define('pgadmin.browser', [
'sources/gettext', 'sources/url_for', 'require', 'jquery', 'underscore',
@@ -675,7 +676,7 @@ define('pgadmin.browser', [
}
}
}).fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
},
@@ -690,7 +691,7 @@ define('pgadmin.browser', [
self.set_master_password('');
}
}).fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
},
@@ -723,7 +724,7 @@ define('pgadmin.browser', [
}, 500);
}
}).fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
},
@@ -1836,7 +1837,7 @@ define('pgadmin.browser', [
});
}
Alertify.pgNotifier(error, xhr, gettext('Error retrieving details for the node.'), function (msg) {
Notify.pgNotifier(error, xhr, gettext('Error retrieving details for the node.'), function (msg) {
if (msg == 'CRYPTKEY_SET') {
fetchNodeInfo(__i, __d, __n);
} else {
@@ -2054,7 +2055,7 @@ define('pgadmin.browser', [
fetchNodeInfo(_callback);
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
fetchNodeInfo(_callback);
});
};

View File

@@ -8,6 +8,7 @@
//////////////////////////////////////////////////////////////
import {removeNodeView} from './node_view';
import Notify from '../../../static/js/helpers/Notifier';
define([
'sources/gettext', 'jquery', 'underscore', 'sources/pgadmin',
@@ -362,7 +363,7 @@ define([
item: item,
info: info,
})) {
Alertify.pgNotifier(
Notify.pgNotifier(
error, xhr, gettext('Error retrieving properties - %s', error.message || that.label),
function(msg) {
if(msg === 'CRYPTKEY_SET') {
@@ -440,7 +441,7 @@ define([
}
return true;
}).fail(function(xhr, error) {
Alertify.pgNotifier(
Notify.pgNotifier(
error, xhr,
gettext('Error dropping %s', d._label.toLowerCase()),
function(alertMsg) {

View File

@@ -10,10 +10,10 @@
import pgAdmin from 'sources/pgadmin';
import url_for from 'sources/url_for';
import $ from 'jquery';
import * as Alertify from 'pgadmin.alertifyjs';
import gettext from 'sources/gettext';
import 'wcdocker';
import pgWindow from 'sources/window';
import Notify from '../../../static/js/helpers/Notifier';
const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
@@ -67,7 +67,7 @@ _.extend(pgBrowser, {
if(_panel.length == 0 && defaultLayoutCallback){
// clear the wcDocker before reset layout.
docker.clear();
Alertify.info(gettext('pgAdmin has reset the layout because the previously saved layout is invalid.'), 0);
Notify.info(gettext('pgAdmin has reset the layout because the previously saved layout is invalid.'), null);
if(defaultLayoutCallback){
defaultLayoutCallback(docker);
}
@@ -153,7 +153,7 @@ _.extend(pgBrowser, {
}).done(function() {
browser.cache_preferences('browser');
}).fail(function(xhr, error) {
Alertify.pgNotifier(error, xhr, gettext('Failed to save the lock layout setting.'));
Notify.pgNotifier(error, xhr, gettext('Failed to save the lock layout setting.'));
});
},

View File

@@ -8,6 +8,7 @@
//////////////////////////////////////////////////////////////
import {getNodeView, removeNodeView} from './node_view';
import Notify from '../../../static/js/helpers/Notifier';
define('pgadmin.browser.node', [
'sources/url_for',
@@ -463,7 +464,7 @@ define('pgadmin.browser.node', [
info: info,
}
)) {
Alertify.pgNotifier(
Notify.pgNotifier(
options.textStatus, xhr,
gettext('Error retrieving properties - %s', options.errorThrown || _label),
function(msg) {
@@ -873,9 +874,9 @@ define('pgadmin.browser.node', [
if (!(_.isFunction(obj.canDropCascade) ?
obj.canDropCascade.apply(obj, [d, i]) : obj.canDropCascade)) {
Alertify.error(
Notify.error(
gettext('The %s "%s" cannot be dropped.', obj.label, d.label),
10
10000
);
return;
}
@@ -890,9 +891,9 @@ define('pgadmin.browser.node', [
if (!(_.isFunction(obj.canDrop) ?
obj.canDrop.apply(obj, [d, i]) : obj.canDrop)) {
Alertify.error(
Notify.error(
gettext('The %s "%s" cannot be dropped/removed.', obj.label, d.label),
10
10000
);
return;
}
@@ -905,7 +906,7 @@ define('pgadmin.browser.node', [
})
.done(function(res) {
if(res.success == 2){
Alertify.error(res.info, 0);
Notify.error(res.info, null);
return;
}
if (res.success == 0) {
@@ -1504,7 +1505,7 @@ define('pgadmin.browser.node', [
$(pnlDependents).removeData('node-prop');
},
error: function(_m, jqxhr) {
Alertify.pgNotifier(
Notify.pgNotifier(
'error', jqxhr,
gettext('Error saving properties')
);

View File

@@ -10,9 +10,9 @@
import pgAdmin from 'sources/pgadmin';
import url_for from 'sources/url_for';
import $ from 'jquery';
import * as Alertify from 'pgadmin.alertifyjs';
import * as SqlEditorUtils from 'sources/sqleditor_utils';
import pgWindow from 'sources/window';
import Notify from '../../../static/js/helpers/Notifier';
//var modifyAnimation = require('sources/modify_animation');
@@ -91,10 +91,6 @@ _.extend(pgBrowser, {
self.preference_version(self.generate_preference_version());
pgBrowser.keyboardNavigation.init();
// if(pgBrowser.tree) {
// modifyAnimation.modifyAcitreeAnimation(self);
// modifyAnimation.modifyAlertifyAnimation(self);
// }
// Initialize Tree saving/reloading
pgBrowser.browserTreeState.init();
@@ -113,7 +109,7 @@ _.extend(pgBrowser, {
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
}, 500);
},

View File

@@ -10,8 +10,8 @@
import pgAdmin from 'sources/pgadmin';
import url_for from 'sources/url_for';
import $ from 'jquery';
import * as Alertify from 'pgadmin.alertifyjs';
import gettext from 'sources/gettext';
import Notify from '../../../static/js/helpers/Notifier';
const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
@@ -26,7 +26,7 @@ _.extend(pgBrowser, {
'command': cmd_string,
}),
}).fail(function(xhr, error) {
Alertify.pgNotifier(error, xhr, gettext('Failed to send signal to runtime.'));
Notify.pgNotifier(error, xhr, gettext('Failed to send signal to runtime.'));
});
},

View File

@@ -7,6 +7,8 @@
//
//////////////////////////////////////////////////////////////
import Notify from '../../../static/js/helpers/Notifier';
define('pgadmin.dashboard', [
'sources/url_for', 'sources/gettext', 'require', 'jquery', 'underscore',
'sources/pgadmin', 'backbone', 'backgrid',
@@ -105,14 +107,14 @@ define('pgadmin.dashboard', [
})
.done(function(res) {
if (res == gettext('Success')) {
Alertify.success(txtSuccess);
Notify.success(txtSuccess);
refresh_grid();
} else {
Alertify.error(txtError);
Notify.error(txtError);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
},
function() {
@@ -237,7 +239,7 @@ define('pgadmin.dashboard', [
$(div).html(data);
})
.fail(function(xhr, error) {
Alertify.pgNotifier(
Notify.pgNotifier(
error, xhr,
gettext('An error occurred whilst loading the dashboard.'),
function(msg) {
@@ -356,7 +358,7 @@ define('pgadmin.dashboard', [
self.init_dashboard();
})
.fail(function(xhr, error) {
Alertify.pgNotifier(
Notify.pgNotifier(
error, xhr,
gettext('An error occurred whilst loading the dashboard.'),
function(msg) {
@@ -1171,7 +1173,7 @@ define('pgadmin.dashboard', [
} else {
txtMessage = gettext('You cannot terminate background worker processes.');
}
Alertify.info(txtMessage);
Notify.info(txtMessage);
return false;
// If it is the last active connection on maintenance db then error out
} else if (maintenance_database == m.get('datname') &&
@@ -1181,11 +1183,11 @@ define('pgadmin.dashboard', [
} else {
txtMessage = gettext('You are not allowed to terminate the main active session.');
}
Alertify.error(txtMessage);
Notify.error(txtMessage);
return false;
} else if (is_cancel_session && m.get('state') == 'idle') {
// If this session is already idle then do nothing
Alertify.info(
Notify.info(
gettext('The session is already in idle state.')
);
return false;
@@ -1205,7 +1207,7 @@ define('pgadmin.dashboard', [
} else {
txtMessage = gettext('Superuser privileges are required to terminate another users query.');
}
Alertify.error(txtMessage);
Notify.error(txtMessage);
return false;
}
},

View File

@@ -7,6 +7,8 @@
//
//////////////////////////////////////////////////////////////
import Notify from '../../../../static/js/helpers/Notifier';
define('misc.dependencies', [
'sources/gettext', 'underscore', 'jquery', 'backbone',
'pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.backgrid',
@@ -268,7 +270,7 @@ define('misc.dependencies', [
item: item,
info: treeHierarchy,
})) {
Alertify.pgNotifier(
Notify.pgNotifier(
error, xhr,
gettext('Error retrieving data from the server: %s', message || _label),
function(alertMsg) {
@@ -391,7 +393,7 @@ define('misc.dependencies', [
item: item,
info: treeHierarchy,
})) {
Alertify.pgNotifier(
Notify.pgNotifier(
error, xhr,
gettext('Error retrieving data from the server: %s', message || _label),
function(alertMsg) {

View File

@@ -7,6 +7,8 @@
//
//////////////////////////////////////////////////////////////
import Notify from '../../../../static/js/helpers/Notifier';
define('misc.dependents', [
'sources/gettext', 'underscore', 'jquery', 'backbone',
'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.backgrid',
@@ -274,7 +276,7 @@ define('misc.dependents', [
item: item,
info: treeHierarchy,
})) {
Alertify.pgNotifier(
Notify.pgNotifier(
error, xhr,
gettext('Error retrieving data from the server: %s', message || _label),
function(alertMsg) {

View File

@@ -13,6 +13,7 @@ import $ from 'jquery';
import Alertify from 'pgadmin.alertifyjs';
import pgAdmin from 'sources/pgadmin';
import {removeTransId, set_last_traversed_dir} from './helpers';
import Notify from '../../../../static/js/helpers/Notifier';
// Declare the Create mode dialog
module.exports = Alertify.dialog('createModeDlg', function() {
@@ -127,12 +128,12 @@ module.exports = Alertify.dialog('createModeDlg', function() {
permission = true;
} else {
$('.file_manager_ok').addClass('disabled');
Alertify.error(data.Error);
Notify.error(data.Error);
}
})
.fail(function() {
$('.file_manager_ok').addClass('disabled');
Alertify.error(gettext('Error occurred while checking access permission.'));
Notify.error(gettext('Error occurred while checking access permission.'));
});
return permission;
},

View File

@@ -17,11 +17,13 @@
* @author Simon Georget <simon (at) linea21 (dot) com>
* @copyright Authors
*/
import Notify from '../../../../static/js/helpers/Notifier';
define([
'jquery', 'underscore', 'pgadmin.alertifyjs',
'jquery', 'underscore',
'sources/gettext', 'sources/url_for', 'dropzone', 'sources/pgadmin',
'sources/csrf', 'tablesorter', 'tablesorter-metric',
], function($, _, Alertify, gettext, url_for, Dropzone, pgAdmin, csrf) {
], function($, _, gettext, url_for, Dropzone, pgAdmin, csrf) {
pgAdmin.Browser = pgAdmin.Browser || {};
@@ -296,9 +298,9 @@ define([
// UnBind toolbar functions.
$('.fileinfo').find('button.rename, button.delete, button.download').off();
Alertify.success(lg.successful_rename);
Notify.success(lg.successful_rename);
} else {
Alertify.error(result.Error);
Notify.error(result.Error);
}
finalName = result['New Name'];
@@ -337,14 +339,14 @@ define([
if (result.Code === 1) {
isDeleted = true;
if (isDeleted) {
Alertify.success(lg.successful_delete);
Notify.success(lg.successful_delete);
var rootpath = result.Path.substring(0, result.Path.length - 1); // removing the last slash
rootpath = rootpath.substr(0, rootpath.lastIndexOf('/') + 1);
getFolderInfo(rootpath);
}
} else {
isDeleted = false;
Alertify.error(result.Error);
Notify.error(result.Error);
}
});
return isDeleted;
@@ -408,7 +410,7 @@ define([
} else {
$('.file_manager_ok').addClass('disabled');
$('.file_manager_ok').attr('disabled', true);
Alertify.error(data.Error);
Notify.error(data.Error);
}
// Disable select button if user select file.
@@ -443,13 +445,13 @@ define([
} else {
$('.file_manager_ok').addClass('disabled');
$('.file_manager_ok').attr('disabled', true);
Alertify.error(data.Error);
Notify.error(data.Error);
}
})
.fail(function() {
$('.file_manager_ok').addClass('disabled');
$('.file_manager_ok').attr('disabled', true);
Alertify.error(
Notify.error(
gettext('Error occurred while checking access permission.')
);
});
@@ -742,7 +744,7 @@ define([
// hide activity indicator
$('.fileinfo').find('span.activity').hide();
if (data.Code === 0) {
Alertify.error(data.Error);
Notify.error(data.Error);
return;
}
@@ -1294,7 +1296,7 @@ define([
}
},
error: function (error) {
Alertify.error(error);
Notify.error(error);
},
});
};
@@ -1774,18 +1776,18 @@ define([
$this.find('.dz-upload').addClass('success');
}, 1000);
$this.find('.dz-upload').css('width', '100%').html('100%');
Alertify.success(lg.upload_success);
Notify.success(lg.upload_success);
} else {
$this.find('.dz-upload').addClass('error');
$this.find('.dz-upload').css('width', '0%').html('0%');
Alertify.error(resp_data.Error);
Notify.error(resp_data.Error);
}
getFolderInfo(path);
},
totaluploadprogress: function() {},
complete: function(file) {
if (file.status == 'error') {
Alertify.error(lg.upload_error);
Notify.error(lg.upload_error);
}
$('.upload_file .dz_cross_btn').removeAttr('disabled');
getFolderInfo(path);
@@ -1958,15 +1960,15 @@ define([
function(resp) {
var result = resp.data.result;
if (result.Code === 1) {
Alertify.success(lg.successful_added_folder);
Notify.success(lg.successful_added_folder);
getFolderInfo(result.Parent);
} else {
Alertify.error(result.Error);
Notify.error(result.Error);
}
}
);
} else {
Alertify.error(lg.no_foldername);
Notify.error(lg.no_foldername);
}
};

View File

@@ -7,6 +7,8 @@
//
//////////////////////////////////////////////////////////////
import Notify from '../../../../static/js/helpers/Notifier';
define('misc.sql', [
'sources/gettext', 'underscore', 'jquery',
'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
@@ -154,7 +156,7 @@ define('misc.sql', [
item: item,
info: treeHierarchy,
})) {
Alertify.pgNotifier(
Notify.pgNotifier(
error, xhr,
gettext('Error retrieving the information - %s', message || _label),
function(msg) {

View File

@@ -7,6 +7,8 @@
//
//////////////////////////////////////////////////////////////
import Notify from '../../../../static/js/helpers/Notifier';
define('misc.statistics', [
'sources/gettext', 'underscore', 'jquery', 'backbone',
'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backgrid', 'alertify', 'sources/size_prettify',
@@ -295,7 +297,7 @@ define('misc.statistics', [
item: item,
info: treeHierarchy,
})) {
Alertify.pgNotifier(
Notify.pgNotifier(
error, xhr,
gettext('Error retrieving the information - %s', message || _label),
function(alertMsg) {

View File

@@ -1,3 +1,11 @@
/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2021, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
import _ from 'lodash';
import React from 'react';

View File

@@ -15,185 +15,6 @@ define([
alertify.defaults.theme.cancel = 'btn btn-secondary fa fa-lg fa-times pg-alertify-button';
alertify.defaults.theme.input = 'form-control';
alertify.defaults.closable = false;
alertify.pgIframeDialog || alertify.dialog('pgIframeDialog', function() {
var iframe;
return {
// dialog constructor function, this will be called when the user calls
// alertify.pgIframeDialog(message)
main: function(message) {
//set the videoId setting and return current instance for chaining.
return this.set({
'pg_msg': message,
});
},
// we only want to override two options (padding and overflow).
setup: function() {
return {
options: {
// Disable both padding and overflow control.
padding: !1,
overflow: !1,
closable: true,
},
};
},
// This will be called once the DOM is ready and will never be invoked
// again. Here we create the iframe to embed the video.
build: function() {
// create the iframe element
iframe = document.createElement('iframe');
iframe.src = '';
iframe.frameBorder = 'no';
iframe.width = '100%';
iframe.height = '100%';
// add it to the dialog
this.elements.content.appendChild(iframe);
//give the dialog initial height (half the screen height).
this.elements.body.style.minHeight = screen.height * .5 + 'px';
},
// dialog custom settings
settings: {
pg_msg: undefined,
},
// listen and respond to changes in dialog settings.
settingUpdated: function(key, oldValue, newValue) {
if(key === 'pg_msg') {
let doc = iframe.contentWindow || iframe.contentDocument;
if (doc.document) {
doc = doc.document;
}
doc.open();
doc.write(newValue);
doc.close();
}
},
// listen to internal dialog events.
hooks: {
// triggered when a dialog option gets update.
// warning! this will not be triggered for settings updates.
onupdate: function(option, oldValue, newValue) {
if(option === 'resizable') {
if (newValue) {
this.elements.content.removeAttribute('style');
iframe && iframe.removeAttribute('style');
} else {
this.elements.content.style.minHeight = 'inherit';
iframe && (iframe.style.minHeight = 'inherit');
}
}
},
},
};
});
alertify.pgNotifier = function(type, xhr, promptmsg, onJSONResult) {
var msg = xhr.responseText,
contentType = xhr.getResponseHeader('Content-Type');
if (xhr.status == 0) {
msg = gettext('Connection to the server has been lost.');
promptmsg = gettext('Connection Lost');
} else {
if (contentType) {
try {
if (contentType.indexOf('application/json') == 0) {
var resp = JSON.parse(msg);
if(resp.info == 'CRYPTKEY_MISSING') {
var pgBrowser = window.pgAdmin.Browser;
pgBrowser.set_master_password('', ()=> {
if(onJSONResult && typeof(onJSONResult) == 'function') {
onJSONResult('CRYPTKEY_SET');
}
});
return;
} else if (resp.result != null && (!resp.errormsg || resp.errormsg == '') &&
onJSONResult && typeof(onJSONResult) == 'function') {
return onJSONResult(resp.result);
}
msg = _.escape(resp.result) || _.escape(resp.errormsg) || 'Unknown error';
}
if (contentType.indexOf('text/html') == 0) {
var alertMessage = promptmsg;
if (type === 'error') {
alertMessage =
'<div class="media text-danger text-14">'
+ '<div class="media-body media-middle">'
+ '<div class="alert-text" role="alert">' + promptmsg + '</div><br/>'
+ '<div class="alert-text" role="alert">' + gettext('Click for details.') + '</div>'
+ '</div>'
+ '</div>';
}
alertify.notify(
alertMessage, type, 0,
function() {
alertify.pgIframeDialog().show().set({
frameless: false,
}).set(
'pg_msg', msg
);
});
return;
}
} catch (e) {
alertify.alert().show().set('message', e.message).set(
'title', 'Error'
).set('closable', true);
}
}
}
alertify.alert().show().set(
'message', msg.replace(new RegExp(/\r?\n/, 'g'), '<br />')
).set('title', promptmsg).set('closable', true);
};
alertify.pgRespErrorNotify = (xhr, error, prefixMsg='') => {
var contentType = xhr.getResponseHeader('Content-Type');
if (xhr.status === 410) {
const pgBrowser = window.pgAdmin.Browser;
pgBrowser.report_error(gettext('Error: Object not found - %s.', xhr.statusText), xhr.responseJSON.errormsg);
} else {
try {
if (xhr.status === 0) {
error = gettext('Connection to the server has been lost.');
} else {
if(contentType){
if(contentType.indexOf('application/json') >= 0) {
var resp = JSON.parse(xhr.responseText);
error = _.escape(resp.result) || _.escape(resp.errormsg) || gettext('Unknown error');
}
}
if (contentType.indexOf('text/html') >= 0) {
var alertMessage =
'<div class="media text-danger text-14">'
+ '<div class="media-body media-middle">'
+ '<div class="alert-text" role="alert">' + gettext('INTERNAL SERVER ERROR') + '</div><br/>'
+ '<div class="alert-text" role="alert">' + gettext('Click for details.') + '</div>'
+ '</div>'
+ '</div>';
alertify.notify(
alertMessage, 'error', 0, () => {
alertify.pgIframeDialog()
.show()
.set({frameless: false})
.set('pg_msg', xhr.responseText);
}
);
return;
}
}
}
catch(e){
error = e.message;
}
alertify.error(prefixMsg +' '+error);
}
};
var alertifyDialogResized = function(stop) {
var self = this;
@@ -423,65 +244,6 @@ define([
return false;
};
var alertifySuccess = alertify.success,
alertifyError = alertify.error,
alertifyWarning = alertify.warning;
/*
For adding the jasmine test cases, we needed to refer the original success,
and error functions, as orig_success and orig_error respectively.
*/
_.extend(alertify, {
orig_success: alertifySuccess,
orig_error: alertifyError,
orig_warning: alertifyWarning,
});
_.extend(alertify, {
success: function(message, timeout, callback) {
var alertMessage =
`<div class="d-flex px-3 py-2">
<div class="pr-2">
<i class="fa fa-check" aria-hidden="true"></i>
</div>
<div class="alert-text-body" role="status">${message}</div>
</div>`;
return alertify.orig_success(alertMessage, timeout, callback);
},
error: function(message, timeout, callback) {
var alertMessage =
`<div class="d-flex px-3 py-2">
<div class="pr-2">
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
</div>
<div class="alert-text-body" role="status">${message}</div>
</div>`;
return alertify.orig_error(alertMessage, timeout, callback);
},
info: function(message, timeout) {
var alertMessage =
`<div class="d-flex px-3 py-2">
<div class="mr-3">
<i class="fa fa-info-circle" aria-hidden="true"></i>
</div>
<div class="alert-text-body" role="status">${message}</div>
</div>`;
var alert = alertify.notify(alertMessage, 'custom', timeout);
return alert;
},
warning: function(message, timeout) {
var alertMessage =
`<div class="d-flex px-3 py-2">
<div class="mr-3">
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
</div>
<div class="alert-text-body" role="status">${message}</div>
</div>`;
var alert = alertify.orig_warning(alertMessage, timeout);
return alert;
},
});
// Confirm dialogue: Set title attribute
alertify.confirm().set({
onshow:function() {

View File

@@ -7,6 +7,8 @@
//
//////////////////////////////////////////////////////////////
import Notify from '../../static/js/helpers/Notifier';
define([
'sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', 'backgrid', 'alertify',
'moment', 'bignumber', 'codemirror', 'sources/utils', 'sources/keyboard_shortcuts', 'sources/select2/configure_show_on_scroll',
@@ -2426,7 +2428,7 @@ define([
Alertify.alert(gettext('Validate binary path'), gettext(res.data));
})
.fail(function(xhr, error) {
Alertify.pgNotifier(error, xhr, gettext('Failed to validate binary path.'));
Notify.pgNotifier(error, xhr, gettext('Failed to validate binary path.'));
});
},
});

View File

@@ -13,11 +13,11 @@ import { makeStyles } from '@material-ui/core/styles';
import { Box, FormControl, OutlinedInput, FormHelperText,
Grid, IconButton, FormControlLabel, Switch, Checkbox, useTheme, InputLabel, Paper } from '@material-ui/core';
import { ToggleButton, ToggleButtonGroup } from '@material-ui/lab';
import ReportProblemIcon from '@material-ui/icons/ReportProblemRounded';
import InfoIcon from '@material-ui/icons/InfoRounded';
import ErrorRoundedIcon from '@material-ui/icons/ErrorOutlineRounded';
import InfoRoundedIcon from '@material-ui/icons/InfoRounded';
import CloseIcon from '@material-ui/icons/CloseRounded';
import CheckIcon from '@material-ui/icons/CheckCircleOutlineRounded';
import CheckRoundedIcon from '@material-ui/icons/CheckRounded';
import WarningRoundedIcon from '@material-ui/icons/WarningRounded';
import FolderOpenRoundedIcon from '@material-ui/icons/FolderOpenRounded';
import DescriptionIcon from '@material-ui/icons/Description';
import Select, {components as RSComponents} from 'react-select';
@@ -91,6 +91,7 @@ export const MESSAGE_TYPE = {
ERROR: 'Error',
INFO: 'Info',
CLOSE: 'Close',
WARNING: 'Warning'
};
/* Icon based on MESSAGE_TYPE */
@@ -99,11 +100,13 @@ function FormIcon({type, close=false, ...props}) {
if(close) {
TheIcon = CloseIcon;
} else if(type === MESSAGE_TYPE.SUCCESS) {
TheIcon = CheckIcon;
TheIcon = CheckRoundedIcon;
} else if(type === MESSAGE_TYPE.ERROR) {
TheIcon = ReportProblemIcon;
TheIcon = ErrorRoundedIcon;
} else if(type === MESSAGE_TYPE.INFO) {
TheIcon = InfoIcon;
TheIcon = InfoRoundedIcon;
} else if(type === MESSAGE_TYPE.WARNING) {
TheIcon = WarningRoundedIcon;
}
return <TheIcon fontSize="small" {...props} />;
@@ -1035,6 +1038,20 @@ const useStylesFormFooter = makeStyles((theme)=>({
iconError: {
color: theme.palette.error.main,
},
containerInfo: {
borderColor: theme.palette.primary.main,
backgroundColor: theme.palette.primary.light,
},
iconInfo: {
color: theme.palette.primary.main,
},
containerWarning: {
borderColor: theme.palette.warning.main,
backgroundColor: theme.palette.warning.light,
},
iconWarning: {
color: theme.palette.warning.main,
},
message: {
marginLeft: theme.spacing(0.5),
},
@@ -1044,26 +1061,38 @@ const useStylesFormFooter = makeStyles((theme)=>({
}));
/* The form footer used mostly for showing error */
export function FormFooterMessage({type=MESSAGE_TYPE.SUCCESS, message, closable=true, onClose=()=>{}}) {
export function FormFooterMessage(props) {
const classes = useStylesFormFooter();
if(!message) {
if(!props.message) {
return <></>;
}
return (
<Box className={classes.root}>
<Box className={clsx(classes.container, classes[`container${type}`])}>
<FormIcon type={type} className={classes[`icon${type}`]}/>
<Box className={classes.message}>{message}</Box>
{closable && <IconButton className={clsx(classes.closeButton, classes[`icon${type}`])} onClick={onClose}>
<FormIcon close={true}/>
</IconButton>}
</Box>
<NotifierMessage {...props}></NotifierMessage>
</Box>
);
}
FormFooterMessage.propTypes = {
message: PropTypes.string,
};
export function NotifierMessage({type=MESSAGE_TYPE.SUCCESS, message, closable=true, onClose=()=>{}}) {
const classes = useStylesFormFooter();
return (
<Box className={clsx(classes.container, classes[`container${type}`])}>
<FormIcon type={type} className={classes[`icon${type}`]}/>
<Box className={classes.message}>{message}</Box>
{closable && <IconButton className={clsx(classes.closeButton, classes[`icon${type}`])} onClick={onClose}>
<FormIcon close={true}/>
</IconButton>}
</Box>
);
}
NotifierMessage.propTypes = {
type: PropTypes.oneOf(Object.values(MESSAGE_TYPE)).isRequired,
message: PropTypes.string,
closable: PropTypes.bool,

View File

@@ -25,6 +25,7 @@ import Loader from 'sources/components/Loader';
import Alertify from 'pgadmin.alertifyjs';
import PropTypes from 'prop-types';
import PrivilegeSchema from '../../../tools/grant_wizard/static/js/privilege_schema.ui';
import Notify from '../../../static/js/helpers/Notifier';
const useStyles = makeStyles(() =>
({
@@ -205,7 +206,7 @@ export default function GrantWizard({ sid, did, nodeInfo, nodeData }) {
setLoaderText('');
})
.catch(() => {
Alertify.error(gettext('Error while fetching grant wizard data.'));
Notify.error(gettext('Error while fetching grant wizard data.'));
setLoaderText('');
});
}, [nodeData]);
@@ -235,7 +236,7 @@ export default function GrantWizard({ sid, did, nodeInfo, nodeData }) {
setLoaderText('');
})
.catch(() => {
Alertify.error(gettext('Error while fetching SQL.'));
Notify.error(gettext('Error while fetching SQL.'));
});
break;
default:
@@ -261,7 +262,7 @@ export default function GrantWizard({ sid, did, nodeInfo, nodeData }) {
})
.catch((error) => {
setLoaderText('');
Alertify.error(gettext(`Error while saving grant wizard data: ${error.response.data.errormsg}`));
Notify.error(gettext(`Error while saving grant wizard data: ${error.response.data.errormsg}`));
});
};

View File

@@ -1,3 +1,12 @@
/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2021, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { Box, makeStyles } from '@material-ui/core';
import DataGridView, { DataGridHeader } from '../SchemaView/DataGridView';

View File

@@ -0,0 +1,181 @@
/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2021, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
import { useSnackbar, SnackbarProvider, SnackbarContent } from 'notistack';
import React from 'react';
import ReactDOM from 'react-dom';
import Theme from 'sources/Theme';
import { NotifierMessage, MESSAGE_TYPE } from '../components/FormComponents';
import CustomPropTypes from '../custom_prop_types';
import gettext from 'sources/gettext';
import pgWindow from 'sources/window';
import Alertify from 'pgadmin.alertifyjs';
const AUTO_HIDE_DURATION = 3000; // In milliseconds
let snackbarRef;
function SnackbarUtilsConfigurator() {
snackbarRef = useSnackbar();
return <></>;
}
let notifierInitialized = false;
export function initializeNotifier(notifierContainer) {
notifierInitialized = true;
ReactDOM.render(
<Theme>
<SnackbarProvider
maxSnack={30}
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}>
<SnackbarUtilsConfigurator />
</SnackbarProvider>
</Theme>, notifierContainer
);
}
export const FinalNotifyContent = React.forwardRef(({children}, ref) => {
return <SnackbarContent style= {{justifyContent:'end'}} ref={ref}>{children}</SnackbarContent>;
});
FinalNotifyContent.displayName = 'FinalNotifyContent';
FinalNotifyContent.propTypes = {
children: CustomPropTypes.children,
};
var Notifier = {
success(msg, autoHideDuration = AUTO_HIDE_DURATION) {
this._callNotify(msg, MESSAGE_TYPE.SUCCESS, autoHideDuration);
},
warning(msg, autoHideDuration = AUTO_HIDE_DURATION) {
this._callNotify(msg, MESSAGE_TYPE.WARNING, autoHideDuration);
},
info(msg, autoHideDuration = AUTO_HIDE_DURATION) {
this._callNotify(msg, MESSAGE_TYPE.INFO, autoHideDuration);
},
error(msg, autoHideDuration = AUTO_HIDE_DURATION) {
this._callNotify(msg, MESSAGE_TYPE.ERROR, autoHideDuration);
},
notify(content, autoHideDuration) {
if (content) {
if(!notifierInitialized) {
initializeNotifier(document.getElementById('notifierContainer'));
}
let options = {autoHideDuration, content:(key) => (
<FinalNotifyContent>{React.cloneElement(content, {onClose:()=>{snackbarRef.closeSnackbar(key);}})}</FinalNotifyContent>
)};
options.content.displayName = 'content';
snackbarRef.enqueueSnackbar(null, options);
}
},
_callNotify(msg, type, autoHideDuration) {
if (!_.isNull(autoHideDuration)) {
this.notify(<NotifierMessage type={type} message={msg} closable={false} />, autoHideDuration);
} else {
this.notify(<NotifierMessage type={type} message={msg}/>, null);
}
},
pgRespErrorNotify(xhr, error, prefixMsg='') {
var contentType = xhr.getResponseHeader('Content-Type');
if (xhr.status === 410) {
const pgBrowser = window.pgAdmin.Browser;
pgBrowser.report_error(gettext('Error: Object not found - %s.', xhr.statusText), xhr.responseJSON.errormsg);
} else {
try {
if (xhr.status === 0) {
error = gettext('Connection to the server has been lost.');
} else {
if(contentType){
if(contentType.indexOf('application/json') >= 0) {
var resp = JSON.parse(xhr.responseText);
error = _.escape(resp.result) || _.escape(resp.errormsg) || gettext('Unknown error');
}
}
if (contentType.indexOf('text/html') >= 0) {
error = gettext('INTERNAL SERVER ERROR');
console.warn(xhr.responseText);
}
}
}
catch(e){
error = e.message;
}
this.error(prefixMsg + ' ' + error);
}
},
pgNotifier(type, xhr, promptmsg, onJSONResult) {
var msg = xhr.responseText,
contentType = xhr.getResponseHeader('Content-Type');
if (xhr.status == 0) {
msg = gettext('Connection to the server has been lost.');
promptmsg = gettext('Connection Lost');
} else {
if (contentType) {
try {
if (contentType.indexOf('application/json') == 0) {
var resp = JSON.parse(msg);
if(resp.info == 'CRYPTKEY_MISSING') {
var pgBrowser = window.pgAdmin.Browser;
pgBrowser.set_master_password('', ()=> {
if(onJSONResult && typeof(onJSONResult) == 'function') {
onJSONResult('CRYPTKEY_SET');
}
});
return;
} else if (resp.result != null && (!resp.errormsg || resp.errormsg == '') &&
onJSONResult && typeof(onJSONResult) == 'function') {
return onJSONResult(resp.result);
}
msg = _.escape(resp.result) || _.escape(resp.errormsg) || 'Unknown error';
}
if (contentType.indexOf('text/html') == 0) {
var alertMessage = promptmsg;
if (type === 'error') {
alertMessage =
'<div class="media text-danger text-14">'
+ '<div class="media-body media-middle">'
+ '<div class="alert-text" role="alert">' + promptmsg + '</div><br/>'
+ '<div class="alert-text" role="alert">' + gettext('Click for details.') + '</div>'
+ '</div>'
+ '</div>';
}
Alertify.notify(
alertMessage, type, 0,
function() {
Alertify.pgIframeDialog().show().set({
frameless: false,
}).set(
'pg_msg', msg
);
});
return;
}
} catch (e) {
Alertify.alert().show().set('message', e.message).set(
'title', 'Error'
).set('closable', true);
}
}
}
Alertify.alert().show().set(
'message', msg.replace(new RegExp(/\r?\n/, 'g'), '<br />')
).set('title', promptmsg).set('closable', true);
}
};
if(window.frameElement) {
Notifier = pgWindow.Notifier;
} else {
pgWindow.Notifier = Notifier;
}
export default Notifier;

View File

@@ -1,3 +1,11 @@
/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2021, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import clsx from 'clsx';

View File

@@ -1,3 +1,12 @@
/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2021, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { Box } from '@material-ui/core';

View File

@@ -15,7 +15,7 @@
import JSONBigNumberLib from 'json-bignumber';
import gettext from 'sources/gettext';
import Alertify from 'pgadmin.alertifyjs';
import Notify from '../../../static/js/helpers/Notifier';
(function($, JSONBigNumber) {
// register namespace
@@ -405,7 +405,7 @@ import Alertify from 'pgadmin.alertifyjs';
modes: ['code', 'form', 'tree','preview'],
onError: function (error){
var msg = 'Invalid Json: ' + error.message.split(':')[0];
Alertify.error(gettext(msg));
Notify.error(gettext(msg));
}
};
$editor = new JSONEditor(jsonContainer, options);
@@ -428,7 +428,7 @@ import Alertify from 'pgadmin.alertifyjs';
modes: ['code', 'form', 'tree','preview'],
onError: function (error){
var msg = 'Invalid Json: ' + error.message.split(':')[0];
Alertify.error(gettext(msg));
Notify.error(gettext(msg));
}
};
if(jsonContainer) {

View File

@@ -22,7 +22,7 @@ function isNotificationEnabled(sqlEditor) {
return sqlEditor.info_notifier_timeout >= 0;
}
export function callRenderAfterPoll(sqlEditor, alertify, res) {
export function callRenderAfterPoll(sqlEditor, Notify, res) {
sqlEditor.query_end_time = new Date();
sqlEditor.rows_affected = res.rows_affected;
sqlEditor.has_more_rows = res.has_more_rows;
@@ -41,7 +41,7 @@ export function callRenderAfterPoll(sqlEditor, alertify, res) {
sqlEditor.update_msg_history(true, res.result, false);
sqlEditor.reset_data_store();
if (isNotificationEnabled(sqlEditor)) {
alertify.success(msg, sqlEditor.info_notifier_timeout);
Notify.success(msg, sqlEditor.info_notifier_timeout);
}
sqlEditor.enable_disable_download_btn(true);
}
@@ -54,4 +54,4 @@ export function callRenderAfterPoll(sqlEditor, alertify, res) {
sqlEditor.setIsQueryRunning(false);
sqlEditor.trigger('pgadmin-sqleditor:loading-icon:hide');
}
}

View File

@@ -17,6 +17,7 @@ import axios from 'axios';
var queryToolActions = require('sources/sqleditor/query_tool_actions');
import filterDialogModel from 'sources/sqleditor/filter_dialog_model';
import {handleQueryToolAjaxError} from 'sources/sqleditor/query_tool_http_error_handler';
import Notify from '../../../static/js/helpers/Notifier';
let FilterDialog = {
geturl: function(transId, reconnect) {
@@ -236,7 +237,7 @@ let FilterDialog = {
setTimeout(
function() {
self.close(); // Close the dialog now
Alertify.success(gettext('Filter updated successfully'));
Notify.success(gettext('Filter updated successfully'));
queryToolActions.executeQuery(handler);
}, 10
);
@@ -256,7 +257,7 @@ let FilterDialog = {
setTimeout(
function() {
Alertify.error(error);
Notify.error(error);
}, 10
);
});

View File

@@ -16,6 +16,7 @@ import pgAdmin from 'sources/pgadmin';
import Backform from 'pgadmin.backform';
import macroModel from 'sources/sqleditor/macro_model';
import axios from 'axios';
import Notify from '../../../static/js/helpers/Notifier';
let MacroDialog = {
'dialog': function(handler) {
@@ -303,7 +304,7 @@ let MacroDialog = {
$($.find('div.btn-group.mr-1.user_macros ul.dropdown-menu')).html($(str));
self.close(); // Close the dialog now
Alertify.success(gettext('Macro updated successfully'));
Notify.success(gettext('Macro updated successfully'));
}, 10
);
} else {
@@ -321,7 +322,7 @@ let MacroDialog = {
setTimeout(
function() {
Alertify.error(error.response.data.errormsg);
Notify.error(error.response.data.errormsg);
}, 10
);
});

View File

@@ -14,6 +14,7 @@ import Alertify from 'pgadmin.alertifyjs';
import pgAdmin from 'sources/pgadmin';
import Backform from 'pgadmin.backform';
import newConnectionDialogModel from 'sources/sqleditor/new_connection_dialog_model';
import Notify from 'static/js/helpers/Notifier';
let NewConnectionDialog = {
@@ -243,7 +244,7 @@ let NewConnectionDialog = {
});
if(!is_create_connection) {
let errmsg = 'Connection with this configuration already present.';
Alertify.info(errmsg);
Notify.info(errmsg);
} else {
let connection_details = {
'server_group': handler.gridView.handler.url_params.sgid,

View File

@@ -14,6 +14,7 @@ import pgAdmin from 'sources/pgadmin';
import Backform from 'pgadmin.backform';
import url_for from 'sources/url_for';
import alertify from 'pgadmin.alertifyjs';
import Notify from '../helpers/Notifier';
export default function newConnectionDialogModel(response, sgid, sid, handler, conn_self) {
@@ -61,7 +62,7 @@ export default function newConnectionDialogModel(response, sgid, sid, handler, c
} else {
msg = e.responseJSON.errormsg;
}
alertify.error(msg);
Notify.error(msg);
});
},
render: function() {

View File

@@ -10,7 +10,7 @@
import gettext from 'sources/gettext';
import Backgrid from 'pgadmin.backgrid';
import Backbone from 'backbone';
import Alertify from 'pgadmin.alertifyjs';
import Notify from '../helpers/Notifier';
let NotificationsModel = Backbone.Model.extend({
defaults: {
@@ -121,7 +121,7 @@ let queryToolNotifications = {
notify_msg = gettext('Asynchronous notification "%s" received from server process with PID %s', notify_messages[i].channel, notify_messages[i].pid);
}
Alertify.info(notify_msg);
Notify.info(notify_msg);
}
// Add notify messages to the collection.

View File

@@ -71,6 +71,7 @@
<![endif]-->
{% block body %}{% endblock %}
<div id="notifierContainer"></div>
<script type="application/javascript">
{% block init_script %}{% endblock %}

View File

@@ -7,6 +7,8 @@
//
//////////////////////////////////////////////////////////////
import Notify from '../../../../static/js/helpers/Notifier';
define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'pgadmin.alertifyjs', 'sources/pgadmin', 'pgadmin.browser', 'backbone',
@@ -521,7 +523,7 @@ define([
pgTools.DirectDebug.polling_timeout_idle = true;
//Set the alertify message to inform the user that execution is completed.
Alertify.success(res.info, 3);
Notify.success(res.info, 3000);
// Update the message tab of the debugger
if (res.data.status_message) {
@@ -555,7 +557,7 @@ define([
pgTools.DirectDebug.polling_timeout_idle = true;
//Set the alertify message to inform the user that execution is completed.
Alertify.success(res.info, 3);
Notify.success(res.info, 3000);
// Update the message tab of the debugger
if (res.data.status_message) {
@@ -601,7 +603,7 @@ define([
//Set the Alertify message to inform the user that execution is
// completed with error.
if (!pgTools.DirectDebug.is_user_aborted_debugging) {
Alertify.error(res.info, 3);
Notify.error(res.info, 3000);
}
// Update the message tab of the debugger
@@ -847,7 +849,7 @@ define([
// Set the Alertify message to inform the user that execution
// is completed.
Alertify.success(res.info, 3);
Notify.success(res.info, 3000);
} else if (res.data.status === 'NotConnected') {
Alertify.alert(
gettext('Debugger Error'),
@@ -1316,9 +1318,9 @@ define([
self.GetLocalVariables(pgTools.DirectDebug.trans_id);
// Show the message to the user that deposit value is success or failure
if (res.data.result) {
Alertify.success(res.data.info, 3);
Notify.success(res.data.info, 3000);
} else {
Alertify.error(res.data.info, 3);
Notify.error(res.data.info, 3000);
}
}
})

View File

@@ -7,6 +7,8 @@
//
//////////////////////////////////////////////////////////////
import Notify from 'static/js/helpers/Notifier';
define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'pgadmin.alertifyjs',
'sources/pgadmin', 'pgadmin.browser', 'backbone', 'backgrid', 'backform',
@@ -528,7 +530,7 @@ define([
})
.done(function(res) {
if (res.success) {
Alertify.success(gettext('Import/Export job created.'), 5);
Notify.success(gettext('Import/Export job created.'), 5000);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
} else {
Alertify.alert(

View File

@@ -6,6 +6,9 @@
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
import Notify from '../../../../static/js/helpers/Notifier';
define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'pgadmin.alertifyjs', 'sources/pgadmin', 'pgadmin.browser', 'backbone',
@@ -369,7 +372,7 @@ define([
.done(function(res) {
if (res.data && res.data.status) {
//Do nothing as we are creating the job and exiting from the main dialog
Alertify.success(res.data.info);
Notify.success(res.data.info);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
} else {
Alertify.alert(

View File

@@ -19,6 +19,8 @@ import {generateScript} from 'tools/datagrid/static/js/show_query_tool';
import 'pgadmin.sqleditor';
import pgWindow from 'sources/window';
import _ from 'underscore';
import Notify from '../../../../static/js/helpers/Notifier';
import { SchemaDiffSelect2Control, SchemaDiffHeaderView,
SchemaDiffFooterView, SchemaDiffSqlControl} from './schema_diff.backform';
@@ -880,7 +882,7 @@ export default class SchemaDiffUI {
}
})
.fail(function(xhr, error) {
Alertify.pgNotifier(error, xhr, gettext('Failed to connect the database.'));
Notify.pgNotifier(error, xhr, gettext('Failed to connect the database.'));
});
}
@@ -889,7 +891,7 @@ export default class SchemaDiffUI {
var onFailure = function(
xhr, status, error, sid, err_callback
) {
Alertify.pgNotifier('error', xhr, error, function(msg) {
Notify.pgNotifier('error', xhr, error, function(msg) {
setTimeout(function() {
Alertify.dlgServerPass(
gettext('Connect to Server'),

View File

@@ -286,7 +286,7 @@ def start_view_data(trans_id):
'filter_applied': filter_applied,
'limit': limit, 'can_edit': can_edit,
'can_filter': can_filter, 'sql': sql,
'info_notifier_timeout': blueprint.info_notifier_timeout.get()
'info_notifier_timeout': blueprint.info_notifier_timeout.get() * 1000
}
)

View File

@@ -14,6 +14,7 @@ __webpack_public_path__ = window.resourceBasePath;
import {launchDataGrid} from 'tools/datagrid/static/js/show_query_tool';
import {generateDatagridTitle} from 'tools/datagrid/static/js/show_data';
import Notify from '../../../../static/js/helpers/Notifier';
define('tools.querytool', [
'sources/gettext', 'sources/url_for', 'jquery', 'jquery.ui',
@@ -1400,7 +1401,7 @@ define('tools.querytool', [
});
grid.onValidationError.subscribe(function (e, args) {
alertify.error(args.validationResults.msg);
Notify.error(args.validationResults.msg);
});
// Resize SlickGrid when window resize
@@ -2317,7 +2318,7 @@ define('tools.querytool', [
self.set_editor_title(_.unescape(connection_details['conn_title']));
self.handler.setTitle(_.unescape(self.handler.url_params.title));
let success_msg = connection_details['server_name'] + '/' + connection_details['database_name'] + '- Database connected';
alertify.success(success_msg);
Notify.success(success_msg);
if(ref){
let connection_data = {
'server_group': self.handler.url_params.sgid,
@@ -2356,7 +2357,7 @@ define('tools.querytool', [
}
alertify.connectServer('Connect to server', xhr.responseJSON.result, connection_details['server'], false, connection_info);
} else {
alertify.error(xhr.responseJSON['errormsg']);
Notify.error(xhr.responseJSON['errormsg']);
}
});
},
@@ -2622,7 +2623,7 @@ define('tools.querytool', [
}),passdata)
.done(function(res) {
if (res.success == 1) {
alertify.success(res.info);
Notify.success(res.info);
if (create_transaction) {
self.initTransaction();
} else if ('fn' in self.state) {
@@ -2749,7 +2750,7 @@ define('tools.querytool', [
});
pgBrowser.Events.on('pgadmin:query_tool:connected_fail:' + transId, (xhr, error)=>{
alertify.pgRespErrorNotify(xhr, error);
Notify.pgRespErrorNotify(xhr, error);
});
self.initTransaction();
@@ -3061,7 +3062,7 @@ define('tools.querytool', [
// We need this because we have separated columns route & result route
// We need to combine both result here in wrapper before rendering grid
call_render_after_poll: function(queryResult) {
callRenderAfterPoll.callRenderAfterPoll(this,alertify,queryResult);
callRenderAfterPoll.callRenderAfterPoll(this, Notify, queryResult);
},
@@ -3144,7 +3145,7 @@ define('tools.querytool', [
// Display the notifier if the timeout is set to >= 0
if (self_col.info_notifier_timeout >= 0) {
alertify.success(msg1 + ' ' + msg2, self_col.info_notifier_timeout);
Notify.success(msg1 + ' ' + msg2, self_col.info_notifier_timeout);
}
var _msg = msg1 + '\n' + msg2;
@@ -3531,7 +3532,7 @@ define('tools.querytool', [
} else {
$('#btn-save-data').prop('disabled', true);
}
alertify.success(gettext('Row(s) deleted.'));
Notify.success(gettext('Row(s) deleted.'));
} else {
let strikeout = true;
@@ -3721,21 +3722,21 @@ define('tools.querytool', [
// Clear msgs after successful save
self.set_sql_message('');
alertify.success(gettext('Data saved successfully.'));
Notify.success(gettext('Data saved successfully.'));
if(is_commit_required)
alertify.info(gettext('Auto-commit is off. You still need to commit changes to the database.'));
Notify.info(gettext('Auto-commit is off. You still need to commit changes to the database.'));
} else {
// Something went wrong while saving data on the db server
self.set_sql_message(res.data.result);
var err_msg = gettext('%s.', res.data.result);
alertify.error(err_msg, 20);
Notify.error(err_msg, 20000);
// If the transaction is not idle, notify the user that previous queries are not rolled back,
// only the failed save queries.
if (transaction_status != 0)
alertify.info(gettext('Saving data changes was rolled back but the current transaction is ' +
Notify.info(gettext('Saving data changes was rolled back but the current transaction is ' +
'still active; previous queries are unaffected.'));
grid.setSelectedRows([]);
// To highlight the row at fault
@@ -3959,7 +3960,7 @@ define('tools.querytool', [
pgAdmin, self, er, '_select_file_handler', stateParams, false
);
if (msg)
alertify.error(msg);
Notify.error(msg);
// hide cursor
$busy_icon_div.removeClass('show_progress');
});
@@ -3988,7 +3989,7 @@ define('tools.querytool', [
})
.done(function(res) {
if (res.data.status) {
alertify.success(gettext('File saved successfully.'));
Notify.success(gettext('File saved successfully.'));
self.gridView.current_file = e;
self.setTitle(self.gridView.current_file.replace(/^.*[\\\/]/g, ''), true);
self.gridView.query_tool_obj.file_data = file_data;
@@ -4013,7 +4014,7 @@ define('tools.querytool', [
pgAdmin, self, er, '_save_file_handler', stateParams, false
);
if (msg)
alertify.error(msg);
Notify.error(msg);
});
},

View File

@@ -108,7 +108,7 @@ class StartRunningQuery:
'status': status, 'result': result,
'can_edit': can_edit, 'can_filter': can_filter,
'info_notifier_timeout':
self.blueprint_object.info_notifier_timeout.get(),
self.blueprint_object.info_notifier_timeout.get() * 1000,
'notifies': notifies,
'transaction_status': trans_status,
}

View File

@@ -7,6 +7,8 @@
//
//////////////////////////////////////////////////////////////
import Notify from '../../../../static/js/helpers/Notifier';
define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'pgadmin.alertifyjs',
'pgadmin.browser', 'backbone', 'backgrid', 'backform', 'pgadmin.browser.node', 'pgadmin.backform',
@@ -680,7 +682,7 @@ define([
} else {
msg = e.responseJSON.errormsg;
}
alertify.error(msg);
Notify.error(msg);
});
},
render: function() {
@@ -788,12 +790,12 @@ define([
self.model.destroy({
wait: true,
success: function() {
alertify.success(gettext('User deleted.'));
Notify.success(gettext('User deleted.'));
alertify.changeOwnershipDialog().destroy();
alertify.UserManagement().destroy();
},
error: function() {
alertify.error(
Notify.error(
gettext('Error during deleting user.')
);
},
@@ -825,10 +827,10 @@ define([
.done(function(res) {
alertify.changeOwnershipDialog().destroy();
alertify.UserManagement().destroy();
alertify.success(gettext(res.info));
Notify.success(gettext(res.info));
})
.fail(function() {
alertify.error(gettext('Unable to change owner.'));
Notify.error(gettext('Unable to change owner.'));
});
},
deleteUser: function() {
@@ -840,10 +842,10 @@ define([
self.model.destroy({
wait: true,
success: function() {
alertify.success(gettext('User deleted.'));
Notify.success(gettext('User deleted.'));
},
error: function() {
alertify.error(
Notify.error(
gettext('Error during deleting user.')
);
},
@@ -1103,13 +1105,13 @@ define([
});
m.startNewSession();
alertify.success(gettext('User \'%s\' saved.',
Notify.success(gettext('User \'%s\' saved.',
m.get('username')
));
},
error: function(res, jqxhr) {
m.startNewSession();
alertify.error(
Notify.error(
gettext('Error saving user: \'%s\'',
jqxhr.responseJSON.errormsg
)

View File

@@ -1,116 +0,0 @@
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2021, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////////////////
import alertify from 'pgadmin.alertifyjs';
import * as $ from 'jquery';
import gettext from 'sources/gettext';
describe('alertify_wrapper', function () {
var env = jasmine.getEnv();
env.allowRespy(true);
describe('alertify_success', function () {
it('calls the success function from alertify and adds the checkmark to the element', function () {
let spyObj = spyOn(alertify, 'orig_success').and.callThrough();
alertify.success('Yay, congrats!', 1);
expect(spyObj).toHaveBeenCalled();
expect(spyObj.calls.mostRecent().args[0]).toContain('Yay, congrats!');
expect(spyObj.calls.mostRecent().args[0]).toContain('class="fa fa-check"');
});
});
describe('alertify_error calls the error function', function() {
it('and adds the warning symbol to the element', function () {
let spyOrigError = spyOn(alertify, 'orig_error').and.callThrough();
alertify.error('bad, very bad', 1);
expect(spyOrigError).toHaveBeenCalled();
expect(spyOrigError.calls.mostRecent().args[0]).toContain('bad, very bad');
expect(spyOrigError.calls.mostRecent().args[0]).toContain('class="fa fa-exclamation-triangle"');
});
});
describe('alertify_error calls pgRespErrorNotify notifier', function() {
it('which alertifies response error for ajax calls', (done) => {
$.ajax({
url: 'http://some/dummy/url',
dataType: 'json',
error: function(xhr, status, error) {
let spyOrigError = spyOn(alertify, 'orig_error').and.callThrough(),
spyNotify = spyOn(alertify, 'notify').and.callThrough();
/*When connection lost*/
xhr.status = 0;
alertify.pgRespErrorNotify(xhr, error);
expect(spyOrigError).toHaveBeenCalled();
expect(spyOrigError.calls.mostRecent().args[0]).toContain(
gettext('Connection to the server has been lost.')
);
/*When some exception occurs at back end*/
xhr.status = 4;
var orig_getResponseHeader = xhr.getResponseHeader;
/*Exception handled by back end*/
xhr.getResponseHeader = (header) => {
if(header === 'Content-Type') {
return 'application/json';
}
else {
return orig_getResponseHeader(header);
}
};
xhr.responseText = '{"errormsg":"Exception XYZ"}';
alertify.pgRespErrorNotify(xhr, error);
expect(spyOrigError).toHaveBeenCalled();
expect(spyOrigError.calls.mostRecent().args[0]).toContain(
gettext('Exception XYZ')
);
/*Exception not handled by back end*/
xhr.getResponseHeader = (header) => {
if(header === 'Content-Type') {
return 'text/html';
}
else {
return orig_getResponseHeader(header);
}
};
xhr.responseText = '<p>Some Exception Occurred</p>';
alertify.pgRespErrorNotify(xhr, error);
expect(spyNotify).toHaveBeenCalled();
expect(spyNotify.calls.mostRecent().args[0]).toContain(
gettext('INTERNAL SERVER ERROR')
);
/*With prefixMsg*/
xhr.getResponseHeader = (header) => {
if(header === 'Content-Type') {
return 'application/json';
}
else {
return orig_getResponseHeader(header);
}
};
xhr.responseText = '{"errormsg":"Exception XYZ"}';
alertify.pgRespErrorNotify(xhr, error, gettext('Some prefix message'));
expect(spyOrigError).toHaveBeenCalled();
expect(spyOrigError.calls.mostRecent().args[0]).toContain(
gettext('Some prefix message')
);
done();
},
});
});
});
});

View File

@@ -17,10 +17,10 @@ import { OutlinedInput, FormHelperText, IconButton, FormControlLabel,
import Select from 'react-select';
import CreatableSelect from 'react-select/creatable';
import CheckRoundedIcon from '@material-ui/icons/CheckRounded';
import ReportProblemIcon from '@material-ui/icons/ReportProblemRounded';
import InfoIcon from '@material-ui/icons/InfoRounded';
import InfoRoundedIcon from '@material-ui/icons/InfoRounded';
import CloseIcon from '@material-ui/icons/CloseRounded';
import CheckIcon from '@material-ui/icons/CheckCircleOutlineRounded';
import ErrorRoundedIcon from '@material-ui/icons/ErrorOutlineRounded';
import WarningRoundedIcon from '@material-ui/icons/WarningRounded';
import {FormInputText, FormInputFileSelect, FormInputSQL,
@@ -560,7 +560,7 @@ describe('FormComponents', ()=>{
});
it('init', ()=>{
expect(ctrl.find(CheckIcon).exists()).toBeTrue();
expect(ctrl.find(CheckRoundedIcon).exists()).toBeTrue();
expect(ctrl.text()).toBe('Some message');
});
@@ -568,12 +568,17 @@ describe('FormComponents', ()=>{
ctrl.setProps({
type: MESSAGE_TYPE.ERROR,
});
expect(ctrl.find(ReportProblemIcon).exists()).toBeTrue();
expect(ctrl.find(ErrorRoundedIcon).exists()).toBeTrue();
ctrl.setProps({
type: MESSAGE_TYPE.INFO,
});
expect(ctrl.find(InfoIcon).exists()).toBeTrue();
expect(ctrl.find(InfoRoundedIcon).exists()).toBeTrue();
ctrl.setProps({
type: MESSAGE_TYPE.WARNING,
});
expect(ctrl.find(WarningRoundedIcon).exists()).toBeTrue();
});
it('closable', ()=>{

View File

@@ -12,6 +12,7 @@
beforeAll(function () {
spyOn(console, 'warn').and.callThrough();
spyOn(console, 'error').and.callThrough();
jasmine.getEnv().allowRespy(true);
});
afterEach(function (done) {

View File

@@ -11,7 +11,7 @@ import {callRenderAfterPoll} from '../../../pgadmin/static/js/sqleditor/call_ren
import moment from 'moment';
describe('#callRenderAfterPoll', () => {
let sqlEditorSpy, queryResult, alertify;
let sqlEditorSpy, queryResult, Notify;
beforeEach(() => {
let today = moment('2018-01-01 10:12:31').toDate();
jasmine.clock().install();
@@ -28,7 +28,7 @@ describe('#callRenderAfterPoll', () => {
check_db_name_change: jasmine.createSpy('SQLEditor.check_db_name_change'),
query_start_time: new Date(),
};
alertify = jasmine.createSpyObj('alertify', ['success']);
Notify = jasmine.createSpyObj('Notify', ['success']);
});
afterEach(function () {
@@ -50,19 +50,19 @@ describe('#callRenderAfterPoll', () => {
});
it('renders the editor', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy._render).toHaveBeenCalledWith(queryResult);
});
it('inform sqleditor that the query stopped running', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
});
it('hides the loading icon', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
});
@@ -79,7 +79,7 @@ describe('#callRenderAfterPoll', () => {
});
it('saves execution information in the history', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.update_msg_history).toHaveBeenCalledWith(
true,
@@ -89,19 +89,19 @@ describe('#callRenderAfterPoll', () => {
});
it('resets the changed data store', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.reset_data_store).toHaveBeenCalled();
});
it('inform sqleditor that the query stopped running', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
});
it('hides the loading icon', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
});
@@ -109,9 +109,9 @@ describe('#callRenderAfterPoll', () => {
describe('notifications are enabled', () => {
it('display notification', () => {
sqlEditorSpy.info_notifier_timeout = 10;
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(alertify.success).toHaveBeenCalledWith(
expect(Notify.success).toHaveBeenCalledWith(
'Query returned successfully in 0 msec.',
10
);
@@ -119,7 +119,7 @@ describe('#callRenderAfterPoll', () => {
});
it('disables the save results button', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.enable_disable_download_btn).toHaveBeenCalledWith(true);
@@ -143,25 +143,25 @@ describe('#callRenderAfterPoll', () => {
});
it('renders the editor', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy._render).toHaveBeenCalledWith(queryResult);
});
it('inform sqleditor that the query stopped running', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
});
it('hides the loading icon', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
});
it('enables sqleditor tools buttons', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.disable_tool_buttons).toHaveBeenCalledWith(false);
});
@@ -178,7 +178,7 @@ describe('#callRenderAfterPoll', () => {
});
it('saves execution information in the history', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.update_msg_history).toHaveBeenCalledWith(
true,
@@ -188,25 +188,25 @@ describe('#callRenderAfterPoll', () => {
});
it('resets the changed data store', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.reset_data_store).toHaveBeenCalled();
});
it('inform sqleditor that the query stopped running', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
});
it('hides the loading icon', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
});
it('enables sqleditor tools buttons', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.disable_tool_buttons).toHaveBeenCalledWith(false);
});
@@ -214,9 +214,9 @@ describe('#callRenderAfterPoll', () => {
describe('notifications are enabled', () => {
it('display notification', () => {
sqlEditorSpy.info_notifier_timeout = 10;
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(alertify.success).toHaveBeenCalledWith(
expect(Notify.success).toHaveBeenCalledWith(
'Query returned successfully in 0 msec.',
10
);
@@ -224,7 +224,7 @@ describe('#callRenderAfterPoll', () => {
});
it('disables the save results button', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.enable_disable_download_btn).toHaveBeenCalledWith(true);
@@ -232,7 +232,7 @@ describe('#callRenderAfterPoll', () => {
});
it('check whether database has been moved/renamed', () => {
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:check_synchronous_db_name_change', queryResult);

View File

@@ -197,8 +197,6 @@ describe('queryToolActions', () => {
spyOn(queryToolActions, '_costsEnabled').and.returnValue(true);
spyOn(queryToolActions, '_summary').and.returnValue(false);
spyOn(queryToolActions, '_settings').and.returnValue(false);
spyOn(queryToolActions, '_summary').and.returnValue(false);
spyOn(queryToolActions, '_settings').and.returnValue(false);
});
it('calls the execute function', () => {

View File

@@ -19,7 +19,7 @@ import {TreeNode} from '../../../pgadmin/static/js/tree/tree_nodes';
describe('#enableTriggers', () => {
let networkMock;
let tree;
let alertify;
let Notify;
let generateUrlSpy;
beforeEach(() => {
networkMock = new MockAdapter(axios);
@@ -47,7 +47,7 @@ describe('#enableTriggers', () => {
const tableNoData = tree.addNewNode('table-no-data', undefined, ['<li>table-no-data</li>']);
tree.addChild(schema1, tableNoData);
alertify = jasmine.createSpyObj('alertify', ['success', 'error']);
Notify = jasmine.createSpyObj('Notify', ['success', 'error']);
generateUrlSpy = jasmine.createSpy('generateUrl');
generateUrlSpy.and.returnValue('/some/place');
});
@@ -58,7 +58,7 @@ describe('#enableTriggers', () => {
});
setTimeout(() => {
expect(enableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
expect(enableTriggers(tree, Notify, generateUrlSpy, {})).toEqual(false);
done();
}, 0);
});
@@ -73,7 +73,7 @@ describe('#enableTriggers', () => {
});
setTimeout(() => {
expect(enableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
expect(enableTriggers(tree, Notify, generateUrlSpy, {})).toEqual(false);
done();
}, 0);
});
@@ -95,15 +95,15 @@ describe('#enableTriggers', () => {
it('displays an alert box with success', (done) => {
tree.selectNode([{id: 'table1'}]);
enableTriggers(tree, alertify, generateUrlSpy, {});
enableTriggers(tree, Notify, generateUrlSpy, {});
setTimeout(() => {
expect(alertify.success).toHaveBeenCalledWith('some information');
expect(Notify.success).toHaveBeenCalledWith('some information');
done();
}, 0);
});
it('reloads the node', (done) => {
enableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
enableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
setTimeout(() => {
expect(tree.selected()).toEqual(['<li>table1</li>']);
done();
@@ -111,7 +111,7 @@ describe('#enableTriggers', () => {
});
it('call backend with the correct parameters', (done) => {
enableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
enableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
setTimeout(() => {
expect(networkMockCalledWith.data).toEqual(JSON.stringify({is_enable_trigger: 'O'}));
done();
@@ -131,15 +131,15 @@ describe('#enableTriggers', () => {
it('displays an error alert', (done) => {
tree.selectNode([{id: 'table1'}]);
enableTriggers(tree, alertify, generateUrlSpy, {});
enableTriggers(tree, Notify, generateUrlSpy, {});
setTimeout(() => {
expect(alertify.error).toHaveBeenCalledWith('some error message');
expect(Notify.error).toHaveBeenCalledWith('some error message');
done();
}, 0);
});
it('unload the node', (done) => {
enableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
enableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
setTimeout(() => {
expect(tree.findNodeByDomElement([{id: 'table1'}]).children.length).toEqual(0);
@@ -154,7 +154,7 @@ describe('#enableTriggers', () => {
describe('#disableTriggers', () => {
let networkMock;
let tree;
let alertify;
let Notify;
let generateUrlSpy;
beforeEach(() => {
networkMock = new MockAdapter(axios);
@@ -175,7 +175,7 @@ describe('#disableTriggers', () => {
const tableNoData = new TreeNode('table-no-data', undefined, ['<li>table-no-data</li>']);
tree.addChild(schema1, tableNoData);
alertify = jasmine.createSpyObj('alertify', ['success', 'error']);
Notify = jasmine.createSpyObj('Notify', ['success', 'error']);
generateUrlSpy = jasmine.createSpy('generateUrl');
generateUrlSpy.and.returnValue('/some/place');
spyOn(tree, 'unload').and.callFake(function() {
@@ -192,7 +192,7 @@ describe('#disableTriggers', () => {
});
setTimeout(() => {
expect(disableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
expect(disableTriggers(tree, Notify, generateUrlSpy, {})).toEqual(false);
done();
}, 0);
});
@@ -207,7 +207,7 @@ describe('#disableTriggers', () => {
});
setTimeout(() => {
expect(disableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
expect(disableTriggers(tree, Notify, generateUrlSpy, {})).toEqual(false);
done();
}, 0);
});
@@ -229,15 +229,15 @@ describe('#disableTriggers', () => {
it('displays an alert box with success', (done) => {
tree.selectNode([{id: 'table1'}]);
disableTriggers(tree, alertify, generateUrlSpy, {});
disableTriggers(tree, Notify, generateUrlSpy, {});
setTimeout(() => {
expect(alertify.success).toHaveBeenCalledWith('some information');
expect(Notify.success).toHaveBeenCalledWith('some information');
done();
}, 0);
});
it('reloads the node', (done) => {
disableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
disableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
setTimeout(() => {
expect(tree.selected()).toEqual(['<li>table1</li>']);
done();
@@ -245,7 +245,7 @@ describe('#disableTriggers', () => {
});
it('call backend with the correct parameters', (done) => {
disableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
disableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
setTimeout(() => {
expect(networkMockCalledWith.data).toEqual(JSON.stringify({is_enable_trigger: 'D'}));
done();
@@ -265,15 +265,15 @@ describe('#disableTriggers', () => {
it('displays an error alert', (done) => {
tree.selectNode([{id: 'table1'}]);
disableTriggers(tree, alertify, generateUrlSpy, {});
disableTriggers(tree, Notify, generateUrlSpy, {});
setTimeout(() => {
expect(alertify.error).toHaveBeenCalledWith('some error message');
expect(Notify.error).toHaveBeenCalledWith('some error message');
done();
}, 0);
});
it('unload the node', (done) => {
disableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
disableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
setTimeout(() => {
expect(tree.findNodeByDomElement([{id: 'table1'}]).children.length).toEqual(0);

View File

@@ -2907,7 +2907,7 @@ closest@^0.0.1:
dependencies:
matches-selector "0.0.1"
clsx@^1.0.2, clsx@^1.0.4:
clsx@^1.0.2, clsx@^1.0.4, clsx@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.1.1.tgz#98b3134f9abbdf23b2663491ace13c5c03a73188"
integrity sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==
@@ -4939,7 +4939,7 @@ hmac-drbg@^1.0.1:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"
hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.3.1, hoist-non-react-statics@^3.3.2:
hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.1, hoist-non-react-statics@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
@@ -6750,6 +6750,14 @@ notificar@^1.0.1:
resolved "https://registry.yarnpkg.com/notificar/-/notificar-1.0.1.tgz#11ba233c261eee02f5d688ee300ece5f72522887"
integrity sha512-jiCay0IY0N+gloyDks+v4WV+OKU4lIXUhQgxw4Iu9bXpw80cNXTezVv46OCK5+E8G8fkt1Bj76DNepULqlQS3Q==
notistack@^1.0.10:
version "1.0.10"
resolved "https://registry.yarnpkg.com/notistack/-/notistack-1.0.10.tgz#8db90830034383467a04184f1fa8ff77f4fc58a5"
integrity sha512-z0y4jJaVtOoH3kc3GtNUlhNTY+5LE04QDeLVujX3VPhhzg67zw055mZjrBF+nzpv3V9aiPNph1EgRU4+t8kQTQ==
dependencies:
clsx "^1.1.0"
hoist-non-react-statics "^3.3.0"
npm-conf@^1.1.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/npm-conf/-/npm-conf-1.1.3.tgz#256cc47bd0e218c259c4e9550bf413bc2192aff9"