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

Improve toggle panels

parent 1e2b6ff2
......@@ -26,6 +26,7 @@ class Component extends PureComponent {
// console.log("currentURL", currentURL)
this.state = {
overrideToggle: null,
client_id: "6233aedf-f08a-4112-9a1b-f33c3cd9b396",
// clientSecret: "",
redirectURL: currentURL,
......@@ -55,6 +56,14 @@ class Component extends PureComponent {
}
}
actTogglePanel = () => {
if (this.state.overrideToggle === null) {
this.setState({overrideToggle: !(this.props.expanded)})
} else {
this.setState({overrideToggle: !(this.state.overrideToggle === true)})
}
}
render() {
// console.log("X This props", this.props)
......@@ -91,10 +100,9 @@ class Component extends PureComponent {
scopes = this.props.serverConfig.scopes
}
let expanded = this.props.expanded && !!this.props.serverConfig
let expanded = (this.state.overrideToggle === true) || this.props.expanded
return (
<Panel header="OAuth Server Configuration" eventKey="2" collapsible={true} defaultExpanded={expanded}>
<Panel onClick={this.actTogglePanel} header="OAuth Server Configuration" eventKey="2" collapsible={true} expanded={expanded}>
<form>
<h4>OAuth Authorization endpoint</h4>
<FormGroup>
......@@ -121,7 +129,7 @@ class Component extends PureComponent {
<FormGroup>
<FormControl type="text" bsSize="large" value={clientSecret} onChange={this.updateFieldHandler.bind(this)("client_secret")} />
</FormGroup>
*/}
*/}
<h4>Scopes</h4>
<FormGroup>
<FormControl type="text" bsSize="large" value={scopes} onChange={this.updateFieldHandler.bind(this)("scopes")} />
......
......@@ -5,9 +5,11 @@ import API from '../utils/API'
const mapStateToProps = (state) => ({
serverError: state.serverError,
expanded: !state.token
expanded: !!(state.serverConfig && state.serverConfig.discovered) && !state.token
})
const mapDispatchToProps = {
discoveryStart: API.discovery,
}
......
......@@ -3,10 +3,13 @@ import ServerConfigInput from '../components/ServerConfigInput'
import actions from '../actions/'
import API from '../utils/API'
const mapStateToProps = (state) => ({
serverConfig: state.serverConfig,
expanded: !state.token
})
const mapStateToProps = (state) => {
return {
serverConfig: state.serverConfig,
expanded: !!(state.serverConfig && state.serverConfig.discovered) && !state.token
}
}
const mapDispatchToProps = {
authenticateStart: API.authenticate,
......
......@@ -26,6 +26,7 @@ const API = {
})
.then((data) => {
// console.log("DATA", data)
data.discovered = true
dispatch(actions.discovery.completed(data))
})
.catch((err) => {
......
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