Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: re-add query type selector to SQL Editor queries in dashboard view #734

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

### 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
Loading