metricHistoryActivation.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import {Fragment} from 'react';
  2. import GlobalSelectionLink from 'sentry/components/globalSelectionLink';
  3. import {
  4. ActivationConditionType,
  5. ActivationTrigger,
  6. type ActivationTriggerActivity,
  7. } from 'sentry/types/alerts';
  8. import type {Organization} from 'sentry/types/organization';
  9. import getDynamicText from 'sentry/utils/getDynamicText';
  10. import {StyledDateTime} from 'sentry/views/alerts/rules/metric/details/styles';
  11. type MetricHistoryActivationProps = {
  12. activationActivity: ActivationTriggerActivity;
  13. organization: Organization;
  14. };
  15. export default function MetricHistoryActivation({
  16. activationActivity,
  17. organization,
  18. }: MetricHistoryActivationProps) {
  19. let trigger;
  20. let activator;
  21. switch (activationActivity.conditionType) {
  22. case String(ActivationConditionType.RELEASE_CREATION):
  23. activator = (
  24. <GlobalSelectionLink
  25. to={{
  26. pathname: `/organizations/${
  27. organization.slug
  28. }/releases/${encodeURIComponent(activationActivity.activator)}/`,
  29. }}
  30. >
  31. {activationActivity.activator}
  32. </GlobalSelectionLink>
  33. );
  34. trigger = <span>Release {activator} created.</span>;
  35. break;
  36. case String(ActivationConditionType.DEPLOY_CREATION):
  37. activator = activationActivity.activator;
  38. trigger = `Deploy ${activator} created.`;
  39. break;
  40. default:
  41. trigger = '--';
  42. }
  43. return (
  44. <Fragment>
  45. <div />
  46. <div>
  47. {trigger}{' '}
  48. {activationActivity.type === ActivationTrigger.ACTIVATED
  49. ? 'Start monitoring.'
  50. : 'Finish monitoring.'}
  51. </div>
  52. <div />
  53. <div>
  54. <StyledDateTime
  55. date={getDynamicText({
  56. value: activationActivity.dateCreated,
  57. fixed: 'Mar 4, 2022 10:44:13 AM UTC',
  58. })}
  59. year
  60. seconds
  61. timeZone
  62. />
  63. </div>
  64. </Fragment>
  65. );
  66. }