FIX: correct group icons and notification message (#193)

FIX: correct group icons and notification message (#193)

  • New group icon
  • Group assignment notification displays group name instead of who assigned
diff --git a/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 b/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6
index 0db5e1c..b8a08f9 100644
--- a/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6
+++ b/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6
@@ -196,9 +196,9 @@ function initialize(api) {
   });
 
   api.addPostSmallActionIcon("assigned", "user-plus");
-  api.addPostSmallActionIcon("assigned_group", "user-plus");
+  api.addPostSmallActionIcon("assigned_group", "group-plus");
   api.addPostSmallActionIcon("unassigned", "user-times");
-  api.addPostSmallActionIcon("unassigned_group", "user-times");
+  api.addPostSmallActionIcon("unassigned_group", "group-times");
 
   api.addPostTransformCallback((transformed) => {
     if (
@@ -221,7 +221,9 @@ function initialize(api) {
         ? topic.assignedToUserPath
         : topic.assignedToGroupPath;
       const tagName = params.tagName || "a";
-      const icon = assignedToUser ? iconHTML("user-plus") : iconHTML("users");
+      const icon = assignedToUser
+        ? iconHTML("user-plus")
+        : iconHTML("group-plus");
       const href =
         tagName === "a" ? `href="${assignedPath}" data-auto-route="true"` : "";
       return `<${tagName} class="assigned-to discourse-tag simple" ${href}>
@@ -254,7 +256,7 @@ function initialize(api) {
       let { assignedToUser, assignedToGroup, href } = attrs;
 
       return h("p.assigned-to", [
-        assignedToUser ? iconNode("user-plus") : iconNode("users"),
+        assignedToUser ? iconNode("user-plus") : iconNode("group-plus"),
         h("span.assign-text", I18n.t("discourse_assign.assigned_to")),
         h(
           "a",
@@ -330,7 +332,7 @@ function initialize(api) {
 
   api.replaceIcon(
     "notification.discourse_assign.assign_group_notification",
-    "users"
+    "group-plus"
   );
 
   api.modifyClass("controller:preferences/notifications", {
diff --git a/assets/javascripts/discourse/components/assign-actions-dropdown.js.es6 b/assets/javascripts/discourse/components/assign-actions-dropdown.js.es6
index 8cc2326..a1c6544 100644
--- a/assets/javascripts/discourse/components/assign-actions-dropdown.js.es6
+++ b/assets/javascripts/discourse/components/assign-actions-dropdown.js.es6
@@ -13,7 +13,7 @@ export default DropdownSelectBoxComponent.extend({
     return [
       {
         id: "unassign",
-        icon: "user-times",
+        icon: this.group ? "group-times" : "user-times",
         name: I18n.t("discourse_assign.unassign.title"),
         description: I18n.t("discourse_assign.unassign.help", {
           username: this.assignee,
diff --git a/assets/javascripts/discourse/templates/components/assigned-topic-list-item.hbs b/assets/javascripts/discourse/templates/components/assigned-topic-list-item.hbs
index 89b1ecb..6cbbc3f 100644
--- a/assets/javascripts/discourse/templates/components/assigned-topic-list-item.hbs
+++ b/assets/javascripts/discourse/templates/components/assigned-topic-list-item.hbs
@@ -58,6 +58,7 @@
     {{assign-actions-dropdown
       topic=topic
       assignee=topic.assigned_to_group.name
+      group=true
       unassign=unassign
       reassign=reassign
     }}
diff --git a/assets/javascripts/discourse/widgets/quick-access-assignments.js.es6 b/assets/javascripts/discourse/widgets/quick-access-assignments.js.es6
index b1280f9..71f225d 100644
--- a/assets/javascripts/discourse/widgets/quick-access-assignments.js.es6
+++ b/assets/javascripts/discourse/widgets/quick-access-assignments.js.es6
@@ -11,7 +11,7 @@ import { h } from "virtual-dom";
 import I18n from "I18n";
 
 const ICON = "user-plus";
-const GROUP_ICON = "users";
+const GROUP_ICON = "group-plus";
 
 createWidget("no-quick-access-assignments", {
   html() {
diff --git a/jobs/regular/assign_notification.rb b/jobs/regular/assign_notification.rb
index 91ff57b..36a4a78 100644
--- a/jobs/regular/assign_notification.rb
+++ b/jobs/regular/assign_notification.rb
@@ -12,7 +12,8 @@ module Jobs
       topic = Topic.find(args[:topic_id])
       assigned_by = User.find(args[:assigned_by_id])
       first_post = topic.posts.find_by(post_number: 1)
-      assigned_to_users = args[:assigned_to_type] == "User" ? [User.find(args[:assigned_to_id])] : Group.find(args[:assigned_to_id]).users
+      assigned_to = args[:assigned_to_type] == "User" ? User.find(args[:assigned_to_id]) : Group.find(args[:assigned_to_id])
+      assigned_to_users = args[:assigned_to_type] == "User" ? [assigned_to] : assigned_to.users
 
       assigned_to_users.each do |user|
         TopicAssigner.publish_topic_tracking_state(topic, user.id)
@@ -40,7 +41,7 @@ module Jobs
           high_priority: true,
           data: {
             message: args[:assigned_to_type] == "User" ? 'discourse_assign.assign_notification' : 'discourse_assign.assign_group_notification',
-            display_username: assigned_by.username,
+            display_username: args[:assigned_to_type] == "User" ? assigned_by.username : assigned_to.name,
             topic_title: topic.title
           }.to_json
         )
diff --git a/plugin.rb b/plugin.rb
index 36df31c..3d0ff41 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -14,6 +14,8 @@ register_asset 'stylesheets/mobile/assigns.scss', :mobile
 register_svg_icon "user-plus"
 register_svg_icon "user-times"
 
+%w[user-plus user-times group-plus group-times].each { |i| register_svg_icon(i) }
+
 load File.expand_path('../lib/discourse_assign/engine.rb', __FILE__)
 load File.expand_path('../lib/discourse_assign/helpers.rb', __FILE__)
 
diff --git a/spec/jobs/regular/assign_notification_spec.rb b/spec/jobs/regular/assign_notification_spec.rb
index 91a6414..00a5b12 100644
--- a/spec/jobs/regular/assign_notification_spec.rb
+++ b/spec/jobs/regular/assign_notification_spec.rb
@@ -95,7 +95,7 @@ RSpec.describe Jobs::AssignNotification do
           high_priority: true,
           data: {
             message: 'discourse_assign.assign_group_notification',
-            display_username: user1.username,
+            display_username: group.name,
             topic_title: topic.title
           }.to_json
         )
@@ -107,7 +107,7 @@ RSpec.describe Jobs::AssignNotification do
           high_priority: true,
           data: {
             message: 'discourse_assign.assign_group_notification',
-            display_username: user1.username,
+            display_username: group.name,
             topic_title: topic.title
           }.to_json
         )
diff --git a/svg-icons/plugin-icons.svg b/svg-icons/plugin-icons.svg
new file mode 100644
index 0000000..2c7f04a
--- /dev/null
+++ b/svg-icons/plugin-icons.svg
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
+  <symbol id='group-plus'  viewBox="0 0 30.7 19"><path d="m13.8 9.04c-2.49 0-4.52-2.03-4.52-4.52s2.03-4.52 4.52-4.52 4.52 2.03 4.52 4.52-2.03 4.52-4.52 4.52z"/><path d="m21 19h-14.5c-0.5 0-0.969-0.408-0.904-0.904 0 0-0.0338-3.27 0.613-4.72 0.552-1.24 1.46-2.43 2.65-3.08 1.58-0.865 3.93 1.92 7.79-0.184 1.19-0.649 3.44 1.59 4.4 3.11 0.878 1.39 0.828 4.87 0.828 4.87 0 0.5-0.404 0.904-0.904 0.904z"/><path d="m8.12 4.02c0-0.177 0.0099-0.354 0.0262-0.526-0.664-0.778-1.64-1.28-2.74-1.28-1.99 0-3.62 1.62-3.62 3.62s1.62 3.62 3.62 3.62c1.66 0 3.05-1.14 3.47-2.67-0.48-0.81-0.761-1.75-0.761-2.76z"/><path d="m6.84 10.8s-2.71 0.42-3.96 0.0645c-1.23-0.351-2.06 1.78-2.55 3-0.634 1.58-0.161 3.33-0.161 3.33 0 0.5 0.404 0.917 0.904 0.904h3.62s-0.0879-1.58 0.484-3.56c0.571-1.97 0.976-2.36 1.41-2.87 0.237-0.316 0.258-0.87 0.258-0.87z"/><path d="m30.1 7.4h-2.52v-2.52c0-0.347-0.284-0.63-0.63-0.63h-1.26c-0.347 0-0.63 0.284-0.63 0.63v2.52h-2.52c-0.347 0-0.63 0.284-0.63 0.63v1.26c0 0.347 0.284 0.63 0.63 0.63h2.52v2.52c0 0.347 0.284 0.63 0.63 0.63h1.26c0.347 0 0.63-0.284 0.63-0.63v-2.52h2.52c0.347 0 0.63-0.284 0.63-0.63v-1.26c0-0.347-0.284-0.63-0.63-0.63z"/></symbol>

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

GitHub sha: b42ec9f7794198882a981fdf5dc1dfe586b6d38b

This commit appears in #193 which was approved by eviltrout. It was merged by lis2.