Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #250 from matrix-org/rav/disable_composer_if_no_pe…
Browse files Browse the repository at this point in the history
…rmission

Disable the message composer if we don't have permission to post
  • Loading branch information
richvdh committed Mar 29, 2016
2 parents a12c182 + cbf5b0e commit abedb05
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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",
Expand Down
60 changes: 45 additions & 15 deletions src/components/views/rooms/MessageComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ module.exports = React.createClass({
var TintableSvg = sdk.getComponent("elements.TintableSvg");
var MessageComposerInput = sdk.getComponent("rooms.MessageComposerInput");

var controls = [];

controls.push(
<div className="mx_MessageComposer_avatar">
<MemberAvatar member={me} width={24} height={24} />
</div>
);

var callButton, videoCallButton, hangupButton;
if (this.props.callState && this.props.callState !== 'ended') {
hangupButton =
Expand All @@ -109,25 +117,47 @@ module.exports = React.createClass({
</div>
}

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 = (
<div className="mx_MessageComposer_upload"
onClick={this.onUploadClick} title="Upload file">
<TintableSvg src="img/upload.svg" width="19" height="24"/>
<input ref="uploadInput" type="file"
style={uploadInputStyle}
onChange={this.onUploadFileSelected} />
</div>
);

controls.push(
<MessageComposerInput tabComplete={this.props.tabComplete}
onResize={this.props.onResize} room={this.props.room} />,
uploadButton,
hangupButton,
callButton,
videoCallButton,
);
} else {
controls.push(
<div className="mx_MessageComposer_noperm_error">
You do not have permission to post to this room
</div>
);
}

return (
<div className="mx_MessageComposer">
<div className="mx_MessageComposer_wrapper">
<div className="mx_MessageComposer_row">
<div className="mx_MessageComposer_avatar">
<MemberAvatar member={me} width={24} height={24} />
</div>
<MessageComposerInput tabComplete={this.props.tabComplete} onResize={this.props.onResize}
room={this.props.room} />
<div className="mx_MessageComposer_upload" onClick={this.onUploadClick} title="Upload file">
<TintableSvg src="img/upload.svg" width="19" height="24"/>
<input type="file" style={uploadInputStyle} ref="uploadInput" onChange={this.onUploadFileSelected} />
<div className="mx_MessageComposer">
<div className="mx_MessageComposer_wrapper">
<div className="mx_MessageComposer_row">
{controls}
</div>
{ hangupButton }
{ callButton }
{ videoCallButton }
</div>
</div>
</div>
);
}
});
Expand Down

0 comments on commit abedb05

Please sign in to comment.