From e306a521fdcb799dae110a4c26905cb0f6ac9de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= <1108771+megothss@users.noreply.github.com> Date: Thu, 8 Jun 2023 11:37:50 -0300 Subject: [PATCH] DEV: Added chat api to remove secondary actions (#21982) In some cases, plugins may want to hide some of these actions at all times, overriding the rules for canX with hiding these buttons. To achieve this, a plugin can call the API `removeChatComposerSecondaryButtons` and pass the list of button IDs that should be removed as argument, like the example below: ``` withPluginApi("1.2.0", (api) => { api.removeChatComposerSecondaryActions("copyLink", "select"); }); ``` --------- Co-authored-by: Martin Brennan --- .../chat-message-actions-desktop.hbs | 18 ++++-- .../chat-message-actions-desktop.js | 6 +- .../chat-message-actions-mobile.hbs | 2 +- .../components/chat-message-actions-mobile.js | 10 ++-- .../discourse/lib/chat-message-interactor.js | 16 ++++- .../pre-initializers/chat-plugin-api.js | 25 ++++++++ .../common/chat-message-actions.scss | 9 +++ .../unit/utility/plugin-api-test.js | 59 ++++++++++++++++++- 8 files changed, 126 insertions(+), 19 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.hbs index 99be83b02d1..4ad120c431f 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.hbs @@ -10,7 +10,15 @@ }} data-id={{this.message.id}} > -
+
{{#if this.shouldRenderFavoriteReactions}} {{#each this.messageInteractor.emojiReactions @@ -57,14 +65,14 @@ {{#if (and this.messageInteractor.message - this.messageInteractor.secondaryButtons.length + this.messageInteractor.secondaryActions.length ) }} {{/if}}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.js b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.js index 7461fbbdf5f..45454acbe13 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.js @@ -31,12 +31,10 @@ export default class ChatMessageActionsDesktop extends Component { } get messageInteractor() { - const activeMessage = this.chat.activeMessage; - return new ChatMessageInteractor( getOwner(this), - activeMessage.model, - activeMessage.context + this.message, + this.context ); } diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.hbs index 8b15d1e73f3..d61d03ef8fe 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.hbs @@ -31,7 +31,7 @@