From b007edca6350aa24e4bf1d3c3190d95a30998e1b Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 27 Nov 2015 10:42:25 +0000 Subject: [PATCH] Merge and move RoomHeader/RoomSettings into React SDK --- src/skins/vector/skindex.js | 4 +- .../vector/views/molecules/RoomHeader.js | 181 -------------- .../vector/views/molecules/RoomSettings.js | 232 ------------------ .../vector/views/organisms/CreateRoom.js | 2 +- .../vector/views/organisms/RoomDirectory.js | 2 +- src/skins/vector/views/organisms/RoomView.js | 4 +- 6 files changed, 6 insertions(+), 419 deletions(-) delete mode 100644 src/skins/vector/views/molecules/RoomHeader.js delete mode 100644 src/skins/vector/views/molecules/RoomSettings.js diff --git a/src/skins/vector/skindex.js b/src/skins/vector/skindex.js index ad990a66f..89b421312 100644 --- a/src/skins/vector/skindex.js +++ b/src/skins/vector/skindex.js @@ -40,6 +40,8 @@ skin['elements.ProgressBar'] = require('matrix-react-sdk/lib/components/views/el skin['elements.UserSelector'] = require('matrix-react-sdk/lib/components/views/elements/UserSelector'); skin['messages.MessageComposer'] = require('matrix-react-sdk/lib/components/views/messages/MessageComposer'); skin['rooms.MemberInfo'] = require('matrix-react-sdk/lib/components/views/rooms/MemberInfo'); +skin['rooms.RoomHeader'] = require('matrix-react-sdk/lib/components/views/rooms/RoomHeader'); +skin['rooms.RoomSettings'] = require('matrix-react-sdk/lib/components/views/rooms/RoomSettings'); skin['create_room.CreateRoomButton'] = require('matrix-react-sdk/lib/components/views/create_room/CreateRoomButton'); skin['create_room.Presets'] = require('matrix-react-sdk/lib/components/views/create_room/Presets'); skin['create_room.RoomAlias'] = require('matrix-react-sdk/lib/components/views/create_room/RoomAlias'); @@ -67,8 +69,6 @@ skin['molecules.MessageContextMenu'] = require('./views/molecules/MessageContext skin['molecules.MessageTile'] = require('./views/molecules/MessageTile'); skin['molecules.RoomCreate'] = require('./views/molecules/RoomCreate'); skin['molecules.RoomDropTarget'] = require('./views/molecules/RoomDropTarget'); -skin['molecules.RoomHeader'] = require('./views/molecules/RoomHeader'); -skin['molecules.RoomSettings'] = require('./views/molecules/RoomSettings'); skin['molecules.RoomTile'] = require('./views/molecules/RoomTile'); skin['molecules.RoomTooltip'] = require('./views/molecules/RoomTooltip'); skin['molecules.SearchBar'] = require('./views/molecules/SearchBar'); diff --git a/src/skins/vector/views/molecules/RoomHeader.js b/src/skins/vector/views/molecules/RoomHeader.js deleted file mode 100644 index 802881729..000000000 --- a/src/skins/vector/views/molecules/RoomHeader.js +++ /dev/null @@ -1,181 +0,0 @@ -/* -Copyright 2015 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. -*/ - -'use strict'; - -var React = require('react'); -var sdk = require('matrix-react-sdk') -var dis = require('matrix-react-sdk/lib/dispatcher') - -var CallHandler = require('matrix-react-sdk/lib/CallHandler'); -var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); -var RoomHeaderController = require('matrix-react-sdk/lib/controllers/molecules/RoomHeader') - -module.exports = React.createClass({ - displayName: 'RoomHeader', - mixins: [RoomHeaderController], - - onNameChange: function(new_name) { - if (this.props.room.name != new_name && new_name) { - MatrixClientPeg.get().setRoomName(this.props.room.roomId, new_name); - } - }, - - getRoomName: function() { - return this.refs.name_edit.value; - }, - - onFullscreenClick: function() { - dis.dispatch({action: 'video_fullscreen', fullscreen: true}, true); - }, - - render: function() { - var EditableText = sdk.getComponent("elements.EditableText"); - var RoomAvatar = sdk.getComponent('avatars.RoomAvatar'); - - var header; - if (this.props.simpleHeader) { - header = -
-
- { this.props.simpleHeader } -
-
- } - else { - var topic = this.props.room.currentState.getStateEvents('m.room.topic', ''); - - var call_buttons; - if (this.state && this.state.call_state != 'ended') { - //var muteVideoButton; - var activeCall = ( - CallHandler.getCallForRoom(this.props.room.roomId) - ); -/* - if (activeCall && activeCall.type === "video") { - muteVideoButton = ( -
- { - (activeCall.isLocalVideoMuted() ? - "Unmute" : "Mute") + " video" - } -
- ); - } - {muteVideoButton} -
- { - (activeCall && activeCall.isMicrophoneMuted() ? - "Unmute" : "Mute") + " audio" - } -
-*/ - - call_buttons = ( -
- End call -
- ); - } - - var name = null; - var topic_el = null; - var cancel_button = null; - var save_button = null; - var settings_button = null; - var actual_name = this.props.room.currentState.getStateEvents('m.room.name', ''); - if (actual_name) actual_name = actual_name.getContent().name; - if (this.props.editing) { - name = -
- -
- // if (topic) topic_el =
- cancel_button =
Cancel
- save_button =
Save Changes
- } else { - // - name = -
-
{ this.props.room.name }
-
- -
-
- if (topic) topic_el =
{ topic.getContent().topic }
; - } - - var roomAvatar = null; - if (this.props.room) { - roomAvatar = ( - - ); - } - - var zoom_button, video_button, voice_button; - if (activeCall) { - if (activeCall.type == "video") { - zoom_button = ( -
- Fullscreen -
- ); - } - video_button = -
- Video call -
; - voice_button = -
- VoIP call -
; - } - - header = -
-
-
- { roomAvatar } -
-
- { name } - { topic_el } -
-
- {call_buttons} - {cancel_button} - {save_button} -
- { video_button } - { voice_button } - { zoom_button } -
- Search -
-
-
- } - - return ( -
- { header } -
- ); - }, -}); diff --git a/src/skins/vector/views/molecules/RoomSettings.js b/src/skins/vector/views/molecules/RoomSettings.js deleted file mode 100644 index 11d80aeee..000000000 --- a/src/skins/vector/views/molecules/RoomSettings.js +++ /dev/null @@ -1,232 +0,0 @@ -/* -Copyright 2015 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. -*/ - -'use strict'; - -var React = require('react'); -var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); -var sdk = require('matrix-react-sdk'); - -var RoomSettingsController = require('matrix-react-sdk/lib/controllers/molecules/RoomSettings') - -module.exports = React.createClass({ - displayName: 'RoomSettings', - mixins: [RoomSettingsController], - - getTopic: function() { - return this.refs.topic.value; - }, - - getJoinRules: function() { - return this.refs.is_private.checked ? "invite" : "public"; - }, - - getHistoryVisibility: function() { - return this.refs.share_history.checked ? "shared" : "invited"; - }, - - getPowerLevels: function() { - if (!this.state.power_levels_changed) return undefined; - - var power_levels = this.props.room.currentState.getStateEvents('m.room.power_levels', ''); - power_levels = power_levels.getContent(); - - var new_power_levels = { - ban: parseInt(this.refs.ban.value), - kick: parseInt(this.refs.kick.value), - redact: parseInt(this.refs.redact.value), - invite: parseInt(this.refs.invite.value), - events_default: parseInt(this.refs.events_default.value), - state_default: parseInt(this.refs.state_default.value), - users_default: parseInt(this.refs.users_default.value), - users: power_levels.users, - events: power_levels.events, - }; - - return new_power_levels; - }, - - onPowerLevelsChanged: function() { - this.setState({ - power_levels_changed: true - }); - }, - - render: function() { - var ChangeAvatar = sdk.getComponent('settings.ChangeAvatar'); - - var topic = this.props.room.currentState.getStateEvents('m.room.topic', ''); - if (topic) topic = topic.getContent().topic; - - var join_rule = this.props.room.currentState.getStateEvents('m.room.join_rules', ''); - if (join_rule) join_rule = join_rule.getContent().join_rule; - - var history_visibility = this.props.room.currentState.getStateEvents('m.room.history_visibility', ''); - if (history_visibility) history_visibility = history_visibility.getContent().history_visibility; - - var power_levels = this.props.room.currentState.getStateEvents('m.room.power_levels', ''); - - var events_levels = power_levels.events || {}; - - if (power_levels) { - power_levels = power_levels.getContent(); - - var ban_level = parseInt(power_levels.ban); - var kick_level = parseInt(power_levels.kick); - var redact_level = parseInt(power_levels.redact); - var invite_level = parseInt(power_levels.invite || 0); - var send_level = parseInt(power_levels.events_default || 0); - var state_level = parseInt(power_levels.state_default || 0); - var default_user_level = parseInt(power_levels.users_default || 0); - - if (power_levels.ban == undefined) ban_level = 50; - if (power_levels.kick == undefined) kick_level = 50; - if (power_levels.redact == undefined) redact_level = 50; - - var user_levels = power_levels.users || {}; - - var user_id = MatrixClientPeg.get().credentials.userId; - - var current_user_level = user_levels[user_id]; - if (current_user_level == undefined) current_user_level = default_user_level; - - var power_level_level = events_levels["m.room.power_levels"]; - if (power_level_level == undefined) { - power_level_level = state_level; - } - - var can_change_levels = current_user_level >= power_level_level; - } else { - var ban_level = 50; - var kick_level = 50; - var redact_level = 50; - var invite_level = 0; - var send_level = 0; - var state_level = 0; - var default_user_level = 0; - - var user_levels = []; - var events_levels = []; - - var current_user_level = 0; - - var power_level_level = 0; - - var can_change_levels = false; - } - - var room_avatar_level = parseInt(power_levels.state_default || 0); - if (events_levels['m.room.avatar'] !== undefined) { - room_avatar_level = events_levels['m.room.avatar']; - } - var can_set_room_avatar = current_user_level >= room_avatar_level; - - var change_avatar; - if (can_set_room_avatar) { - change_avatar =
-

Room Icon

- -
; - } - - var banned = this.props.room.getMembersWithMembership("ban"); - - return ( -
-