Visitar URL original
Remove callback param from CommonActions.refreshMain() · phpmyadmin/phpmyadmin@b3e4010 · GitHub
Skip to content

Commit b3e4010

Browse files
committed
Remove callback param from CommonActions.refreshMain()
This removes the dependency on AJAX in common.js file. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 0160f0a commit b3e4010

6 files changed

Lines changed: 32 additions & 39 deletions

File tree

‎js/src/database/operations.js‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ AJAX.registerOnload('database/operations.js', function () {
106106
if (typeof data !== 'undefined' && data.success === true) {
107107
if ($('#checkbox_switch').is(':checked')) {
108108
CommonParams.set('db', data.newname);
109-
CommonActions.refreshMain(false, function () {
109+
CommonActions.refreshMain(false);
110+
AJAX.callback = () => {
110111
ajaxShowMessage(data.message);
111-
});
112+
};
112113
} else {
113114
CommonParams.set('db', data.db);
114115
ajaxShowMessage(data.message);
@@ -168,12 +169,10 @@ AJAX.registerOnload('database/operations.js', function () {
168169
// Database deleted successfully, refresh both the frames
169170
Navigation.reload();
170171
CommonParams.set('db', '');
171-
CommonActions.refreshMain(
172-
'index.php?route=/server/databases',
173-
function () {
174-
ajaxShowMessage(data.message);
175-
}
176-
);
172+
CommonActions.refreshMain('index.php?route=/server/databases');
173+
AJAX.callback = () => {
174+
ajaxShowMessage(data.message);
175+
};
177176
} else {
178177
ajaxShowMessage(data.error, false);
179178
}

‎js/src/modules/common.js‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import $ from 'jquery';
2-
import { AJAX } from './ajax.js';
32
import { Navigation } from './navigation.js';
43

54
/**
@@ -130,11 +129,10 @@ const CommonActions = {
130129
*
131130
* @param {any} url Undefined to refresh to the same page
132131
* String to go to a different page, e.g: 'index.php'
133-
* @param {function | undefined} callback
134132
*
135133
* @return {void}
136134
*/
137-
refreshMain: function (url, callback = undefined) {
135+
refreshMain: function (url) {
138136
var newUrl = url;
139137
if (! newUrl) {
140138
newUrl = $('#selflink').find('a').attr('href') || window.location.pathname;
@@ -149,9 +147,6 @@ const CommonActions = {
149147
.appendTo('body')
150148
.trigger('click')
151149
.remove();
152-
if (typeof callback !== 'undefined') {
153-
AJAX.callback = callback;
154-
}
155150
}
156151
};
157152

‎js/src/modules/functions.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,9 +1833,7 @@ Functions.onloadCreateTableEvents = function () {
18331833
var tablesTable = $('#tablesForm').find('tbody').not('#tbl_summary_row');
18341834
// this is the first table created in this db
18351835
if (tablesTable.length === 0) {
1836-
CommonActions.refreshMain(
1837-
CommonParams.get('opendb_url')
1838-
);
1836+
CommonActions.refreshMain(CommonParams.get('opendb_url'));
18391837
} else {
18401838
/**
18411839
* @var curr_last_row Object referring to the last <tr> element in {@link tablesTable}

‎js/src/sql.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,12 +841,13 @@ AJAX.registerOnload('sql.js', function () {
841841
} else {
842842
url = 'index.php?route=/server/sql';
843843
}
844-
CommonActions.refreshMain(url, function () {
844+
CommonActions.refreshMain(url);
845+
AJAX.callback = () => {
845846
$('#sqlqueryresultsouter')
846847
.show()
847848
.html(data.message);
848849
highlightSql($('#sqlqueryresultsouter'));
849-
});
850+
};
850851
}
851852

852853
$('.sqlqueryresults').trigger('makegrid');

‎js/src/table/operations.js‎

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ AJAX.registerOnload('table/operations.js', function () {
9191
'table',
9292
$form.find('input[name=\'new_name\']').val()
9393
);
94-
CommonActions.refreshMain(false, function () {
94+
CommonActions.refreshMain(false);
95+
AJAX.callback = () => {
9596
ajaxShowMessage(data.message);
96-
});
97+
};
9798
} else {
9899
ajaxShowMessage(data.message);
99100
}
@@ -117,9 +118,10 @@ AJAX.registerOnload('table/operations.js', function () {
117118
if (typeof data !== 'undefined' && data.success === true) {
118119
CommonParams.set('db', data.params.db);
119120
CommonParams.set('table', data.params.table);
120-
CommonActions.refreshMain('index.php?route=/table/sql', function () {
121+
CommonActions.refreshMain('index.php?route=/table/sql');
122+
AJAX.callback = () => {
121123
ajaxShowMessage(data.message);
122-
});
124+
};
123125
// Refresh navigation when the table is copied
124126
Navigation.reload();
125127
} else {
@@ -166,10 +168,11 @@ AJAX.registerOnload('table/operations.js', function () {
166168
$.post($form.attr('action'), $form.serialize(), function (data) {
167169
if (typeof data !== 'undefined' && data.success === true) {
168170
CommonParams.set('table', data.params.table);
169-
CommonActions.refreshMain(false, function () {
171+
CommonActions.refreshMain(false);
172+
AJAX.callback = () => {
170173
$('#page_content').html(data.message);
171174
highlightSql($('#page_content'));
172-
});
175+
};
173176
// Refresh navigation when the table is renamed
174177
Navigation.reload();
175178
} else {
@@ -290,12 +293,10 @@ AJAX.registerOnload('table/operations.js', function () {
290293
// Table deleted successfully, refresh both the frames
291294
Navigation.reload();
292295
CommonParams.set('table', '');
293-
CommonActions.refreshMain(
294-
CommonParams.get('opendb_url'),
295-
function () {
296-
ajaxShowMessage(data.message);
297-
}
298-
);
296+
CommonActions.refreshMain(CommonParams.get('opendb_url'));
297+
AJAX.callback = () => {
298+
ajaxShowMessage(data.message);
299+
};
299300
} else {
300301
ajaxShowMessage(data.error, false);
301302
}
@@ -324,12 +325,10 @@ AJAX.registerOnload('table/operations.js', function () {
324325
// Table deleted successfully, refresh both the frames
325326
Navigation.reload();
326327
CommonParams.set('table', '');
327-
CommonActions.refreshMain(
328-
CommonParams.get('opendb_url'),
329-
function () {
330-
ajaxShowMessage(data.message);
331-
}
332-
);
328+
CommonActions.refreshMain(CommonParams.get('opendb_url'));
329+
AJAX.callback = () => {
330+
ajaxShowMessage(data.message);
331+
};
333332
} else {
334333
ajaxShowMessage(data.error, false);
335334
}

‎js/src/table/relation.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ AJAX.registerOnload('table/relation.js', function () {
247247
$.post(url, params, function (data) {
248248
if (data.success === true) {
249249
ajaxRemoveMessage($msg);
250-
CommonActions.refreshMain(false, function () {
250+
CommonActions.refreshMain(false);
251+
AJAX.callback = () => {
251252
// Do nothing
252-
});
253+
};
253254
} else {
254255
ajaxShowMessage(window.Messages.strErrorProcessingRequest + ' : ' + data.error, false);
255256
}

0 commit comments

Comments
 (0)