Skip to content

Commit 7ed9533

Browse files
committed
feat(admin-ui): design the layout for api role management #327
1 parent 5d17005 commit 7ed9533

File tree

4 files changed

+54
-50
lines changed

4 files changed

+54
-50
lines changed

plugins/admin/redux/api/PermissionApi.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,32 @@ export default class PermissionApi {
33
this.api = api
44
}
55
getPermissions = () => {
6-
return new Promise((resolve, reject) => {})
6+
return new Promise((resolve, reject) => {
7+
console.log('=============')
8+
})
79
}
810
getPermission = (options) => {
9-
return new Promise((resolve, reject) => {})
11+
return new Promise((resolve, reject) => {
12+
console.log('=============')
13+
})
1014
}
1115

1216
addPermission = (data) => {
13-
return new Promise((resolve, reject) => {})
17+
return new Promise((resolve, reject) => {
18+
console.log('=============')
19+
})
1420
}
1521

1622
editPermission = (data) => {
17-
return new Promise((resolve, reject) => {})
23+
return new Promise((resolve, reject) => {
24+
console.log('=============')
25+
})
1826
}
1927

2028
deletePermission = async (inum) => {
21-
return new Promise((resolve, reject) => {})
29+
return new Promise((resolve, reject) => {
30+
console.log('=============')
31+
})
2232
}
2333

2434
handleResponse(error, reject, resolve, data) {

plugins/admin/redux/api/RoleApi.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,32 @@ export default class RoleApi {
33
this.api = api
44
}
55
getRoles = () => {
6-
return new Promise((resolve, reject) => {})
6+
return new Promise((resolve, reject) => {
7+
console.log('=============')
8+
})
79
}
810
getRole = (options) => {
9-
return new Promise((resolve, reject) => {})
11+
return new Promise((resolve, reject) => {
12+
console.log('=============')
13+
})
1014
}
1115

1216
addRole = (data) => {
13-
return new Promise((resolve, reject) => {})
17+
return new Promise((resolve, reject) => {
18+
console.log('=============')
19+
})
1420
}
1521

1622
editRole = (data) => {
17-
return new Promise((resolve, reject) => {})
23+
return new Promise((resolve, reject) => {
24+
console.log('=============')
25+
})
1826
}
1927

2028
deleteRole = async (inum) => {
21-
return new Promise((resolve, reject) => {})
29+
return new Promise((resolve, reject) => {
30+
console.log('=============')
31+
})
2232
}
2333

2434
handleResponse(error, reject, resolve, data) {

plugins/admin/redux/reducers/ApiPermissionReducer.js

+12-20
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ const reducerName = 'apiPermissionReducer'
2222
export default function apiPermissionReducer(state = INIT_STATE, action) {
2323
switch (action.type) {
2424
case GET_PERMISSIONS:
25-
return {
26-
...state,
27-
loading: true,
28-
}
25+
return handleLoading()
2926
case GET_PERMISSIONS_RESPONSE:
3027
if (action.payload.data) {
3128
return {
@@ -37,10 +34,7 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
3734
return handleDefault()
3835
}
3936
case GET_PERMISSION:
40-
return {
41-
...state,
42-
loading: true,
43-
}
37+
return handleLoading()
4438
case GET_PERMISSION_RESPONSE:
4539
if (action.payload.data) {
4640
return {
@@ -52,10 +46,7 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
5246
return handleDefault()
5347
}
5448
case ADD_PERMISSION:
55-
return {
56-
...state,
57-
loading: true,
58-
}
49+
return handleLoading()
5950
case ADD_PERMISSION_RESPONSE:
6051
if (action.payload.data) {
6152
return {
@@ -68,10 +59,7 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
6859
}
6960

7061
case EDIT_PERMISSION:
71-
return {
72-
...state,
73-
loading: true,
74-
}
62+
return handleLoading()
7563
case EDIT_PERMISSION_RESPONSE:
7664
if (action.payload.data) {
7765
return {
@@ -84,10 +72,7 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
8472
}
8573

8674
case DELETE_PERMISSION:
87-
return {
88-
...state,
89-
loading: true,
90-
}
75+
return handleLoading()
9176
case DELETE_PERMISSION_RESPONSE:
9277
if (action.payload.inum) {
9378
return {
@@ -122,5 +107,12 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
122107
loading: false,
123108
}
124109
}
110+
111+
function handleLoading() {
112+
return {
113+
...state,
114+
loading: true,
115+
}
116+
}
125117
}
126118
reducerRegistry.register(reducerName, apiPermissionReducer)

plugins/admin/redux/reducers/ApiRoleReducer.js

+12-20
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ const reducerName = 'apiRoleReducer'
2424
export default function apiRoleReducer(state = INIT_STATE, action) {
2525
switch (action.type) {
2626
case GET_ROLES:
27-
return {
28-
...state,
29-
loading: true,
30-
}
27+
return handleLoading()
3128
case GET_ROLES_RESPONSE:
3229
if (action.payload.data) {
3330
return {
@@ -39,10 +36,7 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
3936
return handleDefault()
4037
}
4138
case GET_ROLE:
42-
return {
43-
...state,
44-
loading: true,
45-
}
39+
return handleLoading()
4640
case GET_ROLE_RESPONSE:
4741
if (action.payload.data) {
4842
return {
@@ -54,10 +48,7 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
5448
return handleDefault()
5549
}
5650
case ADD_ROLE:
57-
return {
58-
...state,
59-
loading: true,
60-
}
51+
return handleLoading()
6152
case ADD_ROLE_RESPONSE:
6253
if (action.payload.data) {
6354
return {
@@ -70,10 +61,7 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
7061
}
7162

7263
case EDIT_ROLE:
73-
return {
74-
...state,
75-
loading: true,
76-
}
64+
return handleLoading()
7765
case EDIT_ROLE_RESPONSE:
7866
if (action.payload.data) {
7967
return {
@@ -86,10 +74,7 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
8674
}
8775

8876
case DELETE_ROLE:
89-
return {
90-
...state,
91-
loading: true,
92-
}
77+
return handleLoading()
9378
case DELETE_ROLE_RESPONSE:
9479
if (action.payload.inum) {
9580
return {
@@ -118,6 +103,13 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
118103
return handleDefault()
119104
}
120105

106+
function handleLoading() {
107+
return {
108+
...state,
109+
loading: true,
110+
}
111+
}
112+
121113
function handleDefault() {
122114
return {
123115
...state,

0 commit comments

Comments
 (0)