import {Fragment} from 'react'; import styled from '@emotion/styled'; import Button from 'sentry/components/button'; import FieldRequiredBadge from 'sentry/components/forms/field/fieldRequiredBadge'; import TextareaField from 'sentry/components/forms/textareaField'; import {IconDelete} from 'sentry/icons/iconDelete'; import {t} from 'sentry/locale'; import space from 'sentry/styles/space'; import {SamplingInnerName} from 'sentry/types/sampling'; import {getInnerNameLabel} from '../../utils'; import {TagValueAutocomplete, TagValueAutocompleteProps} from './tagValueAutocomplete'; import {getMatchFieldPlaceholder, getTagKey} from './utils'; export type Condition = { category: SamplingInnerName; match?: string; }; interface Props extends Pick { conditions: Condition[]; onChange: ( index: number, field: T, value: Condition[T] ) => void; onDelete: (index: number) => void; } export function Conditions({conditions, orgSlug, projectId, onDelete, onChange}: Props) { return ( {conditions.map((condition, index) => { const {category, match} = condition; const isAutoCompleteField = category === SamplingInnerName.TRACE_ENVIRONMENT || category === SamplingInnerName.TRACE_RELEASE; return ( {getInnerNameLabel(category)} {isAutoCompleteField ? ( onChange(index, 'match', value)} /> ) : ( onChange(index, 'match', value)} placeholder={getMatchFieldPlaceholder(category)} inline={false} rows={1} autosize hideControlState flexibleControlStateSize required stacked /> )}