permissionDenied.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {Component} from 'react';
  2. import {withRouter, WithRouterProps} from 'react-router';
  3. import * as Sentry from '@sentry/react';
  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 {PageContent} from 'sentry/styles/organization';
  9. import {Organization, Project} from 'sentry/types';
  10. import getRouteStringFromRoutes from 'sentry/utils/getRouteStringFromRoutes';
  11. import withOrganization from 'sentry/utils/withOrganization';
  12. import withProject from 'sentry/utils/withProject';
  13. const ERROR_NAME = 'Permission Denied';
  14. type Props = WithRouterProps & {
  15. organization: Organization;
  16. project?: Project;
  17. };
  18. class PermissionDenied extends Component<Props> {
  19. componentDidMount() {
  20. const {organization, project, routes} = this.props;
  21. const route = getRouteStringFromRoutes(routes);
  22. Sentry.withScope(scope => {
  23. scope.setFingerprint([ERROR_NAME, route]);
  24. scope.setExtra('route', route);
  25. scope.setExtra('orgFeatures', (organization && organization.features) || []);
  26. scope.setExtra('orgAccess', (organization && organization.access) || []);
  27. scope.setExtra('projectFeatures', (project && project.features) || []);
  28. Sentry.captureException(new Error(`${ERROR_NAME}${route ? ` : ${route}` : ''}`));
  29. });
  30. }
  31. render() {
  32. return (
  33. <SentryDocumentTitle title={t('Permission Denied')}>
  34. <PageContent>
  35. <LoadingError
  36. message={tct(
  37. `Your role does not have the necessary permissions to access this
  38. resource, please read more about [link:organizational roles]`,
  39. {
  40. link: (
  41. <ExternalLink href="https://docs.sentry.io/product/accounts/membership/" />
  42. ),
  43. }
  44. )}
  45. />
  46. </PageContent>
  47. </SentryDocumentTitle>
  48. );
  49. }
  50. }
  51. export default withRouter(withOrganization(withProject(PermissionDenied)));