deployPreview.tsx 1.4 KB

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