Skip to content

Commit 68f7cb0

Browse files
committed
feat(admin-ui): change uma resource detail page to modal
1 parent 194631d commit 68f7cb0

File tree

7 files changed

+158
-181
lines changed

7 files changed

+158
-181
lines changed

admin-ui/app/locales/en/translation.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"test": "Test",
2222
"view": "View",
2323
"yes": "Yes",
24-
"change_password": "Change Password"
24+
"change_password": "Change Password",
25+
"close": "Close"
2526
},
2627
"dashboard": {
2728
"summary_title": "Actives Users & Access Token Stats",

admin-ui/app/locales/fr/translation.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
"remove": "Supprimer",
8080
"test": "Test",
8181
"view": "Vue",
82-
"yes": "Oui"
82+
"yes": "Oui",
83+
"close": "Fermer"
8384
},
8485
"fields": {
8586
"access_token_signing_alg": "Algorithme de signature de jeton d'accès",

admin-ui/app/locales/pt/translation.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
"remove": "Remover",
7979
"test": "Teste",
8080
"view": "Visualizar",
81-
"yes": "Sim"
81+
"yes": "Sim",
82+
"close": "Fechar"
8283
},
8384
"fields": {
8485
"access_token_signing_alg": "Algoritmo de assinatura de token de acesso",

admin-ui/app/styles/custom/layout.scss

+5
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,9 @@
117117

118118
.common-link {
119119
color: #2767b3
120+
}
121+
122+
.top-5 {
123+
position: relative;
124+
top: 5px;
120125
}

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

+147-25
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1-
import React, { useState } from 'react'
1+
import React, { useState, useContext } from 'react'
22
import Box from '@material-ui/core/Box'
33
import { Link } from 'react-router-dom'
4-
import { Col, Container, FormGroup } from 'Components'
4+
import {
5+
Button,
6+
Modal,
7+
ModalHeader,
8+
ModalBody,
9+
ModalFooter,
10+
} from 'reactstrap'
11+
import isEmpty from 'lodash/isEmpty'
12+
import { useTranslation } from 'react-i18next'
13+
import { connect } from 'react-redux'
14+
import moment from 'moment'
15+
import { Card, Col, Container, FormGroup } from 'Components'
516
import GluuLabel from 'Routes/Apps/Gluu/GluuLabel'
617
import GluuSelectRow from 'Routes/Apps/Gluu/GluuSelectRow'
718
import GluuToogleRow from 'Routes/Apps/Gluu/GluuToogleRow'
819
import GluuInputRow from 'Routes/Apps/Gluu/GluuInputRow'
920
import GluuTypeAheadWithAdd from 'Routes/Apps/Gluu/GluuTypeAheadWithAdd'
10-
import { useTranslation } from 'react-i18next'
21+
import { getScope } from 'Plugins/auth-server/redux/actions/ScopeActions'
1122
import { FormControlLabel, Radio, RadioGroup } from '@material-ui/core'
1223
import GluuTypeAheadForDn from 'Routes/Apps/Gluu/GluuTypeAheadForDn'
24+
import { ThemeContext } from 'Context/theme/themeContext'
25+
import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle'
1326
const DOC_CATEGORY = 'openid_client'
1427

15-
function ClientCibaParUmaPanel({ client, umaResources, scripts, formik }) {
28+
function ClientCibaParUmaPanel({ client, dispatch, scope, umaResources, scripts, formik }) {
1629
const { t } = useTranslation()
30+
const theme = useContext(ThemeContext)
31+
const selectedTheme = theme.state.theme
1732
const claim_uri_id = 'claim_uri_id'
1833

1934
const cibaDeliveryModes = ['poll', 'push', 'ping']
@@ -27,31 +42,28 @@ function ClientCibaParUmaPanel({ client, umaResources, scripts, formik }) {
2742
function uriValidator(uri) {
2843
return uri
2944
}
30-
function getMapping(partial, total) {
31-
if (!partial) {
32-
partial = []
33-
}
34-
return total.filter((item) => partial.includes(item.dn))
35-
}
45+
3646
const [softwareSection, setSoftwareSection] = useState(false)
3747
const [cibaSection, setCibaSection] = useState(false)
48+
const [open, setOpen] = useState(false)
49+
const [selectedUMA, setSelectedUMA] = useState()
50+
const [scopeExpression, setScopeExpression] = useState()
3851

3952
const rptScripts = scripts
4053
.filter((item) => item.scriptType == 'UMA_RPT_CLAIMS')
4154
.filter((item) => item.enabled)
4255
.map((item) => ({ dn: item.dn, name: item.name }))
4356

44-
function handleCibaSection() {
45-
setCibaSection(!cibaSection)
46-
}
47-
function handleSoftwareSection() {
48-
setSoftwareSection(!softwareSection)
49-
}
50-
function emailValidator(email) {
51-
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(
52-
email,
53-
)
57+
const handleUMADetail = (uma) => {
58+
if (!isEmpty(uma)) {
59+
setSelectedUMA(uma)
60+
setScopeExpression(JSON.parse(uma.scopeExpression)?.data)
61+
dispatch(getScope(uma.inum))
62+
}
63+
64+
setOpen(true)
5465
}
66+
5567
return (
5668
<Container>
5769
<h2>{t(`titles.CIBA`)}</h2>
@@ -151,19 +163,129 @@ function ClientCibaParUmaPanel({ client, umaResources, scripts, formik }) {
151163
return (
152164
<Box key={uma.id}>
153165
<Box display="flex">
154-
<Box>
155-
<Link to={`/auth-server/client/uma/${uma.id}`} className="common-link">
156-
{uma.id}
157-
</Link>
166+
<Box className="common-link cursor-pointer" onClick={() => handleUMADetail(uma)}>
167+
{uma.id}
158168
</Box>
159169
</Box>
160170
</Box>
161171
)
162172
})}
163173
</Col>
164174
</FormGroup>
175+
<Modal
176+
isOpen={open}
177+
toggle={() => setOpen(!open)}
178+
size="lg"
179+
className="modal-outline-primary"
180+
>
181+
<ModalHeader toggle={() => setOpen(!open)}>
182+
UMA Resource Detail
183+
</ModalHeader>
184+
<ModalBody>
185+
<Card style={applicationStyle.mainCard}>
186+
<h2>UMA Resource Detail</h2>
187+
<FormGroup row>
188+
<GluuLabel label={t('fields.resourceId')} size={3} />
189+
<Col sm={9} className="top-5">
190+
{selectedUMA?.id}
191+
</Col>
192+
</FormGroup>
193+
<FormGroup row>
194+
<GluuLabel label={t('fields.displayname')} size={3} />
195+
<Col sm={9} className="top-5">
196+
{selectedUMA?.name}
197+
</Col>
198+
</FormGroup>
199+
<FormGroup row>
200+
<GluuLabel label={t('fields.iconUrl')} size={3} />
201+
<Col sm={9} className="top-5">
202+
{!isEmpty(scope) && (
203+
<a href={scope?.iconUrl} target="_blank" alt="iconUrl" className="common-link" rel="noreferrer">
204+
{scope?.iconUrl}
205+
</a>
206+
)}
207+
</Col>
208+
</FormGroup>
209+
<FormGroup row>
210+
<GluuLabel label={t('fields.scopeSelection')} size={3} />
211+
<Col sm={9} className="top-5">
212+
<RadioGroup
213+
row
214+
name="scopeSelection"
215+
value={true}
216+
>
217+
<FormControlLabel
218+
value={true}
219+
control={<Radio color="primary" />}
220+
label={t('fields.scope')}
221+
checked={true}
222+
/>
223+
<FormControlLabel
224+
value={false}
225+
control={<Radio color="primary" />}
226+
label={t('fields.scopeExpression')}
227+
checked={false}
228+
/>
229+
</RadioGroup>
230+
</Col>
231+
</FormGroup>
232+
<FormGroup row>
233+
<GluuLabel label={t('fields.scopeSelection')} size={3} />
234+
<Col sm={9} className="top-5">
235+
{!isEmpty(scopeExpression) && scopeExpression.map((expression, key) => (
236+
<Box key={key}>
237+
<Box display="flex">
238+
<a href={expression} target="_blank" alt="scope expression" className="common-link" rel="noreferrer">
239+
{expression}
240+
</a>
241+
</Box>
242+
</Box>
243+
))}
244+
</Col>
245+
</FormGroup>
246+
<FormGroup row>
247+
<GluuLabel label={t('fields.associatedClient')} size={3} />
248+
<Col sm={9} className="top-5">
249+
{!isEmpty(scope) && scope.clients?.map((client, key) => (
250+
<Box key={key}>
251+
<Box display="flex">
252+
<Link to={`/auth-server/client/edit:${client.inum.substring(0, 4)}`} className="common-link">
253+
{client.inum}
254+
</Link>
255+
</Box>
256+
</Box>
257+
))}
258+
</Col>
259+
</FormGroup>
260+
<FormGroup row>
261+
<GluuLabel label={t('fields.creationTime')} size={3} />
262+
<Col sm={9} className="top-5">
263+
{ moment(selectedUMA?.creationDate).format("ddd, MMM DD, YYYY h:mm:ss A") }
264+
</Col>
265+
</FormGroup>
266+
</Card>
267+
</ModalBody>
268+
<ModalFooter>
269+
<Button
270+
color={`primary-${selectedTheme}`}
271+
style={applicationStyle.buttonStyle}
272+
onClick={() => setOpen(!open)}
273+
>
274+
{t('actions.close')}
275+
</Button>
276+
</ModalFooter>
277+
</Modal>
165278
</Container>
166279
)
167280
}
168281

169-
export default ClientCibaParUmaPanel
282+
const mapStateToProps = (state) => {
283+
return {
284+
clientData: state.oidcReducer.item,
285+
loading: state.oidcReducer.loading,
286+
scope: state.scopeReducer.item,
287+
umaResources: state.oidcReducer.umaResources,
288+
}
289+
}
290+
export default connect(mapStateToProps)(ClientCibaParUmaPanel)
291+

0 commit comments

Comments
 (0)