Skip to content

Commit

Permalink
feat(admin-ui): design the layout for api role management #327
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrydy committed Dec 1, 2021
1 parent 86ba279 commit 14da9b9
Show file tree
Hide file tree
Showing 10 changed files with 440 additions and 107 deletions.
11 changes: 8 additions & 3 deletions app/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@
},
"menus": {
"adminui": "Admin",
"config-api": "Config-api",
"api": {
"roles": "Access roles",
"permissions": "Permissions",
"mapping":"Mapping"
},
"cache": "Cache",
"clients": "Clients",
"configuration": "Configuration",
Expand Down Expand Up @@ -798,7 +804,7 @@
"maxIdleConnections": "The cap on the number of idle instances in the pool. If max idle is set too low on heavily loaded systems it is possible you will see objects being destroyed and almost immediately new objects being created.",
"maxTotalConnections": "The number of maximum connection instances in the pool.",
"connectionTimeout": "Connection time out.",
"soTimeout":"So timeout",
"soTimeout": "So timeout",
"maxRetryAttempts": " Maximum retry attempts in case of failure.",
"defaultCleanupBatchSize": "Default cleanup batch page size.",
"deleteExpiredOnGetRequest": "Whether to delete on get request."
Expand All @@ -810,13 +816,12 @@
"defaultBucket": "The default bucket for the Gluu Server.",
"connectTimeout": "Connection time out.",
"computationPoolSize": "Computation pool size.",
"useSSL":"Use this feature if the backend server allows SSL connectivity.",
"useSSL": "Use this feature if the backend server allows SSL connectivity.",
"sslTrustStoreFile": "SSL truststore file.",
"sslTrustStoreFormat": "SSL truststore format.",
"sslTrustStorePin": "Encoded truststore pin.",
"userName": "Database username.",
"userPassword": "Database password."

},
"sql": {
"config_name": "Enter the sql configuration name.",
Expand Down
88 changes: 0 additions & 88 deletions plugins/admin/components/Roles/AdminUiRole.js

This file was deleted.

69 changes: 69 additions & 0 deletions plugins/admin/components/Roles/UiRoleListPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React from 'react'
import MaterialTable from 'material-table'
import UiRoleDetailPage from './UiRoleDetailPage'
import { Badge } from 'reactstrap'
import { connect } from 'react-redux'
import { useTranslation } from 'react-i18next'
import GluuViewWrapper from '../../../../app/routes/Apps/Gluu/GluuViewWrapper'
import {
hasPermission,
buildPayload,
SCRIPT_READ,
} from '../../../../app/utils/PermChecker'

function UiRoleListPage({ apiRoles, permissions, loading }) {
const { t } = useTranslation()
const pageSize = localStorage.getItem('paggingSize') || 10

return (
<React.Fragment>
<GluuViewWrapper canShow={hasPermission(permissions, SCRIPT_READ)}>
<MaterialTable
columns={[
{
title: `${t('fields.name')}`,
field: 'name',
width: '20%',
render: (rowData) => <Badge color="info">{rowData.name}</Badge>,
},
{ title: `${t('fields.description')}`, field: 'description' },
]}
data={apiRoles}
isLoading={loading || false}
title={t('titles.roles')}
actions={[]}
options={{
search: false,
searchFieldAlignment: 'left',
selection: false,
pageSize: pageSize,
rowStyle: (rowData) => ({
backgroundColor: rowData.enabled ? '#33AE9A' : '#FFF',
}),
headerStyle: {
backgroundColor: '#03a96d',
color: '#FFF',
padding: '2px',
textTransform: 'uppercase',
fontSize: '18px',
},
actionsColumnIndex: -1,
}}
detailPanel={(rowData) => {
return <UiRoleDetailPage row={rowData} />
}}
/>
</GluuViewWrapper>
</React.Fragment>
)
}

const mapStateToProps = (state) => {
return {
apiRoles: state.apiRoleReducer.items,
loading: state.apiRoleReducer.loading,
permissions: state.authReducer.permissions,
}
}

export default connect(mapStateToProps)(UiRoleListPage)
40 changes: 40 additions & 0 deletions plugins/admin/components/Roles/roles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export const roles = [
{
name: 'api-admin',
description:
'This role allows a user to access all list and search features available. Not possible for this role to perform edition nor deletion',
scopes: [
'https://jans.io/oauth/config/attributes.readonly',
'https://jans.io/oauth/config/acrs.readonly',
],
},
{
name: 'api-viewer',
description:
'This role allows a user to perform all possible actions on api objects',
scopes: [
'https://jans.io/oauth/config/attributes.readonly',
'https://jans.io/oauth/config/acrs.readonly',
],
},
{
name: 'api-editor',
description:
'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',
scopes: [
'https://jans.io/oauth/config/attributes.readonly',
'https://jans.io/oauth/config/acrs.readonly',
],
},
{
name: 'api-manager',
description:
'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.',
scopes: [
'https://jans.io/oauth/config/attributes.readonly',
'https://jans.io/oauth/config/acrs.readonly',
],
},
]

export default roles
55 changes: 40 additions & 15 deletions plugins/admin/plugin-metadata.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import HealthPage from './components/Health/HealthPage'
import ReportPage from './components/Reports/ReportPage'
import LicenseDetailsPage from './components/Configuration/LicenseDetailsPage'
import AdminUiRole from './components/Roles/AdminUiRole'
import UiRoleListPage from './components/Roles/UiRoleListPage'
import MonthlyActiveUsersPage from './components/MonthlyActiveUsersPage'
import SettingsPage from './components/Settings/SettingsPage'
import scriptSaga from './redux/sagas/CustomScriptSaga'
import licenseDetailsSaga from './redux/sagas/LicenseDetailsSaga'

import ScriptListPage from './components/CustomScripts/ScriptListPage'
import CustomScriptAddPage from './components/CustomScripts/CustomScriptAddPage'
import CustomScriptEditPage from './components/CustomScripts/CustomScriptEditPage'
import SettingsPage from './components/Settings/SettingsPage'

import mauReducer from './redux/reducers/MauReducer'
import mauSaga from './redux/sagas/MauSaga'
import scriptSaga from './redux/sagas/CustomScriptSaga'
import licenseDetailsSaga from './redux/sagas/LicenseDetailsSaga'

import mauReducer from './redux/reducers/MauReducer'
import scriptReducer from './redux/reducers/CustomScriptReducer'
import apiRoleReducer from './redux/reducers/ApiRoleReducer'
import apiPermissionReducer from './redux/reducers/ApiPermissionReducer'
import licenseDetailsReducer from './redux/reducers/LicenseDetailsReducer'

const PLUGIN_BASE_APTH = '/adm'
Expand All @@ -35,9 +37,24 @@ const pluginMetadata = {
permission: '/config/acrs.readonly',
},
{
title: 'menus.roles',
path: PLUGIN_BASE_APTH + '/roles',
permission: '/config/acrs.readonly',
title: 'menus.config-api',
children: [
{
title: 'menus.api.roles',
path: PLUGIN_BASE_APTH + '/roles',
permission: '/config/acrs.readonly',
},
{
title: 'menus.api.permissions',
path: PLUGIN_BASE_APTH + '/permissions',
permission: '/config/acrs.readonly',
},
{
title: 'menus.api.mapping',
path: PLUGIN_BASE_APTH + '/mapping',
permission: '/config/acrs.readonly',
},
],
},
{
title: 'menus.scripts',
Expand Down Expand Up @@ -69,10 +86,20 @@ const pluginMetadata = {
permission: '/config/acrs.readonly',
},
{
component: AdminUiRole,
component: UiRoleListPage,
path: PLUGIN_BASE_APTH + '/roles',
permission: '/config/acrs.readonly',
},
{
component: UiRoleListPage,
path: PLUGIN_BASE_APTH + '/permissions',
permission: '/config/acrs.readonly',
},
{
component: UiRoleListPage,
path: PLUGIN_BASE_APTH + '/mapping',
permission: '/config/acrs.readonly',
},
{
component: ScriptListPage,
path: PLUGIN_BASE_APTH + '/scripts',
Expand Down Expand Up @@ -102,13 +129,11 @@ const pluginMetadata = {
reducers: [
{ name: 'mauReducer', reducer: mauReducer },
{ name: 'scriptReducer', reducer: scriptReducer },
{ name: 'apiRoleReducer', reducer: apiRoleReducer },
{ name: 'apiPermissionReducer', reducer: apiPermissionReducer },
{ name: 'licenseDetailsReducer', reducer: licenseDetailsReducer },
],
sagas: [
mauSaga(),
scriptSaga(),
licenseDetailsSaga(),
],
sagas: [mauSaga(), scriptSaga(), licenseDetailsSaga()],
}

export default pluginMetadata
26 changes: 26 additions & 0 deletions plugins/admin/redux/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@ export const DELETE_CUSTOM_SCRIPT = 'DELETE_CUSTOM_SCRIPT'
export const DELETE_CUSTOM_SCRIPT_RESPONSE = 'DELETE_CUSTOM_SCRIPT_RESPONSE'
export const SET_SCRIPT_ITEM = 'SET_SCRIPT_ITEM'

// API ROLES
export const GET_ROLES = 'GET_ROLES'
export const GET_ROLES_RESPONSE = 'GET_ROLES_RESPONSE'
export const GET_ROLE = 'GET_ROLE'
export const GET_ROLE_RESPONSE = 'GET_ROLE_RESPONSE'
export const ADD_ROLE = 'ADD_ROLE'
export const ADD_ROLE_RESPONSE = 'ADD_ROLE_RESPONSE'
export const EDIT_ROLE = 'EDIT_ROLE'
export const EDIT_ROLE_RESPONSE = 'EDIT_ROLE_RESPONSE'
export const DELETE_ROLE = 'DELETE_ROLE'
export const DELETE_ROLE_RESPONSE = 'DELETE_ROLE_RESPONSE'
export const SET_ROLE_ITEM = 'SET_ROLE_ITEM'

// API PERMISSIONS
export const GET_PERMISSIONS = 'GET_PERMISSIONS'
export const GET_PERMISSIONS_RESPONSE = 'GET_PERMISSIONS_RESPONSE'
export const GET_PERMISSION = 'GET_PERMISSION'
export const GET_PERMISSION_RESPONSE = 'GET_PERMISSION_RESPONSE'
export const ADD_PERMISSION = 'ADD_PERMISSION'
export const ADD_PERMISSION_RESPONSE = 'ADD_PERMISSION_RESPONSE'
export const EDIT_PERMISSION = 'EDIT_PERMISSION'
export const EDIT_PERMISSION_RESPONSE = 'EDIT_PERMISSION_RESPONSE'
export const DELETE_PERMISSION = 'DELETE_PERMISSION'
export const DELETE_PERMISSION_RESPONSE = 'DELETE_PERMISSION_RESPONSE'
export const SET_PERMISSION_ITEM = 'SET_PERMISSION_ITEM'

//License Details

export const GET_LICENSE_DETAILS = 'GET_LICENSE_DETAILS'
Expand Down
4 changes: 3 additions & 1 deletion plugins/admin/redux/audit/Resources.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const SCRIPT = 'custom-script'
export const SCRIPT = 'custom-script'
export const API_ROLE = 'api-role'
export const API_PERMISSION = 'api-permission'
Loading

0 comments on commit 14da9b9

Please sign in to comment.