Deprecate `success` and `error` in `Discourse.ajax`
This commit is contained in:
parent
6cbcd6e4a6
commit
0b4fc5d81c
|
@ -26,8 +26,7 @@ Discourse.AdminEmailLogsController = Ember.ArrayController.extend(Discourse.Pres
|
|||
this.set('sentTestEmail', false);
|
||||
|
||||
var adminEmailLogsController = this;
|
||||
Discourse.ajax({
|
||||
url: Discourse.getURL("/admin/email_logs/test"),
|
||||
Discourse.ajax(Discourse.getURL("/admin/email_logs/test"), {
|
||||
type: 'POST',
|
||||
data: { email_address: this.get('testEmailAddress') }
|
||||
}).then(function () {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
This controller supports the interface for listing users in the admin section.
|
||||
|
||||
@class AdminUsersListController
|
||||
@class AdminUsersListController
|
||||
@extends Ember.ArrayController
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
**/
|
||||
Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Presence, {
|
||||
username: null,
|
||||
query: null,
|
||||
|
@ -88,9 +88,13 @@ Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Pres
|
|||
@method refreshUsers
|
||||
**/
|
||||
refreshUsers: function() {
|
||||
this.set('loading', true);
|
||||
var _this = this;
|
||||
this.set('content', Discourse.AdminUser.findAll(this.get('query'), this.get('username'), function() { _this.set('loading', false); }));
|
||||
var adminUsersListController = this;
|
||||
adminUsersListController.set('loading', true);
|
||||
|
||||
Discourse.AdminUser.findAll(this.get('query'), this.get('username')).then(function (result) {
|
||||
adminUsersListController.set('content', result);
|
||||
adminUsersListController.set('loading', false);
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
@ -115,5 +119,5 @@ Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Pres
|
|||
approveUsers: function() {
|
||||
Discourse.AdminUser.bulkApprove(this.get('content').filterProperty('selected'));
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
|
|
@ -20,6 +20,6 @@ Discourse.AdminApi = Discourse.Model.extend({
|
|||
|
||||
Discourse.AdminApi.reopenClass({
|
||||
find: function() {
|
||||
return this.getModelAjax('/admin/api');
|
||||
return this.getModelAjax(Discourse.getURL('/admin/api'));
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,10 +19,7 @@ Discourse.AdminDashboard.reopenClass({
|
|||
@return {jqXHR} a jQuery Promise object
|
||||
**/
|
||||
find: function() {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/dashboard"), {
|
||||
type: 'GET',
|
||||
dataType: 'json'
|
||||
}).then(function(json) {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/dashboard")).then(function(json) {
|
||||
var model = Discourse.AdminDashboard.create(json);
|
||||
model.set('loaded', true);
|
||||
return model;
|
||||
|
|
|
@ -191,22 +191,18 @@ Discourse.AdminUser.reopenClass({
|
|||
},
|
||||
|
||||
find: function(username) {
|
||||
return Discourse.ajax({url: Discourse.getURL("/admin/users/") + username}).then(function (result) {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/") + username).then(function (result) {
|
||||
return Discourse.AdminUser.create(result);
|
||||
});
|
||||
},
|
||||
|
||||
findAll: function(query, filter, doneCallback) {
|
||||
var result = Em.A();
|
||||
Discourse.ajax({
|
||||
url: Discourse.getURL("/admin/users/list/") + query + ".json",
|
||||
findAll: function(query, filter) {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/list/") + query + ".json", {
|
||||
data: { filter: filter }
|
||||
}).then(function(users) {
|
||||
users.each(function(u) {
|
||||
result.pushObject(Discourse.AdminUser.create(u));
|
||||
return users.map(function(u) {
|
||||
return Discourse.AdminUser.create(u);
|
||||
});
|
||||
if( doneCallback ) { doneCallback(); }
|
||||
});
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -18,8 +18,7 @@ Discourse.EmailLog.reopenClass({
|
|||
|
||||
findAll: function(filter) {
|
||||
var result = Em.A();
|
||||
Discourse.ajax({
|
||||
url: Discourse.getURL("/admin/email_logs.json"),
|
||||
Discourse.ajax(Discourse.getURL("/admin/email_logs.json"), {
|
||||
data: { filter: filter }
|
||||
}).then(function(logs) {
|
||||
logs.each(function(log) {
|
||||
|
|
|
@ -66,8 +66,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
|||
};
|
||||
|
||||
var siteCustomization = this;
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL("/admin/site_customizations") + (this.id ? '/' + this.id : ''),
|
||||
return Discourse.ajax(Discourse.getURL("/admin/site_customizations") + (this.id ? '/' + this.id : ''), {
|
||||
data: { site_customization: data },
|
||||
type: this.id ? 'PUT' : 'POST'
|
||||
}).then(function (result) {
|
||||
|
@ -81,8 +80,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
|||
|
||||
destroy: function() {
|
||||
if(!this.id) return;
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL("/admin/site_customizations/") + this.id,
|
||||
return Discourse.ajax(Discourse.getURL("/admin/site_customizations/") + this.id, {
|
||||
type: 'DELETE'
|
||||
});
|
||||
}
|
||||
|
@ -101,10 +99,7 @@ var SiteCustomizations = Ember.ArrayProxy.extend({
|
|||
Discourse.SiteCustomization.reopenClass({
|
||||
findAll: function() {
|
||||
var customizations = SiteCustomizations.create({ content: [], loading: true });
|
||||
Discourse.ajax({
|
||||
url: Discourse.getURL("/admin/site_customizations"),
|
||||
dataType: "json"
|
||||
}).then(function (data) {
|
||||
Discourse.ajax(Discourse.getURL("/admin/site_customizations")).then(function (data) {
|
||||
if (data) {
|
||||
data.site_customizations.each(function(c) {
|
||||
customizations.pushObject(Discourse.SiteCustomization.create(c.site_customizations));
|
||||
|
|
|
@ -90,7 +90,7 @@ Discourse.SiteSetting.reopenClass({
|
|||
**/
|
||||
findAll: function() {
|
||||
var result = Em.A();
|
||||
Discourse.ajax({url: Discourse.getURL("/admin/site_settings")}).then(function (settings) {
|
||||
Discourse.ajax(Discourse.getURL("/admin/site_settings")).then(function (settings) {
|
||||
settings.site_settings.each(function(s) {
|
||||
s.originalValue = s.value;
|
||||
result.pushObject(Discourse.SiteSetting.create(s));
|
||||
|
|
|
@ -26,7 +26,7 @@ Discourse.VersionCheck = Discourse.Model.extend({
|
|||
|
||||
Discourse.VersionCheck.reopenClass({
|
||||
find: function() {
|
||||
return Discourse.ajax({ url: Discourse.getURL('/admin/version_check'), dataType: 'json' }).then(function(json) {
|
||||
return Discourse.ajax(Discourse.getURL('/admin/version_check')).then(function(json) {
|
||||
return Discourse.VersionCheck.create(json);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -194,7 +194,30 @@ Discourse = Ember.Application.createWithMixins({
|
|||
@method ajax
|
||||
**/
|
||||
ajax: function() {
|
||||
return $.ajax.apply(this, arguments);
|
||||
|
||||
var url, args;
|
||||
if (arguments.length === 1) {
|
||||
if (typeof arguments[0] === "string") {
|
||||
url = arguments[0];
|
||||
args = {};
|
||||
} else {
|
||||
args = arguments[0];
|
||||
url = args.url;
|
||||
delete args.url;
|
||||
}
|
||||
} else if (arguments.length === 2) {
|
||||
url = arguments[0];
|
||||
args = arguments[1];
|
||||
}
|
||||
|
||||
if (args.success) {
|
||||
console.log("DEPRECATION: Discourse.ajax should use promises, received 'success' callback");
|
||||
}
|
||||
if (args.error) {
|
||||
console.log("DEPRECATION: Discourse.ajax should use promises, received 'error' callback");
|
||||
}
|
||||
|
||||
return $.ajax(url, args);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,9 +49,7 @@ Discourse.Onebox = {
|
|||
$elem.addClass('loading-onebox');
|
||||
|
||||
// Retrieve the onebox
|
||||
var promise = Discourse.ajax({
|
||||
type: 'GET',
|
||||
url: "/onebox",
|
||||
var promise = Discourse.ajax(Discourse.getURL("/onebox"), {
|
||||
data: { url: url, refresh: refresh }
|
||||
});
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@ var cacheTopicId = null;
|
|||
var cacheTime = null;
|
||||
|
||||
var debouncedSearch = Discourse.debouncePromise(function(term, topicId) {
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL('/users/search/users'),
|
||||
return Discourse.ajax(Discourse.getURL('/users/search/users'), {
|
||||
data: {
|
||||
term: term,
|
||||
topic_id: topicId
|
||||
|
|
|
@ -58,8 +58,7 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
|||
// Create our post action
|
||||
var actionSummary = this;
|
||||
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL("/post_actions"),
|
||||
return Discourse.ajax(Discourse.getURL("/post_actions"), {
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: this.get('post.id'),
|
||||
|
@ -78,8 +77,7 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
|||
this.removeAction();
|
||||
|
||||
// Remove our post action
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL("/post_actions/") + (this.get('post.id')),
|
||||
return Discourse.ajax(Discourse.getURL("/post_actions/") + (this.get('post.id')), {
|
||||
type: 'DELETE',
|
||||
data: {
|
||||
post_action_type_id: this.get('id')
|
||||
|
|
|
@ -54,7 +54,7 @@ Discourse.Category = Discourse.Model.extend({
|
|||
|
||||
Discourse.Category.reopenClass({
|
||||
findBySlugOrId: function(slugOrId) {
|
||||
return Discourse.ajax({url: Discourse.getURL("/categories/") + slugOrId + ".json"}).then(function (result) {
|
||||
return Discourse.ajax(Discourse.getURL("/categories/") + slugOrId + ".json").then(function (result) {
|
||||
return Discourse.Category.create(result.category);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,9 +11,8 @@ Discourse.Draft = Discourse.Model.extend({});
|
|||
Discourse.Draft.reopenClass({
|
||||
|
||||
clear: function(key, sequence) {
|
||||
return Discourse.ajax({
|
||||
return Discourse.ajax(Discourse.getURL("/draft"), {
|
||||
type: 'DELETE',
|
||||
url: Discourse.getURL("/draft"),
|
||||
data: {
|
||||
draft_key: key,
|
||||
sequence: sequence
|
||||
|
@ -22,8 +21,7 @@ Discourse.Draft.reopenClass({
|
|||
},
|
||||
|
||||
get: function(key) {
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL('/draft'),
|
||||
return Discourse.ajax(Discourse.getURL('/draft'), {
|
||||
data: { draft_key: key },
|
||||
dataType: 'json'
|
||||
});
|
||||
|
@ -36,9 +34,8 @@ Discourse.Draft.reopenClass({
|
|||
|
||||
save: function(key, sequence, data) {
|
||||
data = typeof data === "string" ? data : JSON.stringify(data);
|
||||
return Discourse.ajax({
|
||||
return Discourse.ajax(Discourse.getURL("/draft"), {
|
||||
type: 'POST',
|
||||
url: Discourse.getURL("/draft"),
|
||||
data: {
|
||||
draft_key: key,
|
||||
data: data,
|
||||
|
|
|
@ -44,7 +44,7 @@ Discourse.Model.reopenClass({
|
|||
**/
|
||||
getModelAjax: function(url) {
|
||||
var modelClass = this;
|
||||
return Discourse.ajax({ url: url, cache: false, dataType: 'json' }).then(function (result) {
|
||||
return Discourse.ajax(url, { cache: false }).then(function (result) {
|
||||
return modelClass.create(result);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -13,19 +13,19 @@ Discourse.Notification = Discourse.Model.extend({
|
|||
return '';
|
||||
}).property('read'),
|
||||
|
||||
url: (function() {
|
||||
url: function() {
|
||||
if (this.blank('data.topic_title')) return "";
|
||||
return Discourse.Utilities.postUrl(this.get('slug'), this.get('topic_id'), this.get('post_number'));
|
||||
}).property(),
|
||||
}.property(),
|
||||
|
||||
rendered: (function() {
|
||||
rendered: function() {
|
||||
var notificationName;
|
||||
notificationName = Discourse.get('site.notificationLookup')[this.notification_type];
|
||||
return Em.String.i18n("notifications." + notificationName, {
|
||||
username: this.data.display_username,
|
||||
link: "<a href='" + (this.get('url')) + "'>" + this.data.topic_title + "</a>"
|
||||
});
|
||||
}).property()
|
||||
}.property()
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue