Skip to content

Commit a421a70

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

File tree

6 files changed

+35
-13
lines changed

6 files changed

+35
-13
lines changed

plugins/admin/components/Roles/UiRoleListPage.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import React, { useEffect } from 'react'
22
import MaterialTable from 'material-table'
33
import { Paper } from '@material-ui/core'
44
import UiRoleDetailPage from './UiRoleDetailPage'
@@ -9,16 +9,28 @@ import { useTranslation } from 'react-i18next'
99
import GluuViewWrapper from '../../../../app/routes/Apps/Gluu/GluuViewWrapper'
1010
import GluuRibbon from '../../../../app/routes/Apps/Gluu/GluuRibbon'
1111
import applicationStyle from '../../../../app/routes/Apps/Gluu/styles/applicationstyle'
12+
import {
13+
deleteRole,
14+
getRoles,
15+
setCurrentItem,
16+
} from '../../redux/actions/ApiRoleActions'
1217
import {
1318
hasPermission,
19+
buildPayload,
1420
SCRIPT_READ,
1521
SCRIPT_WRITE,
1622
} from '../../../../app/utils/PermChecker'
1723

18-
function UiRoleListPage({ apiRoles, permissions, loading }) {
24+
function UiRoleListPage({ apiRoles, permissions, loading, dispatch }) {
1925
const { t } = useTranslation()
2026
const myActions = []
27+
const options = []
28+
const userAction = {}
2129
const pageSize = localStorage.getItem('paggingSize') || 10
30+
useEffect(() => {
31+
buildPayload(userAction, 'ROLES', options)
32+
dispatch(getRoles(userAction))
33+
}, [])
2234

2335
if (hasPermission(permissions, SCRIPT_READ)) {
2436
myActions.push((rowData) => ({
@@ -69,9 +81,9 @@ function UiRoleListPage({ apiRoles, permissions, loading }) {
6981
columns={[
7082
{
7183
title: `${t('fields.name')}`,
72-
field: 'name',
84+
field: 'role',
7385
width: '20%',
74-
render: (rowData) => <Badge color="info">{rowData.name}</Badge>,
86+
render: (rowData) => <Badge color="info">{rowData.role}</Badge>,
7587
},
7688
{ title: `${t('fields.description')}`, field: 'description' },
7789
]}

plugins/admin/components/Roles/roles.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const roles = [
22
{
3-
name: 'api-admin',
3+
role: 'api-admin',
44
description:
55
'This role allows a user to access all list and search features available. Not possible for this role to perform edition nor deletion',
66
scopes: [
@@ -9,7 +9,7 @@ export const roles = [
99
],
1010
},
1111
{
12-
name: 'api-viewer',
12+
role: 'api-viewer',
1313
description:
1414
'This role allows a user to perform all possible actions on api objects',
1515
scopes: [
@@ -18,7 +18,7 @@ export const roles = [
1818
],
1919
},
2020
{
21-
name: 'api-editor',
21+
role: 'api-editor',
2222
description:
2323
'This role allow a user to list, search, add and edit on all available objects excepts the configuration object which is critical for a running server',
2424
scopes: [
@@ -27,7 +27,7 @@ export const roles = [
2727
],
2828
},
2929
{
30-
name: 'api-manager',
30+
role: 'api-manager',
3131
description:
3232
'This role allows a user to list, search, add, edit and delete all available objects include the configuration object(only in view mode). The user cannot edit nor delete the configuration object.',
3333
scopes: [

plugins/admin/plugin-metadata.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import SettingsPage from './components/Settings/SettingsPage'
1111
import mauSaga from './redux/sagas/MauSaga'
1212
import scriptSaga from './redux/sagas/CustomScriptSaga'
1313
import licenseDetailsSaga from './redux/sagas/LicenseDetailsSaga'
14+
import apiRoleSaga from './redux/sagas/ApiRoleSaga'
15+
import apiPermissionSaga from './redux/sagas/ApiPermissionSaga'
1416

1517
import mauReducer from './redux/reducers/MauReducer'
1618
import scriptReducer from './redux/reducers/CustomScriptReducer'
@@ -133,7 +135,13 @@ const pluginMetadata = {
133135
{ name: 'apiPermissionReducer', reducer: apiPermissionReducer },
134136
{ name: 'licenseDetailsReducer', reducer: licenseDetailsReducer },
135137
],
136-
sagas: [mauSaga(), scriptSaga(), licenseDetailsSaga()],
138+
sagas: [
139+
mauSaga(),
140+
scriptSaga(),
141+
licenseDetailsSaga(),
142+
apiRoleSaga(),
143+
apiPermissionSaga(),
144+
],
137145
}
138146

139147
export default pluginMetadata

plugins/admin/redux/api/RoleApi.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ export default class RoleApi {
55
getRoles = () => {
66
return new Promise((resolve, reject) => {
77
console.log('=============get roles')
8+
this.api.getAdminuiRoles((error, data) => {
9+
this.handleResponse(error, reject, resolve, data)
10+
})
811
})
912
}
1013
getRole = (options) => {

plugins/admin/redux/reducers/ApiRoleReducer.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ import {
1313
RESET,
1414
} from '../actions/types'
1515
import reducerRegistry from '../../../../app/redux/reducers/ReducerRegistry'
16-
import roles from '../../components/Roles/roles'
1716

1817
const INIT_STATE = {
19-
items: roles,
20-
loading: true,
18+
items: [],
19+
loading: false,
2120
}
2221
const reducerName = 'apiRoleReducer'
2322

plugins/admin/redux/sagas/ApiRoleSaga.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { initAudit } from '../../../../app/redux/sagas/SagaUtils'
3333
function* newFunction() {
3434
const token = yield select((state) => state.authReducer.token.access_token)
3535
const issuer = yield select((state) => state.authReducer.issuer)
36-
const api = new JansConfigApi.CustomScriptsApi(
36+
const api = new JansConfigApi.AdminUIRoleApi(
3737
getClient(JansConfigApi, token, issuer),
3838
)
3939
return new RoleApi(api)

0 commit comments

Comments
 (0)