Skip to content

Commit

Permalink
feat(admin-ui): create a shared redux that can use by all admin-ui pl…
Browse files Browse the repository at this point in the history
…ugins. #350
  • Loading branch information
syntrydy committed Jan 11, 2022
1 parent 35a7314 commit 02a6427
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions plugins.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
"title": "Services Plugin",
"key": "services",
"metadataFile": "./services/plugin-metadata",
"enabled": false
"enabled": true
},
{
"title": "Auth Server Plugin",
"key": "auth-server",
"metadataFile": "./auth-server/plugin-metadata",
"enabled": false
"enabled": true
},
{
"title": "Schema Plugin",
"key": "schema",
"metadataFile": "./schema/plugin-metadata",
"enabled": false
"enabled": true
},
{
"title": "Admin Plugin",
"key": "admin",
"metadataFile": "./admin/plugin-metadata",
"enabled": false
"enabled": true
}
]
2 changes: 1 addition & 1 deletion plugins/admin/components/MonthlyActiveUsersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ function MonthlyActiveUsersPage({ stat, permissions, loading, dispatch }) {
const mapStateToProps = (state) => {
return {
stat: state.mauReducer.stat,
loading: state.oidcReducer.loading,
loading: state.mauReducer.loading,
permissions: state.authReducer.permissions,
}
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/auth-server/components/Clients/ClientAddPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useHistory } from 'react-router-dom'
import { addNewClientAction } from '../../redux/actions/OIDCActions'
import { getOidcDiscovery } from '../../../../app/redux/actions/OidcDiscoveryActions'
import { getScopes } from '../../redux/actions/ScopeActions'
import { getCustomScripts } from '../../../admin/redux/actions/CustomScriptActions'
import { getScripts } from '../../../../app/redux/actions/InitActions'
import { buildPayload } from '../../../../app/utils/PermChecker'

function ClientAddPage({
Expand All @@ -26,7 +26,7 @@ function ClientAddPage({
dispatch(getScopes(userAction))
}
if (scripts.length < 1) {
dispatch(getCustomScripts(userAction))
dispatch(getScripts(userAction))
}
dispatch(getOidcDiscovery())
}, [])
Expand Down
4 changes: 2 additions & 2 deletions plugins/auth-server/components/Clients/ClientEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { connect } from 'react-redux'
import { editClient } from '../../redux/actions/OIDCActions'
import { getScopes } from '../../redux/actions/ScopeActions'
import { getOidcDiscovery } from '../../../../app/redux/actions/OidcDiscoveryActions'
import { getCustomScripts } from '../../../admin/redux/actions/CustomScriptActions'
import { getScripts } from '../../../../app/redux/actions/InitActions'
import { buildPayload } from '../../../../app/utils/PermChecker'

function ClientEditPage({
Expand All @@ -28,7 +28,7 @@ function ClientEditPage({
dispatch(getScopes(options))
}
if (scripts.length < 1) {
dispatch(getCustomScripts(options))
dispatch(getScripts(options))
}
dispatch(getOidcDiscovery())
}, [])
Expand Down
4 changes: 2 additions & 2 deletions plugins/auth-server/components/Scopes/ScopeAddPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ const mapStateToProps = (state) => {
return {
loading: state.scopeReducer.loading,
permissions: state.authReducer.permissions,
scripts: state.customScriptReducer.items,
attributes: state.attributeReducer.items,
scripts: state.initReducer.scripts,
attributes: state.initReducer.attributes,
}
}
export default connect(mapStateToProps)(ScopeAddPage)
14 changes: 9 additions & 5 deletions plugins/auth-server/components/Scopes/ScopeAddPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ const permissions = [
const INIT_STATE = {
permissions: permissions,
}
const INIT_SCPOPES_STATE = {
const SCPOPES_STATE = {
items: scopes,
item: {},
loading: false,
}
const STATE = {
scopes: [],
scripts: [],
attributes: [],
}
const store = createStore(
combineReducers({
authReducer: (state = INIT_STATE) => state,
customScriptReducer: (state = INIT_SCPOPES_STATE) => state,
attributeReducer: (state = INIT_SCPOPES_STATE) => state,
scopeReducer,
initReducer: (state = STATE) => state,
scopeReducer: (state = SCPOPES_STATE) => state,
noReducer: (state = {}) => state,
}),
)
Expand All @@ -38,7 +42,7 @@ const Wrapper = ({ children }) => (
)

it('Should render the scope add page properly', () => {
render(<ScopeAddPage/>, {
render(<ScopeAddPage />, {
wrapper: Wrapper,
})
screen.getByText(/Display Name/)
Expand Down
4 changes: 2 additions & 2 deletions plugins/auth-server/components/Scopes/ScopeEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const mapStateToProps = (state) => {
scope: state.scopeReducer.item,
loading: state.scopeReducer.loading,
permissions: state.authReducer.permissions,
scripts: state.customScriptReducer.items,
attributes: state.attributeReducer.items,
scripts: state.initReducer.scripts,
attributes: state.initReducer.attributes,
}
}

Expand Down
16 changes: 6 additions & 10 deletions plugins/auth-server/components/Scopes/ScopeEditPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { createStore, combineReducers } from 'redux'
import { Provider } from 'react-redux'
import i18n from '../../../../app/i18n'
import { I18nextProvider } from 'react-i18next'
import attributeReducer from '../../../schema/redux/reducers/AttributeReducer'
import customScriptReducer from '../../../admin/redux/reducers/CustomScriptReducer'
import scopes from './scopes'

const permissions = [
Expand All @@ -17,17 +15,15 @@ const permissions = [
const INIT_STATE = {
permissions: permissions,
}
const INIT_SCPOPES_STATE = {
items: [scopes[0]],
item: {},
loading: false,
const INIT_SHARED_STATE = {
scopes: [scopes[0]],
attributes: [],
scripts: [],
}
const store = createStore(
combineReducers({
authReducer: (state = INIT_STATE) => state,
customScriptReducer,
attributeReducer,
scopeReducer: (state = INIT_SCPOPES_STATE) => state,
initReducer: (state = INIT_SHARED_STATE) => state,
noReducer: (state = {}) => state,
}),
)
Expand All @@ -39,7 +35,7 @@ const Wrapper = ({ children }) => (
)

it('Should render the scope edit page properly', () => {
render(<ScopeEditPage/>, {
render(<ScopeEditPage />, {
wrapper: Wrapper,
})
screen.getByText(/Display Name/)
Expand Down

0 comments on commit 02a6427

Please sign in to comment.