Skip to content

Commit e2fde36

Browse files
committed
feat(admin-ui): update scope and selection
1 parent 44fbf66 commit e2fde36

File tree

4 files changed

+54
-39
lines changed

4 files changed

+54
-39
lines changed

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

+49-27
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ import GluuSelectRow from 'Routes/Apps/Gluu/GluuSelectRow'
1818
import GluuToogleRow from 'Routes/Apps/Gluu/GluuToogleRow'
1919
import GluuInputRow from 'Routes/Apps/Gluu/GluuInputRow'
2020
import GluuTypeAheadWithAdd from 'Routes/Apps/Gluu/GluuTypeAheadWithAdd'
21-
import { getScope } from 'Plugins/auth-server/redux/actions/ScopeActions'
2221
import { FormControlLabel, Radio, RadioGroup } from '@material-ui/core'
2322
import GluuTypeAheadForDn from 'Routes/Apps/Gluu/GluuTypeAheadForDn'
2423
import { ThemeContext } from 'Context/theme/themeContext'
2524
import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle'
2625
const DOC_CATEGORY = 'openid_client'
2726

28-
function ClientCibaParUmaPanel({ client, scope, umaResources, scripts, formik }) {
27+
function ClientCibaParUmaPanel({ client, umaResources, scripts, formik }) {
2928
const { t } = useTranslation()
3029
const theme = useContext(ThemeContext)
3130
const selectedTheme = theme.state.theme
@@ -44,6 +43,7 @@ function ClientCibaParUmaPanel({ client, scope, umaResources, scripts, formik })
4443
const [open, setOpen] = useState(false)
4544
const [selectedUMA, setSelectedUMA] = useState()
4645
const [scopeExpression, setScopeExpression] = useState()
46+
const [showScopeSection, setShowScopeSection] = useState('scope')
4747

4848
const rptScripts = scripts
4949
.filter((item) => item.scriptType == 'UMA_RPT_CLAIMS')
@@ -59,8 +59,6 @@ function ClientCibaParUmaPanel({ client, scope, umaResources, scripts, formik })
5959
setOpen(true)
6060
}
6161

62-
console.log('scope', scope)
63-
6462
return (
6563
<Container>
6664
<h2>{t(`titles.CIBA`)}</h2>
@@ -195,11 +193,9 @@ function ClientCibaParUmaPanel({ client, scope, umaResources, scripts, formik })
195193
<FormGroup row>
196194
<GluuLabel label={t('fields.iconUrl')} size={3} />
197195
<Col sm={9} className="top-5">
198-
{!isEmpty(scope) && (
199-
<a href={scope?.iconUrl} target="_blank" alt="iconUrl" className="common-link" rel="noreferrer">
200-
{scope?.iconUrl}
201-
</a>
202-
)}
196+
<a href={selectedUMA?.iconUri} target="_blank" alt="iconUrl" className="common-link" rel="noreferrer">
197+
{selectedUMA?.iconUri || '-'}
198+
</a>
203199
</Col>
204200
</FormGroup>
205201
<FormGroup row>
@@ -208,45 +204,70 @@ function ClientCibaParUmaPanel({ client, scope, umaResources, scripts, formik })
208204
<RadioGroup
209205
row
210206
name="scopeSelection"
211-
value={true}
207+
value={showScopeSection}
208+
onChange={(e) => setShowScopeSection(e.target.value)}
212209
>
213210
<FormControlLabel
214-
value={true}
211+
value={'scope'}
215212
control={<Radio color="primary" />}
216213
label={t('fields.scope')}
217-
checked={true}
214+
checked={showScopeSection === 'scope'}
218215
/>
219216
<FormControlLabel
220-
value={false}
217+
value={'expression'}
221218
control={<Radio color="primary" />}
222219
label={t('fields.scopeExpression')}
223-
checked={false}
220+
checked={showScopeSection === 'expression'}
224221
/>
225222
</RadioGroup>
226223
</Col>
227224
</FormGroup>
228225
<FormGroup row>
229-
<GluuLabel label={t('fields.scopeSelection')} size={3} />
226+
<GluuLabel label={t('fields.scopeOrExpression')} size={3} />
230227
<Col sm={9} className="top-5">
231-
{!isEmpty(scopeExpression) && scopeExpression.map((expression, key) => (
232-
<Box key={key}>
233-
<Box display="flex">
234-
<a href={expression} target="_blank" alt="scope expression" className="common-link" rel="noreferrer">
235-
{expression}
236-
</a>
237-
</Box>
238-
</Box>
239-
))}
228+
{showScopeSection === 'scope' ? (
229+
<React.Fragment>
230+
{!isEmpty(selectedUMA) && selectedUMA?.scopes?.map((scope, key) => {
231+
const getInum = scope.split(',')[0]
232+
const inum = getInum.length > 0 ? getInum.split('=')[1] : null
233+
234+
if (inum) {
235+
return (
236+
<Box key={key}>
237+
<Box display="flex">
238+
<Link to={`/auth-server/scope/edit:${inum}`} className="common-link">
239+
{scope}
240+
</Link>
241+
</Box>
242+
</Box>
243+
)
244+
}
245+
return '-'
246+
})}
247+
</React.Fragment>
248+
) : (
249+
<React.Fragment>
250+
{!isEmpty(scopeExpression) && scopeExpression.map((expression, key) => (
251+
<Box key={key}>
252+
<Box display="flex">
253+
<a href={expression} target="_blank" alt="scope expression" className="common-link" rel="noreferrer">
254+
{expression}
255+
</a>
256+
</Box>
257+
</Box>
258+
))}
259+
</React.Fragment>
260+
)}
240261
</Col>
241262
</FormGroup>
242263
<FormGroup row>
243264
<GluuLabel label={t('fields.associatedClient')} size={3} />
244265
<Col sm={9} className="top-5">
245-
{!isEmpty(scope) && scope.clients?.map((client, key) => (
266+
{!isEmpty(selectedUMA) && selectedUMA.clients?.map((client, key) => (
246267
<Box key={key}>
247268
<Box display="flex">
248-
<Link to={`/auth-server/client/edit:${client.inum.substring(0, 4)}`} className="common-link">
249-
{client.inum}
269+
<Link to={`/auth-server/client/edit:${client.substring(0, 4)}`} className="common-link">
270+
{client}
250271
</Link>
251272
</Box>
252273
</Box>
@@ -279,6 +300,7 @@ const mapStateToProps = (state) => {
279300
return {
280301
clientData: state.oidcReducer.item,
281302
loading: state.oidcReducer.loading,
303+
scope: state.scopeReducer.item,
282304
}
283305
}
284306
export default connect(mapStateToProps)(ClientCibaParUmaPanel)

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

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useHistory } from 'react-router-dom'
55
import { connect } from 'react-redux'
66
import { editClient } from 'Plugins/auth-server/redux/actions/OIDCActions'
77
import { getUMAResourcesByClient } from 'Plugins/auth-server/redux/actions/UMAResourceActions'
8-
import { getScopes, getScope } from 'Plugins/auth-server/redux/actions/ScopeActions'
8+
import { getScopes } from 'Plugins/auth-server/redux/actions/ScopeActions'
99
import { getOidcDiscovery } from 'Redux/actions/OidcDiscoveryActions'
1010
import { getScripts } from 'Redux/actions/InitActions'
1111
import { buildPayload } from 'Utils/PermChecker'
@@ -17,7 +17,6 @@ function ClientEditPage({
1717
clientData,
1818
view_only,
1919
scopes,
20-
scope,
2120
scripts,
2221
loading,
2322
permissions,
@@ -44,9 +43,6 @@ function ClientEditPage({
4443
if (isEmpty(umaResources)) {
4544
dispatch(getUMAResourcesByClient(clientData?.inum))
4645
}
47-
if (isEmpty(scope)) {
48-
dispatch(getScope(clientData?.inum))
49-
}
5046
dispatch(getOidcDiscovery())
5147
}, [])
5248
useEffect(() => {
@@ -77,7 +73,6 @@ function ClientEditPage({
7773
client_data={clientData}
7874
view_only={view_only}
7975
scopes={scopes}
80-
scope={scope}
8176
scripts={scripts}
8277
permissions={permissions}
8378
oidcConfiguration={oidcConfiguration}
@@ -93,7 +88,6 @@ const mapStateToProps = (state) => {
9388
view_only: state.oidcReducer.view,
9489
loading: state.oidcReducer.loading,
9590
scopes: state.scopeReducer.items,
96-
scope: state.scopeReducer.item,
9791
scripts: state.initReducer.scripts,
9892
permissions: state.authReducer.permissions,
9993
oidcConfiguration: state.oidcDiscoveryReducer.configuration,

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

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ function ClientWizardForm({
3232
client_data,
3333
view_only,
3434
scopes,
35-
scope,
3635
scripts,
3736
permissions,
3837
customOnSubmit,
@@ -426,7 +425,6 @@ function ClientWizardForm({
426425
<ClientCibaParUmaPanel
427426
client={client}
428427
umaResources={umaResources}
429-
scope={scope}
430428
scripts={scripts}
431429
formik={formik}
432430
/>

admin-ui/plugins/auth-server/redux/sagas/OAuthScopeSaga.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
addScopeResponse,
1515
editScopeResponse,
1616
deleteScopeResponse,
17+
setCurrentItem,
1718
} from '../actions/ScopeActions'
1819
import {
1920
GET_SCOPES,
@@ -51,13 +52,13 @@ function* newFunction() {
5152
return new ScopeApi(api)
5253
}
5354

54-
export function* getScopeByInum() {
55+
export function* getScopeByInum({ payload }) {
5556
const audit = yield* initAudit()
5657
try {
5758
addAdditionalData(audit, FETCH, SCOPE, {})
5859
const scopeApi = yield* newFunction()
59-
const data = yield call(scopeApi.getScope)
60-
yield put(deleteScopeResponse(data))
60+
const data = yield call(scopeApi.getScope, payload.action)
61+
yield put(setCurrentItem(data))
6162
yield call(postUserAction, audit)
6263
} catch (e) {
6364
yield put(deleteScopeResponse(null))

0 commit comments

Comments
 (0)