Skip to content

Commit

Permalink
feat(admin-ui): show client of scope in client list page
Browse files Browse the repository at this point in the history
  • Loading branch information
harryandriyan committed Aug 3, 2022
1 parent 73d0ea3 commit 28bf678
Showing 1 changed file with 18 additions and 30 deletions.
48 changes: 18 additions & 30 deletions admin-ui/plugins/auth-server/components/Clients/ClientListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
const selectedTheme = theme.state.theme
const themeColors = getThemeColor(selectedTheme)
const bgThemeColor = { background: themeColors.background }
const [scopeClients, setScopeClients] = useState()
const [haveINUMParam] = useState(search.indexOf('?inum=') > -1)

SetTitle(t('titles.oidc_clients'))

Expand Down Expand Up @@ -129,23 +131,25 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
),
},
]

useEffect(() => {
makeOptions()
buildPayload(userAction, FETCHING_OIDC_CLIENTS, options)
dispatch(getOpenidClients(userAction))
}, [])
useEffect(() => {
buildPayload(userAction, '', options)
dispatch(getScopes(userAction))
}, [])
useEffect(() => {
if (search.indexOf('?inum=') > -1) {
if (haveINUMParam) {
const inumParam = search.replace('?inum=', '')
const searchInput = document.getElementsByClassName('MuiInputBase-inputAdornedStart')[0]

if (inumParam.length > 0) {
const clientsScope = scopes.find(({ inum }) => inum === inumParam)?.clients || []
setScopeClients(clientsScope)
}
} else {
makeOptions()
buildPayload(userAction, FETCHING_OIDC_CLIENTS, options)
dispatch(getOpenidClients(userAction))

searchInput.value = inumParam
buildPayload(userAction, '', options)
dispatch(getScopes(userAction))
}
}, [])
}, [haveINUMParam])

function handleOptionsChange(event) {
if (event.target.name == 'limit') {
memoLimit = event.target.value
Expand Down Expand Up @@ -256,14 +260,6 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
onClick: () => handleGoToClientAddPage(),
})
}
//ToDo to be deleted
function getBadgeTheme(status) {
if (!status) {
return 'primary'
} else {
return 'warning'
}
}

function getTrustedTheme(status) {
if (status) {
Expand All @@ -272,14 +268,6 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
return 'dimmed'
}
}
//ToDo to be deleted
function getClientStatus(status) {
if (!status) {
return t('options.enabled')
} else {
return t('options.disabled')
}
}

return (
<Card style={applicationStyle.mainCard}>
Expand All @@ -295,7 +283,7 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
Container: (props) => <Paper {...props} elevation={0} />,
}}
columns={tableColumns}
data={clients}
data={haveINUMParam ? scopeClients : clients}
isLoading={loading}
title=""
actions={myActions}
Expand Down

0 comments on commit 28bf678

Please sign in to comment.