Authorize.tsx 440 B

1234567891011121314151617
  1. import React, { FC } from 'react';
  2. import { contextSrv } from 'app/core/services/context_srv';
  3. import { AccessControlAction } from 'app/types';
  4. type Props = {
  5. actions: AccessControlAction[];
  6. fallback?: boolean;
  7. };
  8. export const Authorize: FC<Props> = ({ actions, children, fallback = true }) => {
  9. if (actions.some((action) => contextSrv.hasAccess(action, fallback))) {
  10. return <>{children}</>;
  11. } else {
  12. return null;
  13. }
  14. };