DEV: Use `import { inject as controller}` Ember idiom (#13140)

DEV: Use import { inject as controller} Ember idiom (#13140)

diff --git a/app/assets/javascripts/admin/addon/controllers/admin-dashboard-general.js b/app/assets/javascripts/admin/addon/controllers/admin-dashboard-general.js
index a831b68..bde2cf5 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-dashboard-general.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-dashboard-general.js
@@ -1,4 +1,4 @@
-import Controller, { inject } from "@ember/controller";
+import Controller, { inject as controller } from "@ember/controller";
 import AdminDashboard from "admin/models/admin-dashboard";
 import I18n from "I18n";
 import PeriodComputationMixin from "admin/mixins/period-computation";
@@ -18,7 +18,7 @@ function staticReport(reportType) {
 export default Controller.extend(PeriodComputationMixin, {
   isLoading: false,
   dashboardFetchedAt: null,
-  exceptionController: inject("exception"),
+  exceptionController: controller("exception"),
   logSearchQueriesEnabled: setting("log_search_queries"),
 
   @discourseComputed("siteSettings.dashboard_general_tab_activity_metrics")
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-dashboard.js b/app/assets/javascripts/admin/addon/controllers/admin-dashboard.js
index 8995595..c7291f1 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-dashboard.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-dashboard.js
@@ -1,4 +1,4 @@
-import Controller, { inject } from "@ember/controller";
+import Controller, { inject as controller } from "@ember/controller";
 import AdminDashboard from "admin/models/admin-dashboard";
 import VersionCheck from "admin/models/version-check";
 import { computed } from "@ember/object";
@@ -10,7 +10,7 @@ const PROBLEMS_CHECK_MINUTES = 1;
 export default Controller.extend({
   isLoading: false,
   dashboardFetchedAt: null,
-  exceptionController: inject("exception"),
+  exceptionController: controller("exception"),
   showVersionChecks: setting("version_checks"),
 
   @discourseComputed("problems.length")
diff --git a/app/assets/javascripts/discourse/app/controllers/change-owner.js b/app/assets/javascripts/discourse/app/controllers/change-owner.js
index fe2a7c5..96db63e 100644
--- a/app/assets/javascripts/discourse/app/controllers/change-owner.js
+++ b/app/assets/javascripts/discourse/app/controllers/change-owner.js
@@ -1,4 +1,4 @@
-import Controller, { inject } from "@ember/controller";
+import Controller, { inject as controller } from "@ember/controller";
 import DiscourseURL from "discourse/lib/url";
 import I18n from "I18n";
 import ModalFunctionality from "discourse/mixins/modal-functionality";
@@ -9,7 +9,7 @@ import { isEmpty } from "@ember/utils";
 import { next } from "@ember/runloop";
 
 export default Controller.extend(ModalFunctionality, {
-  topicController: inject("topic"),
+  topicController: controller("topic"),
 
   saving: false,
   newOwner: null,
diff --git a/app/assets/javascripts/discourse/app/controllers/change-timestamp.js b/app/assets/javascripts/discourse/app/controllers/change-timestamp.js
index 8e41d3a..0791540 100644
--- a/app/assets/javascripts/discourse/app/controllers/change-timestamp.js
+++ b/app/assets/javascripts/discourse/app/controllers/change-timestamp.js
@@ -1,4 +1,4 @@
-import Controller, { inject } from "@ember/controller";
+import Controller, { inject as controller } from "@ember/controller";
 import DiscourseURL from "discourse/lib/url";
 import I18n from "I18n";
 import ModalFunctionality from "discourse/mixins/modal-functionality";
@@ -9,7 +9,7 @@ import { next } from "@ember/runloop";
 
 // Modal related to changing the timestamp of posts
 export default Controller.extend(ModalFunctionality, {
-  topicController: inject("topic"),
+  topicController: controller("topic"),
   saving: false,
   date: "",
   time: "",
diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js
index 626f339..9fa2593 100644
--- a/app/assets/javascripts/discourse/app/controllers/composer.js
+++ b/app/assets/javascripts/discourse/app/controllers/composer.js
@@ -1,5 +1,5 @@
 import Composer, { SAVE_ICONS, SAVE_LABELS } from "discourse/models/composer";
-import Controller, { inject } from "@ember/controller";
+import Controller, { inject as controller } from "@ember/controller";
 import EmberObject, { action, computed } from "@ember/object";
 import { alias, and, or, reads } from "@ember/object/computed";
 import {
@@ -93,7 +93,7 @@ export function addPopupMenuOptionsCallback(callback) {
 }
 
 export default Controller.extend({
-  topicController: inject("topic"),
+  topicController: controller("topic"),
   router: service(),
 
   checkedMessages: false,
@@ -1137,11 +1137,11 @@ export default Controller.extend({
 
     let promise = new Promise((resolve, reject) => {
       if (this.get("model.hasMetaData") || this.get("model.replyDirty")) {
-        const controller = showModal("discard-draft", {
+        const modal = showModal("discard-draft", {
           model: this.model,
           modalClass: "discard-draft-modal",
         });
-        controller.setProperties({
+        modal.setProperties({
           onDestroyDraft: () => {
             this.destroyDraft()
               .then(() => {
diff --git a/app/assets/javascripts/discourse/app/controllers/delete-topic-confirm.js b/app/assets/javascripts/discourse/app/controllers/delete-topic-confirm.js
index fb8de28..f310161 100644
--- a/app/assets/javascripts/discourse/app/controllers/delete-topic-confirm.js
+++ b/app/assets/javascripts/discourse/app/controllers/delete-topic-confirm.js
@@ -1,4 +1,4 @@
-import Controller, { inject } from "@ember/controller";
+import Controller, { inject as controller } from "@ember/controller";
 import I18n from "I18n";
 import ModalFunctionality from "discourse/mixins/modal-functionality";
 import { action } from "@ember/object";
@@ -7,7 +7,7 @@ import discourseComputed from "discourse-common/utils/decorators";
 // Modal that displays confirmation text when user deletes a topic
 // The modal will display only if the topic exceeds a certain amount of views
 export default Controller.extend(ModalFunctionality, {
-  topicController: inject("topic"),
+  topicController: controller("topic"),
   deletingTopic: false,
 
   @discourseComputed("deletingTopic")
diff --git a/app/assets/javascripts/discourse/app/controllers/discovery-sortable.js b/app/assets/javascripts/discourse/app/controllers/discovery-sortable.js
index 87e44d6..8d02ca3 100644
--- a/app/assets/javascripts/discourse/app/controllers/discovery-sortable.js
+++ b/app/assets/javascripts/discourse/app/controllers/discovery-sortable.js
@@ -1,4 +1,4 @@
-import Controller, { inject } from "@ember/controller";
+import Controller, { inject as controller } from "@ember/controller";
 
 // Just add query params here to have them automatically passed to topic list filters.
 export const queryParams = {
@@ -17,7 +17,7 @@ export const queryParams = {
 
 // Basic controller options
 const controllerOpts = {
-  discoveryTopics: inject("discovery/topics"),
+  discoveryTopics: controller("discovery/topics"),
   queryParams: Object.keys(queryParams),
 };
 
@@ -27,22 +27,21 @@ controllerOpts.queryParams.forEach((p) => {
 });
 
 export function changeSort(sortBy) {
-  let { controller } = this;
   let model = this.controllerFor("discovery.topics").model;
-  if (sortBy === controller.order) {
-    controller.toggleProperty("ascending");
-    model.updateSortParams(sortBy, controller.ascending);
+
+  if (sortBy === this.controller.order) {
+    this.controller.toggleProperty("ascending");
+    model.updateSortParams(sortBy, this.controller.ascending);
   } else {
-    controller.setProperties({ order: sortBy, ascending: false });
+    this.controller.setProperties({ order: sortBy, ascending: false });
     model.updateSortParams(sortBy, false);
   }
 }
 
 export function resetParams(skipParams = []) {
-  let { controller } = this;
   controllerOpts.queryParams.forEach((p) => {

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

GitHub sha: 51b36091

This commit appears in #13140 which was approved by eviltrout. It was merged by CvX.