permissionDenied.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import {Component} from 'react';
  2. // eslint-disable-next-line no-restricted-imports
  3. import {withRouter, WithRouterProps} from 'react-router';
  4. import * as Sentry from '@sentry/react';
  5. import ExternalLink from 'sentry/components/links/externalLink';
  6. import LoadingError from 'sentry/components/loadingError';
  7. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  8. import {t, tct} from 'sentry/locale';
  9. import {PageContent} from 'sentry/styles/organization';
  10. import {Organization, Project} from 'sentry/types';
  11. import getRouteStringFromRoutes from 'sentry/utils/getRouteStringFromRoutes';
  12. import withOrganization from 'sentry/utils/withOrganization';
  13. import withProject from 'sentry/utils/withProject';
  14. const ERROR_NAME = 'Permission Denied';
  15. type Props = WithRouterProps & {
  16. organization: Organization;
  17. project?: Project;
  18. };
  19. class PermissionDenied extends Component<Props> {
  20. componentDidMount() {
  21. const {organization, project, routes} = this.props;
  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. }
  32. render() {
  33. return (
  34. <SentryDocumentTitle title={t('Permission Denied')}>
  35. <PageContent>
  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. </PageContent>
  48. </SentryDocumentTitle>
  49. );
  50. }
  51. }
  52. export default withRouter(withOrganization(withProject(PermissionDenied)));