permissionDenied.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {useEffect} from 'react';
  2. import * as Sentry from '@sentry/react';
  3. import * as Layout from 'sentry/components/layouts/thirds';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import LoadingError from 'sentry/components/loadingError';
  6. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  7. import {t, tct} from 'sentry/locale';
  8. import {Organization, Project} from 'sentry/types';
  9. import getRouteStringFromRoutes from 'sentry/utils/getRouteStringFromRoutes';
  10. import {useRoutes} from 'sentry/utils/useRoutes';
  11. import withOrganization from 'sentry/utils/withOrganization';
  12. import withProject from 'sentry/utils/withProject';
  13. const ERROR_NAME = 'Permission Denied';
  14. type Props = {
  15. organization: Organization;
  16. project?: Project;
  17. };
  18. function PermissionDenied(props: Props) {
  19. const {organization, project} = props;
  20. const routes = useRoutes();
  21. useEffect(() => {
  22. const route = getRouteStringFromRoutes(routes);
  23. Sentry.withScope(scope => {
  24. scope.setFingerprint([ERROR_NAME, route]);
  25. scope.setExtra('route', route);
  26. scope.setExtra('orgFeatures', (organization && organization.features) || []);
  27. scope.setExtra('orgAccess', (organization && organization.access) || []);
  28. scope.setExtra('projectFeatures', (project && project.features) || []);
  29. Sentry.captureException(new Error(`${ERROR_NAME}${route ? ` : ${route}` : ''}`));
  30. });
  31. // eslint-disable-next-line react-hooks/exhaustive-deps
  32. }, []);
  33. return (
  34. <SentryDocumentTitle title={t('Permission Denied')}>
  35. <Layout.Page withPadding>
  36. <LoadingError
  37. message={tct(
  38. `Your role does not have the necessary permissions to access this
  39. resource, please read more about [link:organizational roles]`,
  40. {
  41. link: (
  42. <ExternalLink href="https://docs.sentry.io/product/accounts/membership/" />
  43. ),
  44. }
  45. )}
  46. />
  47. </Layout.Page>
  48. </SentryDocumentTitle>
  49. );
  50. }
  51. export default withOrganization(withProject(PermissionDenied));