mirror of
https://github.com/discourse/discourse.git
synced 2026-07-29 23:58:12 -05:00
DEV: Use type instead of method in ajax calls (#8974)
Even though `type` is an alias for `method`, we have custom logic in `/discourse/lib/ajax` that checks only `type`, and ~200 other ajax calls in the codebase already use `type` param.
This commit is contained in:
@@ -18,7 +18,7 @@ export default Controller.extend(bufferedProperty("model"), {
|
||||
});
|
||||
|
||||
ajax("robots.json", {
|
||||
method: "PUT",
|
||||
type: "PUT",
|
||||
data: { robots_txt: this.buffered.get("robots_txt") }
|
||||
})
|
||||
.then(data => {
|
||||
@@ -34,7 +34,7 @@ export default Controller.extend(bufferedProperty("model"), {
|
||||
isSaving: true,
|
||||
saved: false
|
||||
});
|
||||
ajax("robots.json", { method: "DELETE" })
|
||||
ajax("robots.json", { type: "DELETE" })
|
||||
.then(data => {
|
||||
this.buffered.set("robots_txt", data.robots_txt);
|
||||
this.commitBuffer();
|
||||
|
||||
@@ -92,7 +92,7 @@ export default Controller.extend({
|
||||
result => {
|
||||
if (result) {
|
||||
ajax(`/admin/logs/watched_words/action/${actionKey}.json`, {
|
||||
method: "DELETE"
|
||||
type: "DELETE"
|
||||
}).then(() => {
|
||||
const action = this.findAction(actionKey);
|
||||
if (action) {
|
||||
|
||||
@@ -65,7 +65,7 @@ export default Controller.extend(ModalFunctionality, {
|
||||
|
||||
ajax("/admin/badges/badge_groupings", {
|
||||
data: { ids: groupIds, names },
|
||||
method: "POST"
|
||||
type: "POST"
|
||||
}).then(
|
||||
data => {
|
||||
items = this.model;
|
||||
|
||||
@@ -84,7 +84,7 @@ export default Controller.extend(ModalFunctionality, {
|
||||
const checked = this.privateChecked;
|
||||
if (checked && !this._keyLoading) {
|
||||
this._keyLoading = true;
|
||||
ajax(this.keyGenUrl, { method: "POST" })
|
||||
ajax(this.keyGenUrl, { type: "POST" })
|
||||
.then(pair => {
|
||||
this.setProperties({
|
||||
privateKey: pair.private_key,
|
||||
|
||||
@@ -31,7 +31,7 @@ export default Controller.extend(ModalFunctionality, {
|
||||
category_ids: this._extractSelectedIds(this.categories),
|
||||
topic_ids: this._extractSelectedIds(this.topics)
|
||||
},
|
||||
method: "POST"
|
||||
type: "POST"
|
||||
})
|
||||
.then(
|
||||
() => this.send("closeModal"),
|
||||
|
||||
@@ -5,7 +5,7 @@ const { getProperties } = Ember;
|
||||
export default RestModel.extend({
|
||||
revert() {
|
||||
return ajax(`/admin/customize/email_templates/${this.id}`, {
|
||||
method: "DELETE"
|
||||
type: "DELETE"
|
||||
}).then(result =>
|
||||
getProperties(result.email_template, "subject", "body", "can_revert")
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ const ScreenedEmail = EmberObject.extend({
|
||||
|
||||
clearBlock: function() {
|
||||
return ajax("/admin/logs/screened_emails/" + this.id, {
|
||||
method: "DELETE"
|
||||
type: "DELETE"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ const { getProperties } = Ember;
|
||||
export default RestModel.extend({
|
||||
revert() {
|
||||
return ajax(`/admin/customize/site_texts/${this.id}`, {
|
||||
method: "DELETE"
|
||||
type: "DELETE"
|
||||
}).then(result => getProperties(result.site_text, "value", "can_revert"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ export default Route.extend({
|
||||
preview(badge, explain) {
|
||||
badge.set("preview_loading", true);
|
||||
ajax("/admin/badges/preview.json", {
|
||||
method: "post",
|
||||
type: "POST",
|
||||
data: {
|
||||
sql: badge.get("query"),
|
||||
target_posts: !!badge.get("target_posts"),
|
||||
|
||||
Reference in New Issue
Block a user