@@ -31,21 +31,20 @@ import { SCOPE } from 'Utils/ApiResources'
31
31
import { useTranslation } from 'react-i18next'
32
32
import { ThemeContext } from 'Context/theme/themeContext'
33
33
import { LIMIT , PATTERN } from 'Plugins/auth-server/common/Constants'
34
-
34
+ import moment from 'moment'
35
35
function ScopeForm ( { scope, scripts, attributes, handleSubmit } ) {
36
36
const { t } = useTranslation ( )
37
37
let dynamicScopeScripts = [ ]
38
38
let associatedClients = [ ]
39
39
let umaAuthorizationPolicies = [ ]
40
-
40
+ let associatedClientsSelectedValues = [ ]
41
41
const theme = useContext ( ThemeContext )
42
42
const selectedTheme = theme . state . theme
43
43
const history = useHistory ( )
44
- const spontaneousClientScopes = scope . attributes . spontaneousClientScopes || [ ]
45
44
const dispatch = useDispatch ( )
46
45
const client = scope . clients || [ ]
47
46
48
- // const scripts = useSelector((state) => state.customScriptReducer.items )
47
+ const authReducer = useSelector ( ( state ) => state . authReducer )
49
48
let claims = [ ]
50
49
scripts = scripts || [ ]
51
50
attributes = attributes || [ ]
@@ -59,7 +58,8 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
59
58
. map ( ( item ) => ( { dn : item . dn , name : item . name } ) )
60
59
61
60
associatedClients = client . map ( ( item ) => ( { dn : item . dn , name : item . inum } ) )
62
-
61
+ associatedClientsSelectedValues = client . map ( ( item ) => item . dn )
62
+ console . log ( associatedClients , associatedClientsSelectedValues )
63
63
claims = attributes . map ( ( item ) => ( { dn : item . dn , name : item . displayName } ) )
64
64
65
65
const [ init , setInit ] = useState ( false )
@@ -162,6 +162,8 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
162
162
onSubmit = { ( values ) => {
163
163
const result = Object . assign ( scope , values )
164
164
result [ 'id' ] = result . id
165
+ result [ 'creatorType' ] = 'USER'
166
+ result [ 'creatorId' ] = authReducer . userinfo . inum
165
167
result [ 'attributes' ] . showInConfigurationEndpoint =
166
168
scope . attributes . showInConfigurationEndpoint
167
169
result [ 'attributes' ] . spontaneousClientId =
@@ -366,26 +368,54 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
366
368
/>
367
369
</ Accordion . Body >
368
370
</ Accordion >
369
- < Accordion className = "mb-2 b-primary" initialOpen >
370
- < Accordion . Header className = "text-primary" >
371
- { t ( 'fields.associatedClients' ) . toUpperCase ( ) }
372
- </ Accordion . Header >
373
- < Accordion . Body >
374
- < FormGroup row > </ FormGroup >
375
- < GluuTypeAheadForDn
376
- name = "associatedClients"
377
- label = "fields.associatedClients"
378
- formik = { formik }
379
- value = { getMapping (
380
- scope . associatedClients ,
381
- associatedClients ,
382
- ) }
383
- disabled = { scope . inum ? true : false }
384
- options = { associatedClients }
385
- doc_category = { SCOPE }
386
- />
387
- </ Accordion . Body >
388
- </ Accordion >
371
+ { scope . inum && (
372
+ < >
373
+ < Accordion className = "mb-2 b-primary" initialOpen >
374
+ < Accordion . Header className = "text-primary" >
375
+ { t ( 'fields.associatedClients' ) . toUpperCase ( ) }
376
+ </ Accordion . Header >
377
+ < Accordion . Body >
378
+ < FormGroup row > </ FormGroup >
379
+ < GluuTypeAheadForDn
380
+ name = "associatedClients"
381
+ label = "fields.associatedClients"
382
+ formik = { formik }
383
+ value = { getMapping (
384
+ associatedClientsSelectedValues ,
385
+ associatedClients ,
386
+ ) }
387
+ disabled = { scope . inum ? true : false }
388
+ options = { associatedClients }
389
+ doc_category = { SCOPE }
390
+ />
391
+ </ Accordion . Body >
392
+ </ Accordion >
393
+ < FormGroup row >
394
+ < GluuLabel label = "fields.creationDate" size = { 4 } />
395
+ < Col sm = { 8 } >
396
+ < Input
397
+ defaultValue = { moment ( scope . creationDate ) . format (
398
+ 'YYYY-MM-DD HH:mm:ss' ,
399
+ ) }
400
+ disabled = { true }
401
+ />
402
+ </ Col >
403
+ </ FormGroup >
404
+ < FormGroup row >
405
+ < GluuLabel label = "fields.creatorType" size = { 4 } />
406
+ < Col sm = { 8 } >
407
+ < Input
408
+ defaultValue = {
409
+ [ 'CLIENT' , 'USER' ] . includes ( scope . creatorType )
410
+ ? scope . creatorId || ''
411
+ : scope . creatorType
412
+ }
413
+ disabled = { true }
414
+ />
415
+ </ Col >
416
+ </ FormGroup >
417
+ </ >
418
+ ) }
389
419
</ >
390
420
) }
391
421
{ showSpontaneousPanel && (
@@ -450,7 +480,10 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
450
480
</ Accordion >
451
481
) }
452
482
< FormGroup row > </ FormGroup >
453
- { ! showSpontaneousPanel && ! showUmaPanel && (
483
+ { scope . inum ? (
484
+ ! showSpontaneousPanel &&
485
+ ! showUmaPanel && < GluuCommitFooter saveHandler = { toggle } />
486
+ ) : (
454
487
< GluuCommitFooter saveHandler = { toggle } />
455
488
) }
456
489
0 commit comments