@@ -5,6 +5,7 @@ import { useHistory } from 'react-router-dom'
5
5
import { connect } from 'react-redux'
6
6
import { Paper } from '@material-ui/core'
7
7
import { Card , CardBody , FormGroup , Badge } from '../../../../app/components'
8
+ import { getScopes } from '../../redux/actions/ScopeActions'
8
9
import GluuRibbon from '../../../../app/routes/Apps/Gluu/GluuRibbon'
9
10
import GluuDialog from '../../../../app/routes/Apps/Gluu/GluuDialog'
10
11
import ClientDetailPage from '../Clients/ClientDetailPage'
@@ -34,6 +35,7 @@ import {
34
35
CLIENT_READ ,
35
36
CLIENT_DELETE ,
36
37
} from '../../../../app/utils/PermChecker'
38
+ import ClientShowScopes from './ClientShowScopes'
37
39
38
40
function ClientListPage ( { clients, permissions, scopes, loading, dispatch } ) {
39
41
const { t } = useTranslation ( )
@@ -43,6 +45,10 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
43
45
const history = useHistory ( )
44
46
const pageSize = localStorage . getItem ( 'paggingSize' ) || 10
45
47
48
+ const [ scopesModal , setScopesModal ] = useState ( {
49
+ data : [ ] ,
50
+ show : false ,
51
+ } )
46
52
const [ limit , setLimit ] = useState ( 200 )
47
53
const [ pattern , setPattern ] = useState ( null )
48
54
const [ item , setItem ] = useState ( { } )
@@ -52,6 +58,18 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
52
58
let memoLimit = limit
53
59
let memoPattern = pattern
54
60
61
+ const handler = ( ) => {
62
+ setScopesModal ( {
63
+ data : [ ] ,
64
+ show : false ,
65
+ } )
66
+ }
67
+ const setScopeData = ( data ) => {
68
+ setScopesModal ( {
69
+ data : data ,
70
+ show : true ,
71
+ } )
72
+ }
55
73
const tableColumns = [
56
74
{
57
75
title : `${ t ( 'fields.inum' ) } ` ,
@@ -60,21 +78,35 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
60
78
sorting : true ,
61
79
searchable : true ,
62
80
} ,
81
+ { title : `${ t ( 'fields.client_id' ) } ` , field : 'inum' } ,
63
82
{ title : `${ t ( 'fields.client_name' ) } ` , field : 'displayName' } ,
64
83
{
65
- title : `${ t ( 'fields.application_type' ) } ` ,
66
- field : 'applicationType' ,
84
+ title : `${ t ( 'fields.grant_types' ) } ` ,
85
+ field : 'grantTypes' ,
86
+ render : ( rowData ) => {
87
+ return rowData . grantTypes . map ( ( data ) => {
88
+ return (
89
+ < div style = { { maxWidth : 120 , overflow : 'auto' } } >
90
+ < Badge color = "primary" > { data } </ Badge >
91
+ </ div >
92
+ )
93
+ } )
94
+ } ,
67
95
} ,
68
- { title : `${ t ( 'fields.subject_type' ) } ` , field : 'subjectType' } ,
69
96
{
70
- title : `${ t ( 'fields.status' ) } ` ,
71
- field : 'disabled' ,
72
- type : 'boolean' ,
73
- render : ( rowData ) => (
74
- < Badge color = { getBadgeTheme ( rowData . disabled ) } >
75
- { getClientStatus ( rowData . disabled ) }
76
- </ Badge >
77
- ) ,
97
+ title : `${ t ( 'fields.scopes' ) } ` ,
98
+ field : 'scopes' ,
99
+ render : ( rowData ) => {
100
+ return (
101
+ < Badge
102
+ color = "primary"
103
+ role = { 'button' }
104
+ onClick = { ( ) => setScopeData ( rowData . scopes ) }
105
+ >
106
+ { rowData . scopes ?. length || '0' }
107
+ </ Badge >
108
+ )
109
+ } ,
78
110
} ,
79
111
{
80
112
title : `${ t ( 'fields.is_trusted_client' ) } ` ,
@@ -92,6 +124,10 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
92
124
buildPayload ( userAction , FETCHING_OIDC_CLIENTS , options )
93
125
dispatch ( getOpenidClients ( userAction ) )
94
126
} , [ ] )
127
+ useEffect ( ( ) => {
128
+ buildPayload ( userAction , '' , options )
129
+ dispatch ( getScopes ( userAction ) )
130
+ } , [ ] )
95
131
function handleOptionsChange ( event ) {
96
132
if ( event . target . name == 'limit' ) {
97
133
memoLimit = event . target . value
@@ -162,8 +198,6 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
162
198
iconProps : { color : 'primary' } ,
163
199
isFreeAction : true ,
164
200
onClick : ( ) => {
165
- // setLimit(memoLimit)
166
- // setPattern(memoLimit)
167
201
makeOptions ( )
168
202
buildPayload ( userAction , SEARCHING_OIDC_CLIENTS , options )
169
203
dispatch ( searchClients ( userAction ) )
@@ -204,7 +238,7 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
204
238
onClick : ( ) => handleGoToClientAddPage ( ) ,
205
239
} )
206
240
}
207
-
241
+ //ToDo to be deleted
208
242
function getBadgeTheme ( status ) {
209
243
if ( ! status ) {
210
244
return 'primary'
@@ -220,15 +254,22 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
220
254
return 'info'
221
255
}
222
256
}
257
+ //ToDo to be deleted
223
258
function getClientStatus ( status ) {
224
259
if ( ! status ) {
225
260
return t ( 'options.enabled' )
226
261
} else {
227
262
return t ( 'options.disabled' )
228
263
}
229
264
}
265
+
230
266
return (
231
267
< Card >
268
+ < ClientShowScopes
269
+ handler = { handler }
270
+ isOpen = { scopesModal . show }
271
+ data = { scopesModal . data }
272
+ />
232
273
< GluuRibbon title = { t ( 'titles.oidc_clients' ) } fromLeft />
233
274
< CardBody >
234
275
< FormGroup row />
0 commit comments