element-web/src/components/views/elements/AppPermission.js

44 lines
1 KiB
JavaScript
Raw Normal View History

2017-07-26 10:28:43 +00:00
import React from 'react';
import PropTypes from 'prop-types';
import { URL, URLSearchParams } from 'url';
export default class AppPermission extends React.Component {
constructor(props) {
super(props);
this.state = {
curl: this.getCurl(),
};
}
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);
}
}
render() {
return (
<div>
Load widget with URL : {this.state.cUrl}
<input
type='button'
value='Allow'
onClick={this.props.onPermissionGranted}
/>
</div>
);
}
}
AppPermission.propTypes = {
url: PropTypes.string.isRequired,
onPermissionGranted: PropTypes.func.isRequired,
};
AppPermission.defaultPropTypes = {
onPermissionGranted: function() {},
};