Add message spinner.

pull/21833/head
Richard Lewis 2017-07-27 16:41:52 +01:00
parent f2058e0a6c
commit 8e4f1f0989
1 changed files with 15 additions and 7 deletions

View File

@ -25,6 +25,7 @@ import Modal from '../../../Modal';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import sdk from '../../../index'; import sdk from '../../../index';
import AppPermission from './AppPermission'; import AppPermission from './AppPermission';
import MessageSpinner from './MessageSpinner';
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';
@ -38,6 +39,7 @@ export default React.createClass({
name: React.PropTypes.string.isRequired, name: React.PropTypes.string.isRequired,
room: React.PropTypes.object.isRequired, room: React.PropTypes.object.isRequired,
type: React.PropTypes.string.isRequired, type: React.PropTypes.string.isRequired,
fullWidth: React.PropTypes.bool,
}, },
getDefaultProps: function() { getDefaultProps: function() {
@ -48,11 +50,12 @@ export default React.createClass({
getInitialState: function() { getInitialState: function() {
const widgetPermissionId = [this.props.room.roomId, encodeURIComponent(this.props.url)].join('_'); const widgetPermissionId = [this.props.room.roomId, encodeURIComponent(this.props.url)].join('_');
const hasPermissionToLoad = localStorage.getItem(widgetPermissionId);
return { return {
loading: false, loading: false,
widgetUrl: this.props.url, widgetUrl: this.props.url,
widgetPermissionId: widgetPermissionId, widgetPermissionId: widgetPermissionId,
hasPermissionToLoad: localStorage.getItem(widgetPermissionId), hasPermissionToLoad: Boolean(hasPermissionToLoad === 'true'),
error: null, error: null,
deleting: false, deleting: false,
}; };
@ -123,6 +126,7 @@ export default React.createClass({
_grantWidgetPermission() { _grantWidgetPermission() {
console.warn('Granting permission to load widget - ', this.state.widgetUrl); console.warn('Granting permission to load widget - ', this.state.widgetUrl);
localStorage.setItem(this.state.widgetPermissionId, true); localStorage.setItem(this.state.widgetPermissionId, true);
this.setState({hasPermissionToLoad: true});
}, },
formatAppTileName: function() { formatAppTileName: function() {
@ -157,9 +161,11 @@ export default React.createClass({
if (this.state.loading) { if (this.state.loading) {
appTileBody = ( appTileBody = (
<div> Loading... </div> <div className='mx_AppTileBody mx_AppLoading'>
<MessageSpinner msg='Loading...'/>
</div>
); );
} else if (this.state.hasPermissionToLoad === true) { } else if (this.state.hasPermissionToLoad == true) {
appTileBody = ( appTileBody = (
<div className="mx_AppTileBody"> <div className="mx_AppTileBody">
<iframe <iframe
@ -172,10 +178,12 @@ export default React.createClass({
); );
} else { } else {
appTileBody = ( appTileBody = (
<AppPermission <div className="mx_AppTileBody">
url={this.state.widgetUrl} <AppPermission
onPermissionGranted={this._grantWidgetPermission} url={this.state.widgetUrl}
/> onPermissionGranted={this._grantWidgetPermission}
/>
</div>
); );
} }