Merge pull request #470 from matrix-org/matthew/right-panel-collapse

Matthew/right panel collapse
This commit is contained in:
Matthew Hodgson 2016-09-13 19:09:18 +01:00 committed by GitHub
commit 17cf2fc745
6 changed files with 79 additions and 30 deletions

View file

@ -31,6 +31,7 @@ module.exports = React.createClass({
propTypes: { propTypes: {
onRoomCreated: React.PropTypes.func, onRoomCreated: React.PropTypes.func,
collapsedRhs: React.PropTypes.bool,
}, },
phases: { phases: {
@ -245,7 +246,7 @@ module.exports = React.createClass({
return ( return (
<div className="mx_CreateRoom"> <div className="mx_CreateRoom">
<SimpleRoomHeader title="CreateRoom" /> <SimpleRoomHeader title="CreateRoom" collapsedRhs={ this.props.collapsedRhs }/>
<div className="mx_CreateRoom_body"> <div className="mx_CreateRoom_body">
<input type="text" ref="room_name" value={this.state.room_name} onChange={this.onNameChange} placeholder="Name"/> <br /> <input type="text" ref="room_name" value={this.state.room_name} onChange={this.onNameChange} placeholder="Name"/> <br />
<textarea className="mx_CreateRoom_description" ref="topic" value={this.state.topic} onChange={this.onTopicChange} placeholder="Topic"/> <br /> <textarea className="mx_CreateRoom_description" ref="topic" value={this.state.topic} onChange={this.onTopicChange} placeholder="Topic"/> <br />

View file

@ -1008,8 +1008,7 @@ module.exports = React.createClass({
switch (this.state.page_type) { switch (this.state.page_type) {
case this.PageTypes.RoomView: case this.PageTypes.RoomView:
page_element = ( page_element = <RoomView
<RoomView
ref="roomView" ref="roomView"
roomAddress={this.state.currentRoomAlias || this.state.currentRoomId} roomAddress={this.state.currentRoomAlias || this.state.currentRoomId}
autoJoin={this.state.autoJoin} autoJoin={this.state.autoJoin}
@ -1021,30 +1020,37 @@ module.exports = React.createClass({
eventPixelOffset={this.state.initialEventPixelOffset} eventPixelOffset={this.state.initialEventPixelOffset}
key={this.state.currentRoomAlias || this.state.currentRoomId} key={this.state.currentRoomAlias || this.state.currentRoomId}
opacity={this.state.middleOpacity} opacity={this.state.middleOpacity}
ConferenceHandler={this.props.ConferenceHandler} /> collapsedRhs={ this.state.collapse_rhs }
); ConferenceHandler={this.props.ConferenceHandler}
right_panel = <RightPanel roomId={this.state.currentRoomId} collapsed={this.state.collapse_rhs} opacity={this.state.sideOpacity} /> />
if (!this.state.collapse_rhs) right_panel = <RightPanel roomId={this.state.currentRoomId} opacity={this.state.sideOpacity} />
break; break;
case this.PageTypes.UserSettings: case this.PageTypes.UserSettings:
page_element = <UserSettings page_element = <UserSettings
onClose={this.onUserSettingsClose} onClose={this.onUserSettingsClose}
version={this.state.version} version={this.state.version}
brand={this.props.config.brand} brand={this.props.config.brand}
collapsedRhs={ this.state.collapse_rhs }
enableLabs={this.props.config.enableLabs} enableLabs={this.props.config.enableLabs}
/> />
right_panel = <RightPanel collapsed={this.state.collapse_rhs} opacity={this.state.sideOpacity}/> if (!this.state.collapse_rhs) right_panel = <RightPanel opacity={this.state.sideOpacity}/>
break; break;
case this.PageTypes.CreateRoom: case this.PageTypes.CreateRoom:
page_element = <CreateRoom onRoomCreated={this.onRoomCreated}/> page_element = <CreateRoom
right_panel = <RightPanel collapsed={this.state.collapse_rhs} opacity={this.state.sideOpacity}/> onRoomCreated={this.onRoomCreated}
collapsedRhs={ this.state.collapse_rhs }
/>
if (!this.state.collapse_rhs) right_panel = <RightPanel opacity={this.state.sideOpacity}/>
break; break;
case this.PageTypes.RoomDirectory: case this.PageTypes.RoomDirectory:
page_element = <RoomDirectory /> page_element = <RoomDirectory
right_panel = <RightPanel collapsed={this.state.collapse_rhs} opacity={this.state.sideOpacity}/> collapsedRhs={ this.state.collapse_rhs }
/>
if (!this.state.collapse_rhs) right_panel = <RightPanel opacity={this.state.sideOpacity}/>
break; break;
case this.PageTypes.UserView: case this.PageTypes.UserView:
page_element = null; // deliberately null for now page_element = null; // deliberately null for now
right_panel = <RightPanel userId={this.state.viewUserId} collapsed={false} opacity={this.state.sideOpacity} /> right_panel = <RightPanel userId={this.state.viewUserId} opacity={this.state.sideOpacity} />
break; break;
} }

View file

@ -97,7 +97,7 @@ module.exports = React.createClass({
highlightedEventId: React.PropTypes.string, highlightedEventId: React.PropTypes.string,
// is the RightPanel collapsed? // is the RightPanel collapsed?
rightPanelCollapsed: React.PropTypes.bool, collapsedRhs: React.PropTypes.bool,
}, },
getInitialState: function() { getInitialState: function() {
@ -1374,7 +1374,7 @@ module.exports = React.createClass({
<RoomHeader ref="header" <RoomHeader ref="header"
room={this.state.room} room={this.state.room}
oobData={this.props.oobData} oobData={this.props.oobData}
rightPanelCollapsed={ this.props.rightPanelCollapsed } collapsedRhs={ this.props.collapsedRhs }
/> />
<div className="mx_RoomView_auxPanel"> <div className="mx_RoomView_auxPanel">
<RoomPreviewBar onJoinClick={ this.onJoinButtonClicked } <RoomPreviewBar onJoinClick={ this.onJoinButtonClicked }
@ -1413,7 +1413,11 @@ module.exports = React.createClass({
// We have a regular invite for this room. // We have a regular invite for this room.
return ( return (
<div className="mx_RoomView"> <div className="mx_RoomView">
<RoomHeader ref="header" room={this.state.room}/> <RoomHeader
ref="header"
room={this.state.room}
collapsedRhs={ this.props.collapsedRhs }
/>
<div className="mx_RoomView_auxPanel"> <div className="mx_RoomView_auxPanel">
<RoomPreviewBar onJoinClick={ this.onJoinButtonClicked } <RoomPreviewBar onJoinClick={ this.onJoinButtonClicked }
onRejectClick={ this.onRejectButtonClicked } onRejectClick={ this.onRejectButtonClicked }
@ -1622,6 +1626,7 @@ module.exports = React.createClass({
oobData={this.props.oobData} oobData={this.props.oobData}
editing={this.state.editingRoomSettings} editing={this.state.editingRoomSettings}
saving={this.state.uploadingRoomSettings} saving={this.state.uploadingRoomSettings}
collapsedRhs={ this.props.collapsedRhs }
onSearchClick={this.onSearchClick} onSearchClick={this.onSearchClick}
onSettingsClick={this.onSettingsClick} onSettingsClick={this.onSettingsClick}
onSaveClick={this.onSettingsSaveClick} onSaveClick={this.onSettingsSaveClick}

View file

@ -57,6 +57,9 @@ module.exports = React.createClass({
// True to show the 'labs' section of experimental features // True to show the 'labs' section of experimental features
enableLabs: React.PropTypes.bool, enableLabs: React.PropTypes.bool,
// true if RightPanel is collapsed
collapsedRhs: React.PropTypes.bool,
}, },
getDefaultProps: function() { getDefaultProps: function() {
@ -506,7 +509,11 @@ module.exports = React.createClass({
return ( return (
<div className="mx_UserSettings"> <div className="mx_UserSettings">
<SimpleRoomHeader title="Settings" onCancelClick={ this.props.onClose }/> <SimpleRoomHeader
title="Settings"
collapsedRhs={ this.props.collapsedRhs }
onCancelClick={ this.props.onClose }
/>
<GeminiScrollbar className="mx_UserSettings_body" <GeminiScrollbar className="mx_UserSettings_body"
autoshow={true}> autoshow={true}>

View file

@ -20,6 +20,7 @@ var React = require('react');
var sdk = require('../../../index'); var sdk = require('../../../index');
var MatrixClientPeg = require('../../../MatrixClientPeg'); var MatrixClientPeg = require('../../../MatrixClientPeg');
var Modal = require("../../../Modal"); var Modal = require("../../../Modal");
var dis = require("../../../dispatcher");
var linkify = require('linkifyjs'); var linkify = require('linkifyjs');
var linkifyElement = require('linkifyjs/element'); var linkifyElement = require('linkifyjs/element');
@ -35,7 +36,7 @@ module.exports = React.createClass({
oobData: React.PropTypes.object, oobData: React.PropTypes.object,
editing: React.PropTypes.bool, editing: React.PropTypes.bool,
saving: React.PropTypes.bool, saving: React.PropTypes.bool,
rightPanelCollapsed: React.PropTypes.bool, collapsedRhs: React.PropTypes.bool,
onSettingsClick: React.PropTypes.func, onSettingsClick: React.PropTypes.func,
onSaveClick: React.PropTypes.func, onSaveClick: React.PropTypes.func,
onSearchClick: React.PropTypes.func, onSearchClick: React.PropTypes.func,
@ -114,6 +115,10 @@ module.exports = React.createClass({
}).done(); }).done();
}, },
onShowRhsClick: function(ev) {
dis.dispatch({ action: 'show_right_panel' });
},
/** /**
* After editing the settings, get the new name for the room * After editing the settings, get the new name for the room
* *
@ -287,8 +292,11 @@ module.exports = React.createClass({
} }
var rightPanel_buttons; var rightPanel_buttons;
if (this.props.rightPanelCollapsed) { if (this.props.collapsedRhs) {
// TODO: embed the RightPanel header in here if it's collapsed. rightPanel_buttons =
<div className="mx_RoomHeader_button" onClick={this.onShowRhsClick} title=">">
<TintableSvg src="img/minimise.svg" width="10" height="16"/>
</div>
} }
var right_row; var right_row;

View file

@ -17,6 +17,8 @@ limitations under the License.
'use strict'; 'use strict';
var React = require('react'); var React = require('react');
var sdk = require('../../../index');
var dis = require("../../../dispatcher");
/* /*
* A stripped-down room header used for things like the user settings * A stripped-down room header used for things like the user settings
@ -28,19 +30,39 @@ module.exports = React.createClass({
propTypes: { propTypes: {
title: React.PropTypes.string, title: React.PropTypes.string,
onCancelClick: React.PropTypes.func, onCancelClick: React.PropTypes.func,
// is the RightPanel collapsed?
collapsedRhs: React.PropTypes.bool,
},
onShowRhsClick: function(ev) {
dis.dispatch({ action: 'show_right_panel' });
}, },
render: function() { render: function() {
var TintableSvg = sdk.getComponent("elements.TintableSvg");
var cancelButton; var cancelButton;
if (this.props.onCancelClick) { if (this.props.onCancelClick) {
cancelButton = <div className="mx_RoomHeader_cancelButton" onClick={this.props.onCancelClick}><img src="img/cancel.svg" width="18" height="18" alt="Cancel"/> </div> cancelButton = <div className="mx_RoomHeader_cancelButton" onClick={this.props.onCancelClick}><img src="img/cancel.svg" width="18" height="18" alt="Cancel"/> </div>
} }
var showRhsButton;
/* // don't bother cluttering things up with this for now.
if (this.props.collapsedRhs) {
showRhsButton =
<div className="mx_RoomHeader_button" style={{ float: 'right' }} onClick={this.onShowRhsClick} title=">">
<TintableSvg src="img/minimise.svg" width="10" height="16"/>
</div>
}
*/
return ( return (
<div className="mx_RoomHeader" > <div className="mx_RoomHeader" >
<div className="mx_RoomHeader_wrapper"> <div className="mx_RoomHeader_wrapper">
<div className="mx_RoomHeader_simpleHeader"> <div className="mx_RoomHeader_simpleHeader">
{ this.props.title } { this.props.title }
{ showRhsButton }
{ cancelButton } { cancelButton }
</div> </div>
</div> </div>