Skip to content

Commit

Permalink
feat(admin-ui): update count style and url param
Browse files Browse the repository at this point in the history
  • Loading branch information
harryandriyan committed Aug 4, 2022
1 parent 28bf678 commit 8134ce9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
const themeColors = getThemeColor(selectedTheme)
const bgThemeColor = { background: themeColors.background }
const [scopeClients, setScopeClients] = useState()
const [haveINUMParam] = useState(search.indexOf('?inum=') > -1)
const [haveScopeINUMParam] = useState(search.indexOf('?scopeInum=') > -1)

SetTitle(t('titles.oidc_clients'))

Expand Down Expand Up @@ -133,11 +133,11 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
]

useEffect(() => {
if (haveINUMParam) {
const inumParam = search.replace('?inum=', '')
if (haveScopeINUMParam) {
const scopeInumParam = search.replace('?scopeInum=', '')

if (inumParam.length > 0) {
const clientsScope = scopes.find(({ inum }) => inum === inumParam)?.clients || []
if (scopeInumParam.length > 0) {
const clientsScope = scopes.find(({ inum }) => inum === scopeInumParam)?.clients || []
setScopeClients(clientsScope)
}
} else {
Expand All @@ -148,7 +148,7 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
buildPayload(userAction, '', options)
dispatch(getScopes(userAction))
}
}, [haveINUMParam])
}, [haveScopeINUMParam])

function handleOptionsChange(event) {
if (event.target.name == 'limit') {
Expand Down Expand Up @@ -283,7 +283,7 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
Container: (props) => <Paper {...props} elevation={0} />,
}}
columns={tableColumns}
data={haveINUMParam ? scopeClients : clients}
data={haveScopeINUMParam ? scopeClients : clients}
isLoading={loading}
title=""
actions={myActions}
Expand Down
20 changes: 16 additions & 4 deletions admin-ui/plugins/auth-server/components/Scopes/ScopeListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,27 @@ function ScopeListPage({ scopes, permissions, loading, dispatch }) {
const tableColumns = [
{ title: `${t('fields.id')}`, field: 'id' },
{
title: `${t('fields.openid')}`,
title: `${t('menus.clients')}`,
field: 'dn',
render: (rowData) => {
if (!rowData.clients) {
return 0
return (
<Badge
color={`primary-${selectedTheme}`}
role={'button'}
>
0
</Badge>
)
}
return (
<Link to={`/auth-server/clients?inum=${rowData.inum}`} style={{ color: '#3f51b5' }}>
{rowData.clients?.length}
<Link to={`/auth-server/clients?scopeInum=${rowData.inum}`} style={{ color: '#3f51b5', textDecoration: 'underline' }}>
<Badge
color={`primary-${selectedTheme}`}
role={'button'}
>
{rowData.clients?.length}
</Badge>
</Link>
)
},
Expand Down

0 comments on commit 8134ce9

Please sign in to comment.