/* Copyright 2015, 2016 OpenMarket Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ var React = require('react'); var CallHandler = require('../../../CallHandler'); var MatrixClientPeg = require('../../../MatrixClientPeg'); var Modal = require('../../../Modal'); var sdk = require('../../../index'); var dis = require('../../../dispatcher'); import Autocomplete from './Autocomplete'; import UserSettingsStore from '../../../UserSettingsStore'; export default class MessageComposer extends React.Component { constructor(props, context) { super(props, context); this.onCallClick = this.onCallClick.bind(this); this.onHangupClick = this.onHangupClick.bind(this); this.onUploadClick = this.onUploadClick.bind(this); this.onUploadFileSelected = this.onUploadFileSelected.bind(this); this.onVoiceCallClick = this.onVoiceCallClick.bind(this); this.onInputContentChanged = this.onInputContentChanged.bind(this); this.onUpArrow = this.onUpArrow.bind(this); this.onDownArrow = this.onDownArrow.bind(this); this.onTab = this.onTab.bind(this); this.state = { autocompleteQuery: '', selection: null }; } onUploadClick(ev) { if (MatrixClientPeg.get().isGuest()) { var NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog"); Modal.createDialog(NeedToRegisterDialog, { title: "Please Register", description: "Guest users can't upload files. Please register to upload." }); return; } this.refs.uploadInput.click(); } onUploadFileSelected(ev) { var files = ev.target.files; var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); var TintableSvg = sdk.getComponent("elements.TintableSvg"); var fileList = []; for(var i=0; i {files[i].name} ); } Modal.createDialog(QuestionDialog, { title: "Upload Files", description: (

Are you sure you want upload the following files?

    {fileList}
), onFinished: (shouldUpload) => { if(shouldUpload) { // MessageComposer shouldn't have to rely on its parent passing in a callback to upload a file if (files) { for(var i=0; i ); var callButton, videoCallButton, hangupButton; if (this.props.callState && this.props.callState !== 'ended') { hangupButton =
Hangup
; } else { callButton =
videoCallButton =
} 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}
); } }; MessageComposer.propTypes = { tabComplete: React.PropTypes.any, // a callback which is called when the height of the composer is // changed due to a change in content. onResize: React.PropTypes.func, // js-sdk Room object room: React.PropTypes.object.isRequired, // string representing the current voip call state callState: React.PropTypes.string, // callback when a file to upload is chosen uploadFile: React.PropTypes.func.isRequired, // opacity for dynamic UI fading effects opacity: React.PropTypes.number };