mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
1373b37166
* cleanup tests * more cleanup * added links * test legacy hooks * test legacy hooks * update codeowners * revert package changes * add project specfic example script * remove console log * Update .github/CODEOWNERS Co-authored-by: Timur Olzhabayev <timur.olzhabayev@grafana.com> * Update CODEOWNERS * use correct file names * cleanup tests --------- Co-authored-by: Timur Olzhabayev <timur.olzhabayev@grafana.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { DataQuery } from '@grafana/data';
|
|
import { Button, FilterPill, Modal, Stack } from '@grafana/ui';
|
|
import { testIds } from '../../testIds';
|
|
import { ReactElement, useState } from 'react';
|
|
import { selectQuery } from '../../utils/utils';
|
|
|
|
type Props = {
|
|
targets: DataQuery[] | undefined;
|
|
onDismiss?: () => void;
|
|
};
|
|
|
|
export function QueryModal(props: Props): ReactElement {
|
|
const { targets = [], onDismiss } = props;
|
|
const [selected, setSelected] = useState(targets[0]);
|
|
|
|
return (
|
|
<div data-testid={testIds.modal.container}>
|
|
<p>Please select the query you would like to use to create "something" in the plugin.</p>
|
|
<Stack>
|
|
{targets.map((query) => (
|
|
<FilterPill
|
|
key={query.refId}
|
|
label={query.refId}
|
|
selected={query.refId === selected?.refId}
|
|
onClick={() => setSelected(query)}
|
|
/>
|
|
))}
|
|
</Stack>
|
|
<Modal.ButtonRow>
|
|
<Button variant="secondary" fill="outline" onClick={onDismiss}>
|
|
Cancel
|
|
</Button>
|
|
<Button
|
|
disabled={!Boolean(selected)}
|
|
onClick={() => {
|
|
onDismiss?.();
|
|
selectQuery(selected);
|
|
}}
|
|
>
|
|
OK
|
|
</Button>
|
|
</Modal.ButtonRow>
|
|
</div>
|
|
);
|
|
}
|