-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): create redux for uma
- Loading branch information
1 parent
68f7cb0
commit 8a4aeb4
Showing
13 changed files
with
171 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
admin-ui/plugins/auth-server/redux/actions/UMAResourceActions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { | ||
GET_UMA_RESOURCES, | ||
GET_UMA_RESOURCES_RESPONSE | ||
} from './types' | ||
|
||
export const getUMAResourcesByClient = (inum) => ({ | ||
type: GET_UMA_RESOURCES, | ||
payload: { inum }, | ||
}) | ||
|
||
export const getUMAResourcesByClientResponse = (data) => ({ | ||
type: GET_UMA_RESOURCES_RESPONSE, | ||
payload: { data }, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export default class UMAResourceApi { | ||
constructor(api) { | ||
this.api = api | ||
} | ||
|
||
getUMAResources = async (clientId) => { | ||
return new Promise((resolve, reject) => { | ||
this.api.getOauthUmaResourcesByClientid(clientId, (error, data) => { | ||
this.handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
handleResponse(error, reject, resolve, data) { | ||
if (error) { | ||
reject(error) | ||
} else { | ||
resolve(data) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const OIDC = 'openid-client' | ||
export const SCOPE = 'scope' | ||
export const UMA = 'uma' | ||
export const JSON_CONFIG = 'json-configuration' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
admin-ui/plugins/auth-server/redux/reducers/UMAResourceReducer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { | ||
RESET, | ||
GET_UMA_RESOURCES, | ||
GET_UMA_RESOURCES_RESPONSE | ||
} from '../actions/types' | ||
import reducerRegistry from 'Redux/reducers/ReducerRegistry' | ||
|
||
const INIT_STATE = { | ||
items: [], | ||
loading: false, | ||
} | ||
|
||
const reducerName = 'UMAResourceReducer' | ||
|
||
export default function UMAResourceReducer(state = INIT_STATE, action) { | ||
switch (action.type) { | ||
|
||
case GET_UMA_RESOURCES: | ||
return handleLoading() | ||
|
||
case GET_UMA_RESOURCES_RESPONSE: | ||
if (action.payload.data) { | ||
return { | ||
...state, | ||
items: action.payload.data, | ||
loading: false, | ||
} | ||
} else { | ||
return handleDefault() | ||
} | ||
|
||
case RESET: | ||
return { | ||
...state, | ||
items: INIT_STATE.items, | ||
loading: INIT_STATE.loading, | ||
} | ||
|
||
default: | ||
return handleDefault() | ||
} | ||
|
||
function handleDefault() { | ||
return { | ||
...state, | ||
loading: false, | ||
} | ||
} | ||
function handleLoading() { | ||
return { | ||
...state, | ||
loading: true, | ||
} | ||
} | ||
} | ||
|
||
reducerRegistry.register(reducerName, UMAResourceReducer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.