Remove Alertify from pgAdmin completely. Fixes #7619

This commit is contained in:
Akshay Joshi
2022-09-08 15:16:48 +05:30
parent e1942d8c9e
commit 18b77f15dd
149 changed files with 634 additions and 1573 deletions

View File

@@ -327,7 +327,7 @@ export function JsonTextEditor({row, column, onRowChange, onClose}) {
if(column.column_type_internal === 'jsonb' && !Array.isArray(newVal) && newVal != null) {
newVal = JSONBigNumber.stringify(JSONBigNumber.parse(newVal), null, 2);
} else if (Array.isArray(newVal)) {
var temp = newVal.map((ele)=>{
let temp = newVal.map((ele)=>{
if (typeof ele === 'object') {
return JSONBigNumber.stringify(ele, null, 2);
}

View File

@@ -32,7 +32,7 @@ function registerAutocomplete(api, transId, sqlEditorPref, onFailure) {
let loadingEle;
let prevSearch = null;
OrigCodeMirror.registerHelper('hint', 'sql', function (editor) {
var data = [],
let data = [],
doc = editor.getDoc(),
cur = doc.getCursor(),
// function context
@@ -50,7 +50,7 @@ function registerAutocomplete(api, transId, sqlEditorPref, onFailure) {
* and icon as per the object type.
*/
hint_render: function (elt, data_arg, cur_arg) {
var el = document.createElement('span');
let el = document.createElement('span');
switch (cur_arg.type) {
case 'database':
el.className = 'sqleditor-hint pg-icon-' + cur_arg.type;
@@ -90,15 +90,15 @@ function registerAutocomplete(api, transId, sqlEditorPref, onFailure) {
}
if(!loadingEle) {
var ownerDocument = editor.getInputField().ownerDocument;
let ownerDocument = editor.getInputField().ownerDocument;
loadingEle = ownerDocument.createElement('div');
loadingEle.className = 'CodeMirror-hints';
var iconEle = ownerDocument.createElement('div');
let iconEle = ownerDocument.createElement('div');
iconEle.className = 'icon-spinner';
iconEle.style.marginTop = '4px';
iconEle.style.marginLeft = '2px';
var spanEle = ownerDocument.createElement('span');
let spanEle = ownerDocument.createElement('span');
spanEle.innerText = gettext('Loading...');
spanEle.style.marginLeft = '17px';
@@ -106,7 +106,7 @@ function registerAutocomplete(api, transId, sqlEditorPref, onFailure) {
loadingEle.appendChild(iconEle);
ownerDocument.body.appendChild(loadingEle);
}
var pos = editor.cursorCoords(true);
let pos = editor.cursorCoords(true);
loadingEle.style.left = pos.left + 'px';
loadingEle.style.top = pos.bottom + 'px';
loadingEle.style.height = '25px';
@@ -120,7 +120,7 @@ function registerAutocomplete(api, transId, sqlEditorPref, onFailure) {
return {
then: function (cb) {
var self_local = this;
let self_local = this;
// This function is used to filter the data and call the callback
// function with that filtered data.
@@ -146,7 +146,7 @@ function registerAutocomplete(api, transId, sqlEditorPref, onFailure) {
* Below logic find the start and end point
* to replace the selected auto complete suggestion.
*/
var token = self_local.editor.getTokenAt(cur),
let token = self_local.editor.getTokenAt(cur),
start, end, search;
if (token.end > cur.ch) {
token.end = cur.ch;
@@ -211,7 +211,7 @@ function registerAutocomplete(api, transId, sqlEditorPref, onFailure) {
api.post(self_local.url, JSON.stringify(self_local.data))
.then((res) => {
hideLoading();
var result = [];
let result = [];
_.each(res.data.data.result, function (obj, key) {
result.push({
@@ -264,21 +264,21 @@ export default function Query() {
selectedLineNo = cmObj.getCursor(true).line;
// Fetch the LINE string using regex from the result
var line = /LINE (\d+)/.exec(result),
let line = /LINE (\d+)/.exec(result),
// Fetch the Character string using regex from the result
char = /Character: (\d+)/.exec(result);
// If line and character is null then no need to mark
if (line != null && char != null) {
errorLineNo = (parseInt(line[1]) - 1) + selectedLineNo;
var errorCharNo = (parseInt(char[1]) - 1);
let errorCharNo = (parseInt(char[1]) - 1);
/* We need to loop through each line till the error line and
* count the total no of character to figure out the actual
* starting/ending marker point for the individual line. We
* have also added 1 per line for the "\n" character.
*/
var prevLineChars = 0;
let prevLineChars = 0;
for (let i = selectedLineNo > 0 ? selectedLineNo : 0; i < errorLineNo; i++)
prevLineChars += cmObj.getLine(i).length + 1;
@@ -289,7 +289,7 @@ export default function Query() {
startMarker = errorCharNo - prevLineChars;
// Find the next space from the character or end of line
var errorLine = cmObj.getLine(errorLineNo);
let errorLine = cmObj.getLine(errorLineNo);
if (_.isUndefined(errorLine)) return;
endMarker = errorLine.indexOf(' ', startMarker);

View File

@@ -10,7 +10,7 @@ import gettext from '../../../../static/js/gettext';
import url_for from '../../../../static/js/url_for';
import {getDatabaseLabel, generateTitle} from './sqleditor_title';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import _ from 'underscore';
import _ from 'lodash';
import Notify from '../../../../static/js/helpers/Notifier';
import { isEmptyString } from 'sources/validators';
import { getUtilityView } from '../../../../browser/static/js/utility_view';

View File

@@ -8,9 +8,9 @@
//////////////////////////////////////////////////////////////
import gettext from 'sources/gettext';
import Alertify from 'pgadmin.alertifyjs';
import pgWindow from 'sources/window';
import { retrieveNameSpaceName, retrieveNodeName } from './show_view_data';
import Notify from '../../../../static/js/helpers/Notifier';
const pgAdmin = pgWindow.pgAdmin;
@@ -139,14 +139,7 @@ export function generateTitle(title_placeholder, title_data) {
* This function is used refresh the db node after showing alert to the user
*/
export function refresh_db_node(message, dbNode) {
Alertify.alert()
.setting({
'title': gettext('Database moved/renamed'),
'label':gettext('OK'),
'message': gettext(message),
'onok': function(){
//Set the original db name as soon as user clicks ok button
pgAdmin.Browser.Nodes.database.callbacks.refresh(undefined, dbNode);
},
}).show();
Notify.alert(gettext('Database moved/renamed'), gettext(message), ()=>{
pgAdmin.Browser.Nodes.database.callbacks.refresh(undefined, dbNode);
});
}