[WIP] app tile click to hide app bodies

This commit is contained in:
Luke Barnard 2017-08-16 18:19:12 +01:00
parent 0935f26cf3
commit 38f45bc40d
3 changed files with 32 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,14 @@ export default React.createClass({
return appTileName; return appTileName;
}, },
onClickMenuBar: function(e) {
e.preventDefault();
dis.dispatch({
action: 'appsDrawer',
show: !this.props.show,
});
},
render: function() { render: function() {
let appTileBody; let appTileBody;
@ -218,7 +227,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 +262,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 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 (