-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHaystackQueryInput.tsx
More file actions
67 lines (64 loc) · 1.77 KB
/
HaystackQueryInput.tsx
File metadata and controls
67 lines (64 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { AutoSizeInput, Icon, InlineField } from '@grafana/ui';
import React, { ChangeEvent } from 'react';
import { DEFAULT_QUERY, HaystackQuery } from 'types';
export interface HaystackQueryInputProps {
query: HaystackQuery;
onChange: (query: string) => void;
}
export function HaystackQueryInput({ query, onChange }: HaystackQueryInputProps) {
const onQueryChange = (event: ChangeEvent<HTMLInputElement>) => {
onChange(event.target.value);
};
let minWidth = 50;
switch (query.type) {
case "eval":
return (
<InlineField>
<AutoSizeInput
minWidth={minWidth}
prefix={<Icon name="angle-right" />}
onBlur={onQueryChange}
value={query.eval}
placeholder={DEFAULT_QUERY.eval}
/>
</InlineField>
);
case "hisRead":
return (
<InlineField>
<AutoSizeInput
minWidth={minWidth}
prefix={'@'}
onBlur={onQueryChange}
value={query.hisRead}
placeholder={DEFAULT_QUERY.hisRead}
/>
</InlineField>
);
case "hisReadFilter":
return (
<InlineField>
<AutoSizeInput
minWidth={minWidth}
prefix={<Icon name="filter" />}
onBlur={onQueryChange}
value={query.hisReadFilter}
placeholder={DEFAULT_QUERY.hisReadFilter}
/>
</InlineField>
);
case "read":
return (
<InlineField>
<AutoSizeInput
minWidth={minWidth}
prefix={<Icon name="filter" />}
onBlur={onQueryChange}
value={query.read}
placeholder={DEFAULT_QUERY.read}
/>
</InlineField>
);
}
return <p>Select a query type</p>;
}