grafana/public/app/plugins/datasource/prometheus/configuration/ExemplarsSettings.tsx
Zoltán Bedi 32030f3929
Add e2e test for exemplars flow (#33972)
* Add e2e test for exemplars flow

* Check if data source is created

* Lets see what is going on

* Try again

* Updating the image maybe?

* Revert "Updating the image maybe?"

This reverts commit 968b44b0d9.

* Try with force

* Use electron

* Wait for new url?

* Wait?????

* Should be good now

* Revert e2e recording
2021-05-13 14:17:09 +02:00

56 lines
1.5 KiB
TypeScript

import { css } from '@emotion/css';
import { selectors } from '@grafana/e2e-selectors';
import { Button } from '@grafana/ui';
import React from 'react';
import { ExemplarTraceIdDestination } from '../types';
import ExemplarSetting from './ExemplarSetting';
type Props = {
options?: ExemplarTraceIdDestination[];
onChange: (value: ExemplarTraceIdDestination[]) => void;
};
export function ExemplarsSettings({ options, onChange }: Props) {
return (
<>
<h3 className="page-heading">Exemplars</h3>
{options &&
options.map((option, index) => {
return (
<ExemplarSetting
key={index}
value={option}
onChange={(newField) => {
const newOptions = [...options];
newOptions.splice(index, 1, newField);
onChange(newOptions);
}}
onDelete={() => {
const newOptions = [...options];
newOptions.splice(index, 1);
onChange(newOptions);
}}
/>
);
})}
<Button
variant="secondary"
aria-label={selectors.components.DataSource.Prometheus.configPage.exemplarsAddButton}
className={css`
margin-bottom: 10px;
`}
icon="plus"
onClick={(event) => {
event.preventDefault();
const newOptions = [...(options || []), { name: 'traceID' }];
onChange(newOptions);
}}
>
Add
</Button>
</>
);
}