Skip to content

Commit 28bf678

Browse files
committed
feat(admin-ui): show client of scope in client list page
1 parent 73d0ea3 commit 28bf678

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

admin-ui/plugins/auth-server/components/Clients/ClientListPage.js

+18-30
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
5151
const selectedTheme = theme.state.theme
5252
const themeColors = getThemeColor(selectedTheme)
5353
const bgThemeColor = { background: themeColors.background }
54+
const [scopeClients, setScopeClients] = useState()
55+
const [haveINUMParam] = useState(search.indexOf('?inum=') > -1)
5456

5557
SetTitle(t('titles.oidc_clients'))
5658

@@ -129,23 +131,25 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
129131
),
130132
},
131133
]
134+
132135
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) {
143137
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))
145147

146-
searchInput.value = inumParam
148+
buildPayload(userAction, '', options)
149+
dispatch(getScopes(userAction))
147150
}
148-
}, [])
151+
}, [haveINUMParam])
152+
149153
function handleOptionsChange(event) {
150154
if (event.target.name == 'limit') {
151155
memoLimit = event.target.value
@@ -256,14 +260,6 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
256260
onClick: () => handleGoToClientAddPage(),
257261
})
258262
}
259-
//ToDo to be deleted
260-
function getBadgeTheme(status) {
261-
if (!status) {
262-
return 'primary'
263-
} else {
264-
return 'warning'
265-
}
266-
}
267263

268264
function getTrustedTheme(status) {
269265
if (status) {
@@ -272,14 +268,6 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
272268
return 'dimmed'
273269
}
274270
}
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-
}
283271

284272
return (
285273
<Card style={applicationStyle.mainCard}>
@@ -295,7 +283,7 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
295283
Container: (props) => <Paper {...props} elevation={0} />,
296284
}}
297285
columns={tableColumns}
298-
data={clients}
286+
data={haveINUMParam ? scopeClients : clients}
299287
isLoading={loading}
300288
title=""
301289
actions={myActions}

0 commit comments

Comments
 (0)