1
- import React , { useState } from 'react'
1
+ import React , { useState , useContext } from 'react'
2
2
import Box from '@material-ui/core/Box'
3
3
import { Link } from 'react-router-dom'
4
- import { Col , Container , FormGroup } from 'Components'
4
+ import {
5
+ Button ,
6
+ Modal ,
7
+ ModalHeader ,
8
+ ModalBody ,
9
+ ModalFooter ,
10
+ } from 'reactstrap'
11
+ import isEmpty from 'lodash/isEmpty'
12
+ import { useTranslation } from 'react-i18next'
13
+ import { connect } from 'react-redux'
14
+ import moment from 'moment'
15
+ import { Card , Col , Container , FormGroup } from 'Components'
5
16
import GluuLabel from 'Routes/Apps/Gluu/GluuLabel'
6
17
import GluuSelectRow from 'Routes/Apps/Gluu/GluuSelectRow'
7
18
import GluuToogleRow from 'Routes/Apps/Gluu/GluuToogleRow'
8
19
import GluuInputRow from 'Routes/Apps/Gluu/GluuInputRow'
9
20
import GluuTypeAheadWithAdd from 'Routes/Apps/Gluu/GluuTypeAheadWithAdd'
10
- import { useTranslation } from 'react-i18next '
21
+ import { getScope } from 'Plugins/auth-server/redux/actions/ScopeActions '
11
22
import { FormControlLabel , Radio , RadioGroup } from '@material-ui/core'
12
23
import GluuTypeAheadForDn from 'Routes/Apps/Gluu/GluuTypeAheadForDn'
24
+ import { ThemeContext } from 'Context/theme/themeContext'
25
+ import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle'
13
26
const DOC_CATEGORY = 'openid_client'
14
27
15
- function ClientCibaParUmaPanel ( { client, umaResources, scripts, formik } ) {
28
+ function ClientCibaParUmaPanel ( { client, dispatch , scope , umaResources, scripts, formik } ) {
16
29
const { t } = useTranslation ( )
30
+ const theme = useContext ( ThemeContext )
31
+ const selectedTheme = theme . state . theme
17
32
const claim_uri_id = 'claim_uri_id'
18
33
19
34
const cibaDeliveryModes = [ 'poll' , 'push' , 'ping' ]
@@ -27,31 +42,28 @@ function ClientCibaParUmaPanel({ client, umaResources, scripts, formik }) {
27
42
function uriValidator ( uri ) {
28
43
return uri
29
44
}
30
- function getMapping ( partial , total ) {
31
- if ( ! partial ) {
32
- partial = [ ]
33
- }
34
- return total . filter ( ( item ) => partial . includes ( item . dn ) )
35
- }
45
+
36
46
const [ softwareSection , setSoftwareSection ] = useState ( false )
37
47
const [ cibaSection , setCibaSection ] = useState ( false )
48
+ const [ open , setOpen ] = useState ( false )
49
+ const [ selectedUMA , setSelectedUMA ] = useState ( )
50
+ const [ scopeExpression , setScopeExpression ] = useState ( )
38
51
39
52
const rptScripts = scripts
40
53
. filter ( ( item ) => item . scriptType == 'UMA_RPT_CLAIMS' )
41
54
. filter ( ( item ) => item . enabled )
42
55
. map ( ( item ) => ( { dn : item . dn , name : item . name } ) )
43
56
44
- function handleCibaSection ( ) {
45
- setCibaSection ( ! cibaSection )
46
- }
47
- function handleSoftwareSection ( ) {
48
- setSoftwareSection ( ! softwareSection )
49
- }
50
- function emailValidator ( email ) {
51
- return / ^ [ a - z A - Z 0 - 9 . ! # $ % & ' * + / = ? ^ _ ` { | } ~ - ] + @ [ a - z A - Z 0 - 9 - ] + (?: \. [ a - z A - Z 0 - 9 - ] + ) * $ / . test (
52
- email ,
53
- )
57
+ const handleUMADetail = ( uma ) => {
58
+ if ( ! isEmpty ( uma ) ) {
59
+ setSelectedUMA ( uma )
60
+ setScopeExpression ( JSON . parse ( uma . scopeExpression ) ?. data )
61
+ dispatch ( getScope ( uma . inum ) )
62
+ }
63
+
64
+ setOpen ( true )
54
65
}
66
+
55
67
return (
56
68
< Container >
57
69
< h2 > { t ( `titles.CIBA` ) } </ h2 >
@@ -151,19 +163,129 @@ function ClientCibaParUmaPanel({ client, umaResources, scripts, formik }) {
151
163
return (
152
164
< Box key = { uma . id } >
153
165
< Box display = "flex" >
154
- < Box >
155
- < Link to = { `/auth-server/client/uma/${ uma . id } ` } className = "common-link" >
156
- { uma . id }
157
- </ Link >
166
+ < Box className = "common-link cursor-pointer" onClick = { ( ) => handleUMADetail ( uma ) } >
167
+ { uma . id }
158
168
</ Box >
159
169
</ Box >
160
170
</ Box >
161
171
)
162
172
} ) }
163
173
</ Col >
164
174
</ FormGroup >
175
+ < Modal
176
+ isOpen = { open }
177
+ toggle = { ( ) => setOpen ( ! open ) }
178
+ size = "lg"
179
+ className = "modal-outline-primary"
180
+ >
181
+ < ModalHeader toggle = { ( ) => setOpen ( ! open ) } >
182
+ UMA Resource Detail
183
+ </ ModalHeader >
184
+ < ModalBody >
185
+ < Card style = { applicationStyle . mainCard } >
186
+ < h2 > UMA Resource Detail</ h2 >
187
+ < FormGroup row >
188
+ < GluuLabel label = { t ( 'fields.resourceId' ) } size = { 3 } />
189
+ < Col sm = { 9 } className = "top-5" >
190
+ { selectedUMA ?. id }
191
+ </ Col >
192
+ </ FormGroup >
193
+ < FormGroup row >
194
+ < GluuLabel label = { t ( 'fields.displayname' ) } size = { 3 } />
195
+ < Col sm = { 9 } className = "top-5" >
196
+ { selectedUMA ?. name }
197
+ </ Col >
198
+ </ FormGroup >
199
+ < FormGroup row >
200
+ < GluuLabel label = { t ( 'fields.iconUrl' ) } size = { 3 } />
201
+ < Col sm = { 9 } className = "top-5" >
202
+ { ! isEmpty ( scope ) && (
203
+ < a href = { scope ?. iconUrl } target = "_blank" alt = "iconUrl" className = "common-link" rel = "noreferrer" >
204
+ { scope ?. iconUrl }
205
+ </ a >
206
+ ) }
207
+ </ Col >
208
+ </ FormGroup >
209
+ < FormGroup row >
210
+ < GluuLabel label = { t ( 'fields.scopeSelection' ) } size = { 3 } />
211
+ < Col sm = { 9 } className = "top-5" >
212
+ < RadioGroup
213
+ row
214
+ name = "scopeSelection"
215
+ value = { true }
216
+ >
217
+ < FormControlLabel
218
+ value = { true }
219
+ control = { < Radio color = "primary" /> }
220
+ label = { t ( 'fields.scope' ) }
221
+ checked = { true }
222
+ />
223
+ < FormControlLabel
224
+ value = { false }
225
+ control = { < Radio color = "primary" /> }
226
+ label = { t ( 'fields.scopeExpression' ) }
227
+ checked = { false }
228
+ />
229
+ </ RadioGroup >
230
+ </ Col >
231
+ </ FormGroup >
232
+ < FormGroup row >
233
+ < GluuLabel label = { t ( 'fields.scopeSelection' ) } size = { 3 } />
234
+ < Col sm = { 9 } className = "top-5" >
235
+ { ! isEmpty ( scopeExpression ) && scopeExpression . map ( ( expression , key ) => (
236
+ < Box key = { key } >
237
+ < Box display = "flex" >
238
+ < a href = { expression } target = "_blank" alt = "scope expression" className = "common-link" rel = "noreferrer" >
239
+ { expression }
240
+ </ a >
241
+ </ Box >
242
+ </ Box >
243
+ ) ) }
244
+ </ Col >
245
+ </ FormGroup >
246
+ < FormGroup row >
247
+ < GluuLabel label = { t ( 'fields.associatedClient' ) } size = { 3 } />
248
+ < Col sm = { 9 } className = "top-5" >
249
+ { ! isEmpty ( scope ) && scope . clients ?. map ( ( client , key ) => (
250
+ < Box key = { key } >
251
+ < Box display = "flex" >
252
+ < Link to = { `/auth-server/client/edit:${ client . inum . substring ( 0 , 4 ) } ` } className = "common-link" >
253
+ { client . inum }
254
+ </ Link >
255
+ </ Box >
256
+ </ Box >
257
+ ) ) }
258
+ </ Col >
259
+ </ FormGroup >
260
+ < FormGroup row >
261
+ < GluuLabel label = { t ( 'fields.creationTime' ) } size = { 3 } />
262
+ < Col sm = { 9 } className = "top-5" >
263
+ { moment ( selectedUMA ?. creationDate ) . format ( "ddd, MMM DD, YYYY h:mm:ss A" ) }
264
+ </ Col >
265
+ </ FormGroup >
266
+ </ Card >
267
+ </ ModalBody >
268
+ < ModalFooter >
269
+ < Button
270
+ color = { `primary-${ selectedTheme } ` }
271
+ style = { applicationStyle . buttonStyle }
272
+ onClick = { ( ) => setOpen ( ! open ) }
273
+ >
274
+ { t ( 'actions.close' ) }
275
+ </ Button >
276
+ </ ModalFooter >
277
+ </ Modal >
165
278
</ Container >
166
279
)
167
280
}
168
281
169
- export default ClientCibaParUmaPanel
282
+ const mapStateToProps = ( state ) => {
283
+ return {
284
+ clientData : state . oidcReducer . item ,
285
+ loading : state . oidcReducer . loading ,
286
+ scope : state . scopeReducer . item ,
287
+ umaResources : state . oidcReducer . umaResources ,
288
+ }
289
+ }
290
+ export default connect ( mapStateToProps ) ( ClientCibaParUmaPanel )
291
+
0 commit comments