mirror of https://github.com/vector-im/riot-web
Merge pull request #2361 from matrix-org/bwindels/collapserhs
Redesign: allow to hide the right panel when clicking already active button & persistpull/21833/head
commit
0676c1b8ad
|
@ -1311,7 +1311,7 @@ export default React.createClass({
|
||||||
<div className="mx_GroupView_header_rightCol">
|
<div className="mx_GroupView_header_rightCol">
|
||||||
{ rightButtons }
|
{ rightButtons }
|
||||||
</div>
|
</div>
|
||||||
<GroupHeaderButtons />
|
<GroupHeaderButtons collapsedRhs={this.props.collapsedRhs} />
|
||||||
</div>
|
</div>
|
||||||
<MainSplit collapsedRhs={this.props.collapsedRhs} panel={rightPanel}>
|
<MainSplit collapsedRhs={this.props.collapsedRhs} panel={rightPanel}>
|
||||||
<GeminiScrollbarWrapper className="mx_GroupView_body">
|
<GeminiScrollbarWrapper className="mx_GroupView_body">
|
||||||
|
|
|
@ -62,7 +62,7 @@ const LoggedInView = React.createClass({
|
||||||
// Called with the credentials of a registered user (if they were a ROU that
|
// Called with the credentials of a registered user (if they were a ROU that
|
||||||
// transitioned to PWLU)
|
// transitioned to PWLU)
|
||||||
onRegistered: PropTypes.func,
|
onRegistered: PropTypes.func,
|
||||||
|
collapsedRhs: PropTypes.bool,
|
||||||
teamToken: PropTypes.string,
|
teamToken: PropTypes.string,
|
||||||
|
|
||||||
// Used by the RoomView to handle joining rooms
|
// Used by the RoomView to handle joining rooms
|
||||||
|
@ -438,7 +438,7 @@ const LoggedInView = React.createClass({
|
||||||
eventPixelOffset={this.props.initialEventPixelOffset}
|
eventPixelOffset={this.props.initialEventPixelOffset}
|
||||||
key={this.props.currentRoomId || 'roomview'}
|
key={this.props.currentRoomId || 'roomview'}
|
||||||
disabled={this.props.middleDisabled}
|
disabled={this.props.middleDisabled}
|
||||||
collapsedRhs={this.props.collapseRhs}
|
collapsedRhs={this.props.collapsedRhs}
|
||||||
ConferenceHandler={this.props.ConferenceHandler}
|
ConferenceHandler={this.props.ConferenceHandler}
|
||||||
/>;
|
/>;
|
||||||
break;
|
break;
|
||||||
|
@ -488,7 +488,7 @@ const LoggedInView = React.createClass({
|
||||||
page_element = <GroupView
|
page_element = <GroupView
|
||||||
groupId={this.props.currentGroupId}
|
groupId={this.props.currentGroupId}
|
||||||
isNew={this.props.currentGroupIsNew}
|
isNew={this.props.currentGroupIsNew}
|
||||||
collapsedRhs={this.props.collapseRhs}
|
collapsedRhs={this.props.collapsedRhs}
|
||||||
/>;
|
/>;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ export default class MainSplit extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
if (this.props.panel && !this.collapsedRhs) {
|
if (this.props.panel && !this.props.collapsedRhs) {
|
||||||
this._createResizer();
|
this._createResizer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ export default React.createClass({
|
||||||
viewUserId: null,
|
viewUserId: null,
|
||||||
|
|
||||||
collapseLhs: false,
|
collapseLhs: false,
|
||||||
collapseRhs: false,
|
collapsedRhs: window.localStorage.getItem("mx_rhs_collapsed") === "true",
|
||||||
leftDisabled: false,
|
leftDisabled: false,
|
||||||
middleDisabled: false,
|
middleDisabled: false,
|
||||||
rightDisabled: false,
|
rightDisabled: false,
|
||||||
|
@ -555,7 +555,7 @@ export default React.createClass({
|
||||||
break;
|
break;
|
||||||
case 'view_user':
|
case 'view_user':
|
||||||
// FIXME: ugly hack to expand the RightPanel and then re-dispatch.
|
// FIXME: ugly hack to expand the RightPanel and then re-dispatch.
|
||||||
if (this.state.collapseRhs) {
|
if (this.state.collapsedRhs) {
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'show_right_panel',
|
action: 'show_right_panel',
|
||||||
|
@ -656,13 +656,15 @@ export default React.createClass({
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'hide_right_panel':
|
case 'hide_right_panel':
|
||||||
|
window.localStorage.setItem("mx_rhs_collapsed", true);
|
||||||
this.setState({
|
this.setState({
|
||||||
collapseRhs: true,
|
collapsedRhs: true,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'show_right_panel':
|
case 'show_right_panel':
|
||||||
|
window.localStorage.setItem("mx_rhs_collapsed", false);
|
||||||
this.setState({
|
this.setState({
|
||||||
collapseRhs: false,
|
collapsedRhs: false,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'panel_disable': {
|
case 'panel_disable': {
|
||||||
|
@ -1217,7 +1219,7 @@ export default React.createClass({
|
||||||
view: VIEWS.LOGIN,
|
view: VIEWS.LOGIN,
|
||||||
ready: false,
|
ready: false,
|
||||||
collapseLhs: false,
|
collapseLhs: false,
|
||||||
collapseRhs: false,
|
collapsedRhs: false,
|
||||||
currentRoomId: null,
|
currentRoomId: null,
|
||||||
page_type: PageTypes.RoomDirectory,
|
page_type: PageTypes.RoomDirectory,
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,6 +36,7 @@ export default class HeaderButton extends React.Component {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_right_panel_phase',
|
action: 'view_right_panel_phase',
|
||||||
phase: this.props.clickPhase,
|
phase: this.props.clickPhase,
|
||||||
|
fromHeader: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import dis from '../../../dispatcher';
|
import dis from '../../../dispatcher';
|
||||||
|
|
||||||
export default class HeaderButtons extends React.Component {
|
export default class HeaderButtons extends React.Component {
|
||||||
|
@ -25,7 +26,7 @@ export default class HeaderButtons extends React.Component {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
phase: initialPhase,
|
phase: props.collapsedRhs ? null : initialPhase,
|
||||||
isUserPrivilegedInGroup: null,
|
isUserPrivilegedInGroup: null,
|
||||||
};
|
};
|
||||||
this.onAction = this.onAction.bind(this);
|
this.onAction = this.onAction.bind(this);
|
||||||
|
@ -49,9 +50,24 @@ export default class HeaderButtons extends React.Component {
|
||||||
|
|
||||||
onAction(payload) {
|
onAction(payload) {
|
||||||
if (payload.action === "view_right_panel_phase") {
|
if (payload.action === "view_right_panel_phase") {
|
||||||
this.setState({
|
// only actions coming from header buttons should collapse the right panel
|
||||||
phase: payload.phase,
|
if (this.state.phase === payload.phase && payload.fromHeader) {
|
||||||
});
|
dis.dispatch({
|
||||||
|
action: 'hide_right_panel',
|
||||||
|
});
|
||||||
|
this.setState({
|
||||||
|
phase: null,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (this.props.collapsedRhs) {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'show_right_panel',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.setState({
|
||||||
|
phase: payload.phase,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,3 +78,7 @@ export default class HeaderButtons extends React.Component {
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HeaderButtons.propTypes = {
|
||||||
|
collapsedRhs: PropTypes.bool,
|
||||||
|
};
|
||||||
|
|
|
@ -394,14 +394,6 @@ module.exports = React.createClass({
|
||||||
</AccessibleButton>;
|
</AccessibleButton>;
|
||||||
}
|
}
|
||||||
|
|
||||||
let rightPanelButtons;
|
|
||||||
if (this.props.collapsedRhs) {
|
|
||||||
rightPanelButtons =
|
|
||||||
<AccessibleButton className="mx_RoomHeader_button mx_RoomHeader_showPanel" onClick={this.onShowRhsClick} title={_t('Show panel')}>
|
|
||||||
<TintableSvg src="img/maximise.svg" width="10" height="16" />
|
|
||||||
</AccessibleButton>;
|
|
||||||
}
|
|
||||||
|
|
||||||
let rightRow;
|
let rightRow;
|
||||||
let manageIntegsButton;
|
let manageIntegsButton;
|
||||||
if (this.props.room && this.props.room.roomId && this.props.inRoom) {
|
if (this.props.room && this.props.room.roomId && this.props.inRoom) {
|
||||||
|
@ -419,7 +411,6 @@ module.exports = React.createClass({
|
||||||
{ manageIntegsButton }
|
{ manageIntegsButton }
|
||||||
{ forgetButton }
|
{ forgetButton }
|
||||||
{ searchButton }
|
{ searchButton }
|
||||||
{ rightPanelButtons }
|
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +424,7 @@ module.exports = React.createClass({
|
||||||
{ saveButton }
|
{ saveButton }
|
||||||
{ cancelButton }
|
{ cancelButton }
|
||||||
{ rightRow }
|
{ rightRow }
|
||||||
<RoomHeaderButtons />
|
<RoomHeaderButtons collapsedRhs={this.props.collapsedRhs} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue