12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import {hasEveryAccess} from 'sentry/components/acl/access';
- import type {Project, Scope, Team} from 'sentry/types';
- import useOrganization from 'sentry/utils/useOrganization';
- import {useUser} from 'sentry/utils/useUser';
- type Props = {
-
- access?: Scope[];
-
- project?: Project | null | undefined;
-
- team?: Team | null | undefined;
- };
- export function useAccess({access = [], team, project}: Props) {
- const user = useUser();
- const organization = useOrganization();
- team = team ?? undefined;
- project = project ?? undefined;
- const hasAccess = hasEveryAccess(access, {organization, team, project});
- const hasSuperuser = Boolean(user?.isSuperuser);
- return {
- hasAccess,
- hasSuperuser,
- };
- }
|