From 8ec0ffea3a5dac008e491617577f5905625ffeca Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 26 Sep 2019 14:24:10 +0100
Subject: [PATCH] Make the message context menu more accessible
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/structures/TabbedView.js | 4 +-
.../views/context_menus/MessageContextMenu.js | 102 +++++++++++-------
.../views/messages/MessageActionBar.js | 4 +-
3 files changed, 69 insertions(+), 41 deletions(-)
diff --git a/src/components/structures/TabbedView.js b/src/components/structures/TabbedView.js
index cf603a75b3..0e76143f92 100644
--- a/src/components/structures/TabbedView.js
+++ b/src/components/structures/TabbedView.js
@@ -84,9 +84,9 @@ export class TabbedView extends React.Component {
const onClickHandler = () => this._setActiveTab(tab);
const onKeyDownHandler = (e) => {
- e.stopPropagation();
- e.preventDefault();
if (e.keyCode === KeyCode.ENTER || e.keyCode === KeyCode.SPACE) {
+ e.stopPropagation();
+ e.preventDefault();
this._setActiveTab(tab);
}
};
diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js
index 66005eb730..1d859da047 100644
--- a/src/components/views/context_menus/MessageContextMenu.js
+++ b/src/components/views/context_menus/MessageContextMenu.js
@@ -2,6 +2,7 @@
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2018 New Vector Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
+Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -30,11 +31,28 @@ import Resend from '../../../Resend';
import SettingsStore from '../../../settings/SettingsStore';
import { isUrlPermitted } from '../../../HtmlUtils';
import { isContentActionable } from '../../../utils/EventUtils';
+import {KeyCode} from "../../../Keyboard";
function canCancel(eventStatus) {
return eventStatus === EventStatus.QUEUED || eventStatus === EventStatus.NOT_SENT;
}
+const DropdownButton = ({children, onClick}) => {
+ const onKeyDown = (e) => {
+ if (e.keyCode === KeyCode.ENTER || e.keyCode === KeyCode.SPACE) {
+ e.stopPropagation();
+ e.preventDefault();
+ onClick();
+ }
+ };
+ return (
+
+ { children }
+
+ );
+};
+
+
module.exports = createReactClass({
displayName: 'MessageContextMenu',
@@ -319,89 +337,89 @@ module.exports = createReactClass({
if (!mxEvent.isRedacted()) {
if (eventStatus === EventStatus.NOT_SENT) {
resendButton = (
-
+
{ _t('Resend') }
-
+
);
}
if (editStatus === EventStatus.NOT_SENT) {
resendEditButton = (
-
+
{ _t('Resend edit') }
-
+
);
}
if (unsentReactionsCount !== 0) {
resendReactionsButton = (
-
+
{ _t('Resend %(unsentCount)s reaction(s)', {unsentCount: unsentReactionsCount}) }
-
+
);
}
}
if (redactStatus === EventStatus.NOT_SENT) {
resendRedactionButton = (
-
+
{ _t('Resend removal') }
-
+
);
}
if (isSent && this.state.canRedact) {
redactButton = (
-
+
{ _t('Remove') }
-
+
);
}
if (allowCancel) {
cancelButton = (
-
+
{ _t('Cancel Sending') }
-
+
);
}
if (isContentActionable(mxEvent)) {
forwardButton = (
-
+
{ _t('Forward Message') }
-
+
);
if (this.state.canPin) {
pinButton = (
-
+
{ this._isPinned() ? _t('Unpin Message') : _t('Pin Message') }
-
+
);
}
}
const viewSourceButton = (
-
+
{ _t('View Source') }
-
+
);
if (mxEvent.getType() !== mxEvent.getWireType()) {
viewClearSourceButton = (
-
+
{ _t('View Decrypted Source') }
-
+
);
}
if (this.props.eventTileOps) {
if (this.props.eventTileOps.isWidgetHidden()) {
unhidePreviewButton = (
-
+
{ _t('Unhide Preview') }
-
+
);
}
}
@@ -412,20 +430,19 @@ module.exports = createReactClass({
}
// XXX: if we use room ID, we should also include a server where the event can be found (other than in the domain of the event ID)
const permalinkButton = (
-
+
);
if (this.props.eventTileOps && this.props.eventTileOps.getInnerText) {
quoteButton = (
-
+
{ _t('Quote') }
-
+
);
}
@@ -435,34 +452,43 @@ module.exports = createReactClass({
isUrlPermitted(mxEvent.event.content.external_url)
) {
externalURLButton = (
-
+
+
+ { _t('Source URL') }
+
+
);
}
if (this.props.collapseReplyThread) {
collapseReplyThread = (
-
+
{ _t('Collapse Reply Thread') }
-
+
);
}
let e2eInfo;
if (this.props.e2eInfoCallback) {
- e2eInfo =
+ e2eInfo = (
+
{ _t('End-to-end encryption information') }
-
;
+
+ );
}
let reportEventButton;
if (mxEvent.getSender() !== me) {
reportEventButton = (
-
+
{ _t('Report Content') }
-
+
);
}
diff --git a/src/components/views/messages/MessageActionBar.js b/src/components/views/messages/MessageActionBar.js
index 8db268076c..1797065f11 100644
--- a/src/components/views/messages/MessageActionBar.js
+++ b/src/components/views/messages/MessageActionBar.js
@@ -166,9 +166,11 @@ export default class MessageActionBar extends React.PureComponent {
{reactButton}
{replyButton}
{editButton}
-
;
}