Skip to content

Commit

Permalink
fix(admin-ui): removed redux & action types
Browse files Browse the repository at this point in the history
  • Loading branch information
jv18creator committed May 25, 2023
1 parent 483774d commit d00d49f
Show file tree
Hide file tree
Showing 35 changed files with 306 additions and 396 deletions.
3 changes: 1 addition & 2 deletions admin-ui/app/redux/store/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { combineReducers } from 'redux'
import { configureStore } from '@reduxjs/toolkit'
import { configureStore, combineReducers } from '@reduxjs/toolkit'
import createSagaMiddleware from 'redux-saga'
import appReducers from '../reducers'
import RootSaga from '../sagas'
Expand Down
8 changes: 4 additions & 4 deletions admin-ui/app/routes/Apps/Gluu/Tests/GluuAppSiderbar.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import { render } from '@testing-library/react'
import GluuAppSidebar from '../GluuAppSidebar'
import { combineReducers, createStore } from 'redux'
import { BrowserRouter as Router } from 'react-router-dom'
import { Provider } from 'react-redux'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'
import Sidebar from 'Components/Sidebar'
import { configureStore, combineReducers } from '@reduxjs/toolkit'

jest.spyOn(global.console, 'log').mockImplementation(jest.fn())
jest.spyOn(global.console, 'error').mockImplementation(jest.fn())
Expand All @@ -20,12 +20,12 @@ const INIT_STATE = {
permissions: permissions,
}

