@@ -51,6 +51,8 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
51
51
const selectedTheme = theme . state . theme
52
52
const themeColors = getThemeColor ( selectedTheme )
53
53
const bgThemeColor = { background : themeColors . background }
54
+ const [ scopeClients , setScopeClients ] = useState ( )
55
+ const [ haveINUMParam ] = useState ( search . indexOf ( '?inum=' ) > - 1 )
54
56
55
57
SetTitle ( t ( 'titles.oidc_clients' ) )
56
58
@@ -129,23 +131,25 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
129
131
) ,
130
132
} ,
131
133
]
134
+
132
135
useEffect ( ( ) => {
133
- makeOptions ( )
134
- buildPayload ( userAction , FETCHING_OIDC_CLIENTS , options )
135
- dispatch ( getOpenidClients ( userAction ) )
136
- } , [ ] )
137
- useEffect ( ( ) => {
138
- buildPayload ( userAction , '' , options )
139
- dispatch ( getScopes ( userAction ) )
140
- } , [ ] )
141
- useEffect ( ( ) => {
142
- if ( search . indexOf ( '?inum=' ) > - 1 ) {
136
+ if ( haveINUMParam ) {
143
137
const inumParam = search . replace ( '?inum=' , '' )
144
- const searchInput = document . getElementsByClassName ( 'MuiInputBase-inputAdornedStart' ) [ 0 ]
138
+
139
+ if ( inumParam . length > 0 ) {
140
+ const clientsScope = scopes . find ( ( { inum } ) => inum === inumParam ) ?. clients || [ ]
141
+ setScopeClients ( clientsScope )
142
+ }
143
+ } else {
144
+ makeOptions ( )
145
+ buildPayload ( userAction , FETCHING_OIDC_CLIENTS , options )
146
+ dispatch ( getOpenidClients ( userAction ) )
145
147
146
- searchInput . value = inumParam
148
+ buildPayload ( userAction , '' , options )
149
+ dispatch ( getScopes ( userAction ) )
147
150
}
148
- } , [ ] )
151
+ } , [ haveINUMParam ] )
152
+
149
153
function handleOptionsChange ( event ) {
150
154
if ( event . target . name == 'limit' ) {
151
155
memoLimit = event . target . value
@@ -256,14 +260,6 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
256
260
onClick : ( ) => handleGoToClientAddPage ( ) ,
257
261
} )
258
262
}
259
- //ToDo to be deleted
260
- function getBadgeTheme ( status ) {
261
- if ( ! status ) {
262
- return 'primary'
263
- } else {
264
- return 'warning'
265
- }
266
- }
267
263
268
264
function getTrustedTheme ( status ) {
269
265
if ( status ) {
@@ -272,14 +268,6 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
272
268
return 'dimmed'
273
269
}
274
270
}
275
- //ToDo to be deleted
276
- function getClientStatus ( status ) {
277
- if ( ! status ) {
278
- return t ( 'options.enabled' )
279
- } else {
280
- return t ( 'options.disabled' )
281
- }
282
- }
283
271
284
272
return (
285
273
< Card style = { applicationStyle . mainCard } >
@@ -295,7 +283,7 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
295
283
Container : ( props ) => < Paper { ...props } elevation = { 0 } /> ,
296
284
} }
297
285
columns = { tableColumns }
298
- data = { clients }
286
+ data = { haveINUMParam ? scopeClients : clients }
299
287
isLoading = { loading }
300
288
title = ""
301
289
actions = { myActions }
0 commit comments