FIX: Show holiday flair in user directory (#46)

FIX: Show holiday flair in user directory (#46)

diff --git a/assets/javascripts/connectors/after-user-name/holiday-flair.js.es6 b/assets/javascripts/connectors/after-user-name/holiday-flair.js.es6
new file mode 100644
index 0000000..553d665
--- /dev/null
+++ b/assets/javascripts/connectors/after-user-name/holiday-flair.js.es6
@@ -0,0 +1,19 @@
+import { emojiUrlFor } from "discourse/lib/text";
+
+const HOLIDAY_EMOJI_NAME = "desert_island";
+
+export default {
+  shouldRender(args, context) {
+    return (
+      context.siteSettings.calendar_enabled &&
+      context.site.users_on_holiday.includes(args.user.username)
+    );
+  },
+
+  setupComponent(args, component) {
+    component.setProperties({
+      holidayEmojiName: `:${HOLIDAY_EMOJI_NAME}:`,
+      holidayEmoji: emojiUrlFor(HOLIDAY_EMOJI_NAME)
+    });
+  }
+};
diff --git a/assets/javascripts/templates/connectors/after-user-name/holiday-flair.hbs b/assets/javascripts/templates/connectors/after-user-name/holiday-flair.hbs
new file mode 100644
index 0000000..dd0b0bc
--- /dev/null
+++ b/assets/javascripts/templates/connectors/after-user-name/holiday-flair.hbs
@@ -0,0 +1 @@
+<img src={{holidayEmoji}} class="emoji" alt={{holidayEmojiName}}>
diff --git a/test/javascripts/acceptance/holiday-flair-test.js.es6 b/test/javascripts/acceptance/holiday-flair-test.js.es6
new file mode 100644
index 0000000..b49dc95
--- /dev/null
+++ b/test/javascripts/acceptance/holiday-flair-test.js.es6
@@ -0,0 +1,66 @@
+import selectKit from "helpers/select-kit-helper";
+import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+
+acceptance("Discourse Calendar - Holiday Flair", {
+  loggedIn: true,
+  settings: { calendar_enabled: true },
+  site: {
+    users_on_holiday: ["foo"]
+  },
+
+  pretend(server, helper) {
+    server.get("/directory_items", () => {
+      return helper.response({
+        directory_items: [
+          {
+            id: 1,
+            likes_received: 0,
+            likes_given: 0,
+            topics_entered: 0,
+            topic_count: 0,
+            post_count: 0,
+            posts_read: 0,
+            days_visited: 1,
+            user: {
+              id: 1,
+              username: "foo",
+              name: "Foo",
+              avatar_template:
+                "/letter_avatar_proxy/v4/letter/f/3be4f8/{size}.png"
+            }
+          },
+          {
+            id: 2,
+            likes_received: 0,
+            likes_given: 0,
+            topics_entered: 0,
+            topic_count: 0,
+            post_count: 0,
+            posts_read: 0,
+            days_visited: 1,
+            user: {
+              id: 2,
+              username: "bar",
+              name: "Bar",
+              avatar_template:
+                "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png"
+            }
+          }
+        ],
+        meta: {
+          last_updated_at: "2020-01-01T12:00:00.000Z",
+          total_rows_directory_items: 2,
+          load_more_directory_items:
+            "/directory_items?order=likes_received&page=1&period=weekly"
+        }
+      });
+    });
+  }
+});
+
+QUnit.test("shows holiday emoji in directory", async assert => {
+  await visit("/users");
+  assert.equal(find(".holiday-flair").length, 1);
+  assert.equal(find("div[data-username='foo'] .holiday-flair").length, 1);
+  assert.equal(find("div[data-username='bar'] .holiday-flair").length, 0);
+});

GitHub sha: 7b4f9895

This commit appears in #46 which was approved by eviltrout and ZogStriP. It was merged by nbianca.