developmentAlerts.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {DEPLOY_PREVIEW_CONFIG, EXPERIMENTAL_SPA} from 'sentry/constants';
  3. import {t, tct} from 'sentry/locale';
  4. import AlertStore from 'sentry/stores/alertStore';
  5. export function displayDeployPreviewAlert() {
  6. if (!DEPLOY_PREVIEW_CONFIG) {
  7. return;
  8. }
  9. const {branch, commitSha, githubOrg, githubRepo} = DEPLOY_PREVIEW_CONFIG;
  10. const repoUrl = `https://github.com/${githubOrg}/${githubRepo}`;
  11. const commitLink = (
  12. <ExternalLink href={`${repoUrl}/commit/${commitSha}`}>
  13. {t('%s@%s', `${githubOrg}/${githubRepo}`, commitSha.slice(0, 6))}
  14. </ExternalLink>
  15. );
  16. const branchLink = (
  17. <ExternalLink href={`${repoUrl}/tree/${branch}`}>{branch}</ExternalLink>
  18. );
  19. AlertStore.addAlert({
  20. id: 'deploy-preview',
  21. message: tct(
  22. 'You are viewing a frontend deploy preview of [commitLink] ([branchLink])',
  23. {commitLink, branchLink}
  24. ),
  25. type: 'warning',
  26. neverExpire: true,
  27. noDuplicates: true,
  28. });
  29. }
  30. export function displayExperimentalSpaAlert() {
  31. if (!EXPERIMENTAL_SPA) {
  32. return;
  33. }
  34. AlertStore.addAlert({
  35. id: 'develop-proxy',
  36. message: t(
  37. 'You are developing against production Sentry API, please BE CAREFUL, as your changes will affect production data.'
  38. ),
  39. type: 'warning',
  40. opaque: true,
  41. neverExpire: true,
  42. noDuplicates: true,
  43. });
  44. }