metricsRemovedAlertsWidgetsAlert.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import styled from '@emotion/styled';
  2. import Alert, {type AlertProps} from 'sentry/components/alert';
  3. import {Button} from 'sentry/components/button';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import {IconClose} from 'sentry/icons';
  6. import {t, tct} from 'sentry/locale';
  7. import {space} from 'sentry/styles/space';
  8. import type {Organization} from 'sentry/types/organization';
  9. import useDismissAlert from 'sentry/utils/useDismissAlert';
  10. const LOCAL_STORAGE_KEY = 'metrics-removed-alerts-wizards-info-dismissed';
  11. export function MetricsRemovedAlertsWidgetsAlert({
  12. style,
  13. organization,
  14. }: Pick<AlertProps, 'style'> & {organization: Organization}) {
  15. const {dismiss, isDismissed} = useDismissAlert({
  16. key: LOCAL_STORAGE_KEY,
  17. expirationDays: 365,
  18. });
  19. const hasDeletedAlertsOrWidgets = organization.features.includes(
  20. 'custom-metrics-alerts-widgets-removal-info'
  21. );
  22. if (isDismissed || !hasDeletedAlertsOrWidgets) {
  23. return null;
  24. }
  25. return (
  26. <Alert type="info" showIcon style={style}>
  27. <AlertContent>
  28. <div>
  29. {tct(
  30. 'The Metrics beta program has ended on October 7th and all alerts/dashboard widgets using custom metrics have been removed. For more details, please [link:read the FAQs]. Thank you again for participating.',
  31. {
  32. link: (
  33. <ExternalLink href="https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Metrics-Beta-Coming-to-an-End" />
  34. ),
  35. }
  36. )}
  37. </div>
  38. <DismissButton
  39. priority="link"
  40. icon={<IconClose />}
  41. onClick={dismiss}
  42. aria-label={t('Dismiss Alert')}
  43. title={t('Dismiss Alert')}
  44. />
  45. </AlertContent>
  46. </Alert>
  47. );
  48. }
  49. const DismissButton = styled(Button)`
  50. color: ${p => p.theme.alert.warning.color};
  51. pointer-events: all;
  52. &:hover {
  53. opacity: 0.5;
  54. }
  55. `;
  56. const AlertContent = styled('div')`
  57. display: grid;
  58. grid-template-columns: 1fr max-content;
  59. gap: ${space(1)};
  60. align-items: center;
  61. `;