import React, { ChangeEvent, useState } from 'react'; import { Button, Icon, InlineField, InlineFieldRow, Input } from '@grafana/ui'; import MappingsHelp from './MappingsHelp'; type Props = { mappings: string[]; onChange: (mappings: string[]) => void; onDismiss: () => void; onRestoreHelp: () => void; showHelp: boolean; }; export const MappingsConfiguration = (props: Props): JSX.Element => { const [mappings, setMappings] = useState(props.mappings || []); return (

Label mappings

{!props.showHelp && (

)} {props.showHelp && }
{mappings.map((mapping, i) => ( ) => { let newMappings = mappings.concat(); newMappings[i] = changeEvent.target.value; setMappings(newMappings); }} onBlur={() => { props.onChange(mappings); }} placeholder="e.g. test.metric.(labelName).*" value={mapping} /> ))}
); };