import type {BaseButtonProps} from 'sentry/components/button'; import {Button} from 'sentry/components/button'; import Confirm from 'sentry/components/confirm'; import {Tooltip} from 'sentry/components/tooltip'; import {IconNot, IconPlay} from 'sentry/icons'; import {t} from 'sentry/locale'; type BlockTarget = 'metric' | 'tag'; export interface BlockButtonProps extends BaseButtonProps { blockTarget: BlockTarget; hasAccess: boolean; isBlocked: boolean; onConfirm: () => void; } const tooltipText: Record = { metric: t( 'Disabling a metric blocks its ingestion and makes it inaccessible in Metrics, Alerts, and Dashboards.' ), tag: t( 'Disabling a tag blocks its ingestion and makes it inaccessible in Metrics, Alerts, and Dashboards.' ), }; const blockConfirmText: Record = { metric: t( 'Are you sure you want to disable this metric? It will no longer be ingested, and will not be available for use in Metrics, Alerts, or Dashboards.' ), tag: t( 'Are you sure you want to disable this tag? It will no longer be ingested, and will not be available for use in Metrics, Alerts, or Dashboards.' ), }; const unblockConfirmText: Record = { metric: t('Are you sure you want to activate this metric?'), tag: t('Are you sure you want to activate this tag?'), }; const blockAriaLabel: Record = { metric: t('Disable metric'), tag: t('Disable tag'), }; const unblockAriaLabel: Record = { metric: t('Activate metric'), tag: t('Activate tag'), }; export function BlockButton({ isBlocked, blockTarget, onConfirm, hasAccess, disabled, ...props }: BlockButtonProps) { const button = ( ); const hasTooltip = !hasAccess || !isBlocked; return hasTooltip ? ( {button} ) : ( button ); }