Skip to content

Commit 37f6ce8

Browse files
feature: Makes default queries placeholders
This avoids an issue where the first query doesn't work.
1 parent 5ca0191 commit 37f6ce8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/components/QueryEditor.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export function QueryEditor({ query, onChange, onRunQuery }: Props) {
1212
onChange({ ...query, type: queryTypes[queryTypeIndex].label });
1313
};
1414
const onEvalChange = (event: ChangeEvent<HTMLInputElement>) => {
15-
onChange({ ...query, eval: event.target.value });
15+
onChange({ ...query, type: 'Eval', eval: event.target.value });
1616
};
1717
const onHisReadChange = (event: ChangeEvent<HTMLInputElement>) => {
18-
onChange({ ...query, hisRead: event.target.value });
18+
onChange({ ...query, type: 'HisRead', hisRead: event.target.value });
1919
};
2020

2121
const queryTypes = [
@@ -46,11 +46,11 @@ export function QueryEditor({ query, onChange, onRunQuery }: Props) {
4646
switch(queryType.value) {
4747
case 0: // Eval
4848
return <InlineField label="Axon" labelWidth="auto" tooltip="An Axon expression to evaluate on the Haystack server">
49-
<Input width={100} prefix={<Icon name="angle-right" />} onChange={onEvalChange} value={query.eval ?? DEFAULT_QUERY.eval} />
49+
<Input width={100} prefix={<Icon name="angle-right" />} onChange={onEvalChange} value={query.eval} placeholder={DEFAULT_QUERY.eval} />
5050
</InlineField>
5151
case 1: // HisRead
5252
return <InlineField label="Point ID" labelWidth="auto" tooltip="The ID of the point to read">
53-
<Input width={100} prefix={<Icon name="angle-right" />} onChange={onHisReadChange} value={query.hisRead ?? DEFAULT_QUERY.hisRead} />
53+
<Input width={100} prefix={<Icon name="angle-right" />} onChange={onHisReadChange} value={query.hisRead} placeholder={DEFAULT_QUERY.hisRead} />
5454
</InlineField>
5555
}
5656
return <p>Select a query type</p>
@@ -59,7 +59,6 @@ export function QueryEditor({ query, onChange, onRunQuery }: Props) {
5959
return (
6060
<div className="gf-form">
6161
<Form
62-
defaultValues={DEFAULT_QUERY}
6362
onSubmit={(newQuery: Partial<MyQuery>) => query = { ...query, ...newQuery }}
6463
>{({register, errors}) => {
6564
return (

0 commit comments

Comments
 (0)