Skip to content

Commit

Permalink
feat(admin-ui): get clients from scope api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
harryandriyan committed Aug 2, 2022
1 parent 511b549 commit 73d0ea3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
1 change: 1 addition & 0 deletions admin-ui/plugins/auth-server/common/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const TYPE_ID = 'typeId'
export const LIMIT = 'limit'
export const TYPE = 'type'
export const PATTERN = 'pattern'
export const WITH_ASSOCIATED_CLIENTS = 'withAssociatedClients'

export const SEARCHING_OIDC_CLIENTS = 'Search openid connect clients'
export const FETCHING_OIDC_CLIENTS = 'Fetch openid connect clients'
Expand Down
29 changes: 10 additions & 19 deletions admin-ui/plugins/auth-server/components/Scopes/ScopeListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import {
deleteScope,
setCurrentItem,
} from 'Plugins/auth-server/redux/actions/ScopeActions'
import {
getOpenidClients,
} from 'Plugins/auth-server/redux/actions/OIDCActions'
import {
hasPermission,
buildPayload,
Expand All @@ -36,13 +33,13 @@ import {
PATTERN_ID,
SEARCHING_SCOPES,
FETCHING_SCOPES,
FETCHING_OIDC_CLIENTS,
WITH_ASSOCIATED_CLIENTS,
} from 'Plugins/auth-server/common/Constants'
import SetTitle from 'Utils/SetTitle'
import { ThemeContext } from 'Context/theme/themeContext'
import getThemeColor from 'Context/theme/config'

function ScopeListPage({ scopes, permissions, loading, dispatch, clients }) {
function ScopeListPage({ scopes, permissions, loading, dispatch }) {
const { t } = useTranslation()
const userAction = {}
const options = {}
Expand Down Expand Up @@ -71,16 +68,14 @@ function ScopeListPage({ scopes, permissions, loading, dispatch, clients }) {
title: `${t('fields.openid')}`,
field: 'dn',
render: (rowData) => {
if (clients.length !== 0) {
const countClient = clients?.filter(({ scopes }) => scopes?.some(inum => inum === rowData.dn)).length
return (
<Link to={`/auth-server/clients?inum=${rowData.dn}`} style={{ color: '#3f51b5' }}>
{countClient}
</Link>
)
if (!rowData.clients) {
return 0
}

return null
return (
<Link to={`/auth-server/clients?inum=${rowData.inum}`} style={{ color: '#3f51b5' }}>
{rowData.clients?.length}
</Link>
)
},
},
{ title: `${t('fields.description')}`, field: 'description' },
Expand All @@ -99,10 +94,6 @@ function ScopeListPage({ scopes, permissions, loading, dispatch, clients }) {
makeOptions()
buildPayload(userAction, FETCHING_SCOPES, options)
dispatch(getScopes(userAction))

makeClientOptions()
buildPayload(userAction, FETCHING_OIDC_CLIENTS, clientOptions)
dispatch(getOpenidClients(userAction))
}, [])

function handleOptionsChange(event) {
Expand All @@ -117,6 +108,7 @@ function ScopeListPage({ scopes, permissions, loading, dispatch, clients }) {
setLimit(memoLimit)
setPattern(memoPattern)
options[LIMIT] = memoLimit
options[WITH_ASSOCIATED_CLIENTS] = true
if (memoPattern) {
options[PATTERN] = memoPattern
}
Expand Down Expand Up @@ -258,7 +250,6 @@ function ScopeListPage({ scopes, permissions, loading, dispatch, clients }) {
const mapStateToProps = (state) => {
return {
scopes: state.scopeReducer.items,
clients: state.oidcReducer.items,
loading: state.scopeReducer.loading,
permissions: state.authReducer.permissions,
}
Expand Down

0 comments on commit 73d0ea3

Please sign in to comment.