Add behaviour to toggle app draw on app tile header click

pull/21833/head
Luke Barnard 2017-08-16 18:19:12 +01:00
parent 0935f26cf3
commit 57505c3a61
3 changed files with 39 additions and 12 deletions

View File

@ -28,6 +28,7 @@ import AppPermission from './AppPermission';
import AppWarning from './AppWarning'; import AppWarning from './AppWarning';
import MessageSpinner from './MessageSpinner'; import MessageSpinner from './MessageSpinner';
import WidgetUtils from '../../../WidgetUtils'; import WidgetUtils from '../../../WidgetUtils';
import dis from '../../../dispatcher';
const ALLOWED_APP_URL_SCHEMES = ['https:', 'http:']; const ALLOWED_APP_URL_SCHEMES = ['https:', 'http:'];
const betaHelpMsg = 'This feature is currently experimental and is intended for beta testing only'; const betaHelpMsg = 'This feature is currently experimental and is intended for beta testing only';
@ -182,6 +183,21 @@ export default React.createClass({
return appTileName; return appTileName;
}, },
onClickMenuBar: function(ev) {
ev.preventDefault();
// Ignore clicks on menu bar children
if (ev.target !== this.refs.menu_bar) {
return;
}
// Toggle the view state of the apps drawer
dis.dispatch({
action: 'appsDrawer',
show: !this.props.show,
});
},
render: function() { render: function() {
let appTileBody; let appTileBody;
@ -218,7 +234,7 @@ export default React.createClass({
/> />
</div> </div>
); );
} else { } else if (this.props.show) {
appTileBody = ( appTileBody = (
<div className="mx_AppTileBody"> <div className="mx_AppTileBody">
<iframe <iframe
@ -253,7 +269,7 @@ export default React.createClass({
return ( return (
<div className={this.props.fullWidth ? "mx_AppTileFullWidth" : "mx_AppTile"} id={this.props.id}> <div className={this.props.fullWidth ? "mx_AppTileFullWidth" : "mx_AppTile"} id={this.props.id}>
<div className="mx_AppTileMenuBar"> <div ref="menu_bar" className="mx_AppTileMenuBar" onClick={this.onClickMenuBar}>
{this.formatAppTileName()} {this.formatAppTileName()}
<span className="mx_AppTileMenuBarWidgets"> <span className="mx_AppTileMenuBarWidgets">
<span className="mx_Beta" alt={betaHelpMsg} title={betaHelpMsg}>&#946;</span> <span className="mx_Beta" alt={betaHelpMsg} title={betaHelpMsg}>&#946;</span>

View File

@ -54,6 +54,7 @@ module.exports = React.createClass({
this.scalarClient.connect().done(() => { this.scalarClient.connect().done(() => {
this.forceUpdate(); this.forceUpdate();
if (this.state.apps && this.state.apps.length < 1) { if (this.state.apps && this.state.apps.length < 1) {
// XXX: This should not be called here, we should do something much nicer
this.onClickAddWidget(); this.onClickAddWidget();
} }
// TODO -- Handle Scalar errors // TODO -- Handle Scalar errors
@ -183,17 +184,25 @@ module.exports = React.createClass({
fullWidth={arr.length<2 ? true : false} fullWidth={arr.length<2 ? true : false}
room={this.props.room} room={this.props.room}
userId={this.props.userId} userId={this.props.userId}
show={this.props.showApps}
/>); />);
}); });
const addWidget = this.state.apps && this.state.apps.length < 2 && this._canUserModify() && let addWidget;
(<div onClick={this.onClickAddWidget} if (this.props.showApps &&
role="button" this.state.apps &&
tabIndex="0" this.state.apps.length < 2 &&
className="mx_AddWidget_button" this._canUserModify()
title={_t('Add a widget')}> ) {
[+] {_t('Add a widget')} addWidget = <div
</div>); onClick={this.onClickAddWidget}
role="button"
tabIndex="0"
className="mx_AddWidget_button"
title={_t('Add a widget')}>
[+] {_t('Add a widget')}
</div>;
}
return ( return (
<div className="mx_AppsDrawer"> <div className="mx_AppsDrawer">

View File

@ -129,11 +129,13 @@ module.exports = React.createClass({
); );
let appsDrawer = null; let appsDrawer = null;
if(UserSettingsStore.isFeatureEnabled('matrix_apps') && this.props.showApps) { if(UserSettingsStore.isFeatureEnabled('matrix_apps')) {
appsDrawer = <AppsDrawer ref="appsDrawer" appsDrawer = <AppsDrawer ref="appsDrawer"
room={this.props.room} room={this.props.room}
userId={this.props.userId} userId={this.props.userId}
maxHeight={this.props.maxHeight}/>; maxHeight={this.props.maxHeight}
showApps={this.props.showApps}
/>;
} }
return ( return (