Skip to content

Commit f341b7f

Browse files
committed
feat(admin-ui): list OIDC according to ticket 204
1 parent 54a3eef commit f341b7f

File tree

2 files changed

+88
-14
lines changed

2 files changed

+88
-14
lines changed

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

+55-14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useHistory } from 'react-router-dom'
55
import { connect } from 'react-redux'
66
import { Paper } from '@material-ui/core'
77
import { Card, CardBody, FormGroup, Badge } from '../../../../app/components'
8+
import { getScopes } from '../../redux/actions/ScopeActions'
89
import GluuRibbon from '../../../../app/routes/Apps/Gluu/GluuRibbon'
910
import GluuDialog from '../../../../app/routes/Apps/Gluu/GluuDialog'
1011
import ClientDetailPage from '../Clients/ClientDetailPage'
@@ -34,6 +35,7 @@ import {
3435
CLIENT_READ,
3536
CLIENT_DELETE,
3637
} from '../../../../app/utils/PermChecker'
38+
import ClientShowScopes from './ClientShowScopes'
3739

3840
function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
3941
const { t } = useTranslation()
@@ -43,6 +45,10 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
4345
const history = useHistory()
4446
const pageSize = localStorage.getItem('paggingSize') || 10
4547

48+
const [scopesModal, setScopesModal] = useState({
49+
data: [],
50+
show: false,
51+
})
4652
const [limit, setLimit] = useState(200)
4753
const [pattern, setPattern] = useState(null)
4854
const [item, setItem] = useState({})
@@ -52,6 +58,18 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
5258
let memoLimit = limit
5359
let memoPattern = pattern
5460

61+
const handler = () => {
62+
setScopesModal({
63+
data: [],
64+
show: false,
65+
})
66+
}
67+
const setScopeData = (data) => {
68+
setScopesModal({
69+
data: data,
70+
show: true,
71+
})
72+
}
5573
const tableColumns = [
5674
{
5775
title: `${t('fields.inum')}`,
@@ -60,21 +78,35 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
6078
sorting: true,
6179
searchable: true,
6280
},
81+
{ title: `${t('fields.client_id')}`, field: 'inum' },
6382
{ title: `${t('fields.client_name')}`, field: 'displayName' },
6483
{
65-
title: `${t('fields.application_type')}`,
66-
field: 'applicationType',
84+
title: `${t('fields.grant_types')}`,
85+
field: 'grantTypes',
86+
render: (rowData) => {
87+
return rowData.grantTypes.map((data) => {
88+
return (
89+
<div style={{ maxWidth: 120, overflow: 'auto' }}>
90+
<Badge color="primary">{data}</Badge>
91+
</div>
92+
)
93+
})
94+
},
6795
},
68-
{ title: `${t('fields.subject_type')}`, field: 'subjectType' },
6996
{
70-
title: `${t('fields.status')}`,
71-
field: 'disabled',
72-
type: 'boolean',
73-
render: (rowData) => (
74-
<Badge color={getBadgeTheme(rowData.disabled)}>
75-
{getClientStatus(rowData.disabled)}
76-
</Badge>
77-
),
97+
title: `${t('fields.scopes')}`,
98+
field: 'scopes',
99+
render: (rowData) => {
100+
return (
101+
<Badge
102+
color="primary"
103+
role={'button'}
104+
onClick={() => setScopeData(rowData.scopes)}
105+
>
106+
{rowData.scopes?.length || '0'}
107+
</Badge>
108+
)
109+
},
78110
},
79111
{
80112
title: `${t('fields.is_trusted_client')}`,
@@ -92,6 +124,10 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
92124
buildPayload(userAction, FETCHING_OIDC_CLIENTS, options)
93125
dispatch(getOpenidClients(userAction))
94126
}, [])
127+
useEffect(() => {
128+
buildPayload(userAction, '', options)
129+
dispatch(getScopes(userAction))
130+
}, [])
95131
function handleOptionsChange(event) {
96132
if (event.target.name == 'limit') {
97133
memoLimit = event.target.value
@@ -162,8 +198,6 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
162198
iconProps: { color: 'primary' },
163199
isFreeAction: true,
164200
onClick: () => {
165-
// setLimit(memoLimit)
166-
// setPattern(memoLimit)
167201
makeOptions()
168202
buildPayload(userAction, SEARCHING_OIDC_CLIENTS, options)
169203
dispatch(searchClients(userAction))
@@ -204,7 +238,7 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
204238
onClick: () => handleGoToClientAddPage(),
205239
})
206240
}
207-
241+
//ToDo to be deleted
208242
function getBadgeTheme(status) {
209243
if (!status) {
210244
return 'primary'
@@ -220,15 +254,22 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
220254
return 'info'
221255
}
222256
}
257+
//ToDo to be deleted
223258
function getClientStatus(status) {
224259
if (!status) {
225260
return t('options.enabled')
226261
} else {
227262
return t('options.disabled')
228263
}
229264
}
265+
230266
return (
231267
<Card>
268+
<ClientShowScopes
269+
handler={handler}
270+
isOpen={scopesModal.show}
271+
data={scopesModal.data}
272+
/>
232273
<GluuRibbon title={t('titles.oidc_clients')} fromLeft />
233274
<CardBody>
234275
<FormGroup row />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react'
2+
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'
3+
import { Badge } from '../../../../app/components'
4+
import { useSelector } from 'react-redux'
5+
6+
function ClientShowScopes({ handler, data, isOpen }) {
7+
const scopes = useSelector((state) => state.scopeReducer.items)
8+
const clientScopes = scopes
9+
.filter((item) => data.includes(item.dn, 0))
10+
.map((item) => item.id)
11+
return (
12+
<Modal isOpen={isOpen} toggle={handler} className="modal-outline-primary">
13+
<ModalHeader>Scopes</ModalHeader>
14+
<ModalBody>
15+
{clientScopes.map((scope, key) => {
16+
return (
17+
<div>
18+
<Badge color="primary" key={key}>
19+
{scope}
20+
</Badge>
21+
</div>
22+
)
23+
})}
24+
</ModalBody>
25+
<ModalFooter>
26+
<Button color="secondary" onClick={handler}>
27+
Close
28+
</Button>
29+
</ModalFooter>
30+
</Modal>
31+
)
32+
}
33+
export default ClientShowScopes

0 commit comments

Comments
 (0)