DEV: Use `type` instead of `method` in ajax calls (#8974)

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.

diff --git a/app/assets/javascripts/admin/controllers/admin-customize-robots-txt.js b/app/assets/javascripts/admin/controllers/admin-customize-robots-txt.js
index 5c6d249..a3e43f2 100644
--- a/app/assets/javascripts/admin/controllers/admin-customize-robots-txt.js
+++ b/app/assets/javascripts/admin/controllers/admin-customize-robots-txt.js
@@ -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();
diff --git a/app/assets/javascripts/admin/controllers/admin-watched-words-action.js b/app/assets/javascripts/admin/controllers/admin-watched-words-action.js
index 5de0003..cf5815d 100644
--- a/app/assets/javascripts/admin/controllers/admin-watched-words-action.js
+++ b/app/assets/javascripts/admin/controllers/admin-watched-words-action.js
@@ -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) {
diff --git a/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js b/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js
index 7bc3603..f1d1274 100644
--- a/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js
+++ b/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js
@@ -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;
diff --git a/app/assets/javascripts/admin/controllers/modals/admin-install-theme.js b/app/assets/javascripts/admin/controllers/modals/admin-install-theme.js
index 7c00365..16cf203 100644
--- a/app/assets/javascripts/admin/controllers/modals/admin-install-theme.js
+++ b/app/assets/javascripts/admin/controllers/modals/admin-install-theme.js
@@ -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,
diff --git a/app/assets/javascripts/admin/controllers/modals/admin-reseed.js b/app/assets/javascripts/admin/controllers/modals/admin-reseed.js
index 176c46b..326a3a6 100644
--- a/app/assets/javascripts/admin/controllers/modals/admin-reseed.js
+++ b/app/assets/javascripts/admin/controllers/modals/admin-reseed.js
@@ -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"),
diff --git a/app/assets/javascripts/admin/models/email-template.js b/app/assets/javascripts/admin/models/email-template.js
index 2dddb27..550148e 100644
--- a/app/assets/javascripts/admin/models/email-template.js
+++ b/app/assets/javascripts/admin/models/email-template.js
@@ -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")
     );
diff --git a/app/assets/javascripts/admin/models/screened-email.js b/app/assets/javascripts/admin/models/screened-email.js
index ea72510..4ef3217 100644
--- a/app/assets/javascripts/admin/models/screened-email.js
+++ b/app/assets/javascripts/admin/models/screened-email.js
@@ -10,7 +10,7 @@ const ScreenedEmail = EmberObject.extend({
 
   clearBlock: function() {
     return ajax("/admin/logs/screened_emails/" + this.id, {
-      method: "DELETE"
+      type: "DELETE"
     });
   }
 });
diff --git a/app/assets/javascripts/admin/models/site-text.js b/app/assets/javascripts/admin/models/site-text.js
index 8bcb8c7..793ab33 100644
--- a/app/assets/javascripts/admin/models/site-text.js
+++ b/app/assets/javascripts/admin/models/site-text.js
@@ -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"));
   }
 });
diff --git a/app/assets/javascripts/admin/routes/admin-badges-show.js b/app/assets/javascripts/admin/routes/admin-badges-show.js
index 67acdcb..4a29cfa 100644
--- a/app/assets/javascripts/admin/routes/admin-badges-show.js
+++ b/app/assets/javascripts/admin/routes/admin-badges-show.js
@@ -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"),
diff --git a/app/assets/javascripts/discourse/adapters/post.js b/app/assets/javascripts/discourse/adapters/post.js
index 9501980..1382d8d 100644
--- a/app/assets/javascripts/discourse/adapters/post.js
+++ b/app/assets/javascripts/discourse/adapters/post.js
@@ -13,7 +13,7 @@ export default RestAdapter.extend({
   createRecord(store, type, args) {
     const typeField = underscore(type);
     args.nested_post = true;
-    return ajax(this.pathFor(store, type), { method: "POST", data: args }).then(
+    return ajax(this.pathFor(store, type), { type: "POST", data: args }).then(
       function(json) {
         return new Result(json[typeField], json);
       }
diff --git a/app/assets/javascripts/discourse/adapters/rest.js b/app/assets/javascripts/discourse/adapters/rest.js
index bc28399..e92f325 100644
--- a/app/assets/javascripts/discourse/adapters/rest.js
+++ b/app/assets/javascripts/discourse/adapters/rest.js
@@ -133,7 +133,7 @@ export default EmberObject.extend({
 
   destroyRecord(store, type, record) {
     return ajax(this.pathFor(store, type, record.get("id")), {
-      method: "DELETE"
+      type: "DELETE"
     });
   }
 });
diff --git a/app/assets/javascripts/discourse/components/reviewable-claimed-topic.js b/app/assets/javascripts/discourse/components/reviewable-claimed-topic.js
index 273b51a..5ebc97a 100644
--- a/app/assets/javascripts/discourse/components/reviewable-claimed-topic.js
+++ b/app/assets/javascripts/discourse/components/reviewable-claimed-topic.js
@@ -14,7 +14,7 @@ export default Component.extend({
   actions: {
     unclaim() {
       ajax(`/reviewable_claimed_topics/${this.topicId}`, {
-        method: "DELETE"
+        type: "DELETE"
       }).then(() => {
         this.set("claimedBy", null);
       });
diff --git a/app/assets/javascripts/discourse/components/reviewable-item.js b/app/assets/javascripts/discourse/components/reviewable-item.js
index c301f1a..6f62710 100644
--- a/app/assets/javascripts/discourse/components/reviewable-item.js
+++ b/app/assets/javascripts/discourse/components/reviewable-item.js

[... diff too long, it was truncated ...]

GitHub sha: 67b34600

This commit appears in #8974 which was approved by davidtaylorhq and davidtaylorhq. It was merged by CvX.