import {forwardRef} from 'react'; import styled from '@emotion/styled'; import Button from 'sentry/components/button'; import TextOverflow from 'sentry/components/textOverflow'; import {IconDelete, IconEdit} from 'sentry/icons'; import {t} from 'sentry/locale'; import space from 'sentry/styles/space'; import {MethodType, Rule, RuleType} from './types'; import {getMethodLabel, getRuleLabel} from './utils'; type Props = { rules: Array; disabled?: boolean; onDeleteRule?: (id: Rule['id']) => () => void; onEditRule?: (id: Rule['id']) => () => void; }; const getListItemDescription = (rule: Rule) => { const {method, type, source} = rule; const methodLabel = getMethodLabel(method); const typeLabel = getRuleLabel(type); const descriptionDetails: Array = []; descriptionDetails.push(`[${methodLabel.label}]`); descriptionDetails.push( rule.type === RuleType.PATTERN ? `[${rule.pattern}]` : `[${typeLabel}]` ); if (rule.method === MethodType.REPLACE && rule.placeholder) { descriptionDetails.push(` with [${rule.placeholder}]`); } return `${descriptionDetails.join(' ')} ${t('from')} [${source}]`; }; const Rules = forwardRef(function RulesList( {rules, onEditRule, onDeleteRule, disabled}: Props, ref: React.Ref ) { return ( {rules.map(rule => { const {id} = rule; return ( {getListItemDescription(rule)} {onEditRule && (