Skip to content

Commit

Permalink
feat(admin-ui): add uma resources detail
Browse files Browse the repository at this point in the history
  • Loading branch information
harryandriyan committed Aug 12, 2022
1 parent dd23342 commit 84acd39
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 4 deletions.
8 changes: 7 additions & 1 deletion admin-ui/app/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,13 @@
"userName": "User Name",
"nickName": "Nick Name",
"givenName": "Given Name",
"resources": "Resources"
"resources": "Resources",
"resourceId": "Resource id",
"iconUrl": "Icon URL",
"scopeSelection": "Scope Selection",
"scopeOrExpression": "Scope (or Expression)",
"associatedClient": "Associated Client",
"creationTime": "Creation Time"
},
"languages": {
"french": "French",
Expand Down
8 changes: 7 additions & 1 deletion admin-ui/app/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,13 @@
"email": "E-mail",
"userName": "Nom d'utilisateur",
"nickName": "Surnom",
"resources": "Ressources"
"resources": "Ressources",
"resourceId": "Identifiant de la ressource",
"iconUrl": "URL de l'icône",
"scopeSelection": "Sélection de la portée",
"scopeOrExpression": "Portée (ou Expression)",
"associatedClient": "Client associé",
"creationTime": "Heure de création"
},
"messages": {
"action_commit_question": "Journal d'audit : vous souhaitez appliquer les modifications apportées sur cette page ?",
Expand Down
8 changes: 7 additions & 1 deletion admin-ui/app/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,13 @@
"email": "E-mail",
"userName": "Nome do usuário",
"nickName": "Apelido",
"resources": "Recursos"
"resources": "Recursos",
"resourceId": "ID do recurso",
"iconUrl": "URL do ícone",
"scopeSelection": "Seleção de Escopo",
"scopeOrExpression": "Escopo (ou Expressão)",
"associatedClient": "Cliente Associado",
"creationTime": "Tempo de Criação"
},
"messages": {
"action_commit_question": "Registro de auditoria: deseja aplicar as alterações feitas nesta página?",
Expand Down
148 changes: 148 additions & 0 deletions admin-ui/plugins/auth-server/components/Clients/ClientUMADetailPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import React, { useEffect, useState } from 'react'
import Box from '@material-ui/core/Box'
import { Link } from 'react-router-dom'
import { FormControlLabel, Radio, RadioGroup } from '@material-ui/core'
import moment from 'moment'
import GluuLoader from 'Routes/Apps/Gluu/GluuLoader'
import { Col, Container, FormGroup, Card } from 'Components'
import { useParams } from 'react-router-dom'
import { connect } from 'react-redux'
import { getUMAResourcesByClient } from 'Plugins/auth-server/redux/actions/OIDCActions'
import { getScope } from 'Plugins/auth-server/redux/actions/ScopeActions'
import { getOidcDiscovery } from 'Redux/actions/OidcDiscoveryActions'
import { useTranslation } from 'react-i18next'
import isEmpty from 'lodash/isEmpty'
import GluuLabel from 'Routes/Apps/Gluu/GluuLabel'
import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle'

function ClientUMADetailPage({
clientData,
scope,
loading,
dispatch,
umaResources,
}) {
const { t } = useTranslation()
const { id } = useParams()
const [selectedUMA, setSelectedUMA] = useState()
const [scopeExpression, setScopeExpression] = useState()

useEffect(() => {
if (isEmpty(umaResources)) {
dispatch(getUMAResourcesByClient(clientData?.inum))
}
dispatch(getOidcDiscovery())
}, [])

useEffect(() => {
const umaResource = umaResources.find(uma => uma.id === id) || {}

if (!isEmpty(umaResource)) {
setSelectedUMA(umaResource)
setScopeExpression(JSON.parse(umaResource.scopeExpression)?.data)
}

if (isEmpty(scope) && !isEmpty(umaResource)) {
dispatch(getScope(umaResource.inum))
}
}, [umaResources, scope])

return (
<GluuLoader blocking={loading}>
<Card style={applicationStyle.mainCard}>
<Container style={{ maxWidth: '100%', padding: 20 }}>
<h2>UMA Resource Detail</h2>
<FormGroup row>
<GluuLabel label={t('fields.resourceId')} size={3} />
<Col sm={9}>
{id}
</Col>
</FormGroup>
<FormGroup row>
<GluuLabel label={t('fields.displayname')} size={3} />
<Col sm={9}>
{selectedUMA?.name}
</Col>
</FormGroup>
<FormGroup row>
<GluuLabel label={t('fields.iconUrl')} size={3} />
<Col sm={9}>
{!isEmpty(scope) && (
<a href={scope?.iconUrl} target="_blank" alt="iconUrl" className="common-link" rel="noreferrer">
{scope?.iconUrl}
</a>
)}
</Col>
</FormGroup>
<FormGroup row>
<GluuLabel label={t('fields.scopeSelection')} size={3} />
<Col sm={9}>
<RadioGroup
row
name="accessTokenAsJwt"
value={true}
onChange={(e) => console.log(e)}
>
<FormControlLabel
value={true}
control={<Radio color="primary" />}
label="Scope"
checked={true}
/>
<FormControlLabel
value={false}
control={<Radio color="primary" />}
label="Scope Expression"
checked={false}
/>
</RadioGroup>
</Col>
</FormGroup>
<FormGroup row>
<GluuLabel label={t('fields.scopeSelection')} size={3} />
<Col sm={9}>
{!isEmpty(scopeExpression) && scopeExpression.map((expression, key) => (
<Box key={key}>
<Box display="flex">
<a href={expression} target="_blank" alt="scope expression" className="common-link" rel="noreferrer">
{expression}
</a>
</Box>
</Box>
))}
</Col>
</FormGroup>
<FormGroup row>
<GluuLabel label={t('fields.associatedClient')} size={3} />
<Col sm={9}>
{!isEmpty(scope) && scope.clients?.map((client, key) => (
<Box key={key}>
<Box display="flex">
<Link to={`/auth-server/client/edit:${client.inum.substring(0, 4)}`} className="common-link">
{client.inum}
</Link>
</Box>
</Box>
))}
</Col>
</FormGroup>
<FormGroup row>
<GluuLabel label={t('fields.creationTime')} size={3} />
<Col sm={9}>
{ moment(selectedUMA?.creationDate).format("ddd, MMM DD, YYYY h:mm:ss A") }
</Col>
</FormGroup>
</Container>
</Card>
</GluuLoader>
)
}
const mapStateToProps = (state) => {
return {
clientData: state.oidcReducer.item,
loading: state.oidcReducer.loading,
scope: state.scopeReducer.item,
umaResources: state.oidcReducer.umaResources,
}
}
export default connect(mapStateToProps)(ClientUMADetailPage)
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ function ClientWizardForm({
>
{t('actions.apply')}
</Button>
)}
)}
</div>
</CardFooter>
<Button
Expand Down
6 changes: 6 additions & 0 deletions admin-ui/plugins/auth-server/plugin-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ScopeEditPage from './components/Scopes/ScopeEditPage'
import ClientListPage from './components/Clients/ClientListPage'
import ClientAddPage from './components/Clients/ClientAddPage'
import ClientEditPage from './components/Clients/ClientEditPage'
import ClientUMADetailPage from './components/Clients/ClientUMADetailPage'

import PropertiesPage from './components/Configuration/ConfigPage'
import KeysPage from './components/Configuration/Keys/KeysPage'
Expand Down Expand Up @@ -92,6 +93,11 @@ const pluginMetadata = {
path: PLUGIN_BASE_APTH + '/client/edit:id',
permission: CLIENT_WRITE,
},
{
component: ClientUMADetailPage,
path: PLUGIN_BASE_APTH + '/client/uma/:id',
permission: CLIENT_WRITE,
},
{
component: ScopeListPage,
path: PLUGIN_BASE_APTH + '/scopes',
Expand Down

0 comments on commit 84acd39

Please sign in to comment.