Skip to content

Commit

Permalink
fix: re-add query type selector to SQL Editor queries in dashboard vi…
Browse files Browse the repository at this point in the history
…ew (#734)
  • Loading branch information
SpencerTorres authored Mar 1, 2024
1 parent 48b156b commit 42f5e6d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Added `$__fromTime_ms` macro that represents the dashboard "from" time in milliseconds using a `DateTime64(3)`
- Added `$__toTime_ms` macro that represents the dashboard "to" time in milliseconds using a `DateTime64(3)`
- Added `$__timeFilter_ms` macro that uses `DateTime64(3)` for millisecond precision time filtering
- Re-added query type selector in dashboard view. This was only visible in explore view, but somehow it affects dashboard view, and so it has been re-added. (#730)
- When OTel is enabled, Trace ID queries now use a skip index to optimize exact ID lookups on large trace datasets (#724)

### Fixes
Expand Down
13 changes: 5 additions & 8 deletions src/components/SqlEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { CoreApp, QueryEditorProps } from '@grafana/data';
import { QueryEditorProps } from '@grafana/data';
import { CodeEditor, monacoTypes } from '@grafana/ui';
import { Datasource } from 'data/CHDatasource';
import { registerSQL, Range, Fetcher } from './sqlProvider';
Expand Down Expand Up @@ -31,7 +31,7 @@ function setupAutoSize(editor: monacoTypes.editor.IStandaloneCodeEditor) {
}

export const SqlEditor = (props: SqlEditorProps) => {
const { app, query, onChange, datasource } = props;
const { query, onChange, datasource } = props;
const sqlQuery = query as CHSqlQuery;
const queryType = sqlQuery.queryType || QueryType.Table;

Expand Down Expand Up @@ -90,12 +90,9 @@ export const SqlEditor = (props: SqlEditorProps) => {

return (
<>
{/* Only show in explore view where panel can't be manually selected. Dashboard view lets you change the panel. */}
{app === CoreApp.Explore && (
<div className={'gf-form ' + styles.QueryEditor.queryType}>
<QueryTypeSwitcher queryType={queryType} onChange={(queryType) => saveChanges({ queryType })} sqlEditor />
</div>
)}
<div className={'gf-form ' + styles.QueryEditor.queryType}>
<QueryTypeSwitcher queryType={queryType} onChange={(queryType) => saveChanges({ queryType })} sqlEditor />
</div>
<div className={styles.Common.wrapper}>
<CodeEditor
aria-label="SQL Editor"
Expand Down

0 comments on commit 42f5e6d

Please sign in to comment.