2017-07-26 13:28:43 +03:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-07-26 18:47:58 +03:00
|
|
|
import url from 'url';
|
2017-07-26 13:28:43 +03:00
|
|
|
|
|
|
|
export default class AppPermission extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2017-07-26 18:47:58 +03:00
|
|
|
const curl = this.getCurl();
|
2017-07-26 13:28:43 +03:00
|
|
|
this.state = {
|
2017-07-26 18:47:58 +03:00
|
|
|
curl: curl,
|
2017-07-26 13:28:43 +03:00
|
|
|
};
|
2017-07-26 18:47:58 +03:00
|
|
|
console.log('curl', curl);
|
2017-07-26 13:28:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
getCurl() {
|
2017-07-26 18:47:58 +03:00
|
|
|
const wurl = url.parse(this.props.url);
|
|
|
|
let curl;
|
|
|
|
|
|
|
|
const searchParams = new URLSearchParams(wurl.search);
|
|
|
|
if(searchParams && searchParams.get('url')) {
|
|
|
|
curl = searchParams.get('url');
|
2017-07-26 13:28:43 +03:00
|
|
|
}
|
2017-07-26 18:47:58 +03:00
|
|
|
curl = curl || wurl;
|
|
|
|
return curl;
|
2017-07-26 13:28:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2017-07-26 18:47:58 +03:00
|
|
|
<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>
|
2017-07-26 13:28:43 +03:00
|
|
|
<input
|
2017-07-26 18:47:58 +03:00
|
|
|
className='mx_AppPermissionButton'
|
2017-07-26 13:28:43 +03:00
|
|
|
type='button'
|
|
|
|
value='Allow'
|
|
|
|
onClick={this.props.onPermissionGranted}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AppPermission.propTypes = {
|
|
|
|
url: PropTypes.string.isRequired,
|
|
|
|
onPermissionGranted: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
AppPermission.defaultPropTypes = {
|
|
|
|
onPermissionGranted: function() {},
|
|
|
|
};
|