Skip to content

Commit

Permalink
fix(admin-ui): dashboard and roles page fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mjatin-dev committed Oct 28, 2022
1 parent 03a56ff commit bf6afe4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions admin-ui/app/utils/PermChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const SQL_WRITE = BASE_URL + '/config/database/sql.write'
export const SQL_DELETE = BASE_URL + '/config/database/sql.delete'

export const STAT_READ = BASE_URL + '/config/stats.readonly'
export const STAT_JANS_READ = 'jans_stat'
export const STAT_JANS_READ = BASE_URL + '/config/stats.jans_stat.readonly'

export const USER_READ = BASE_URL + '/config/user.readonly'
export const USER_WRITE = BASE_URL + '/config/user.write'
Expand All @@ -94,10 +94,15 @@ export const SESSION_READ = BASE_URL + '/jans-auth-server/session.readonly'
export const SESSION_DELETE = BASE_URL + '/jans-auth-server/session.delete'

export const hasPermission = (scopes, scope) => {
let available = false;
if (scopes) {
return scopes.map(scp => scope === scp)
for(let i in scopes){
if(scopes[i] === scope){
available = true;
}
}
}
return false
return available
}

export const buildPayload = (userAction, message, payload) => {
Expand Down
3 changes: 3 additions & 0 deletions admin-ui/plugins/admin/components/Roles/UiRoleListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import SetTitle from 'Utils/SetTitle'
import { ThemeContext } from 'Context/theme/themeContext'
import getThemeColor from 'Context/theme/config'
import { ROLE_DELETE } from '../../../../app/utils/PermChecker'

function UiRoleListPage({ apiRoles, permissions, loading, dispatch }) {
const { t } = useTranslation()
Expand Down Expand Up @@ -141,6 +142,8 @@ function UiRoleListPage({ apiRoles, permissions, loading, dispatch }) {
return <UiRoleDetailPage row={rowData} />
}}
editable={{
isDeleteHidden:() => !hasPermission(permissions, ROLE_DELETE),
isEditHidden:() => !hasPermission(permissions, ROLE_WRITE),
onRowUpdate: (newData, oldData) =>
new Promise((resolve, reject) => {
buildPayload(userAction, 'Edit role', newData)
Expand Down

0 comments on commit bf6afe4

Please sign in to comment.