Skip to content

Commit aac6eca

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

File tree

5 files changed

+31
-35
lines changed

5 files changed

+31
-35
lines changed

plugins/admin/components/Roles/UiRoleListPage.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ import { Badge } from 'reactstrap'
55
import { connect } from 'react-redux'
66
import { useTranslation } from 'react-i18next'
77
import GluuViewWrapper from '../../../../app/routes/Apps/Gluu/GluuViewWrapper'
8-
import {
9-
hasPermission,
10-
buildPayload,
11-
SCRIPT_READ,
12-
} from '../../../../app/utils/PermChecker'
8+
import { hasPermission, SCRIPT_READ } from '../../../../app/utils/PermChecker'
139

1410
function UiRoleListPage({ apiRoles, permissions, loading }) {
1511
const { t } = useTranslation()

plugins/admin/redux/api/PermissionApi.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ export default class PermissionApi {
44
}
55
getPermissions = () => {
66
return new Promise((resolve, reject) => {
7-
console.log('=============')
7+
console.log('=============get permissions')
88
})
99
}
1010
getPermission = (options) => {
1111
return new Promise((resolve, reject) => {
12-
console.log('=============')
12+
console.log('============= get single permission')
1313
})
1414
}
1515

1616
addPermission = (data) => {
1717
return new Promise((resolve, reject) => {
18-
console.log('=============')
18+
console.log('============= add permission')
1919
})
2020
}
2121

2222
editPermission = (data) => {
2323
return new Promise((resolve, reject) => {
24-
console.log('=============')
24+
console.log('=============edit permission')
2525
})
2626
}
2727

2828
deletePermission = async (inum) => {
2929
return new Promise((resolve, reject) => {
30-
console.log('=============')
30+
console.log('=============delete permission')
3131
})
3232
}
3333

plugins/admin/redux/api/RoleApi.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ export default class RoleApi {
44
}
55
getRoles = () => {
66
return new Promise((resolve, reject) => {
7-
console.log('=============')
7+
console.log('=============get roles')
88
})
99
}
1010
getRole = (options) => {
1111
return new Promise((resolve, reject) => {
12-
console.log('=============')
12+
console.log('=============get role')
1313
})
1414
}
1515

1616
addRole = (data) => {
1717
return new Promise((resolve, reject) => {
18-
console.log('=============')
18+
console.log('============= add role ' + data)
1919
})
2020
}
2121

2222
editRole = (data) => {
2323
return new Promise((resolve, reject) => {
24-
console.log('=============')
24+
console.log('=============edit role ' + data)
2525
})
2626
}
2727

2828
deleteRole = async (inum) => {
2929
return new Promise((resolve, reject) => {
30-
console.log('=============')
30+
console.log('=============delete role ' + inum)
3131
})
3232
}
3333

plugins/admin/redux/reducers/ApiPermissionReducer.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,15 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
2525
return handleLoading()
2626
case GET_PERMISSIONS_RESPONSE:
2727
if (action.payload.data) {
28-
return {
29-
...state,
30-
items: action.payload.data,
31-
loading: false,
32-
}
28+
return handleItems()
3329
} else {
3430
return handleDefault()
3531
}
3632
case GET_PERMISSION:
3733
return handleLoading()
3834
case GET_PERMISSION_RESPONSE:
3935
if (action.payload.data) {
40-
return {
41-
...state,
42-
items: action.payload.data,
43-
loading: false,
44-
}
36+
return handleItems()
4537
} else {
4638
return handleDefault()
4739
}
@@ -101,6 +93,14 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
10193
return handleDefault()
10294
}
10395

96+
function handleItems() {
97+
return {
98+
...state,
99+
items: action.payload.data,
100+
loading: false,
101+
}
102+
}
103+
104104
function handleDefault() {
105105
return {
106106
...state,

plugins/admin/redux/reducers/ApiRoleReducer.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,15 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
2727
return handleLoading()
2828
case GET_ROLES_RESPONSE:
2929
if (action.payload.data) {
30-
return {
31-
...state,
32-
items: action.payload.data,
33-
loading: false,
34-
}
30+
return handleItems()
3531
} else {
3632
return handleDefault()
3733
}
3834
case GET_ROLE:
3935
return handleLoading()
4036
case GET_ROLE_RESPONSE:
4137
if (action.payload.data) {
42-
return {
43-
...state,
44-
items: action.payload.data,
45-
loading: false,
46-
}
38+
return handleItems()
4739
} else {
4840
return handleDefault()
4941
}
@@ -103,6 +95,14 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
10395
return handleDefault()
10496
}
10597

98+
function handleItems() {
99+
return {
100+
...state,
101+
items: action.payload.data,
102+
loading: false,
103+
}
104+
}
105+
106106
function handleLoading() {
107107
return {
108108
...state,

0 commit comments

Comments
 (0)