From b3d9c9c5ce4a57c367e03c55951668cdd57d8bc7 Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 10 Sep 2017 20:07:05 +0200 Subject: [PATCH] Adding preselect items --- src/components/HTTPFetchView.jsx | 69 +++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 19 deletions(-) diff --git a/src/components/HTTPFetchView.jsx b/src/components/HTTPFetchView.jsx index dcc6542..0b59cca 100644 --- a/src/components/HTTPFetchView.jsx +++ b/src/components/HTTPFetchView.jsx @@ -53,35 +53,66 @@ class Component extends PureComponent { renderDropdownButton() { const i = "drpdwn" const title = "Load preset URL" - return ( - - groups-api.dataporten.no/groups/me/groups - https://4f2.httpjs.net/ - - ); + 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 ( + {link.title} + ) + }) + + return ( + + {menuitems} + + ); + } + return null } render() { console.error("Component", this.props) if (!this.props.token) { - return ( -

Not ready. No token found.

- ) + return null } let userinfo = null - if (this.props.serverConfig.userinfo_endpoint) { - userinfo = ( -
-

Fetch userinfo from {this.props.serverConfig.userinfo_endpoint}

- -
- ) - } + // if (this.props.serverConfig.userinfo_endpoint) { + // userinfo = ( + //
+ //

Fetch userinfo from {this.props.serverConfig.userinfo_endpoint}

+ // + //
+ // ) + // } -- GitLab