From 336217f668f81bd1513ea401be985f83e2c3b62c Mon Sep 17 00:00:00 2001 From: Germain Date: Wed, 19 Jan 2022 10:39:33 +0000 Subject: [PATCH] Add view in room to action bar in thread list (#7519) --- res/css/views/messages/_MessageActionBar.scss | 8 ++++ src/components/views/rooms/EventTile.tsx | 38 ++++++++++++++----- src/i18n/strings/en_EN.json | 6 +-- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/res/css/views/messages/_MessageActionBar.scss b/res/css/views/messages/_MessageActionBar.scss index e78b8cefe2..a9c6e3b39c 100644 --- a/res/css/views/messages/_MessageActionBar.scss +++ b/res/css/views/messages/_MessageActionBar.scss @@ -127,6 +127,14 @@ limitations under the License. mask-image: url('$(res)/img/element-icons/collapse-message.svg'); } +.mx_MessageActionBar_viewInRoom::after { + mask-image: url('$(res)/img/element-icons/view-in-room.svg'); +} + +.mx_MessageActionBar_copyLinkToThread::after { + mask-image: url('$(res)/img/element-icons/link.svg'); +} + .mx_MessageActionBar_downloadButton.mx_MessageActionBar_downloadSpinnerButton::after { background-color: transparent; // hide the download icon mask } diff --git a/src/components/views/rooms/EventTile.tsx b/src/components/views/rooms/EventTile.tsx index ff1aee9650..62c78ae48f 100644 --- a/src/components/views/rooms/EventTile.tsx +++ b/src/components/views/rooms/EventTile.tsx @@ -67,13 +67,13 @@ import { TimelineRenderingType } from "../../../contexts/RoomContext"; import { MediaEventHelper } from "../../../utils/MediaEventHelper"; import Toolbar from '../../../accessibility/Toolbar'; import { RovingAccessibleTooltipButton } from '../../../accessibility/roving/RovingAccessibleTooltipButton'; -import { RovingThreadListContextMenu } from '../context_menus/ThreadListContextMenu'; import { ThreadNotificationState } from '../../../stores/notifications/ThreadNotificationState'; import { RoomNotificationStateStore } from '../../../stores/notifications/RoomNotificationStateStore'; import { NotificationStateEvents } from '../../../stores/notifications/NotificationState'; import { NotificationColor } from '../../../stores/notifications/NotificationColor'; -import AccessibleButton from '../elements/AccessibleButton'; +import AccessibleButton, { ButtonEvent } from '../elements/AccessibleButton'; import { CardContext } from '../right_panel/BaseCard'; +import { copyPlaintext } from '../../../utils/strings'; const eventTileTypes = { [EventType.RoomMessage]: 'messages.MessageEvent', @@ -706,6 +706,23 @@ export default class EventTile extends React.Component { } } + private viewInRoom = (evt: ButtonEvent): void => { + evt.preventDefault(); + evt.stopPropagation(); + dis.dispatch({ + action: Action.ViewRoom, + event_id: this.props.mxEvent.getId(), + highlighted: true, + room_id: this.props.mxEvent.getRoomId(), + }); + }; + + private copyLinkToThread = async (evt: ButtonEvent): Promise => { + const { permalinkCreator, mxEvent } = this.props; + const matrixToUrl = permalinkCreator.forEvent(mxEvent.getId()); + await copyPlaintext(matrixToUrl); + }; + private onRoomReceipt = (ev: MatrixEvent, room: Room): void => { // ignore events for other rooms const tileRoom = this.context.getRoom(this.props.mxEvent.getRoomId()); @@ -1469,15 +1486,16 @@ export default class EventTile extends React.Component { showThread({ rootEvent: this.props.mxEvent, push: true })} - key="thread" + className="mx_MessageActionBar_maskButton mx_MessageActionBar_viewInRoom" + onClick={this.viewInRoom} + title={_t("View in room")} + key="view_in_room" /> - { msgOption } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index f81ef8c1a7..86f2e90efb 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1677,7 +1677,8 @@ "Key request sent.": "Key request sent.", "Re-request encryption keys from your other sessions.": "Re-request encryption keys from your other sessions.", "Message Actions": "Message Actions", - "Reply in thread": "Reply in thread", + "View in room": "View in room", + "Copy link to thread": "Copy link to thread", "This message cannot be decrypted": "This message cannot be decrypted", "Encrypted by an unverified session": "Encrypted by an unverified session", "Unencrypted": "Unencrypted", @@ -2094,6 +2095,7 @@ "Error processing audio message": "Error processing audio message", "React": "React", "Edit": "Edit", + "Reply in thread": "Reply in thread", "Reply": "Reply", "Collapse quotes │ ⇧+click": "Collapse quotes │ ⇧+click", "Expand quotes │ ⇧+click": "Expand quotes │ ⇧+click", @@ -2886,7 +2888,6 @@ "Source URL": "Source URL", "Collapse reply thread": "Collapse reply thread", "Report": "Report", - "View in room": "View in room", "Forget": "Forget", "Mentions only": "Mentions only", "See room timeline (devtools)": "See room timeline (devtools)", @@ -2897,7 +2898,6 @@ "Move down": "Move down", "View Community": "View Community", "Thread options": "Thread options", - "Copy link to thread": "Copy link to thread", "Unable to start audio streaming.": "Unable to start audio streaming.", "Failed to start livestream": "Failed to start livestream", "Start audio stream": "Start audio stream",