Skip to content

Commit

Permalink
feat(admin-ui): implement get supported services and get supported fi…
Browse files Browse the repository at this point in the history
…le types #1635
  • Loading branch information
syntrydy committed Jun 5, 2024
1 parent 55655d1 commit b45df5e
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 18 deletions.
4 changes: 2 additions & 2 deletions admin-ui/app/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"access_token_signing_alg": "JWS alg for signing",
"asset_name": "Asset Name",
"upload": "Select a file to upload",
"jansModuleProperty": "Related Services",
"jansServices": "Related Services",
"default_permission_in_token": "Default permission in token",
"aui_feature_ids": "Admin UI Features",
"introspection_signed_response_alg": "Introspection Signed Response Alg",
Expand Down Expand Up @@ -878,7 +878,7 @@
},
"documentation": {
"asset":{
"jansModuleProperty": "Related Services"
"jansServices": "Related Services"
},
"webhook": {
"url": "Webhook URL.",
Expand Down
4 changes: 2 additions & 2 deletions admin-ui/app/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"tag": "Étiqueter",
"issuer": "Émetteur",
"upload": "Select a file to upload",
"jansModuleProperty": "Jans Module Properties",
"jansServices": "Jans Module Properties",
"message_provider_type": "Type de fournisseur de messages",
"ssl_key_store_file_path": "Chemin du fichier du magasin de clés SSL",
"principal_attribute": "Attribut Principal",
Expand Down Expand Up @@ -779,7 +779,7 @@
},
"documentation": {
"asset":{
"jansModuleProperty": "Jans Module Properties"
"jansServices": "Jans Module Properties"
},
"webhook": {
"url": "URL du webhook.",
Expand Down
4 changes: 2 additions & 2 deletions admin-ui/app/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"asset_name": "Asset Name",
"tag": "Marcação",
"upload": "Select a file to upload",
"jansModuleProperty": "Related Services",
"jansServices": "Related Services",
"default_permission_in_token": "Permissão padrão no token",
"introspection_signed_response_alg": "Algoritmo de assinatura da resposta de introspeção",
"introspection_encrypted_response_alg": "Algoritmo de criptografia da resposta de introspeção",
Expand Down Expand Up @@ -776,7 +776,7 @@
},
"documentation": {
"asset":{
"jansModuleProperty": "Related Services"
"jansServices": "Related Services"
},
"webhook": {
"url": "URL do webhook.",
Expand Down
16 changes: 7 additions & 9 deletions admin-ui/plugins/admin/components/Assets/AssetForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const AssetForm = () => {
displayName: selectedAsset?.displayName || '',
jansEnabled: selectedAsset?.jansEnabled || false,
description: selectedAsset?.description || '',
jansModuleProperty: selectedAsset?.jansModuleProperty || []
jansServices: selectedAsset?.jansServices || []
},
onSubmit: (values) => {
const faulty = validatePayload(values)
Expand Down Expand Up @@ -150,7 +150,6 @@ const AssetForm = () => {
/>
</Col>
</FormGroup>

<GluuInputRow
label='fields.asset_name'
formik={formik}
Expand All @@ -164,7 +163,6 @@ const AssetForm = () => {
errorMessage={formik.errors.displayName}
showError={formik.errors.displayName && formik.touched.displayName}
/>

<GluuInputRow
label='fields.description'
formik={formik}
Expand All @@ -178,9 +176,9 @@ const AssetForm = () => {
</Col>
<GluuTypeAhead
name='services'
label={t('fields.jansModuleProperty')}
label={t('fields.jansServices')}
formik={formik}
options={["config-api","auth-server","scim","casa"]}
options={["config-api", "auth-server", "scim", "casa"]}
lsize={4}
rsize={8}
required
Expand All @@ -190,13 +188,13 @@ const AssetForm = () => {
{false &&
<GluuArrayCompleter
formik={formik}
name='jansModuleProperty'
name='jansServices'
rsize={8}
lsize={4}
doc_category={ASSET}
label='fields.jansModuleProperty'
value={selectedAsset.jansModuleProperty || []}
options={selectedAsset.jansModuleProperty || []} >
label='fields.jansServices'
value={selectedAsset.jansServices || []}
options={selectedAsset.jansServices || []} >
</GluuArrayCompleter>
}
<FormGroup row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import getThemeColor from 'Context/theme/config'
import { LIMIT_ID, PATTERN_ID } from 'Plugins/admin/common/Constants'
import SetTitle from 'Utils/SetTitle'
import { useNavigate } from 'react-router'
import { getJansAssets, deleteJansAsset, setSelectedAsset } from 'Plugins/admin/redux/features/AssetSlice'
import { getJansAssets, deleteJansAsset, setSelectedAsset, getAssetServices, getAssetTypes } from 'Plugins/admin/redux/features/AssetSlice'

const JansAssetListPage = () => {
const dispatch = useDispatch()
Expand Down Expand Up @@ -54,6 +54,8 @@ const JansAssetListPage = () => {
const [limit, setLimit] = useState(10)
const [pattern, setPattern] = useState(null)
useEffect(() => {
dispatch(getAssetServices({ action: options }))
dispatch(getAssetTypes({ action: options }))
options['limit'] = 10
dispatch(getJansAssets({ action: options }))
}, [])
Expand Down
21 changes: 19 additions & 2 deletions admin-ui/plugins/admin/redux/api/AssetApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,27 @@ export default class AssetApi {
})
}

getAssetServices = () => {
return new Promise((resolve, reject) => {
this.api.getAssetServices((error, data) => {
handleResponse(error, reject, resolve, data)
})
})
}

getAssetTypes = () => {
return new Promise((resolve, reject) => {
this.api.getAssetTypes((error, data) => {
handleResponse(error, reject, resolve, data)
})
})
}


createJansAsset = (body, token) => {
const document = {
"displayName": body.displayName, "description": body.description,
"document": body.displayName, "jansModuleProperty": body?.jansModuleProperty || [], "jansEnabled": body.jansEnabled
"document": body.displayName, "jansServices": body?.jansServices || [], "jansEnabled": body.jansEnabled
}
const formData = new FormData();
const assetFileBlob = new Blob([body.document], {
Expand Down Expand Up @@ -44,7 +61,7 @@ export default class AssetApi {
updateJansAsset = (body) => {
const document = {
"displayName": body.displayName, "description": body.description,
"document": body.displayName, "jansModuleProperty": body?.jansModuleProperty || [], "jansEnabled": body.jansEnabled
"document": body.displayName, "jansServices": body?.jansServices || [], "jansEnabled": body.jansEnabled
}
const formData = new FormData();
const assetFileBlob = new Blob([body.document], {
Expand Down
24 changes: 24 additions & 0 deletions admin-ui/plugins/admin/redux/features/AssetSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { createSlice } from '@reduxjs/toolkit'

const initialState = {
assets: [],
services: [],
fileTypes: [],
loading: false,
saveOperationFlag: false,
errorInSaveOperationFlag: false,
Expand Down Expand Up @@ -32,6 +34,24 @@ const assetSlice = createSlice({
state.entriesCount = action.payload.data.entriesCount
}
},
getAssetServices: (state, action) => {
state.loading = true
},
getAssetServicesResponse: (state, action) => {
state.loading = false
if (action.payload?.data) {
state.services = action.payload.data
}
},
getAssetTypes: (state, action) => {
state.loading = true
},
getAssetTypesResponse: (state, action) => {
state.loading = false
if (action.payload?.data) {
state.fileTypes = action.payload.data
}
},
createJansAsset: (state) => {
state.loading = true
state.saveOperationFlag = false
Expand Down Expand Up @@ -86,6 +106,10 @@ export const {
fetchJansAssets,
getJansAssets,
getJansAssetResponse,
getAssetServices,
getAssetServicesResponse,
getAssetTypes,
getAssetTypesResponse,
createJansAsset,
createJansAssetResponse,
deleteJansAsset,
Expand Down
67 changes: 67 additions & 0 deletions admin-ui/plugins/admin/redux/sagas/AssetSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { call, all, put, fork, takeLatest, select } from 'redux-saga/effects'
import {
fetchJansAssets,
getJansAssetResponse,
getAssetServicesResponse,
getAssetTypesResponse,
createJansAssetResponse,
deleteJansAssetResponse,
updateJansAssetResponse,
Expand Down Expand Up @@ -57,6 +59,61 @@ export function* getJansAssets({ payload }) {
}
}

export function* getAssetServices({ payload }) {
const audit = yield* initAudit()
try {
payload = payload || { action: {} }
addAdditionalData(audit, FETCH, 'assetServices', payload)
const assetApi = yield* newFunction()
const data = yield call(assetApi.getAssetServices, payload.action)
yield put(getAssetServicesResponse({ data }))
yield call(postUserAction, audit)
return data
} catch (e) {
yield put(
updateToast(
true,
'error',
e?.response?.body?.responseMessage || e.message
)
)
yield put(getAssetServicesResponse({ data: null }))
if (isFourZeroOneError(e)) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
yield put(getAPIAccessToken(jwt))
}
return e
}
}

export function* getAssetTypes({ payload }) {
const audit = yield* initAudit()
try {
payload = payload || { action: {} }
addAdditionalData(audit, FETCH, 'assetTypes', payload)
const assetApi = yield* newFunction()
const data = yield call(assetApi.getAssetTypes, payload.action)
yield put(getAssetTypesResponse({ data }))
yield call(postUserAction, audit)
return data
} catch (e) {
yield put(
updateToast(
true,
'error',
e?.response?.body?.responseMessage || e.message
)
)
yield put(getAssetTypesResponse({ data: null }))
if (isFourZeroOneError(e)) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
yield put(getAPIAccessToken(jwt))
}
return e
}
}


export function* createJansAsset({ payload }) {
const audit = yield* initAudit()
try {
Expand Down Expand Up @@ -151,6 +208,14 @@ export function* watchGetJansAssets() {
yield takeLatest('asset/getJansAssets', getJansAssets)
}

export function* watchGetAssetTypes() {
yield takeLatest('asset/getAssetTypes', getAssetTypes)
}

export function* watchGetAssetServices() {
yield takeLatest('asset/getAssetServices', getAssetServices)
}

export function* watchCreateJansAsset() {
yield takeLatest('asset/createJansAsset', createJansAsset)
}
Expand All @@ -167,6 +232,8 @@ export function* watchUpdateJansAsset() {

export default function* rootSaga() {
yield all([
fork(watchGetAssetServices),
fork(watchGetAssetTypes),
fork(watchGetJansAssets),
fork(watchCreateJansAsset),
fork(watchDeleteJansAsset),
Expand Down

0 comments on commit b45df5e

Please sign in to comment.