FIX: Don't try to render buttons when no data (#56)

FIX: Don’t try to render buttons when no data (#56)

(e.g. when the user profile is hidden)

diff --git a/assets/javascripts/discourse/connectors/user-card-additional-buttons/endorsement-button.js b/assets/javascripts/discourse/connectors/user-card-additional-buttons/endorsement-button.js
new file mode 100644
index 0000000..466e7b7
--- /dev/null
+++ b/assets/javascripts/discourse/connectors/user-card-additional-buttons/endorsement-button.js
@@ -0,0 +1,5 @@
+export default {
+  shouldRender(args) {
+    return !!args.user.category_expert_endorsements;
+  },
+};
diff --git a/assets/javascripts/discourse/connectors/user-profile-controls/endorsement-button.js b/assets/javascripts/discourse/connectors/user-profile-controls/endorsement-button.js
new file mode 100644
index 0000000..fa0c60e
--- /dev/null
+++ b/assets/javascripts/discourse/connectors/user-profile-controls/endorsement-button.js
@@ -0,0 +1,5 @@
+export default {
+  shouldRender(args) {
+    return !!args.model.category_expert_endorsements;
+  },
+};
diff --git a/test/javascripts/acceptance/category-experts-post-test.js b/test/javascripts/acceptance/category-experts-post-test.js
index 850b1c3..d6140f6 100644
--- a/test/javascripts/acceptance/category-experts-post-test.js
+++ b/test/javascripts/acceptance/category-experts-post-test.js
@@ -4,6 +4,8 @@ import {
   queryAll,
 } from "discourse/tests/helpers/qunit-helpers";
 import topicFixtures from "discourse/tests/fixtures/topic";
+import { test } from "qunit";
+import { click, visit } from "@ember/test-helpers";
 
 const groupName = "some-group";
 
diff --git a/test/javascripts/acceptance/endorsement-checkboxes-test.js b/test/javascripts/acceptance/endorsement-checkboxes-test.js
index 7ef5fd5..0ba4387 100644
--- a/test/javascripts/acceptance/endorsement-checkboxes-test.js
+++ b/test/javascripts/acceptance/endorsement-checkboxes-test.js
@@ -6,6 +6,8 @@ import {
 } from "discourse/tests/helpers/qunit-helpers";
 import userFixtures from "discourse/tests/fixtures/user-fixtures";
 import categories from "../category-expert-categories";
+import { test } from "qunit";
+import { click, visit } from "@ember/test-helpers";
 
 acceptance(
   "Discourse Category Experts - No existing endorsements",

GitHub sha: e2d543460671fa3d068c3f8f41a1f368f37e843d

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