Skip to content

Commit

Permalink
feat(admin-ui): handle delete uma
Browse files Browse the repository at this point in the history
  • Loading branch information
harryandriyan committed Aug 18, 2022
1 parent 9116ecc commit 2d1c47d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,23 @@ import GluuTypeAheadForDn from 'Routes/Apps/Gluu/GluuTypeAheadForDn'
import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle'
import { deleteUMAResource } from 'Plugins/auth-server/redux/actions/UMAResourceActions'
import { setCurrentItem } from 'Plugins/auth-server/redux/actions/ScopeActions'
import {
setCurrentItem as setCurrentItemClient,
viewOnly
} from 'Plugins/auth-server/redux/actions/OIDCActions'
import GluuDialog from 'Routes/Apps/Gluu/GluuDialog'
const DOC_CATEGORY = 'openid_client'

function ClientCibaParUmaPanel({ client, dispatch, umaResources, scopes, scripts, formik }) {
function ClientCibaParUmaPanel({ client,
clients,
dispatch,
umaResources,
scopes,
scripts,
setCurrentStep,
sequence,
formik,
}) {
const { t } = useTranslation()
const history = useHistory()
const claim_uri_id = 'claim_uri_id'
Expand Down Expand Up @@ -72,17 +85,28 @@ function ClientCibaParUmaPanel({ client, dispatch, umaResources, scopes, scripts
const onDeletionConfirmed = (message) => {
const params = {
id: selectedUMA.id,
message
action_message: message,
action_data: selectedUMA.id
}
dispatch(deleteUMAResource(params))
setConfirmModal(false)
setOpen(false)
}

const handleScopeEdit = (scope) => {
dispatch(setCurrentItem(scope))
return history.push(`/auth-server/scope/edit:${scope.inum}`)
}

const handleClientEdit = (inum) => {
const currentClient = clients.find(client => client.inum === inum)
dispatch(setCurrentItemClient(currentClient))
setOpen(false)
dispatch(viewOnly(true))
setCurrentStep(sequence[0])
return history.push(`/auth-server/client/edit:${inum?.substring(0, 4)}`)
}

useEffect(() => {
if(!isEmpty(selectedUMA) && !isEmpty(selectedUMA.scopes) && selectedUMA.scopes?.length > 0) {
const list = selectedUMA.scopes.map(scope => {
Expand Down Expand Up @@ -225,7 +249,7 @@ function ClientCibaParUmaPanel({ client, dispatch, umaResources, scopes, scripts
size="lg"
className="modal-outline-primary"
>
<ModalHeader toggle={() => setOpen(!open)}>
<ModalHeader toggle={() => setOpen(!open)}>
UMA Resource Detail
</ModalHeader>
<ModalBody>
Expand Down Expand Up @@ -316,9 +340,9 @@ function ClientCibaParUmaPanel({ client, dispatch, umaResources, scopes, scripts
return (
<Box key={key}>
<Box display="flex">
<Link to={`/auth-server/client/edit:${inum}`} className="common-link">
<a href="javascript:;" onClick={() => handleClientEdit(inum)} className="common-link">
{inum}
</Link>
</a>
</Box>
</Box>
)}
Expand Down Expand Up @@ -358,7 +382,7 @@ function ClientCibaParUmaPanel({ client, dispatch, umaResources, scopes, scripts

const mapStateToProps = (state) => {
return {
clientData: state.oidcReducer.item,
clients: state.oidcReducer.items,
loading: state.oidcReducer.loading,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { connect } from 'react-redux'
import { Paper } from '@material-ui/core'
import { Card, CardBody, Badge } from 'Components'
import { getScopes } from 'Plugins/auth-server/redux/actions/ScopeActions'
import { resetUMAResources } from 'Plugins/auth-server/redux/actions/UMAResourceActions'
import GluuDialog from 'Routes/Apps/Gluu/GluuDialog'
import ClientDetailPage from '../Clients/ClientDetailPage'
import GluuAdvancedSearch from 'Routes/Apps/Gluu/GluuAdvancedSearch'
Expand Down Expand Up @@ -156,6 +157,10 @@ function ClientListPage({ clients, permissions, scopes, loading, dispatch }) {
}
}, [haveScopeINUMParam])

useEffect(() => {
dispatch(resetUMAResources())
}, [])

function handleOptionsChange(event) {
if (event.target.name == 'limit') {
memoLimit = event.target.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ function ClientWizardForm({
umaResources={umaResources}
scopes={scopes}
scripts={scripts}
setCurrentStep={setCurrentStep}
sequence={sequence}
formik={formik}
/>
{/* <ClientScript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
GET_UMA_RESOURCES,
GET_UMA_RESOURCES_RESPONSE,
DELETE_UMA_RESOURCE,
DELETE_UMA_RESOURCE_RESPONSE
DELETE_UMA_RESOURCE_RESPONSE,
RESET
} from './types'

export const getUMAResourcesByClient = (inum) => ({
Expand All @@ -24,3 +25,8 @@ export const deleteUMAResourceResponse = (data) => ({
type: DELETE_UMA_RESOURCE_RESPONSE,
payload: { data },
})

export const resetUMAResources = () => ({
type: RESET,
payload: {},
})

0 comments on commit 2d1c47d

Please sign in to comment.