FIX: Composer save button should be ✏ Save Edit when editing a PM post (#12521)

FIX: Composer save button should be :pencil2: Save Edit when editing a PM post (#12521)

Meta topic: Edits on Private Messages should generate a notification - #4 by Nacho_Caballero - feature - Discourse Meta.

diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js
index f50deaa..967dbaa 100644
--- a/app/assets/javascripts/discourse/app/controllers/composer.js
+++ b/app/assets/javascripts/discourse/app/controllers/composer.js
@@ -231,7 +231,7 @@ export default Controller.extend({
     if (isWhispering) {
       return "far-eye-slash";
     }
-    if (privateMessage) {
+    if (privateMessage && modelAction === Composer.REPLY) {
       return "envelope";
     }
 
@@ -249,7 +249,7 @@ export default Controller.extend({
       return "composer.overwrite_edit";
     } else if (isWhispering) {
       return "composer.create_whisper";
-    } else if (privateMessage) {
+    } else if (privateMessage && modelAction === Composer.REPLY) {
       return "composer.create_pm";
     }
 
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
index 6476fb3..7081f8e 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
@@ -23,6 +23,9 @@ acceptance("Composer", function (needs) {
     server.post("/uploads/lookup-urls", () => {
       return helper.response([]);
     });
+    server.get("/posts/419", () => {
+      return helper.response({ id: 419 });
+    });
   });
 
   skip("Tests the Composer controls", async function (assert) {
@@ -816,6 +819,23 @@ acceptance("Composer", function (needs) {
     );
   });
 
+  test("edit button when editing a post in a PM", async function (assert) {
+    await visit("/t/34");
+    await click("article#post_3 button.show-more-actions");
+    await click("article#post_3 button.edit");
+
+    assert.equal(
+      queryAll(".save-or-cancel button.create").text().trim(),
+      I18n.t("composer.save_edit"),
+      "save button says Save Edit"
+    );
+    assert.ok(
+      queryAll(".save-or-cancel button.create svg.d-icon-pencil-alt").length ===
+        1,
+      "save button has pencil icon"
+    );
+  });
+
   test("Image resizing buttons", async function (assert) {
     await visit("/");
     await click("#create-topic");

GitHub sha: f74785f7

This commit appears in #12521 which was approved by eviltrout. It was merged by OsamaSayegh.