FIX: allows invite modal from topic-map post-actions (#7047)

FIX: allows invite modal from topic-map post-actions (#7047)

diff --git a/app/assets/javascripts/discourse/initializers/topic-footer-buttons.js.es6 b/app/assets/javascripts/discourse/initializers/topic-footer-buttons.js.es6
index 54ef5e5..74bbcf4 100644
--- a/app/assets/javascripts/discourse/initializers/topic-footer-buttons.js.es6
+++ b/app/assets/javascripts/discourse/initializers/topic-footer-buttons.js.es6
@@ -45,7 +45,6 @@ export default {
           }
 
           showModal("share-and-invite", {
-            model: this.get("topic"),
             modalClass: "share-and-invite",
             panels
           });
diff --git a/app/assets/javascripts/discourse/routes/topic.js.es6 b/app/assets/javascripts/discourse/routes/topic.js.es6
index 78673ca..06518c1 100644
--- a/app/assets/javascripts/discourse/routes/topic.js.es6
+++ b/app/assets/javascripts/discourse/routes/topic.js.es6
@@ -48,6 +48,31 @@ const TopicRoute = Discourse.Route.extend({
   },
 
   actions: {
+    showInvite() {
+      let invitePanelTitle;
+
+      if (this.get("isPM")) {
+        invitePanelTitle = "topic.invite_private.title";
+      } else if (this.get("invitingToTopic")) {
+        invitePanelTitle = "topic.invite_reply.title";
+      } else {
+        invitePanelTitle = "user.invited.create";
+      }
+
+      showModal("share-and-invite", {
+        modalClass: "share-and-invite",
+        panels: [
+          {
+            id: "invite",
+            title: invitePanelTitle,
+            model: {
+              inviteModel: this.modelFor("topic")
+            }
+          }
+        ]
+      });
+    },
+
     showFlags(model) {
       let controller = showModal("flag", { model });
       controller.setProperties({ flagTopic: false });
diff --git a/app/assets/javascripts/discourse/templates/topic.hbs b/app/assets/javascripts/discourse/templates/topic.hbs
index ea74abe..14b06cf 100644
--- a/app/assets/javascripts/discourse/templates/topic.hbs
+++ b/app/assets/javascripts/discourse/templates/topic.hbs
@@ -200,7 +200,8 @@
                 selectReplies=(action "selectReplies")
                 selectBelow=(action "selectBelow")
                 fillGapBefore=(action "fillGapBefore")
-                fillGapAfter=(action "fillGapAfter")}}
+                fillGapAfter=(action "fillGapAfter")
+                showInvite=(route-action "showInvite")}}
             {{/unless}}
 
             {{conditional-loading-spinner condition=model.postStream.loadingBelow}}

GitHub sha: 8d779db2