Skip to content

Commit

Permalink
Merge pull request #1064 from GluuFederation/admin-ui-issue-1060
Browse files Browse the repository at this point in the history
feat(admin-ui): remove the redux boilerplate in admin using redux toolkit #1060
  • Loading branch information
duttarnab authored Jun 1, 2023
2 parents 52690b3 + 543c586 commit d8705b8
Show file tree
Hide file tree
Showing 57 changed files with 737 additions and 1,341 deletions.
48 changes: 0 additions & 48 deletions admin-ui/app/redux/actions/InitActions.js

This file was deleted.

26 changes: 0 additions & 26 deletions admin-ui/app/redux/actions/LicenseDetailsActions.js

This file was deleted.

11 changes: 0 additions & 11 deletions admin-ui/app/redux/actions/MauActions.js

This file was deleted.

1 change: 0 additions & 1 deletion admin-ui/app/redux/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Redux Actions
*/
export * from './AuthActions'
export * from './InitActions'
export * from './LicenseActions'
export * from './OidcDiscoveryActions'
export * from './AttributesActions'
17 changes: 0 additions & 17 deletions admin-ui/app/redux/actions/types.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
export const GET_MAU = 'GET_MAU'
export const GET_MAU_RESPONSE = 'GET_MAU_RESPONSE'
//Stat Actions
export const GET_SCRIPTS_FOR_STAT = 'GET_SCRIPTS_FOR_STAT'
export const GET_SCRIPTS_FOR_STAT_RESPONSE = 'GET_SCRIPTS_FOR_STAT_RESPONSE'
export const GET_SCOPES_FOR_STAT = 'GET_SCOPES_FOR_STAT'
export const GET_SCOPES_FOR_STAT_RESPONSE = 'GET_SCOPES_FOR_STAT_RESPONSE'
export const GET_ATTRIBUTES_FOR_STAT = 'GET_ATTRIBUTES_FOR_STAT'
export const GET_ATTRIBUTES_FOR_STAT_RESPONSE =
'GET_ATTRIBUTES_FOR_STAT_RESPONSE'
export const GET_ATTRIBUTES_FOR_USER_MANAGEMENT = "GET_ATTRIBUTES_FOR_USER_MANAGEMENT"
export const GET_ATTRIBUTES_FOR_USER_MANAGEMENT_RESPONSE = "GET_ATTRIBUTES_FOR_USER_MANAGEMENT_RESPONSE"
export const GET_CLIENTS_FOR_STAT = 'GET_CLIENTS_FOR_STAT'
export const GET_CLIENTS_FOR_STAT_RESPONSE = 'GET_CLIENTS_FOR_STAT_RESPONSE'

// Auth Actions
export const GET_OAUTH2_CONFIG = 'GET_OAUTH2_CONFIG'
Expand Down Expand Up @@ -87,12 +76,6 @@ export const GET_OIDC_DISCOVERY_RESPONSE = 'GET_OIDC_DISCOVERY_RESPONSE'
export const GET_HEALTH = 'GET_HEALTH'
export const GET_HEALTH_RESPONSE = 'GET_HEALTH_RESPONSE'

//License Details
export const GET_LICENSE_DETAILS = 'GET_LICENSE_DETAILS'
export const GET_LICENSE_DETAILS_RESPONSE = 'GET_LICENSE_DETAILS_RESPONSE'
export const UPDATE_LICENSE_DETAILS = 'UPDATE_LICENSE_DETAILS'
export const UPDATE_LICENSE_DETAILS_RESPONSE = 'UPDATE_LICENSE_DETAILS_RESPONSE'

//User Management
export const GET_USERS = 'GET_USERS'
export const GET_USERS_RESPONSE = 'GET_USERS_RESPONSE'
Expand Down
55 changes: 55 additions & 0 deletions admin-ui/app/redux/features/initSlice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import reducerRegistry from 'Redux/reducers/ReducerRegistry'
import { createSlice } from '@reduxjs/toolkit'

const initialState = {
scripts: [],
clients: [],
scopes: [],
attributes: [],
totalClientsEntries: 0
}

const initSlice = createSlice({
name: 'init',
initialState,
reducers: {
getScripts: () => {},
getScriptsResponse: (state, action) => {
if (action.payload?.data) {
state.scripts = action.payload.data?.entries
}
},
getClients: () => {},
getClientsResponse: (state, action) => {
if (action.payload?.data) {
state.clients = action.payload.data?.entries
state.totalClientsEntries = action.payload.data.totalEntriesCount
}
},
getScopes: () => {},
getScopesResponse: (state, action) => {
if (action.payload?.data) {
state.scopes = action.payload.data
}
},
getAttributes: () => {},
getAttributesResponse: (state, action) => {
if (action.payload?.data) {
state.attributes = action.payload.data?.entries
}
}
}
})

export const {
getScripts,
getScriptsResponse,
getClients,
getClientsResponse,
getScopes,
getScopesResponse,
getAttributes,
getAttributesResponse
} = initSlice.actions
export const { actions, reducer, state } = initSlice
reducerRegistry.register('initReducer', reducer)
59 changes: 59 additions & 0 deletions admin-ui/app/redux/features/licenseDetailsSlice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import reducerRegistry from 'Redux/reducers/ReducerRegistry'
import { createSlice } from '@reduxjs/toolkit'

const initialState = {
item: {},
loading: true
}

const licenseDetailsSlice = createSlice({
name: 'licenseDetails',
initialState,
reducers: {
getLicenseDetails: (state) => ({
...state,
loading: true
}),
getLicenseDetailsResponse: (state, action) => {
if (action.payload?.data) {
return {
...state,
item: action.payload.data,
loading: false
}
} else {
return {
...state,
loading: false
}
}
},
updateLicenseDetails: (state) => ({
...state,
loading: true
}),
updateLicenseDetailsResponse: (state, action) => {
if (action.payload?.data) {
return {
...state,
items: action.payload.data,
loading: false
}
} else {
return {
...state,
loading: false
}
}
}
}
})

export const {
getLicenseDetails,
getLicenseDetailsResponse,
updateLicenseDetails,
updateLicenseDetailsResponse
} = licenseDetailsSlice.actions
export const { actions, reducer, state } = licenseDetailsSlice
reducerRegistry.register('licenseDetailsReducer', reducer)
82 changes: 0 additions & 82 deletions admin-ui/app/redux/reducers/InitReducer.js

This file was deleted.

54 changes: 0 additions & 54 deletions admin-ui/app/redux/reducers/LicenseDetailsReducer.js

This file was deleted.

Loading

0 comments on commit d8705b8

Please sign in to comment.