1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-28 15:22:05 +03:00

Hide apps drawer when viewining room settings.

This commit is contained in:
Richard Lewis
2018-02-09 13:23:34 +00:00
parent 9e3c1fbc7a
commit 55593416fa
3 changed files with 34 additions and 18 deletions

View File

@ -1605,7 +1605,8 @@ module.exports = React.createClass({
displayConfCallNotification={this.state.displayConfCallNotification} displayConfCallNotification={this.state.displayConfCallNotification}
maxHeight={this.state.auxPanelMaxHeight} maxHeight={this.state.auxPanelMaxHeight}
onResize={this.onChildResize} onResize={this.onChildResize}
showApps={this.state.showApps && !this.state.editingRoomSettings} > showApps={this.state.showApps}
hideAppsDrawer={this.state.editingRoomSettings} >
{ aux } { aux }
</AuxPanel> </AuxPanel>
); );

View File

@ -35,7 +35,15 @@ module.exports = React.createClass({
displayName: 'AppsDrawer', displayName: 'AppsDrawer',
propTypes: { propTypes: {
userId: React.PropTypes.string.isRequired,
room: React.PropTypes.object.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() { getInitialState: function() {
@ -46,7 +54,7 @@ module.exports = React.createClass({
componentWillMount: function() { componentWillMount: function() {
ScalarMessaging.startListening(); ScalarMessaging.startListening();
MatrixClientPeg.get().on("RoomState.events", this.onRoomStateEvents); MatrixClientPeg.get().on('RoomState.events', this.onRoomStateEvents);
}, },
componentDidMount: function() { componentDidMount: function() {
@ -56,7 +64,7 @@ module.exports = React.createClass({
this.scalarClient.connect().then(() => { this.scalarClient.connect().then(() => {
this.forceUpdate(); this.forceUpdate();
}).catch((e) => { }).catch((e) => {
console.log("Failed to connect to integrations server"); console.log('Failed to connect to integrations server');
// TODO -- Handle Scalar errors // TODO -- Handle Scalar errors
// this.setState({ // this.setState({
// scalar_error: err, // scalar_error: err,
@ -70,7 +78,7 @@ module.exports = React.createClass({
componentWillUnmount: function() { componentWillUnmount: function() {
ScalarMessaging.stopListening(); ScalarMessaging.stopListening();
if (MatrixClientPeg.get()) { if (MatrixClientPeg.get()) {
MatrixClientPeg.get().removeListener("RoomState.events", this.onRoomStateEvents); MatrixClientPeg.get().removeListener('RoomState.events', this.onRoomStateEvents);
} }
dis.unregister(this.dispatcherRef); dis.unregister(this.dispatcherRef);
}, },
@ -81,7 +89,7 @@ module.exports = React.createClass({
}, },
onAction: function(action) { onAction: function(action) {
const hideWidgetKey = this.props.room.roomId + "_hide_widget_drawer"; const hideWidgetKey = this.props.room.roomId + '_hide_widget_drawer';
switch (action.action) { switch (action.action) {
case 'appsDrawer': case 'appsDrawer':
// When opening the app drawer when there aren't any apps, // When opening the app drawer when there aren't any apps,
@ -109,7 +117,7 @@ module.exports = React.createClass({
* passed through encodeURIComponent. * passed through encodeURIComponent.
* @param {string} pathTemplate The path with template variables e.g. '/foo/$bar'. * @param {string} pathTemplate The path with template variables e.g. '/foo/$bar'.
* @param {Object} variables The key/value pairs to replace the template * @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'. * @return {string} The result of replacing all template variables e.g. '/foo/baz'.
*/ */
encodeUri: function(pathTemplate, variables) { encodeUri: function(pathTemplate, variables) {
@ -187,13 +195,13 @@ module.exports = React.createClass({
}, },
_launchManageIntegrations: function() { _launchManageIntegrations: function() {
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager"); const IntegrationsManager = sdk.getComponent('views.settings.IntegrationsManager');
const src = (this.scalarClient !== null && this.scalarClient.hasCredentials()) ? const src = (this.scalarClient !== null && this.scalarClient.hasCredentials()) ?
this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room, 'add_integ') : this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room, 'add_integ') :
null; null;
Modal.createTrackedDialog('Integrations Manager', '', IntegrationsManager, { Modal.createTrackedDialog('Integrations Manager', '', IntegrationsManager, {
src: src, src: src,
}, "mx_IntegrationsManager"); }, 'mx_IntegrationsManager');
}, },
onClickAddWidget: function(e) { 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 // Display a warning dialog if the max number of widgets have already been added to the room
const apps = this._getApps(); const apps = this._getApps();
if (apps && apps.length >= MAX_WIDGETS) { 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.`; const errorMsg = `The maximum number of ${MAX_WIDGETS} widgets have already been added to this room.`;
console.error(errorMsg); console.error(errorMsg);
Modal.createDialog(ErrorDialog, { Modal.createDialog(ErrorDialog, {
title: _t("Cannot add any more widgets"), title: _t('Cannot add any more widgets'),
description: _t("The maximum permitted number of widgets have already been added to this room."), description: _t('The maximum permitted number of widgets have already been added to this room.'),
}); });
return; return;
} }
@ -238,11 +246,11 @@ module.exports = React.createClass({
) { ) {
addWidget = <div addWidget = <div
onClick={this.onClickAddWidget} onClick={this.onClickAddWidget}
role="button" role='button'
tabIndex="0" tabIndex='0'
className={this.state.apps.length<2 ? className={this.state.apps.length<2 ?
"mx_AddWidget_button mx_AddWidget_button_full_width" : 'mx_AddWidget_button mx_AddWidget_button_full_width' :
"mx_AddWidget_button" 'mx_AddWidget_button'
} }
title={_t('Add a widget')}> title={_t('Add a widget')}>
[+] { _t('Add a widget') } [+] { _t('Add a widget') }
@ -250,8 +258,8 @@ module.exports = React.createClass({
} }
return ( return (
<div className="mx_AppsDrawer"> <div className={'mx_AppsDrawer' + (this.props.hide ? ' mx_AppsDrawer_hidden' : '')}>
<div id="apps" className="mx_AppsContainer"> <div id='apps' className='mx_AppsContainer'>
{ apps } { apps }
</div> </div>
{ this._canUserModify() && addWidget } { this._canUserModify() && addWidget }

View File

@ -31,7 +31,8 @@ module.exports = React.createClass({
// js-sdk room object // js-sdk room object
room: React.PropTypes.object.isRequired, room: React.PropTypes.object.isRequired,
userId: React.PropTypes.string.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 // Conference Handler implementation
conferenceHandler: React.PropTypes.object, conferenceHandler: React.PropTypes.object,
@ -51,6 +52,11 @@ module.exports = React.createClass({
onResize: React.PropTypes.func, onResize: React.PropTypes.func,
}, },
defaultProps: {
showApps: true,
hideAppsDrawer: false,
},
shouldComponentUpdate: function(nextProps, nextState) { shouldComponentUpdate: function(nextProps, nextState) {
return (!ObjectUtils.shallowEqual(this.props, nextProps) || return (!ObjectUtils.shallowEqual(this.props, nextProps) ||
!ObjectUtils.shallowEqual(this.state, nextState)); !ObjectUtils.shallowEqual(this.state, nextState));
@ -133,6 +139,7 @@ module.exports = React.createClass({
userId={this.props.userId} userId={this.props.userId}
maxHeight={this.props.maxHeight} maxHeight={this.props.maxHeight}
showApps={this.props.showApps} showApps={this.props.showApps}
hide={this.props.hideAppsDrawer}
/>; />;
return ( return (