Commit 04076aa0 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg

Add preset selector for urls

parent 0f8e062f
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import {Navbar, Nav, NavItem, NavDropdown, MenuItem, Glyphicon, Jumbotron, Button} from 'react-bootstrap' import {DropdownButton, Navbar, Nav, NavItem, NavDropdown, MenuItem, Glyphicon, Jumbotron, Button} from 'react-bootstrap'
import {Row, Col, Collapse, FormControl, FormGroup, ControlLabel, HelpBlock, PanelGroup, Panel} from 'react-bootstrap' import {Row, Col, Collapse, FormControl, FormGroup, ControlLabel, HelpBlock, PanelGroup, Panel} from 'react-bootstrap'
import FontAwesome from 'react-fontawesome' import FontAwesome from 'react-fontawesome'
...@@ -22,6 +22,13 @@ export function expiresText(expires) { ...@@ -22,6 +22,13 @@ export function expiresText(expires) {
class Component extends PureComponent { class Component extends PureComponent {
constructor(props) {
super(props)
this.state = {
customEndpoint: ""
}
}
updateAPIendpoint(e) { updateAPIendpoint(e) {
this.setState({customEndpoint: e.target.value}) this.setState({customEndpoint: e.target.value})
} }
...@@ -38,6 +45,22 @@ class Component extends PureComponent { ...@@ -38,6 +45,22 @@ class Component extends PureComponent {
this.props.httpRequestStart(endpoint) this.props.httpRequestStart(endpoint)
} }
preselect(key, event) {
console.log("Key", key, "event", event)
this.setState({customEndpoint: key})
}
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>
);
}
render() { render() {
console.error("Component", this.props) console.error("Component", this.props)
...@@ -48,7 +71,6 @@ class Component extends PureComponent { ...@@ -48,7 +71,6 @@ class Component extends PureComponent {
} }
let userinfo = null let userinfo = null
if (this.props.serverConfig.userinfo_endpoint) { if (this.props.serverConfig.userinfo_endpoint) {
userinfo = ( userinfo = (
...@@ -61,13 +83,16 @@ class Component extends PureComponent { ...@@ -61,13 +83,16 @@ class Component extends PureComponent {
) )
} }
return ( return (
<Panel header="HTTP Client using OAuth Access Token" eventKey="1" collapsible={true} expanded={true}> <Panel header="HTTP Client using OAuth Access Token" eventKey="1" collapsible={true} expanded={true}>
{userinfo} {userinfo}
<div> <div>
<p>Fetch userinfo from</p> <p>Fetch data from</p>
{this.renderDropdownButton()}
<FormGroup <FormGroup
className="gutter" className="gutter"
controlId="formBasicText" controlId="formBasicText"
...@@ -76,6 +101,7 @@ class Component extends PureComponent { ...@@ -76,6 +101,7 @@ class Component extends PureComponent {
type="text" type="text"
bsSize="large" bsSize="large"
placeholder="http://httpjs.net/foo" placeholder="http://httpjs.net/foo"
value={this.state.customEndpoint}
onChange={this.updateAPIendpoint.bind(this)} onChange={this.updateAPIendpoint.bind(this)}
/> />
<HelpBlock>Fill out the hostname of your OAuth server. Will only work if your OAuth server support OpenID Connect Discovery. If not, please enter configuration manually.</HelpBlock> <HelpBlock>Fill out the hostname of your OAuth server. Will only work if your OAuth server support OpenID Connect Discovery. If not, please enter configuration manually.</HelpBlock>
......
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