Support for common rooms in MemberInfo

Renames RoomDNDView to DNDRoomTile which now provides a separate DNDRoomTile component rather than
clobberring RoomTile, so we can use a draggable one where we want a draggable one and a non-draggable
one where we don't want it to be draggable. RoomTile main is still polluted with DND stuff, but is
now optional.

Remove BottomLeftMenuTile because it was no longer used in the bottom left menu. Just include
the equivalent markup directly in the one place we now use it (in MemberTile in react-sdk).
pull/2147/head
David Baker 2016-09-09 16:15:45 +01:00
parent bf02a21c7d
commit 57804f4e02
7 changed files with 23 additions and 63 deletions

View File

@ -48,8 +48,7 @@ module.exports.components['views.login.VectorLoginFooter'] = require('./componen
module.exports.components['views.login.VectorLoginHeader'] = require('./components/views/login/VectorLoginHeader');
module.exports.components['views.messages.DateSeparator'] = require('./components/views/messages/DateSeparator');
module.exports.components['views.messages.MessageTimestamp'] = require('./components/views/messages/MessageTimestamp');
module.exports.components['views.rooms.BottomLeftMenuTile'] = require('./components/views/rooms/BottomLeftMenuTile');
module.exports.components['views.rooms.RoomDNDView'] = require('./components/views/rooms/RoomDNDView');
module.exports.components['views.rooms.DNDRoomTile'] = require('./components/views/rooms/DNDRoomTile');
module.exports.components['views.rooms.RoomDropTarget'] = require('./components/views/rooms/RoomDropTarget');
module.exports.components['views.rooms.RoomTooltip'] = require('./components/views/rooms/RoomTooltip');
module.exports.components['views.rooms.SearchBar'] = require('./components/views/rooms/SearchBar');

View File

@ -46,7 +46,6 @@ module.exports = React.createClass({
},
render: function() {
var BottomLeftMenuTile = sdk.getComponent('rooms.BottomLeftMenuTile');
var TintableSvg = sdk.getComponent('elements.TintableSvg');
return (
<div className="mx_BottomLeftMenu">

View File

@ -368,12 +368,12 @@ var RoomSubList = React.createClass({
makeRoomTiles: function() {
var self = this;
var RoomTile = sdk.getComponent("rooms.RoomTile");
var DNDRoomTile = sdk.getComponent("rooms.DNDRoomTile");
return this.state.sortedList.map(function(room) {
var selected = room.roomId == self.props.selectedRoom;
// XXX: is it evil to pass in self as a prop to RoomTile?
return (
<RoomTile
<DNDRoomTile
room={ room }
roomSubList={ self }
key={ room.roomId }

View File

@ -1,57 +0,0 @@
/*
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.
*/
'use strict';
var React = require('react');
var sdk = require('matrix-react-sdk')
module.exports = React.createClass({
displayName: 'BottomLeftMenuTile',
getInitialState: function() {
return( { hover : false });
},
onMouseEnter: function() {
this.setState( { hover : true });
},
onMouseLeave: function() {
this.setState( { hover : false });
},
render: function() {
var label;
if (!this.props.collapsed) {
label = <div className="mx_RoomTile_name">{ this.props.label }</div>;
}
else if (this.state.hover) {
var RoomTooltip = sdk.getComponent("rooms.RoomTooltip");
label = <RoomTooltip bottom={ true } label={ this.props.label }/>;
}
return (
<div className="mx_RoomTile" onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave} onClick={this.props.onClick}>
<div className="mx_RoomTile_avatar">
<img src={ this.props.img } width="26" height="26"/>
</div>
{ label }
</div>
);
}
});

View File

@ -25,6 +25,13 @@ var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
var sdk = require('matrix-react-sdk');
var RoomTile = require('matrix-react-sdk/lib/components/views/rooms/RoomTile');
/**
* Defines a new Component, DNDRoomTile that wraps RoomTile, making it draggable.
* Requires extra props:
* roomSubList: React.PropTypes.object.isRequired,
* refreshSubList: React.PropTypes.func.isRequired,
*/
/**
* Specifies the drag source contract.
* Only `beginDrag` function is required.
@ -202,4 +209,3 @@ DragSource('RoomTile', roomTileSource, function(connect, monitor) {
};
})(RoomTile));
module.exports.replaces = 'RoomTile';

View File

@ -73,3 +73,12 @@ limitations under the License.
margin-left: 8px;
line-height: 23px;
}
.mx_MemberInfo_createRoom {
cursor: pointer;
}
.mx_MemberInfo_createRoom_label {
width: 160px ! important;
}

View File

@ -28,6 +28,10 @@ limitations under the License.
height: 24px;
}
.mx_RightPanel .mx_RoomTile_nameContainer {
width: 170px;
}
.mx_RoomTile_avatar {
display: inline-block;
padding-top: 5px;