permissionDenied.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import React from 'react';
  2. import DocumentTitle from 'react-document-title';
  3. import {withRouter, WithRouterProps} from 'react-router';
  4. import * as Sentry from '@sentry/react';
  5. import ExternalLink from 'app/components/links/externalLink';
  6. import LoadingError from 'app/components/loadingError';
  7. import {t, tct} from 'app/locale';
  8. import {PageContent} from 'app/styles/organization';
  9. import {LightWeightOrganization, Project} from 'app/types';
  10. import getRouteStringFromRoutes from 'app/utils/getRouteStringFromRoutes';
  11. import withOrganization from 'app/utils/withOrganization';
  12. import withProject from 'app/utils/withProject';
  13. const ERROR_NAME = 'Permission Denied';
  14. type Props = WithRouterProps & {
  15. organization: LightWeightOrganization;
  16. project?: Project;
  17. };
  18. class PermissionDenied extends React.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. <DocumentTitle 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. </DocumentTitle>
  48. );
  49. }
  50. }
  51. export default withRouter(withOrganization(withProject(PermissionDenied)));