From 55593416fa71c9c2a77382da8053457c6a5d4d39 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Fri, 9 Feb 2018 13:23:34 +0000 Subject: [PATCH] Hide apps drawer when viewining room settings. --- src/components/structures/RoomView.js | 3 +- src/components/views/rooms/AppsDrawer.js | 40 ++++++++++++++---------- src/components/views/rooms/AuxPanel.js | 9 +++++- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 60987fe26e..4873bbc961 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1605,7 +1605,8 @@ module.exports = React.createClass({ displayConfCallNotification={this.state.displayConfCallNotification} maxHeight={this.state.auxPanelMaxHeight} onResize={this.onChildResize} - showApps={this.state.showApps && !this.state.editingRoomSettings} > + showApps={this.state.showApps} + hideAppsDrawer={this.state.editingRoomSettings} > { aux } ); diff --git a/src/components/views/rooms/AppsDrawer.js b/src/components/views/rooms/AppsDrawer.js index 7541b304a2..a8336edfc3 100644 --- a/src/components/views/rooms/AppsDrawer.js +++ b/src/components/views/rooms/AppsDrawer.js @@ -35,7 +35,15 @@ module.exports = React.createClass({ displayName: 'AppsDrawer', propTypes: { + userId: React.PropTypes.string.isRequired, room: React.PropTypes.object.isRequired, + showApps: React.PropTypes.bool, // Should apps be rendered + hide: React.PropTypes.bool, // If rendered, should apps drawer be visible + }, + + defaultProps: { + showApps: true, + hide: false, }, getInitialState: function() { @@ -46,7 +54,7 @@ module.exports = React.createClass({ componentWillMount: function() { ScalarMessaging.startListening(); - MatrixClientPeg.get().on("RoomState.events", this.onRoomStateEvents); + MatrixClientPeg.get().on('RoomState.events', this.onRoomStateEvents); }, componentDidMount: function() { @@ -56,7 +64,7 @@ module.exports = React.createClass({ this.scalarClient.connect().then(() => { this.forceUpdate(); }).catch((e) => { - console.log("Failed to connect to integrations server"); + console.log('Failed to connect to integrations server'); // TODO -- Handle Scalar errors // this.setState({ // scalar_error: err, @@ -70,7 +78,7 @@ module.exports = React.createClass({ componentWillUnmount: function() { ScalarMessaging.stopListening(); if (MatrixClientPeg.get()) { - MatrixClientPeg.get().removeListener("RoomState.events", this.onRoomStateEvents); + MatrixClientPeg.get().removeListener('RoomState.events', this.onRoomStateEvents); } dis.unregister(this.dispatcherRef); }, @@ -81,7 +89,7 @@ module.exports = React.createClass({ }, onAction: function(action) { - const hideWidgetKey = this.props.room.roomId + "_hide_widget_drawer"; + const hideWidgetKey = this.props.room.roomId + '_hide_widget_drawer'; switch (action.action) { case 'appsDrawer': // When opening the app drawer when there aren't any apps, @@ -109,7 +117,7 @@ module.exports = React.createClass({ * passed through encodeURIComponent. * @param {string} pathTemplate The path with template variables e.g. '/foo/$bar'. * @param {Object} variables The key/value pairs to replace the template - * variables with. E.g. { "$bar": "baz" }. + * variables with. E.g. { '$bar': 'baz' }. * @return {string} The result of replacing all template variables e.g. '/foo/baz'. */ encodeUri: function(pathTemplate, variables) { @@ -187,13 +195,13 @@ module.exports = React.createClass({ }, _launchManageIntegrations: function() { - const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager"); + const IntegrationsManager = sdk.getComponent('views.settings.IntegrationsManager'); const src = (this.scalarClient !== null && this.scalarClient.hasCredentials()) ? this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room, 'add_integ') : null; Modal.createTrackedDialog('Integrations Manager', '', IntegrationsManager, { src: src, - }, "mx_IntegrationsManager"); + }, 'mx_IntegrationsManager'); }, onClickAddWidget: function(e) { @@ -201,12 +209,12 @@ module.exports = React.createClass({ // Display a warning dialog if the max number of widgets have already been added to the room const apps = this._getApps(); if (apps && apps.length >= MAX_WIDGETS) { - const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + const ErrorDialog = sdk.getComponent('dialogs.ErrorDialog'); const errorMsg = `The maximum number of ${MAX_WIDGETS} widgets have already been added to this room.`; console.error(errorMsg); Modal.createDialog(ErrorDialog, { - title: _t("Cannot add any more widgets"), - description: _t("The maximum permitted number of widgets have already been added to this room."), + title: _t('Cannot add any more widgets'), + description: _t('The maximum permitted number of widgets have already been added to this room.'), }); return; } @@ -238,11 +246,11 @@ module.exports = React.createClass({ ) { addWidget =
[+] { _t('Add a widget') } @@ -250,8 +258,8 @@ module.exports = React.createClass({ } return ( -
-
+
+
{ apps }
{ this._canUserModify() && addWidget } diff --git a/src/components/views/rooms/AuxPanel.js b/src/components/views/rooms/AuxPanel.js index c0857d9691..749026d5c6 100644 --- a/src/components/views/rooms/AuxPanel.js +++ b/src/components/views/rooms/AuxPanel.js @@ -31,7 +31,8 @@ module.exports = React.createClass({ // js-sdk room object room: React.PropTypes.object.isRequired, userId: React.PropTypes.string.isRequired, - showApps: React.PropTypes.bool, + showApps: React.PropTypes.bool, // Render apps + hideAppsDrawer: React.PropTypes.bool, // Do not display apps drawer and content (may still be rendered) // Conference Handler implementation conferenceHandler: React.PropTypes.object, @@ -51,6 +52,11 @@ module.exports = React.createClass({ onResize: React.PropTypes.func, }, + defaultProps: { + showApps: true, + hideAppsDrawer: false, + }, + shouldComponentUpdate: function(nextProps, nextState) { return (!ObjectUtils.shallowEqual(this.props, nextProps) || !ObjectUtils.shallowEqual(this.state, nextState)); @@ -133,6 +139,7 @@ module.exports = React.createClass({ userId={this.props.userId} maxHeight={this.props.maxHeight} showApps={this.props.showApps} + hide={this.props.hideAppsDrawer} />; return (