Skip to content

Commit a1b568c

Browse files
committed
feat(admin-ui): get scope by inum api not triggered
1 parent 6c1db7b commit a1b568c

File tree

7 files changed

+52
-24
lines changed

7 files changed

+52
-24
lines changed

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

+25-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react'
1+
import React, { useState, useEffect } from 'react'
22
import Box from '@material-ui/core/Box'
33
import { Link } from 'react-router-dom'
44
import {
@@ -22,11 +22,11 @@ import { FormControlLabel, Radio, RadioGroup } from '@material-ui/core'
2222
import GluuTypeAheadForDn from 'Routes/Apps/Gluu/GluuTypeAheadForDn'
2323
import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle'
2424
import { deleteUMAResource } from 'Plugins/auth-server/redux/actions/UMAResourceActions'
25+
import { getScope } from 'Plugins/auth-server/redux/actions/ScopeActions'
2526
import GluuDialog from 'Routes/Apps/Gluu/GluuDialog'
26-
import { buildPayload } from 'Utils/PermChecker'
2727
const DOC_CATEGORY = 'openid_client'
2828

29-
function ClientCibaParUmaPanel({ client, dispatch, umaResources, scripts, formik }) {
29+
function ClientCibaParUmaPanel({ client, dispatch, umaResources, scope, scripts, formik }) {
3030
const { t } = useTranslation()
3131
const claim_uri_id = 'claim_uri_id'
3232
const cibaDeliveryModes = ['poll', 'push', 'ping']
@@ -68,11 +68,26 @@ function ClientCibaParUmaPanel({ client, dispatch, umaResources, scripts, formik
6868
}
6969

7070
const onDeletionConfirmed = (message) => {
71-
buildPayload({}, message, selectedUMA.id)
72-
dispatch(deleteUMAResource(selectedUMA.id))
71+
const params = {
72+
id: selectedUMA.id,
73+
message
74+
}
75+
dispatch(deleteUMAResource(params))
7376
setConfirmModal(false)
7477
}
7578

79+
useEffect(() => {
80+
if(!isEmpty(selectedUMA) && !isEmpty(selectedUMA.scopes) && selectedUMA.scopes?.length > 0) {
81+
selectedUMA.scopes.map(scope => {
82+
// scope data example [string] inum=9bc94613-f678-4bb9-a19d-ed026b492247,ou=scopes,o=jans
83+
const getInum = scope.split(',')[0]
84+
const inum = getInum.split('=')[1]
85+
86+
dispatch(getScope(inum))
87+
})
88+
}
89+
}, [selectedUMA])
90+
7691
return (
7792
<Container>
7893
<h2>{t(`titles.CIBA`)}</h2>
@@ -255,16 +270,16 @@ function ClientCibaParUmaPanel({ client, dispatch, umaResources, scripts, formik
255270
<Col sm={9} className="top-5">
256271
{showScopeSection === 'scope' ? (
257272
<React.Fragment>
258-
{!isEmpty(selectedUMA) && selectedUMA?.scopes?.map((scope, key) => {
259-
const getInum = scope.split(',')[0]
273+
{!isEmpty(selectedUMA) && selectedUMA?.scopes?.map((scopeString, key) => {
274+
const getInum = scopeString.split(',')[0]
260275
const inum = getInum.length > 0 ? getInum.split('=')[1] : null
261276

262-
if (inum) {
277+
if (!isEmpty(scope[inum])) {
263278
return (
264279
<Box key={key}>
265280
<Box display="flex">
266-
<Link to={`/auth-server/scope/edit:${inum}`} className="common-link">
267-
{scope}
281+
<Link to={`/auth-server/scope/edit:${scope[inum]?.inum}`} className="common-link">
282+
{scope[inum]?.displayName}
268283
</Link>
269284
</Box>
270285
</Box>

admin-ui/plugins/auth-server/redux/actions/ScopeActions.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ export const deleteScopeResponse = (data) => ({
8080
payload: { data },
8181
})
8282

83-
export const setCurrentItem = (item) => ({
84-
type: SET_ITEM,
85-
payload: { item },
86-
})
83+
export const setCurrentItem = (item, inum) => {
84+
console.log(item, inum)
85+
return ({
86+
type: SET_ITEM,
87+
payload: { item, inum },
88+
})
89+
}

admin-ui/plugins/auth-server/redux/api/ScopeApi.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class ScopeApi {
1919
})
2020
}
2121

22-
getScope = async (id) => {
22+
patchScope = async (id) => {
2323
return new Promise((resolve, reject) => {
2424
this.api.patchOauthScopesById(id, (error, data) => {
2525
this.handleResponse(error, reject, resolve, data)

admin-ui/plugins/auth-server/redux/api/UMAResourceApi.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ export default class UMAResourceApi {
1111
})
1212
}
1313

14-
deteleUMAResources = async (id) => {
14+
deteleUMAResource = async (id) => {
1515
return new Promise((resolve, reject) => {
1616
this.api.deleteOauthUmaResourcesById(id, (error, data) => {
17+
console.log('delete uma')
1718
this.handleResponse(error, reject, resolve, data)
1819
})
1920
})

admin-ui/plugins/auth-server/redux/reducers/ScopeReducer.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,7 @@ export default function scopeReducer(state = INIT_STATE, action) {
121121
}
122122

123123
case SET_ITEM:
124-
return {
125-
...state,
126-
item: action.payload.item,
127-
loading: false,
128-
}
124+
return setItem()
129125
case RESET:
130126
return {
131127
...state,
@@ -135,6 +131,18 @@ export default function scopeReducer(state = INIT_STATE, action) {
135131
default:
136132
return handleDefault()
137133
}
134+
function setItem() {
135+
const currentItem = state.item
136+
const newItem = { ...currentItem, [action.payload.inum]: action.payload.item }
137+
138+
console.log('newItem', newItem)
139+
140+
return {
141+
...state,
142+
item: newItem,
143+
loading: false,
144+
}
145+
}
138146
function handleLoading() {
139147
return {
140148
...state,

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export function* getScopeByInum({ payload }) {
5858
addAdditionalData(audit, FETCH, SCOPE, {})
5959
const scopeApi = yield* newFunction()
6060
const data = yield call(scopeApi.getScope, payload.action)
61-
yield put(setCurrentItem(data))
61+
console.log('data', data)
62+
yield put(setCurrentItem(data, payload.action))
6263
yield call(postUserAction, audit)
6364
} catch (e) {
6465
yield put(deleteScopeResponse(null))

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export function* deleteUMAResourceById({ payload }) {
5656
try {
5757
addAdditionalData(audit, DELETION, UMA, payload)
5858
const api = yield* newFunction()
59-
yield call(api.deleteUMAResourceById, payload.action.action_data)
60-
yield put(deleteUMAResourceResponse(payload.action.action_data))
59+
yield call(api.deteleUMAResource, payload.action.id)
60+
yield put(deleteUMAResourceResponse(payload.action.id))
6161
yield call(postUserAction, audit)
6262
} catch (e) {
6363
yield put(deleteUMAResourceResponse(null))

0 commit comments

Comments
 (0)