|
| 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 CreateRoomController = require("../../../../src/controllers/organisms/CreateRoom"); |
| 22 | + |
| 23 | +var ComponentBroker = require('../../../../src/ComponentBroker'); |
| 24 | + |
| 25 | +var CreateRoomButton = ComponentBroker.get("atoms/create_room/CreateRoomButton"); |
| 26 | +var RoomNameTextbox = ComponentBroker.get("atoms/create_room/RoomNameTextbox"); |
| 27 | +var Presets = ComponentBroker.get("atoms/create_room/Presets"); |
| 28 | +var UserSelector = ComponentBroker.get("molecules/UserSelector"); |
| 29 | + |
| 30 | + |
| 31 | +module.exports = React.createClass({ |
| 32 | + displayName: 'CreateRoom', |
| 33 | + mixins: [CreateRoomController], |
| 34 | + |
| 35 | + getPreset: function() { |
| 36 | + return this.refs.presets.getPreset(); |
| 37 | + }, |
| 38 | + |
| 39 | + getName: function() { |
| 40 | + return this.refs.name_textbox.getName(); |
| 41 | + }, |
| 42 | + |
| 43 | + getInvitedUsers: function() { |
| 44 | + return this.refs.user_selector.getUserIds(); |
| 45 | + }, |
| 46 | + |
| 47 | + render: function() { |
| 48 | + var curr_phase = this.state.phase; |
| 49 | + if (curr_phase == this.phases.CREATING) { |
| 50 | + return ( |
| 51 | + <div>Creating...</div> |
| 52 | + ); |
| 53 | + } else { |
| 54 | + var error_box = ""; |
| 55 | + if (curr_phase == this.phases.ERROR) { |
| 56 | + error_box = ( |
| 57 | + <div className="mx_Error"> |
| 58 | + An error occured: {this.state.error_string} |
| 59 | + </div> |
| 60 | + ); |
| 61 | + } |
| 62 | + return ( |
| 63 | + <div className="mx_CreateRoom"> |
| 64 | + <label>Room Name <RoomNameTextbox ref="name_textbox" /></label> |
| 65 | + <Presets ref="presets"/> |
| 66 | + <UserSelector ref="user_selector"/> |
| 67 | + <CreateRoomButton onCreateRoom={this.onCreateRoom} /> |
| 68 | + {error_box} |
| 69 | + </div> |
| 70 | + ); |
| 71 | + } |
| 72 | + } |
| 73 | +}); |
0 commit comments