|
| 1 | +/* |
| 2 | +Copyright 2015 OpenMarket Ltd |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +'use strict'; |
| 18 | + |
| 19 | +var React = require('react'); |
| 20 | + |
| 21 | +var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); |
| 22 | +var dis = require('matrix-react-sdk/lib/dispatcher'); |
| 23 | + |
| 24 | +module.exports = React.createClass({ |
| 25 | + displayName: 'MessageContextMenu', |
| 26 | + |
| 27 | + onResendClick: function() { |
| 28 | + MatrixClientPeg.get().resendEvent( |
| 29 | + this.props.mxEvent, MatrixClientPeg.get().getRoom( |
| 30 | + this.props.mxEvent.getRoomId() |
| 31 | + ) |
| 32 | + ).done(function() { |
| 33 | + dis.dispatch({ |
| 34 | + action: 'message_sent' |
| 35 | + }); |
| 36 | + }, function() { |
| 37 | + dis.dispatch({ |
| 38 | + action: 'message_send_failed' |
| 39 | + }); |
| 40 | + }); |
| 41 | + dis.dispatch({action: 'message_resend_started'}); |
| 42 | + if (this.props.onFinished) this.props.onFinished(); |
| 43 | + }, |
| 44 | + |
| 45 | + onViewSourceClick: function() { |
| 46 | + }, |
| 47 | + |
| 48 | + render: function() { |
| 49 | + var resendButton; |
| 50 | + var viewSourceButton; |
| 51 | + |
| 52 | + if (this.props.mxEvent.status == 'not_sent') { |
| 53 | + resendButton = ( |
| 54 | + <div className="mx_ContextualMenu_field" onClick={this.onResendClick}> |
| 55 | + Resend |
| 56 | + </div> |
| 57 | + ); |
| 58 | + } |
| 59 | + viewSourceButton = ( |
| 60 | + <div className="mx_ContextualMenu_field" onClick={this.onViewSourceClick}> |
| 61 | + View Source |
| 62 | + </div> |
| 63 | + ); |
| 64 | + |
| 65 | + return ( |
| 66 | + <div> |
| 67 | + {resendButton} |
| 68 | + {viewSourceButton} |
| 69 | + </div> |
| 70 | + ); |
| 71 | + } |
| 72 | +}); |
0 commit comments