RedHatInsights/insights-rbac-ui

View on GitHub
src/helpers/permission/permission-helper.js

Summary

Maintainability
A
2 hrs
Test Coverage
import { getPermissionApi } from '../shared/user-login';

const accessApi = getPermissionApi();

const disallowedPermissions = ['inventory:staleness'];

export async function listPermissions(
  limit,
  offset,
  orderBy,
  application,
  resourceType,
  verb,
  permission,
  excludeGlobals,
  excludeRoles,
  allowedOnly,
  options
) {
  const response = await accessApi.listPermissions(
    limit,
    offset,
    orderBy,
    application,
    resourceType,
    verb,
    permission,
    excludeGlobals,
    excludeRoles,
    allowedOnly,
    options
  );

  return {
    ...response,
    data: response.data.filter(({ permission }) => !disallowedPermissions.some((item) => permission.includes(item))),
  };
}

export async function listPermissionOptions(field, limit, offset, application, resourceType, verb, allowedOnly, options) {
  return await accessApi.listPermissionOptions(field, limit, offset, application, resourceType, verb, undefined, allowedOnly, options);
}