Skip to content

Commit

Permalink
feat: gentle commit for backup
Browse files Browse the repository at this point in the history
  • Loading branch information
mjatin-dev committed Mar 11, 2022
1 parent 5b5b630 commit 6542d2d
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const UserList = () => {

useEffect(() => {
dispatch(getUsers({}))
console.log('HERE')
}, [])
return <div></div>
}
Expand Down
3 changes: 3 additions & 0 deletions admin-ui/plugins/admin/plugin-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import CustomScriptAddPage from './components/CustomScripts/CustomScriptAddPage'
import CustomScriptEditPage from './components/CustomScripts/CustomScriptEditPage'
import SettingsPage from './components/Settings/SettingsPage'
import MauGraph from './components/MAU/MauGraph'

import scriptSaga from './redux/sagas/CustomScriptSaga'
import licenseDetailsSaga from './redux/sagas/LicenseDetailsSaga'
import apiRoleSaga from './redux/sagas/ApiRoleSaga'
Expand All @@ -22,6 +23,7 @@ import apiRoleReducer from './redux/reducers/ApiRoleReducer'
import apiPermissionReducer from './redux/reducers/ApiPermissionReducer'
import licenseDetailsReducer from './redux/reducers/LicenseDetailsReducer'
import mappingReducer from './redux/reducers/MappingReducer'
import userReducer from './redux/reducers/UserReducer'
import {
ACR_READ,
ROLE_READ,
Expand Down Expand Up @@ -155,6 +157,7 @@ const pluginMetadata = {
{ name: 'apiPermissionReducer', reducer: apiPermissionReducer },
{ name: 'licenseDetailsReducer', reducer: licenseDetailsReducer },
{ name: 'mappingReducer', reducer: mappingReducer },
{ name: 'userReducer', reducer: userReducer },
],
sagas: [
scriptSaga(),
Expand Down
7 changes: 6 additions & 1 deletion admin-ui/plugins/admin/redux/actions/UserActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { UM_GET_USERS } from './types'
import { UM_GET_USERS, UM_UPDATE_USERS_RESPONSE } from './types'

export const getUsers = (action) => ({
type: UM_GET_USERS,
payload: { action },
})

export const updateUserResponse = (action) => ({
type: UM_UPDATE_USERS_RESPONSE,
payload: { action },
})
1 change: 1 addition & 0 deletions admin-ui/plugins/admin/redux/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ export const UPDATE_LICENSE_DETAILS_RESPONSE = 'UPDATE_LICENSE_DETAILS_RESPONSE'
// User Management

export const UM_GET_USERS = 'UM_GET_USERS'
export const UM_UPDATE_USERS_RESPONSE = 'UM_UPDATE_USERS_RESPONSE'
5 changes: 5 additions & 0 deletions admin-ui/plugins/admin/redux/api/UserApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ export default class UserApi {
constructor(api) {
this.api = api
}

getUsers = () => {
return new Promise((resolve, reject) => {
this.api.getScimUsers((error, data) => {
console.log('API', data)
console.log('API', error)
this.handleResponse(error, reject, resolve, data)
})
})
}

handleResponse(error, reject, resolve, data) {
if (error) {
console.log(error)
reject(error)
} else {
console.log('DATA', data)
resolve(data)
}
}
Expand Down
29 changes: 29 additions & 0 deletions admin-ui/plugins/admin/redux/reducers/UserReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { UM_UPDATE_USERS_RESPONSE } from '../actions/types'
import reducerRegistry from '../../../../app/redux/reducers/ReducerRegistry'

const INIT_STATE = {
items: [],
loading: false,
}
const reducerName = 'userReducer'

export default function userReducer(state = INIT_STATE, action) {
switch (action.type) {
case UM_UPDATE_USERS_RESPONSE:
console.log(action)
return {
...state,
loading: false,
}
default:
return handleDefault()
}

function handleDefault() {
return {
...state,
loading: false,
}
}
}
reducerRegistry.register(reducerName, userReducer)
18 changes: 7 additions & 11 deletions admin-ui/plugins/admin/redux/sagas/UserSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ import {
select,
takeEvery,
} from 'redux-saga/effects'
import {
getMappingResponse,
updatePermissionsServerResponse,
updatePermissionsLoading,
getMapping,
} from '../actions/MappingActions'
import { API_USERS } from '../audit/Resources'
import { FETCH } from '../../../../app/audit/UserActionType'
import { getAPIAccessToken } from '../../../../app/redux/actions/AuthActions'
Expand All @@ -23,10 +17,10 @@ import {
import { UM_GET_USERS } from '../actions/types'
import UserApi from '../api/UserApi'
import { getClient } from '../../../../app/redux/api/base'
import { postUserAction } from '../../../../app/redux/api/backend-api'
const JansConfigApi = require('jans_config_api')
import { initAudit } from '../../../../app/redux/sagas/SagaUtils'

import { updateUserResponse } from '../actions/UserActions'
import { postUserAction } from '../../../../app/redux/api/backend-api'
function* newFunction() {
const token = yield select((state) => state.authReducer.token.access_token)
const issuer = yield select((state) => state.authReducer.issuer)
Expand All @@ -41,10 +35,12 @@ export function* getUsersSaga({ payload }) {
try {
addAdditionalData(audit, FETCH, API_USERS, payload)
const userApi = yield* newFunction()
const data = yield call(userApi.getUsers)
console.log('Called')
const data = yield call(userApi.getUsers, payload)
yield put(updateUserResponse(data))
console.log(data)
// yield put(getMappingResponse(data))
// yield call(postUserAction, audit)
yield call(postUserAction, audit)
} catch (e) {
console.log(e)
// yield put(getMappingResponse(null))
Expand All @@ -56,7 +52,7 @@ export function* getUsersSaga({ payload }) {
}

export function* watchGetUsers() {
yield takeLatest(UM_GET_USERS, getUsersSaga)
yield takeEvery(UM_GET_USERS, getUsersSaga)
}

export default function* rootSaga() {
Expand Down

0 comments on commit 6542d2d

Please sign in to comment.