1
- import React , { useState } from 'react'
1
+ import React , { useEffect , useState } from 'react'
2
2
import { Formik , ErrorMessage } from 'formik'
3
3
import * as Yup from 'yup'
4
4
import {
@@ -24,7 +24,7 @@ import { useTranslation } from 'react-i18next'
24
24
function ScopeForm ( { scope, scripts, attributes, handleSubmit } ) {
25
25
const { t } = useTranslation ( )
26
26
let dynamicScopeScripts = [ ]
27
- let spontaneousClientScopes = [ ]
27
+ let spontaneousClientScopes = scope . attributes . spontaneousClientScopes || [ ]
28
28
let claims = [ ]
29
29
scripts = scripts || [ ]
30
30
attributes = attributes || [ ]
@@ -106,9 +106,12 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
106
106
const result = Object . assign ( scope , values )
107
107
//result[‘scopeType’] = document.getElementById(‘scopeType’).value
108
108
result [ 'id' ] = result . displayName
109
- result [ 'attributes' ] . showInConfigurationEndpoint = scope . attributes . showInConfigurationEndpoint
110
- result [ 'attributes' ] . spontaneousClientId = scope . attributes . spontaneousClientId
111
- result [ 'attributes' ] . spontaneousClientScopes = scope . attributes . spontaneousClientScopes
109
+ result [ 'attributes' ] . showInConfigurationEndpoint =
110
+ scope . attributes . showInConfigurationEndpoint
111
+ result [ 'attributes' ] . spontaneousClientId =
112
+ scope . attributes . spontaneousClientId
113
+ result [ 'attributes' ] . spontaneousClientScopes =
114
+ scope . spontaneousClientScopes
112
115
handleSubmit ( JSON . stringify ( result ) )
113
116
} }
114
117
>
@@ -256,7 +259,10 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
256
259
defaultValue = { scope . attributes . spontaneousClientId }
257
260
onChange = { ( e ) => {
258
261
scope . attributes . spontaneousClientId = e . target . value
259
- formik . setFieldValue ( 'spontaneousClientId' , e . target . value )
262
+ formik . setFieldValue (
263
+ 'spontaneousClientId' ,
264
+ e . target . value ,
265
+ )
260
266
} }
261
267
/>
262
268
</ Col >
@@ -281,8 +287,12 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
281
287
scope . attributes . showInConfigurationEndpoint
282
288
}
283
289
onChange = { ( e ) => {
284
- scope . attributes . showInConfigurationEndpoint = e . target . value
285
- formik . setFieldValue ( 'showInConfigurationEndpoint' , e . target . value )
290
+ scope . attributes . showInConfigurationEndpoint =
291
+ e . target . value
292
+ formik . setFieldValue (
293
+ 'showInConfigurationEndpoint' ,
294
+ e . target . value ,
295
+ )
286
296
} }
287
297
>
288
298
< option value = "true" > { t ( 'options.true' ) } </ option >
@@ -297,10 +307,11 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
297
307
label = "fields.spontaneous_client_scopes"
298
308
formik = { formik }
299
309
value = { getMapping (
300
- scope . attributes . spontaneousClientScopes ,
301
310
spontaneousClientScopes ,
311
+ scope . attributes . spontaneousClientScopes . map ( ( item ) => ( { dn : item || "" , name : item || "" } ) ) ,
302
312
) }
303
- options = { spontaneousClientScopes }
313
+ allowNew = { true }
314
+ options = { spontaneousClientScopes . map ( ( item ) => ( { dn : item || "" , name : item || "" } ) ) }
304
315
doc_category = { SCOPE }
305
316
/>
306
317
</ Accordion . Body >
0 commit comments