Skip to content

Commit fef0cac

Browse files
feat: Refactors VerticalGroup to Stack
Also makes the query inputs auto-sized
1 parent 7979dcc commit fef0cac

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/components/HaystackQueryInput.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Icon, InlineField, Input } from '@grafana/ui';
1+
import { AutoSizeInput, Icon, InlineField } from '@grafana/ui';
22
import React, { ChangeEvent } from 'react';
33
import { DEFAULT_QUERY, HaystackQuery } from 'types';
44

@@ -12,13 +12,13 @@ export function HaystackQueryInput({ query, onChange }: HaystackQueryInputProps)
1212
onChange(event.target.value);
1313
};
1414

15-
let width = 100;
15+
let minWidth = 50;
1616
switch (query.type) {
1717
case "eval":
1818
return (
1919
<InlineField>
20-
<Input
21-
width={width}
20+
<AutoSizeInput
21+
minWidth={minWidth}
2222
prefix={<Icon name="angle-right" />}
2323
onChange={onQueryChange}
2424
value={query.eval}
@@ -29,8 +29,8 @@ export function HaystackQueryInput({ query, onChange }: HaystackQueryInputProps)
2929
case "hisRead":
3030
return (
3131
<InlineField>
32-
<Input
33-
width={width}
32+
<AutoSizeInput
33+
minWidth={minWidth}
3434
prefix={'@'}
3535
onChange={onQueryChange}
3636
value={query.hisRead}
@@ -41,8 +41,8 @@ export function HaystackQueryInput({ query, onChange }: HaystackQueryInputProps)
4141
case "hisReadFilter":
4242
return (
4343
<InlineField>
44-
<Input
45-
width={width}
44+
<AutoSizeInput
45+
minWidth={minWidth}
4646
prefix={<Icon name="filter" />}
4747
onChange={onQueryChange}
4848
value={query.hisReadFilter}
@@ -53,8 +53,8 @@ export function HaystackQueryInput({ query, onChange }: HaystackQueryInputProps)
5353
case "read":
5454
return (
5555
<InlineField>
56-
<Input
57-
width={width}
56+
<AutoSizeInput
57+
minWidth={minWidth}
5858
prefix={<Icon name="filter" />}
5959
onChange={onQueryChange}
6060
value={query.read}

src/components/QueryEditor.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { } from 'react';
2-
import { Button, Form, VerticalGroup } from '@grafana/ui';
2+
import { Button, Form, Stack } from '@grafana/ui';
33
import { QueryEditorProps } from '@grafana/data';
44
import { DataSource } from '../datasource';
55
import { HaystackDataSourceOptions, HaystackQuery } from '../types';
@@ -30,11 +30,13 @@ export function QueryEditor({ datasource, query, onChange, onRunQuery }: Props)
3030
}
3131

3232
return (
33-
<div className="gf-form">
3433
<Form onSubmit={onSubmit}>
3534
{({ register, errors }) => {
3635
return (
37-
<VerticalGroup>
36+
<Stack
37+
direction="column"
38+
alignItems="flex-start"
39+
>
3840
<HaystackQueryTypeSelector
3941
datasource={datasource}
4042
type={query.type}
@@ -46,10 +48,9 @@ export function QueryEditor({ datasource, query, onChange, onRunQuery }: Props)
4648
onChange={onQueryChange}
4749
/>
4850
<Button type="submit" >Run</Button>
49-
</VerticalGroup>
51+
</Stack>
5052
);
5153
}}
5254
</Form>
53-
</div>
5455
);
5556
}

0 commit comments

Comments
 (0)