mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 03:07:17 -05:00
UX: improve logic for new topic and new PM composer actions (#35834)
A follow-up to #35764. This change enhances the logic when **New topic** option should be shown/hidden in composer actions: 1. After user switches to **Personal message** mode, we allow to switch back to **New topic** mode: <img width="265" height="153" alt="Screenshot 2025-11-05 at 22 17 16" src="https://github.com/user-attachments/assets/5dedf69d-8e0c-4b28-abb5-1be4d5662a81" /> and <img width="332" height="177" alt="Screenshot 2025-11-05 at 22 22 05" src="https://github.com/user-attachments/assets/5e17c82d-10fb-4407-b9f8-ced78a85fdd5" /> 2. In **New topic** mode there is no need to render **New topic** option: |Before|After| |---|---| |<img width="345" height="233" alt="Screenshot 2025-11-05 at 18 57 20" src="https://github.com/user-attachments/assets/eef3d4da-b58e-4a11-90df-f76774630fad" />|<img width="453" height="197" alt="Screenshot 2025-11-05 at 22 19 37" src="https://github.com/user-attachments/assets/816b1199-01a7-4022-8695-61cc9edc2473" />|
This commit is contained in:
@@ -2998,7 +2998,7 @@ en:
|
||||
reply: "Reply"
|
||||
cancel: "Cancel"
|
||||
create_topic: "Create Topic"
|
||||
create_pm: "Send Message"
|
||||
create_pm: "Send message"
|
||||
create_whisper: "Whisper"
|
||||
create_shared_draft: "Create Shared Draft"
|
||||
edit_shared_draft: "Edit Shared Draft"
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
visit,
|
||||
waitFor,
|
||||
} from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import { module, test } from "qunit";
|
||||
import sinon from "sinon";
|
||||
import { PLATFORM_KEY_MODIFIER } from "discourse/lib/keyboard-shortcuts";
|
||||
import LinkLookup from "discourse/lib/link-lookup";
|
||||
@@ -814,6 +814,51 @@ import { i18n } from "discourse-i18n";
|
||||
.exists("goes back to open state if there's errors");
|
||||
});
|
||||
|
||||
module(
|
||||
"Composer can switch between new topic and new PM in different contexts",
|
||||
function () {
|
||||
test("within post/topic context", async function (assert) {
|
||||
await visit("/t/this-is-a-test-topic/54081");
|
||||
await click(".topic-post[data-post-number='1'] button.reply");
|
||||
await selectKit(".composer-actions").expand();
|
||||
assert.notStrictEqual(
|
||||
selectKit(".composer-actions")
|
||||
.rowByValue("create_private_message")
|
||||
.exists(),
|
||||
"New message option is not present when in reply mode"
|
||||
);
|
||||
|
||||
await click("#reply-control .discard-button");
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
await selectKit(".composer-actions").expand();
|
||||
assert.true(
|
||||
selectKit(".composer-actions")
|
||||
.rowByValue("reply_to_topic")
|
||||
.exists(),
|
||||
"composer topic context is preserved when reopened"
|
||||
);
|
||||
|
||||
await selectKit(".composer-actions").selectRowByValue(
|
||||
"create_private_message"
|
||||
);
|
||||
assert.dom(".action-title").hasText(i18n("topic.private_message"));
|
||||
assert
|
||||
.dom(".save-or-cancel button")
|
||||
.hasText(i18n("composer.create_pm"));
|
||||
|
||||
await selectKit(".composer-actions").expand();
|
||||
await selectKit(".composer-actions").selectRowByValue(
|
||||
"create_topic"
|
||||
);
|
||||
assert.dom(".action-title").hasText(i18n("topic.create_long"));
|
||||
assert
|
||||
.dom(".save-or-cancel button")
|
||||
.hasText(i18n("composer.create_topic"));
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
test("Composer can toggle between reply and createTopic", async function (assert) {
|
||||
await visit("/t/this-is-a-test-topic/54081");
|
||||
await click(".topic-post[data-post-number='1'] button.reply");
|
||||
|
||||
@@ -240,7 +240,11 @@ export default class ComposerActions extends DropdownSelectBoxComponent {
|
||||
});
|
||||
}
|
||||
|
||||
if (items.length === 0 && this.currentUser.can_create_topic) {
|
||||
if (
|
||||
this.currentUser.can_create_topic &&
|
||||
this.action !== CREATE_TOPIC &&
|
||||
(items.length === 0 || this.action === PRIVATE_MESSAGE)
|
||||
) {
|
||||
items.push({
|
||||
name: i18n("composer.composer_actions.create_topic.label"),
|
||||
description: i18n("composer.composer_actions.create_topic.desc"),
|
||||
|
||||
@@ -30,7 +30,7 @@ describe "Private Message", type: :system do
|
||||
expect(composer).to be_opened
|
||||
|
||||
composer.open_composer_actions
|
||||
composer.select_action("New message")
|
||||
composer.select_action(I18n.t("js.composer.composer_actions.create_personal_message.label"))
|
||||
|
||||
expect(composer.button_label).to have_text(I18n.t("js.composer.create_pm"))
|
||||
end
|
||||
@@ -42,7 +42,24 @@ describe "Private Message", type: :system do
|
||||
expect(composer).to be_opened
|
||||
|
||||
composer.open_composer_actions
|
||||
expect(composer).to have_no_action("New message")
|
||||
expect(composer).to have_no_action(
|
||||
I18n.t("js.composer.composer_actions.create_personal_message.label"),
|
||||
)
|
||||
end
|
||||
|
||||
it "can switch between topic and personal message modes" do
|
||||
visit "/new-topic"
|
||||
expect(composer).to be_opened
|
||||
|
||||
# Switch to personal message
|
||||
composer.open_composer_actions
|
||||
composer.select_action(I18n.t("js.composer.composer_actions.create_personal_message.label"))
|
||||
expect(composer.button_label).to have_text(I18n.t("js.composer.create_pm"))
|
||||
|
||||
# Switch back to topic
|
||||
composer.open_composer_actions
|
||||
composer.select_action(I18n.t("js.composer.composer_actions.create_topic.label"))
|
||||
expect(composer.button_label).to have_text(I18n.t("js.composer.create_topic"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user