DEV: Post-release cleanup (#163)

DEV: Post-release cleanup (#163)

Included:

  • DEV: Post-release cleanup
  • DEV: Tests cleanup
  • DEV: Import cleanup
  • DEV: Drop a compatibility fix
  • DEV: Use index_by
  • DEV: Use ember imports
  • DEV: Use discourseDebounce
  • DEV: Use @action
  • DEV: Use the optional chaining operator
  • DEV: Fix an invalid test
  • DEV: Use discourseModule
  • DEV: Add .prettierrc
  • DEV: Sync up the version number
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1 @@
+{}
diff --git a/app/controllers/discourse_assign/assign_controller.rb b/app/controllers/discourse_assign/assign_controller.rb
index 9e9521c..612a3b2 100644
--- a/app/controllers/discourse_assign/assign_controller.rb
+++ b/app/controllers/discourse_assign/assign_controller.rb
@@ -98,21 +98,13 @@ module DiscourseAssign
 
       Topic.preload_custom_fields(topics, TopicList.preloaded_custom_fields)
 
-      # TODO Drop AvatarLookup after Discourse 2.6.0 release
-      lookup_columns = defined?(UserLookup) ? UserLookup.lookup_columns : AvatarLookup.lookup_columns
-
       users = User
         .where("users.id IN (SELECT value::int FROM topic_custom_fields WHERE name = 'assigned_to_id' AND topic_id IN (?))", topics.map(&:id))
         .joins('join user_emails on user_emails.user_id = users.id AND user_emails.primary')
-        .select(lookup_columns)
+        .select(UserLookup.lookup_columns)
         .to_a
 
-      # TODO Drop after Discourse 2.6.0 release
-      if User.respond_to?(:allowed_user_custom_fields)
-        User.preload_custom_fields(users, User.allowed_user_custom_fields(guardian))
-      else
-        User.preload_custom_fields(users, User.whitelisted_user_custom_fields(guardian))
-      end
+      User.preload_custom_fields(users, User.allowed_user_custom_fields(guardian))
 
       users = users.to_h { |u| [u.id, u] }
       topics.each do |t|
diff --git a/assets/javascripts/discourse-assign/connectors/advanced-search-options-below/assigned-advanced-search.js.es6 b/assets/javascripts/discourse-assign/connectors/advanced-search-options-below/assigned-advanced-search.js.es6
index 9d58e2d..366dacd 100644
--- a/assets/javascripts/discourse-assign/connectors/advanced-search-options-below/assigned-advanced-search.js.es6
+++ b/assets/javascripts/discourse-assign/connectors/advanced-search-options-below/assigned-advanced-search.js.es6
@@ -1,15 +1,16 @@
+import { action } from "@ember/object";
+
 export default {
   shouldRender(args, component) {
     return component.currentUser && component.currentUser.can_assign;
   },
 
-  actions: {
-    onChangeAssigned(value) {
-      if (this.onChangeSearchedTermField) {
-        this.onChangeSearchedTermField("assigned", "updateInRegex", value);
-      } else {
-        this.set("searchedTerms.assigned", value);
-      }
-    },
+  @action
+  onChangeAssigned(value) {
+    if (this.onChangeSearchedTermField) {
+      this.onChangeSearchedTermField("assigned", "updateInRegex", value);
+    } else {
+      this.set("searchedTerms.assigned", value);
+    }
   },
 };
diff --git a/assets/javascripts/discourse-assign/connectors/category-custom-settings/assign-settings.js.es6 b/assets/javascripts/discourse-assign/connectors/category-custom-settings/assign-settings.js.es6
index c85e99e..eaa312c 100644
--- a/assets/javascripts/discourse-assign/connectors/category-custom-settings/assign-settings.js.es6
+++ b/assets/javascripts/discourse-assign/connectors/category-custom-settings/assign-settings.js.es6
@@ -1,10 +1,11 @@
+import { action } from "@ember/object";
+
 export default {
-  actions: {
-    onChangeSetting(value) {
-      this.set(
-        "category.custom_fields.enable_unassigned_filter",
-        value ? "true" : "false"
-      );
-    },
+  @action
+  onChangeSetting(value) {
+    this.set(
+      "category.custom_fields.enable_unassigned_filter",
+      value ? "true" : "false"
+    );
   },
 };
diff --git a/assets/javascripts/discourse-assign/controllers/assign-user.js.es6 b/assets/javascripts/discourse-assign/controllers/assign-user.js.es6
index 198e9ee..1d6fa03 100644
--- a/assets/javascripts/discourse-assign/controllers/assign-user.js.es6
+++ b/assets/javascripts/discourse-assign/controllers/assign-user.js.es6
@@ -1,13 +1,16 @@
+import Controller, { inject as controller } from "@ember/controller";
+import { inject as service } from "@ember/service";
 import { ajax } from "discourse/lib/ajax";
 import { popupAjaxError } from "discourse/lib/ajax-error";
-import { inject as controller } from "@ember/controller";
 import { not } from "@ember/object/computed";
+import { isEmpty } from "@ember/utils";
+import { action } from "@ember/object";
 
-export default Ember.Controller.extend({
+export default Controller.extend({
   topicBulkActions: controller(),
   assignSuggestions: null,
   allowedGroups: null,
-  taskActions: Ember.inject.service(),
+  taskActions: service(),
   autofocus: not("capabilities.touch"),
 
   init() {
@@ -33,50 +36,50 @@ export default Ember.Controller.extend({
     });
   },
 
-  actions: {
-    assignUser(user) {
-      if (this.isBulkAction) {
-        this.bulkAction(user.username);
-        return;
-      }
-      this.setProperties({
-        "model.username": user.username,
-        "model.allowedGroups": this.taskActions.allowedGroups,
-      });
-      this.send("assign");
-    },
+  @action
+  assignUser(user) {
+    if (this.isBulkAction) {
+      this.bulkAction(user.username);
+      return;
+    }
+    this.setProperties({
+      "model.username": user.username,
+      "model.allowedGroups": this.taskActions.allowedGroups,
+    });
+    this.send("assign");
+  },
 
-    assign() {
-      if (this.isBulkAction) {
-        this.bulkAction(this.model.username);
-        return;
-      }
-      let path = "/assign/assign";
+  @action
+  assign() {
+    if (this.isBulkAction) {
+      this.bulkAction(this.model.username);
+      return;
+    }
+    let path = "/assign/assign";
 
-      if (Ember.isEmpty(this.get("model.username"))) {
-        path = "/assign/unassign";
-        this.set("model.assigned_to_user", null);
-      }
+    if (isEmpty(this.get("model.username"))) {
+      path = "/assign/unassign";
+      this.set("model.assigned_to_user", null);
+    }
 
-      this.send("closeModal");
+    this.send("closeModal");
 
-      return ajax(path, {
-        type: "PUT",
-        data: {
-          username: this.get("model.username"),
-          topic_id: this.get("model.topic.id"),
-        },
+    return ajax(path, {
+      type: "PUT",
+      data: {
+        username: this.get("model.username"),
+        topic_id: this.get("model.topic.id"),
+      },
+    })
+      .then(() => {
+        if (this.get("model.onSuccess")) {
+          this.get("model.onSuccess")();
+        }
       })
-        .then(() => {
-          if (this.get("model.onSuccess")) {
-            this.get("model.onSuccess")();
-          }
-        })
-        .catch(popupAjaxError);
-    },
+      .catch(popupAjaxError);
+  },
 
-    updateUsername(selected) {
-      this.set("model.username", selected.firstObject);
-    },
+  updateUsername(selected) {
+    this.set("model.username", selected.firstObject);
   },
 });
diff --git a/assets/javascripts/discourse-assign/controllers/group-assigned-show.js.es6 b/assets/javascripts/discourse-assign/controllers/group-assigned-show.js.es6
index b753c71..bdc5dfc 100644
--- a/assets/javascripts/discourse-assign/controllers/group-assigned-show.js.es6
+++ b/assets/javascripts/discourse-assign/controllers/group-assigned-show.js.es6
@@ -1,12 +1,15 @@
 import UserTopicsList from "discourse/controllers/user-topics-list";
 import { alias } from "@ember/object/computed";
 import discourseComputed from "discourse-common/utils/decorators";
-import debounce from "discourse/plugins/discourse-assign/lib/debounce";
+import discourseDebounce from "discourse-common/lib/debounce";
 import { INPUT_DELAY } from "discourse-common/config/environment";
+import { inject as controller } from "@ember/controller";
+import { inject as service } from "@ember/service";
+import { action } from "@ember/object";
 
 export default UserTopicsList.extend({
-  user: Ember.inject.controller(),
-  taskActions: Ember.inject.service(),
+  user: controller(),
+  taskActions: service(),
   order: "",
   ascending: false,
   search: "",

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

GitHub sha: 195dcc92cb3bab9dd7b7457efb7beca06959baae

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