Grant permission to load app widget.

This commit is contained in:
Richard Lewis 2017-07-26 16:47:58 +01:00
parent 76f4f88fcd
commit 9f52c13bea
2 changed files with 21 additions and 9 deletions

View File

@ -1,30 +1,41 @@
import React from 'react';
import PropTypes from 'prop-types';
import { URL, URLSearchParams } from 'url';
import url from 'url';
export default class AppPermission extends React.Component {
constructor(props) {
super(props);
const curl = this.getCurl();
this.state = {
curl: this.getCurl(),
curl: curl,
};
console.log('curl', curl);
}
getCurl() {
let wurl = URL.parse(this.props.url);
console.log('wurl', wurl);
if(wurl.searchParams.get('url')) {
let curl = wurl.searchParams.get('url');
console.log('curl', curl);
const wurl = url.parse(this.props.url);
let curl;
const searchParams = new URLSearchParams(wurl.search);
if(searchParams && searchParams.get('url')) {
curl = searchParams.get('url');
}
curl = curl || wurl;
return curl;
}
render() {
return (
<div>
Load widget with URL : {this.state.cUrl}
<div className='mx_AppPermissionWarning'>
<div className='mx_AppPermissionWarningImage'>
<img src='img/warning.svg' alt='Warning'/>
</div>
<div className='mx_AppPermissionWarningText'>
<span className='mx_AppPermissionWarningTextLabel'>Do you want to load widget from URL?:</span> <span className='mx_AppPermissionWarningTextURL'>{this.state.curl}</span>
</div>
<input
className='mx_AppPermissionButton'
type='button'
value='Allow'
onClick={this.props.onPermissionGranted}

View File

@ -174,6 +174,7 @@ export default React.createClass({
appTileBody = (
<AppPermission
url={this.state.widgetUrl}
onPermissionGranted={this._grantWidgetPermission}
/>
);
}