From bbafd8c2d33db1779f9c61577f6b8a23fcabfe11 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Dec 2018 15:22:02 +0100 Subject: [PATCH 1/7] toggle right panel when clicking already active header button --- .../views/right_panel/HeaderButton.js | 1 + .../views/right_panel/HeaderButtons.js | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/views/right_panel/HeaderButton.js b/src/components/views/right_panel/HeaderButton.js index a01d3444f1..bb9f613607 100644 --- a/src/components/views/right_panel/HeaderButton.js +++ b/src/components/views/right_panel/HeaderButton.js @@ -36,6 +36,7 @@ export default class HeaderButton extends React.Component { dis.dispatch({ action: 'view_right_panel_phase', phase: this.props.clickPhase, + fromHeader: true, }); } diff --git a/src/components/views/right_panel/HeaderButtons.js b/src/components/views/right_panel/HeaderButtons.js index 3c59c52089..16f7f006f8 100644 --- a/src/components/views/right_panel/HeaderButtons.js +++ b/src/components/views/right_panel/HeaderButtons.js @@ -49,9 +49,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.state.phase) { + dis.dispatch({ + action: 'show_right_panel', + }); + } + this.setState({ + phase: payload.phase, + }); + } } } From 65f9bc97540f9f2b49e5f9af8fd77a82a89d3e62 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Dec 2018 15:23:46 +0100 Subject: [PATCH 2/7] remove expand button in room header --- src/components/views/rooms/RoomHeader.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index 3b85730e11..e92d1499aa 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -394,14 +394,6 @@ module.exports = React.createClass({ ; } - let rightPanelButtons; - if (this.props.collapsedRhs) { - rightPanelButtons = - - - ; - } - let rightRow; let manageIntegsButton; if (this.props.room && this.props.room.roomId && this.props.inRoom) { @@ -419,7 +411,6 @@ module.exports = React.createClass({ { manageIntegsButton } { forgetButton } { searchButton } - { rightPanelButtons } ; } From f7b6e9c6fc90fe02c6a0b5c01b832cca487f236d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Dec 2018 15:30:39 +0100 Subject: [PATCH 3/7] name collapsedRhs consistently everywhere --- src/components/structures/LoggedInView.js | 4 ++-- src/components/structures/MatrixChat.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index 635c5de44e..c36d3fe651 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -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} ConferenceHandler={this.props.ConferenceHandler} />; break; @@ -488,7 +488,7 @@ const LoggedInView = React.createClass({ page_element = ; break; } diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 0a062afc43..ebc56dc438 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -161,7 +161,7 @@ export default React.createClass({ viewUserId: null, collapseLhs: false, - collapseRhs: false, + collapsedRhs: false, leftDisabled: false, middleDisabled: false, rightDisabled: false, @@ -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', @@ -657,12 +657,12 @@ export default React.createClass({ break; case 'hide_right_panel': this.setState({ - collapseRhs: true, + collapsedRhs: true, }); break; case 'show_right_panel': this.setState({ - collapseRhs: false, + collapsedRhs: false, }); break; case 'panel_disable': { @@ -1217,7 +1217,7 @@ export default React.createClass({ view: VIEWS.LOGIN, ready: false, collapseLhs: false, - collapseRhs: false, + collapsedRhs: false, currentRoomId: null, page_type: PageTypes.RoomDirectory, }); From a734fb9d35a5750c47ce7c7352378d6dd83304f7 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Dec 2018 15:55:26 +0100 Subject: [PATCH 4/7] dont set initial phase, show panel when collapsed --- src/components/structures/GroupView.js | 2 +- src/components/views/right_panel/HeaderButtons.js | 4 ++-- src/components/views/rooms/RoomHeader.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 3f20a6da98..d77837ad63 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -1311,7 +1311,7 @@ export default React.createClass({
{ rightButtons }
- + diff --git a/src/components/views/right_panel/HeaderButtons.js b/src/components/views/right_panel/HeaderButtons.js index 16f7f006f8..e0448c0ae2 100644 --- a/src/components/views/right_panel/HeaderButtons.js +++ b/src/components/views/right_panel/HeaderButtons.js @@ -25,7 +25,7 @@ export default class HeaderButtons extends React.Component { super(props); this.state = { - phase: initialPhase, + phase: props.collapsedRhs ? null : initialPhase, isUserPrivilegedInGroup: null, }; this.onAction = this.onAction.bind(this); @@ -58,7 +58,7 @@ export default class HeaderButtons extends React.Component { phase: null, }); } else { - if (!this.state.phase) { + if (this.props.collapsedRhs) { dis.dispatch({ action: 'show_right_panel', }); diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index e92d1499aa..8aea31f9ed 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -424,7 +424,7 @@ module.exports = React.createClass({ { saveButton } { cancelButton } { rightRow } - + ); From f744374d1d5a7c40458a4cca078f50ac0c3d3df1 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Dec 2018 15:56:17 +0100 Subject: [PATCH 5/7] read collapsedRhs from props when mounting main split --- src/components/structures/MainSplit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/MainSplit.js b/src/components/structures/MainSplit.js index 6fd0274f1a..5c69ef6745 100644 --- a/src/components/structures/MainSplit.js +++ b/src/components/structures/MainSplit.js @@ -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(); } } From b7c353d0a6caa096e290f714e27566c6b7df3477 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Dec 2018 15:56:35 +0100 Subject: [PATCH 6/7] persist and load collapsed rhs globally --- src/components/structures/MatrixChat.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index ebc56dc438..187caa69df 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -161,7 +161,7 @@ export default React.createClass({ viewUserId: null, collapseLhs: false, - collapsedRhs: false, + collapsedRhs: window.localStorage.getItem("mx_rhs_collapsed") === "true", leftDisabled: false, middleDisabled: false, rightDisabled: false, @@ -656,11 +656,13 @@ export default React.createClass({ }); break; case 'hide_right_panel': + window.localStorage.setItem("mx_rhs_collapsed", true); this.setState({ collapsedRhs: true, }); break; case 'show_right_panel': + window.localStorage.setItem("mx_rhs_collapsed", false); this.setState({ collapsedRhs: false, }); From f6727c5724bdadfcfa2d8449282f2c52264ffa85 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 Dec 2018 10:34:26 +0100 Subject: [PATCH 7/7] add collapsedRhs to propTypes --- src/components/structures/LoggedInView.js | 2 +- src/components/views/right_panel/HeaderButtons.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index c36d3fe651..0433ce25b3 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -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 diff --git a/src/components/views/right_panel/HeaderButtons.js b/src/components/views/right_panel/HeaderButtons.js index e0448c0ae2..4ba0148652 100644 --- a/src/components/views/right_panel/HeaderButtons.js +++ b/src/components/views/right_panel/HeaderButtons.js @@ -18,6 +18,7 @@ limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import dis from '../../../dispatcher'; export default class HeaderButtons extends React.Component { @@ -77,3 +78,7 @@ export default class HeaderButtons extends React.Component { ; } } + +HeaderButtons.propTypes = { + collapsedRhs: PropTypes.bool, +};