diff --git a/app/assets/javascripts/discourse/app/components/sidebar/messages-section.js b/app/assets/javascripts/discourse/app/components/sidebar/messages-section.js new file mode 100644 index 00000000000..a71dc9dd4b9 --- /dev/null +++ b/app/assets/javascripts/discourse/app/components/sidebar/messages-section.js @@ -0,0 +1,17 @@ +import { action } from "@ember/object"; + +import GlimmerComponent from "discourse/components/glimmer"; +import Composer from "discourse/models/composer"; +import { getOwner } from "discourse-common/lib/get-owner"; + +export default class SidebarMessagesSection extends GlimmerComponent { + @action + composePersonalMessage() { + const composerArgs = { + action: Composer.PRIVATE_MESSAGE, + draftKey: Composer.NEW_TOPIC_KEY, + }; + + getOwner(this).lookup("controller:composer").open(composerArgs); + } +} diff --git a/app/assets/javascripts/discourse/app/templates/components/sidebar.hbs b/app/assets/javascripts/discourse/app/templates/components/sidebar.hbs index 9c69d3ae7c8..7469358ed58 100644 --- a/app/assets/javascripts/discourse/app/templates/components/sidebar.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/sidebar.hbs @@ -7,6 +7,8 @@ {{#if this.siteSettings.tagging_enabled}} {{/if}} + + {{/if}} diff --git a/app/assets/javascripts/discourse/app/templates/components/sidebar/messages-section.hbs b/app/assets/javascripts/discourse/app/templates/components/sidebar/messages-section.hbs new file mode 100644 index 00000000000..735f04344cc --- /dev/null +++ b/app/assets/javascripts/discourse/app/templates/components/sidebar/messages-section.hbs @@ -0,0 +1,10 @@ + + + diff --git a/app/assets/javascripts/discourse/app/templates/components/sidebar/section.hbs b/app/assets/javascripts/discourse/app/templates/components/sidebar/section.hbs index 3667ba75a0f..0a6a8afed04 100644 --- a/app/assets/javascripts/discourse/app/templates/components/sidebar/section.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/sidebar/section.hbs @@ -4,7 +4,13 @@ {{d-icon this.headerCaretIcon}} - + + {{@headerLinkText}} diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-messages-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-messages-section-test.js new file mode 100644 index 00000000000..c24f44e1ca9 --- /dev/null +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-messages-section-test.js @@ -0,0 +1,44 @@ +import { click, currentURL, visit } from "@ember/test-helpers"; + +import { + acceptance, + conditionalTest, + exists, +} from "discourse/tests/helpers/qunit-helpers"; +import { isLegacyEmber } from "discourse-common/config/environment"; + +acceptance("Sidebar - Messages Section", function (needs) { + needs.user({ + experimental_sidebar_enabled: true, + }); + + conditionalTest( + "clicking on section header button", + !isLegacyEmber(), + async function (assert) { + await visit("/"); + + await click(".sidebar-section-messages .sidebar-section-header-button"); + + assert.ok( + exists("#reply-control.private-message"), + "it opens the composer" + ); + } + ); + + conditionalTest( + "clicking on section header link", + !isLegacyEmber(), + async function (assert) { + await visit("/"); + await click(".sidebar-section-messages .sidebar-section-header-link"); + + assert.strictEqual( + currentURL(), + `/u/eviltrout/messages`, + "it should transistion to the user's messages" + ); + } + ); +}); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 3a58d4bb83a..4be6914c16d 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -4041,6 +4041,10 @@ en: unread_count: "%{count} unread" new_count: "%{count} new" sections: + messages: + header_link_title: "personal messages" + header_link_text: "Messages" + header_action_title: "create a personal message" tags: no_tracked_tags: "You are not tracking any tags." header_link_title: "all tags"