Skip to content

Commit b4d6521

Browse files
committed
fix(admin-ui): resolve all bugs displayed for admin-ui bug #308
1 parent 0e2a476 commit b4d6521

File tree

2 files changed

+23
-45
lines changed

2 files changed

+23
-45
lines changed

plugins/auth-server/redux/reducers/OIDCReducer.js

+10-16
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,9 @@ const reducerName = 'oidcReducer'
2525
export default function oidcReducer(state = INIT_STATE, action) {
2626
switch (action.type) {
2727
case GET_OPENID_CLIENTS:
28-
return {
29-
...state,
30-
loading: true,
31-
}
28+
return handleLoading()
3229
case SEARCH_CLIENTS:
33-
return {
34-
...state,
35-
loading: true,
36-
}
30+
return handleLoading()
3731
case GET_OPENID_CLIENTS_RESPONSE:
3832
if (action.payload.data) {
3933
return {
@@ -46,10 +40,7 @@ export default function oidcReducer(state = INIT_STATE, action) {
4640
}
4741

4842
case ADD_NEW_CLIENT:
49-
return {
50-
...state,
51-
loading: true,
52-
}
43+
return handleLoading()
5344
case ADD_CLIENT_RESPONSE:
5445
if (action.payload.data) {
5546
return {
@@ -83,10 +74,7 @@ export default function oidcReducer(state = INIT_STATE, action) {
8374
}
8475

8576
case DELETE_CLIENT:
86-
return {
87-
...state,
88-
loading: true,
89-
}
77+
return handleLoading()
9078

9179
case DELETE_CLIENT_RESPONSE:
9280
if (action.payload.data) {
@@ -132,5 +120,11 @@ export default function oidcReducer(state = INIT_STATE, action) {
132120
loading: false,
133121
}
134122
}
123+
function handleLoading() {
124+
return {
125+
...state,
126+
loading: true,
127+
}
128+
}
135129
}
136130
reducerRegistry.register(reducerName, oidcReducer)

plugins/auth-server/redux/reducers/ScopeReducer.js

+13-29
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,9 @@ const reducerName = 'scopeReducer'
2727
export default function scopeReducer(state = INIT_STATE, action) {
2828
switch (action.type) {
2929
case GET_SCOPES:
30-
return {
31-
...state,
32-
loading: true,
33-
}
30+
return handleLoading()
3431
case SEARCH_SCOPES:
35-
return {
36-
...state,
37-
loading: true,
38-
}
32+
return handleLoading()
3933
case GET_SCOPES_RESPONSE:
4034
if (action.payload.data) {
4135
return {
@@ -47,10 +41,7 @@ export default function scopeReducer(state = INIT_STATE, action) {
4741
return handleDefault()
4842
}
4943
case GET_SCOPE_BY_INUM:
50-
return {
51-
...state,
52-
loading: true,
53-
}
44+
return handleLoading()
5445
case GET_SCOPE_BY_INUM_RESPONSE:
5546
if (action.payload.data) {
5647
return {
@@ -62,10 +53,7 @@ export default function scopeReducer(state = INIT_STATE, action) {
6253
return handleDefault()
6354
}
6455
case GET_SCOPE_BY_PATTERN:
65-
return {
66-
...state,
67-
loading: true,
68-
}
56+
return handleLoading()
6957
case GET_SCOPE_BY_PATTERN_RESPONSE:
7058
if (action.payload.data) {
7159
return {
@@ -78,10 +66,7 @@ export default function scopeReducer(state = INIT_STATE, action) {
7866
}
7967

8068
case ADD_SCOPE:
81-
return {
82-
...state,
83-
loading: true,
84-
}
69+
return handleLoading()
8570
case ADD_SCOPE_RESPONSE:
8671
if (action.payload.data) {
8772
return {
@@ -94,10 +79,7 @@ export default function scopeReducer(state = INIT_STATE, action) {
9479
}
9580

9681
case EDIT_SCOPE:
97-
return {
98-
...state,
99-
loading: true,
100-
}
82+
return handleLoading()
10183

10284
case EDIT_SCOPE_RESPONSE:
10385
if (action.payload.data) {
@@ -110,10 +92,7 @@ export default function scopeReducer(state = INIT_STATE, action) {
11092
return handleDefault()
11193
}
11294
case DELETE_SCOPE:
113-
return {
114-
...state,
115-
loading: true,
116-
}
95+
return handleLoading()
11796
case DELETE_SCOPE_RESPONSE:
11897
if (action.payload.data) {
11998
return {
@@ -140,7 +119,12 @@ export default function scopeReducer(state = INIT_STATE, action) {
140119
default:
141120
return handleDefault()
142121
}
143-
122+
function handleLoading() {
123+
return {
124+
...state,
125+
loading: true,
126+
}
127+
}
144128
function handleDefault() {
145129
return {
146130
...state,

0 commit comments

Comments
 (0)