FIX: brings back [+ New Topic] btn from share-popup post action (#7182)

FIX: brings back [+ New Topic] btn from share-popup post action (#7182)

diff --git a/app/assets/javascripts/discourse/components/share-popup.js.es6 b/app/assets/javascripts/discourse/components/share-popup.js.es6
index 5b0ff97..d2e556f 100644
--- a/app/assets/javascripts/discourse/components/share-popup.js.es6
+++ b/app/assets/javascripts/discourse/components/share-popup.js.es6
@@ -154,6 +154,14 @@ export default Ember.Component.extend({
   },
 
   actions: {
+    replyAsNewTopic() {
+      const postStream = this.get("topic.postStream");
+      const postId = this.postId || postStream.findPostIdForPostNumber(1);
+      const post = postStream.findLoadedPost(postId);
+      this.replyAsNewTopic(post);
+      this.send("close");
+    },
+
     close() {
       this.setProperties({
         link: null,
diff --git a/app/assets/javascripts/discourse/templates/components/share-popup.hbs b/app/assets/javascripts/discourse/templates/components/share-popup.hbs
index 84b946fc..55f2877 100644
--- a/app/assets/javascripts/discourse/templates/components/share-popup.hbs
+++ b/app/assets/javascripts/discourse/templates/components/share-popup.hbs
@@ -12,11 +12,29 @@
 </div>
 
 <div class="actions">
-  {{#each sources as |s|}}
-    {{share-source source=s title=model.title action=(action "share")}}
-  {{/each}}
+  <div class="sources">
+    {{#each sources as |s|}}
+      {{share-source source=s title=model.title action=(action "share")}}
+    {{/each}}
+  </div>
+
+  <div class="alt-actions">
+    {{#if topic.details.can_reply_as_new_topic}}
+      <div class="reply-as-new-topic">
+        {{#if topic.isPrivateMessage}}
+          <a href class="new-topic" {{action "replyAsNewTopic"}} aria-label={{i18n "post.reply_as_new_private_message"}} title={{i18n "post.reply_as_new_private_message"}}>
+            {{d-icon "plus"}}
+            {{i18n "user.new_private_message"}}
+          </a>
+        {{else}}
+          <a href class="new-topic" {{action "replyAsNewTopic"}} aria-label={{i18n "post.reply_as_new_topic"}} title={{i18n "post.reply_as_new_topic"}}>
+            {{d-icon "plus"}}
+            {{i18n "topic.create"}}
+          </a>
+        {{/if}}
+      </div>
+    {{/if}}
 
-  <div class="link">
     <a href {{action "close"}} class="close-share" aria-label={{i18n "share.close"}} title={{i18n "share.close"}}>
       {{d-icon "times"}}
     </a>
diff --git a/app/assets/javascripts/discourse/templates/topic.hbs b/app/assets/javascripts/discourse/templates/topic.hbs
index 61dd9e9..15a2a33 100644
--- a/app/assets/javascripts/discourse/templates/topic.hbs
+++ b/app/assets/javascripts/discourse/templates/topic.hbs
@@ -318,7 +318,7 @@
     </div>
   {{/if}}
 
-  {{share-popup topic=model}}
+  {{share-popup topic=model replyAsNewTopic=(action "replyAsNewTopic")}}
 
   {{#if embedQuoteButton}}
     {{quote-button quoteState=quoteState selectText=(action "selectText")}}
diff --git a/app/assets/stylesheets/common/base/share_link.scss b/app/assets/stylesheets/common/base/share_link.scss
index 5b2311c..38d7340 100644
--- a/app/assets/stylesheets/common/base/share_link.scss
+++ b/app/assets/stylesheets/common/base/share_link.scss
@@ -63,12 +63,6 @@
       color: dark-light-choose($twitter, white);
     }
   }
-  .link {
-    font-size: $font-up-3;
-    a {
-      color: dark-light-choose($primary-medium, $secondary-medium);
-    }
-  }
 
   input[type="text"] {
     font-size: $font-up-1;
@@ -77,11 +71,36 @@
 
   .actions {
     display: flex;
-    align-items: center;
+    align-items: flex-end;
     margin-top: s(2);
 
-    .link {
-      margin-left: auto;
+    .sources {
+      display: flex;
+      align-items: center;
+      flex-wrap: wrap;
+      flex-direction: row;
+      max-width: 45%;
+
+      .social-link {
+        margin-right: s(2);
+      }
+    }
+
+    .alt-actions {
+      display: flex;
+      align-items: center;
+      flex: 1;
+      justify-content: flex-end;
+      height: 36px;
+
+      .close-share {
+        font-size: $font-up-3;
+        color: dark-light-choose($primary-medium, $secondary-medium);
+      }
+
+      .new-topic {
+        margin-right: s(4);
+      }
     }
   }
 }
diff --git a/test/javascripts/acceptance/topic-test.js.es6 b/test/javascripts/acceptance/topic-test.js.es6
index b5f5893..73447b5 100644
--- a/test/javascripts/acceptance/topic-test.js.es6
+++ b/test/javascripts/acceptance/topic-test.js.es6
@@ -22,6 +22,69 @@ acceptance("Topic", {
   }
 });
 
+QUnit.test("Reply as new topic", async assert => {
+  await visit("/t/internationalization-localization/280");
+  await click("button.share:eq(0)");
+  await click(".reply-as-new-topic a");
+
+  assert.ok(exists(".d-editor-input"), "the composer input is visible");
+
+  assert.equal(
+    find(".d-editor-input")
+      .val()
+      .trim(),
+    `Continuing the discussion from [Internationalization / localization](${
+      window.location.origin
+    }/t/internationalization-localization/280):`,
+    "it fills composer with the ring string"
+  );
+  assert.equal(
+    selectKit(".category-chooser")
+      .header()
+      .value(),
+    "2",
+    "it fills category selector with the right category"
+  );
+});
+
+QUnit.test("Reply as new message", async assert => {
+  await visit("/t/pm-for-testing/12");
+  await click("button.share:eq(0)");
+  await click(".reply-as-new-topic a");
+
+  assert.ok(exists(".d-editor-input"), "the composer input is visible");
+
+  assert.equal(
+    find(".d-editor-input")
+      .val()
+      .trim(),
+    `Continuing the discussion from [PM for testing](${
+      window.location.origin
+    }/t/pm-for-testing/12):`,
+    "it fills composer with the ring string"
+  );
+
+  const targets = find(".item span", ".composer-fields");
+
+  assert.equal(
+    $(targets[0]).text(),
+    "someguy",
+    "it fills up the composer with the right user to start the PM to"
+  );
+
+  assert.equal(
+    $(targets[1]).text(),
+    "test",
+    "it fills up the composer with the right user to start the PM to"
+  );
+
+  assert.equal(
+    $(targets[2]).text(),
+    "Group",
+    "it fills up the composer with the right group to start the PM to"
+  );
+});
+
 QUnit.test("Share Modal", async assert => {
   await visit("/t/internationalization-localization/280");
   await click(".topic-post:first-child button.share");

GitHub sha: de6a7e32