Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Redesign: allow to hide the right panel when clicking already active button & persist #2361

Merged
merged 7 commits into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/structures/GroupView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ export default React.createClass({
<div className="mx_GroupView_header_rightCol">
{ rightButtons }
</div>
<GroupHeaderButtons />
<GroupHeaderButtons collapsedRhs={this.props.collapsedRhs} />
</div>
<MainSplit collapsedRhs={this.props.collapsedRhs} panel={rightPanel}>
<GeminiScrollbarWrapper className="mx_GroupView_body">
Expand Down
6 changes: 3 additions & 3 deletions src/components/structures/LoggedInView.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const LoggedInView = React.createClass({
// Called with the credentials of a registered user (if they were a ROU that
// transitioned to PWLU)
onRegistered: PropTypes.func,

collapsedRhs: PropTypes.bool,
teamToken: PropTypes.string,

// Used by the RoomView to handle joining rooms
Expand Down Expand Up @@ -438,7 +438,7 @@ const LoggedInView = React.createClass({
eventPixelOffset={this.props.initialEventPixelOffset}
key={this.props.currentRoomId || 'roomview'}
disabled={this.props.middleDisabled}
collapsedRhs={this.props.collapseRhs}
collapsedRhs={this.props.collapsedRhs}
bwindels marked this conversation as resolved.
Show resolved Hide resolved
ConferenceHandler={this.props.ConferenceHandler}
/>;
break;
Expand Down Expand Up @@ -488,7 +488,7 @@ const LoggedInView = React.createClass({
page_element = <GroupView
groupId={this.props.currentGroupId}
isNew={this.props.currentGroupIsNew}
collapsedRhs={this.props.collapseRhs}
collapsedRhs={this.props.collapsedRhs}
/>;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/structures/MainSplit.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class MainSplit extends React.Component {
}

componentDidMount() {
if (this.props.panel && !this.collapsedRhs) {
if (this.props.panel && !this.props.collapsedRhs) {
this._createResizer();
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/components/structures/MatrixChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default React.createClass({
viewUserId: null,

collapseLhs: false,
collapseRhs: false,
collapsedRhs: window.localStorage.getItem("mx_rhs_collapsed") === "true",
leftDisabled: false,
middleDisabled: false,
rightDisabled: false,
Expand Down Expand Up @@ -555,7 +555,7 @@ export default React.createClass({
break;
case 'view_user':
// FIXME: ugly hack to expand the RightPanel and then re-dispatch.
if (this.state.collapseRhs) {
if (this.state.collapsedRhs) {
setTimeout(()=>{
dis.dispatch({
action: 'show_right_panel',
Expand Down Expand Up @@ -656,13 +656,15 @@ export default React.createClass({
});
break;
case 'hide_right_panel':
window.localStorage.setItem("mx_rhs_collapsed", true);
this.setState({
collapseRhs: true,
collapsedRhs: true,
});
break;
case 'show_right_panel':
window.localStorage.setItem("mx_rhs_collapsed", false);
this.setState({
collapseRhs: false,
collapsedRhs: false,
});
break;
case 'panel_disable': {
Expand Down Expand Up @@ -1217,7 +1219,7 @@ export default React.createClass({
view: VIEWS.LOGIN,
ready: false,
collapseLhs: false,
collapseRhs: false,
collapsedRhs: false,
currentRoomId: null,
page_type: PageTypes.RoomDirectory,
});
Expand Down
1 change: 1 addition & 0 deletions src/components/views/right_panel/HeaderButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class HeaderButton extends React.Component {
dis.dispatch({
action: 'view_right_panel_phase',
phase: this.props.clickPhase,
fromHeader: true,
});
}

Expand Down
28 changes: 24 additions & 4 deletions src/components/views/right_panel/HeaderButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ limitations under the License.
*/

import React from 'react';
import PropTypes from 'prop-types';
import dis from '../../../dispatcher';

export default class HeaderButtons extends React.Component {
constructor(props, initialPhase) {
super(props);

this.state = {
phase: initialPhase,
phase: props.collapsedRhs ? null : initialPhase,
isUserPrivilegedInGroup: null,
};
this.onAction = this.onAction.bind(this);
Expand All @@ -49,9 +50,24 @@ export default class HeaderButtons extends React.Component {

onAction(payload) {
if (payload.action === "view_right_panel_phase") {
this.setState({
phase: payload.phase,
});
// only actions coming from header buttons should collapse the right panel
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,
});
}
}
}

Expand All @@ -62,3 +78,7 @@ export default class HeaderButtons extends React.Component {
</div>;
}
}

HeaderButtons.propTypes = {
collapsedRhs: PropTypes.bool,
};
11 changes: 1 addition & 10 deletions src/components/views/rooms/RoomHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,6 @@ module.exports = React.createClass({
</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 manageIntegsButton;
if (this.props.room && this.props.room.roomId && this.props.inRoom) {
Expand All @@ -419,7 +411,6 @@ module.exports = React.createClass({
{ manageIntegsButton }
{ forgetButton }
{ searchButton }
{ rightPanelButtons }
</div>;
}

Expand All @@ -433,7 +424,7 @@ module.exports = React.createClass({
{ saveButton }
{ cancelButton }
{ rightRow }
<RoomHeaderButtons />
<RoomHeaderButtons collapsedRhs={this.props.collapsedRhs} />
</div>
</div>
);
Expand Down