From cbf5b0eca378396b4311a6603a7be8353b66b684 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 24 Mar 2016 13:57:21 +0000 Subject: [PATCH] Disable the message composer if we don't have permission to post Rehashes dave's earlier PR which did the same thing --- package.json | 2 +- src/components/views/rooms/MessageComposer.js | 60 ++++++++++++++----- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index d2e9c32d746..457e5bd0fdb 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "highlight.js": "^8.9.1", "linkifyjs": "^2.0.0-beta.4", "marked": "^0.3.5", - "matrix-js-sdk": "^0.5.0", + "matrix-js-sdk": "matrix-org/matrix-js-sdk#develop", "optimist": "^0.6.1", "q": "^1.4.1", "react": "^0.14.2", diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index bd84fd85beb..947f27331c1 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -91,6 +91,14 @@ module.exports = React.createClass({ var TintableSvg = sdk.getComponent("elements.TintableSvg"); var MessageComposerInput = sdk.getComponent("rooms.MessageComposerInput"); + var controls = []; + + controls.push( +
+ +
+ ); + var callButton, videoCallButton, hangupButton; if (this.props.callState && this.props.callState !== 'ended') { hangupButton = @@ -109,25 +117,47 @@ module.exports = React.createClass({ } + var canSendMessages = this.props.room.currentState.maySendMessage( + MatrixClientPeg.get().credentials.userId); + + if (canSendMessages) { + // This also currently includes the call buttons. Really we should + // check separately for whether we can call, but this is slightly + // complex because of conference calls. + var uploadButton = ( +
+ + +
+ ); + + controls.push( + , + uploadButton, + hangupButton, + callButton, + videoCallButton, + ); + } else { + controls.push( +
+ You do not have permission to post to this room +
+ ); + } + return ( -
-
-
-
- -
- -
- - +
+
+
+ {controls}
- { hangupButton } - { callButton } - { videoCallButton }
-
); } });