import React from 'react';
import { contextSrv } from 'app/core/services/context_srv';
interface Props {
action: string;
children: React.ReactNode;
fallback?: React.ReactNode;
}
export const UserManagerWrapper: React.FC<Props> = ({ action, children, fallback = null }) => {
const hasPermission = contextSrv.hasPermission(action);
return hasPermission ? <>{children}</> : <>{fallback}</>;
};
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter