import type React from 'react'; import {useEffect, useRef} from 'react'; import styled from '@emotion/styled'; import {Button} from 'sentry/components/button'; import {Tooltip} from 'sentry/components/tooltip'; import {IconEdit} from 'sentry/icons'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {PercentInput} from 'sentry/views/settings/dynamicSampling/percentInput'; import {useHasDynamicSamplingWriteAccess} from 'sentry/views/settings/dynamicSampling/utils/access'; interface Props { help: React.ReactNode; label: React.ReactNode; onChange: (value: string) => void; previousValue: string; showPreviousValue: boolean; value: string; error?: string; isBulkEditActive?: boolean; isBulkEditEnabled?: boolean; onBulkEditChange?: (value: boolean) => void; } export function OrganizationSampleRateInput({ value, onChange, isBulkEditEnabled, isBulkEditActive, label, help, error, previousValue, showPreviousValue, onBulkEditChange, }: Props) { const hasAccess = useHasDynamicSamplingWriteAccess(); const inputRef = useRef(null); // Autofocus the input when bulk edit is activated useEffect(() => { if (isBulkEditActive) { inputRef.current?.focus(); } }, [isBulkEditActive]); const showBulkEditButton = hasAccess && isBulkEditEnabled && !isBulkEditActive; return ( {help} {showBulkEditButton && (