Skip to content

Commit

Permalink
fix: all scopes fields should be saved on add/edit #144
Browse files Browse the repository at this point in the history
  • Loading branch information
duttarnab committed Mar 15, 2022
1 parent c783f54 commit 44a1d75
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions admin-ui/plugins/auth-server/components/Scopes/ScopeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,19 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
function enableDynamic(type) {
return type === 'dynamic'
}
function handleScopeTypeChanged() {
const type = document.getElementById('scopeType')
if (type && type.value === 'openid') {
function handleScopeTypeChanged(type) {
if (type && type === 'openid') {
handleClaimsPanel(true)
} else {
handleClaimsPanel(false)
}
if (type && type.value === 'dynamic') {
if (type && type === 'dynamic') {
handleDynamicPanel(true)
} else {
handleDynamicPanel(false)
}
scope.dynamicScopeScripts = ''
scope.claims = ''
}

function getMapping(partial, total) {
Expand Down Expand Up @@ -103,10 +104,11 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
})}
onSubmit={(values) => {
const result = Object.assign(scope, values)
result['scopeType'] = document.getElementById('scopeType').value
//result[scopeType] = document.getElementById(scopeType).value
result['id'] = result.displayName
result['attributes'].showInConfigurationEndpoint =
result.showInConfigurationEndpoint
result['attributes'].showInConfigurationEndpoint = scope.attributes.showInConfigurationEndpoint
result['attributes'].spontaneousClientId = scope.attributes.spontaneousClientId
result['attributes'].spontaneousClientScopes = scope.attributes.spontaneousClientScopes
handleSubmit(JSON.stringify(result))
}}
>
Expand Down Expand Up @@ -177,7 +179,10 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
id="scopeType"
name="scopeType"
defaultValue={scope.scopeType}
onChange={handleScopeTypeChanged}
onChange={(e) => {
handleScopeTypeChanged(e.target.value)
formik.setFieldValue('scopeType', e.target.value)
}}
>
<option value="">{t('actions.choose')}...</option>
<option value="oauth">OAuth</option>
Expand Down Expand Up @@ -249,7 +254,10 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
id="spontaneousClientId"
name="spontaneousClientId"
defaultValue={scope.attributes.spontaneousClientId}
onChange={formik.handleChange}
onChange={(e) => {
scope.attributes.spontaneousClientId = e.target.value
formik.setFieldValue('spontaneousClientId', e.target.value)
}}
/>
</Col>
</FormGroup>
Expand All @@ -272,7 +280,10 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
defaultValue={
scope.attributes.showInConfigurationEndpoint
}
onChange={formik.handleChange}
onChange={(e) => {
scope.attributes.showInConfigurationEndpoint = e.target.value
formik.setFieldValue('showInConfigurationEndpoint', e.target.value)
}}
>
<option value="true">{t('options.true')}</option>
<option value="false">{t('options.false')}</option>
Expand Down

0 comments on commit 44a1d75

Please sign in to comment.