const store = createStore(
combineReducers({
const store = configureStore({
reducer: combineReducers({
authReducer: (state = INIT_STATE) => state,
noReducer: (state = {}) => state,
}),
)
})
const pageConfig = {}
const Wrapper = ({ children }) => (
<I18nextProvider i18n={i18n}>
Expand Down
11 changes: 6 additions & 5 deletions admin-ui/app/routes/License/LicenseDetailsPage.test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import LicenseDetailsPage from './LicenseDetailsPage'
import { createStore, combineReducers } from 'redux'
import LicenseDetailsPage from './LicenseDetailsPage'
import { Provider } from 'react-redux'
import i18n from '../../i18n'
import { I18nextProvider } from 'react-i18next'
import license from "./license"
import AppTestWrapper from 'Routes/Apps/Gluu/Tests/Components/AppTestWrapper.test'
import { combineReducers, configureStore } from '@reduxjs/toolkit'

const INIT_LICENSE_DETAIL_STATE = {
item: license,
loading: false,
}
const store = createStore(
combineReducers({

const store = configureStore({
reducer: combineReducers({
licenseDetailsReducer: (state = INIT_LICENSE_DETAIL_STATE) => state,
noReducer: (state = {}) => state,
}),
)
})

const Wrapper = ({ children }) => (
<AppTestWrapper>
Expand Down
1 change: 0 additions & 1 deletion admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
"react-tooltip": "^5.10.5",
"reactstrap": "^9.1.8",
"recharts": "^2.5.0",
"redux": "^4.2.1",
"redux-persist": "^6.0.0",
"redux-saga": "^1.2.3",
"sass": "^1.60.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import CustomScriptAddPage from './CustomScriptAddPage'
import { createStore, combineReducers } from 'redux'
import { Provider } from 'react-redux'
import i18n from '../../../../app/i18n'
import { I18nextProvider } from 'react-i18next'
import item from "./item"
import AppTestWrapper from 'Routes/Apps/Gluu/Tests/Components/AppTestWrapper.test'
import { combineReducers, configureStore } from '@reduxjs/toolkit'

const permissions = [
'https://jans.io/oauth/config/attributes.readonly',
Expand All @@ -21,14 +21,15 @@ const INIT_CUSTOM_SCRIPT_STATE = {
item,
],
loading: false,
}
const store = createStore(
combineReducers({
}

const store = configureStore({
reducer: combineReducers({
authReducer: (state = INIT_STATE) => state,
customScriptReducer: (state = INIT_CUSTOM_SCRIPT_STATE) => state,
noReducer: (state = {}) => state,
}),
)
})

const Wrapper = ({ children }) => (
<AppTestWrapper>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import CustomScriptEditPage from './CustomScriptEditPage'
import { createStore, combineReducers } from 'redux'
import CustomScriptEditPage from './CustomScriptEditPage'
import { Provider } from 'react-redux'
import item from "./item"
import script from "./script.test"
import AppTestWrapper from 'Routes/Apps/Gluu/Tests/Components/AppTestWrapper.test'
import { combineReducers, configureStore } from '@reduxjs/toolkit'

const permissions = [
'https://jans.io/oauth/config/attributes.readonly',
Expand All @@ -22,13 +22,14 @@ const INIT_CUSTOM_SCRIPT_STATE = {
item: item,
loading: false,
}
const store = createStore(
combineReducers({

const store = configureStore({
reducer: combineReducers({
authReducer: (state = INIT_STATE) => state,
customScriptReducer: (state = INIT_CUSTOM_SCRIPT_STATE) => state,
noReducer: (state = {}) => state,
}),
)
})

const Wrapper = ({ children }) => (
<AppTestWrapper>
Expand Down
11 changes: 6 additions & 5 deletions admin-ui/plugins/admin/components/Roles/UiRoleListPage.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import { render } from '@testing-library/react'
import UiRoleListPage from './UiRoleListPage'
import { createStore, combineReducers } from 'redux'
import UiRoleListPage from './UiRoleListPage'
import { Provider } from 'react-redux'
import roles from "./roles"
import AppTestWrapper from 'Routes/Apps/Gluu/Tests/Components/AppTestWrapper.test'
import { combineReducers, configureStore } from '@reduxjs/toolkit'

const permissions = [
'https://jans.io/oauth/config/attributes.readonly',
Expand All @@ -18,13 +18,14 @@ const INIT_API_ROLE_STATE = {
items: roles,
loading: false,
}
const store = createStore(
combineReducers({

const store = configureStore({
reducer: combineReducers({
authReducer: (state = INIT_STATE) => state,
apiRoleReducer: (state = INIT_API_ROLE_STATE) => state,
noReducer: (state = {}) => state,
}),
)
})

const Wrapper = ({ children }) => (
<AppTestWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import GluuLoader from 'Routes/Apps/Gluu/GluuLoader'
import { useNavigate } from 'react-router-dom'
import { addNewClientAction } from 'Plugins/auth-server/redux/actions/OIDCActions'
import { getOidcDiscovery } from 'Redux/actions/OidcDiscoveryActions'
import { getScopes } from 'Plugins/auth-server/redux/actions/ScopeActions'
import { getScopes } from 'Plugins/auth-server/redux/features/scopeSlice'
import { getScripts } from 'Redux/actions/InitActions'
import { buildPayload } from 'Utils/PermChecker'
import GluuAlert from 'Routes/Apps/Gluu/GluuAlert'
Expand All @@ -29,7 +29,7 @@ function ClientAddPage({
useEffect(() => {
buildPayload(userAction, '', options)
if (scopes.length < 1) {
dispatch(getScopes(userAction))
dispatch(getScopes({ action: userAction }))
}
if (scripts.length < 1) {
dispatch(getScripts(userAction))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import ClientAddPage from './ClientAddPage'
import { BrowserRouter as Router } from 'react-router-dom'
import { createStore, combineReducers } from 'redux'
import { BrowserRouter as Router } from 'react-router-dom'
import { Provider } from 'react-redux'
import i18n from '../../../../app/i18n'
import { I18nextProvider } from 'react-i18next'
Expand All @@ -11,6 +10,7 @@ import oidcDiscoveryReducer from 'Redux/reducers/OidcDiscoveryReducer'
import { reducer as scopeReducer} from 'Plugins/auth-server/redux/features/scopeSlice'
import umaResourceReducer from 'Plugins/auth-server/redux/reducers/UMAResourceReducer'
import AppTestWrapper from 'Routes/Apps/Gluu/Tests/Components/AppTestWrapper.test'
import { combineReducers, configureStore } from '@reduxjs/toolkit'
const permissions = [
'https://jans.io/oauth/config/openid/clients.readonly',
'https://jans.io/oauth/config/openid/clients.write',
Expand All @@ -37,8 +37,9 @@ const INIT_SCPOPES_STATE = {
item: {},
loading: false,
}
const store = createStore(
combineReducers({

const store = configureStore({
reducer: combineReducers({
authReducer: (state = INIT_STATE) => state,
oidcReducer: (state = INIT_SCPOPES_STATE) => state,
umaResourceReducer,
Expand All @@ -47,7 +48,7 @@ const store = createStore(
oidcDiscoveryReducer,
noReducer: (state = {}) => state,
}),
)
})

const Wrapper = ({ children }) => (
<AppTestWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ import { useTranslation } from 'react-i18next'
import { getClientScopeByInum } from '../../../../app/utils/Util'
import { useDispatch, useSelector } from 'react-redux'
import { PER_PAGE_SCOPES } from '../../common/Constants'
import { getClientScopes } from '../../redux/actions/ScopeActions'
import { isEmpty } from 'lodash'
import _debounce from 'lodash/debounce'
import { getScopes } from 'Plugins/auth-server/redux/actions/ScopeActions'
import { getScopes, getClientScopes } from 'Plugins/auth-server/redux/features/scopeSlice'
const DOC_CATEGORY = 'openid_client'

const ClientBasicPanel = ({
Expand Down Expand Up @@ -94,7 +93,7 @@ const ClientBasicPanel = ({
}
userAction["pattern"] = scopeInums.join(",")
userAction["limit"] = PER_PAGE_SCOPES
dispatch(getClientScopes(userAction))
dispatch(getClientScopes({ action: userAction }))
}
}, [])

Expand All @@ -108,7 +107,7 @@ const ClientBasicPanel = ({
delete userScopeAction.startIndex
}
if (totalItems + PER_PAGE_SCOPES > userScopeAction.limit) {
dispatch(getScopes(userScopeAction))
dispatch(getScopes({ action: userScopeAction }))
}
};

Expand All @@ -122,7 +121,7 @@ const ClientBasicPanel = ({
function handleDebounceFn(inputValue) {
userScopeAction['pattern'] = inputValue
delete userScopeAction.startIndex
dispatch(getScopes(userScopeAction))
dispatch(getScopes({ action: userScopeAction }))
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { FormControlLabel, Radio, RadioGroup } from '@mui/material'
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 } from 'Plugins/auth-server/redux/features/scopeSlice'
import {
setCurrentItem as setCurrentItemClient,
viewOnly,
Expand Down Expand Up @@ -95,7 +95,7 @@ function ClientCibaParUmaPanel({
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import GluuLoader from 'Routes/Apps/Gluu/GluuLoader'
import { useNavigate } from 'react-router-dom'
import { connect } from 'react-redux'
import { editClient } from 'Plugins/auth-server/redux/actions/OIDCActions'
import { getScopes, getScopeByCreator } from 'Plugins/auth-server/redux/actions/ScopeActions'
import { getScopes, getScopeByCreator } from 'Plugins/auth-server/redux/features/scopeSlice'
import { getOidcDiscovery } from 'Redux/actions/OidcDiscoveryActions'
import { getUMAResourcesByClient } from 'Plugins/auth-server/redux/actions/UMAResourceActions'
import { getScripts } from 'Redux/actions/InitActions'
Expand Down Expand Up @@ -33,10 +33,10 @@ function ClientEditPage({
const navigate =useNavigate()

useEffect(() => {
dispatch(getScopeByCreator({ inum: clientData.inum }))
dispatch(getScopeByCreator({ action: { inum: clientData.inum } }))
buildPayload(userAction, '', options)
if (scopes.length < 1) {
dispatch(getScopes(options))
dispatch(getScopes({ action: options }))
}
if (scripts.length < 1) {
dispatch(getScripts(options))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import ClientEditPage from './ClientEditPage'
import { createStore, combineReducers } from 'redux'
import { Provider } from 'react-redux'
import clients from './clients.test'
import initReducer from 'Redux/reducers/InitReducer'
import oidcDiscoveryReducer from 'Redux/reducers/OidcDiscoveryReducer'
import { reducer as scopeReducer} from 'Plugins/auth-server/redux/features/scopeSlice'
import umaResourceReducer from 'Plugins/auth-server/redux/reducers/UMAResourceReducer'
import AppTestWrapper from 'Routes/Apps/Gluu/Tests/Components/AppTestWrapper.test'
import { combineReducers, configureStore } from '@reduxjs/toolkit'
const permissions = [
'https://jans.io/oauth/config/openid/clients.readonly',
'https://jans.io/oauth/config/openid/clients.write',
Expand All @@ -25,8 +25,8 @@ const INIT_CLIENTS_STATE = {
errorInSaveOperationFlag: false
}

const store = createStore(
combineReducers({
const store = configureStore({
reducer: combineReducers({
authReducer: (state = INIT_STATE) => state,
oidcReducer: (state = INIT_CLIENTS_STATE) => state,
umaResourceReducer,
Expand All @@ -35,7 +35,7 @@ const store = createStore(
oidcDiscoveryReducer,
noReducer: (state = {}) => state,
}),
)
})

const Wrapper = ({ children }) => (
<AppTestWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useNavigate, useLocation } from 'react-router-dom'
import { useSelector, useDispatch } from 'react-redux'
import { Paper, TablePagination } from '@mui/material'
import { Card, CardBody, Badge } from 'Components'
import { getScopes } from 'Plugins/auth-server/redux/actions/ScopeActions'
import { getScopes } from 'Plugins/auth-server/redux/features/scopeSlice'
import { resetUMAResources } from 'Plugins/auth-server/redux/actions/UMAResourceActions'
import GluuDialog from 'Routes/Apps/Gluu/GluuDialog'
import ClientDetailPage from '../Clients/ClientDetailPage'
Expand Down Expand Up @@ -190,7 +190,7 @@ function ClientListPage() {

buildPayload(userAction, '', options)
userAction['limit'] = 100
dispatch(getScopes(userAction))
dispatch(getScopes({ action: userAction }))

setTimeout(() => {
setIsPageLoading(false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import ClientListPage from './ClientListPage'
import { combineReducers, createStore} from 'redux'
import ClientListPage from './ClientListPage'
import { Provider } from 'react-redux'
import clients from './clients.test'
import AppTestWrapper from 'Routes/Apps/Gluu/Tests/Components/AppTestWrapper.test'
import { combineReducers, configureStore } from '@reduxjs/toolkit'

const permissions = [
'https://jans.io/oauth/config/openid/clients.readonly',
Expand Down Expand Up @@ -40,14 +40,15 @@ const INIT_SCPOPES_STATE = {
item: {},
loading: false,
}
const store = createStore(
combineReducers({

const store = configureStore({
reducer: combineReducers({
authReducer: (state = INIT_STATE) => state,
oidcReducer: (state = INIT_CLIENTS_STATE) => state,
scopeReducer: (state = INIT_SCPOPES_STATE) => state,
noReducer: (state = {}) => state,
}),
)
})

const Wrapper = ({ children }) => (
<AppTestWrapper>
Expand Down
Loading

0 comments on commit d00d49f

Please sign in to comment.