Skip to content

Commit

Permalink
fix query editor error bug
Browse files Browse the repository at this point in the history
  • Loading branch information
haohanyang committed Sep 23, 2024
1 parent f29b743 commit e5469f3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ export function QueryEditor({ query, onChange }: Props) {
const queryJson = JSON.parse(queryText);

if (!Array.isArray(queryJson)) {
setQueryTextError("Invalid query");
} else {
setQueryTextError(null);
}
setQueryTextError("This is not a valid Mongo Aggregation Pipeline");
} catch (e) {
setQueryTextError("This is not a valid Mongo Aggregation Pipeline");
setQueryTextError("Invalid query");
}
}
};
Expand Down Expand Up @@ -81,9 +82,9 @@ export function QueryEditor({ query, onChange }: Props) {
</InlineFieldRow>
<Divider />
<Field label="Query Text" description="Enter the Mongo Aggregation Pipeline"
error={queryTextError} invalid={!!queryTextError}>
error={queryTextError} invalid={queryTextError != null}>
<CodeEditor onEditorDidMount={onCodeEditorDidMount} width="100%" height={300} language="json"
onBlur={onQueryTextChange} value={queryText || ""} />
onBlur={onQueryTextChange} value={queryText || ""} showMiniMap={false} />
</Field>
<Button onClick={onFormatQueryText}>Format</Button>
</>
Expand Down

0 comments on commit e5469f3

Please sign in to comment.