Commit b3d9c9c5 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg

Adding preselect items

parent be32cc95
......@@ -53,35 +53,66 @@ class Component extends PureComponent {
renderDropdownButton() {
const i = "drpdwn"
const title = "Load preset URL"
return (
<DropdownButton bsStyle="default" title={title} key={i} id={`dropdown-basic-${i}`} onSelect={this.preselect.bind(this)}>
<MenuItem eventKey="https://groups-api.dataporten.no/groups/me/groups">groups-api.dataporten.no/groups/me/groups</MenuItem>
<MenuItem eventKey="https://4f2.httpjs.net/">https://4f2.httpjs.net/</MenuItem>
</DropdownButton>
);
console.log("PROPOS", this.props)
if (this.props.serverConfig && this.props.serverConfig.authorization_endpoint && this.props.serverConfig.authorization_endpoint === 'https://auth.dataporten.no/oauth/authorization') {
let links = []
if (this.props.serverConfig.userinfo_endpoint) {
links.push({
url: this.props.serverConfig.userinfo_endpoint,
title: "Userinfo endpoint "
})
}
const cntrl = /^gk_([^_]+)$/i
this.props.token.scopes.forEach((scope) => {
if (scope === 'groups') {
links.push({
url: "https://groups-api.dataporten.no/groups/me/groups",
title: "Dataporten groups API: My groups"
})
}
let res = cntrl.exec(scope)
if (res) {
links.push({
url: "https://" + res[1] + ".dataporten-api.no/",
title: "Dataporten APIGK " + res[1]
})
console.log(res)
}
})
let menuitems = links.map((link) => {
return (
<MenuItem key={link.url} eventKey={link.url}>{link.title}</MenuItem>
)
})
return (
<DropdownButton bsStyle="default" title={title} key={i} id={`dropdown-basic-${i}`} onSelect={this.preselect.bind(this)}>
{menuitems}
</DropdownButton>
);
}
return null
}
render() {
console.error("Component", this.props)
if (!this.props.token) {
return (
<p>Not ready. No token found.</p>
)
return null
}
let userinfo = null
if (this.props.serverConfig.userinfo_endpoint) {
userinfo = (
<div>
<p>Fetch userinfo from <code>{this.props.serverConfig.userinfo_endpoint}</code></p>
<Button onClick={this.fetchUserinfo.bind(this)} bsStyle="default">
<FontAwesome name='arrow-circle-o-right' /> Get userinfo
</Button>
</div>
)
}
// if (this.props.serverConfig.userinfo_endpoint) {
// userinfo = (
// <div>
// <p>Fetch userinfo from <code>{this.props.serverConfig.userinfo_endpoint}</code></p>
// <Button onClick={this.fetchUserinfo.bind(this)} bsStyle="default">
// <FontAwesome name='arrow-circle-o-right' /> Get userinfo
// </Button>
// </div>
// )
// }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment