Skip to content

Commit

Permalink
refactor: drop Format (queryType)
Browse files Browse the repository at this point in the history
This has been removed before and since then nobody really explained what it is useful for.
  • Loading branch information
simPod committed Dec 26, 2022
1 parent fa4386a commit a4aca41
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions src/Component/QueryEditorContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QueryEditorProps, SelectableValue } from '@grafana/data';
import { QueryEditorProps } from '@grafana/data';
import { EditorField, EditorFieldGroup, EditorHeader, EditorRows } from '@grafana/experimental';
import React, { ComponentType, useCallback } from 'react';
import { DataSource } from '../DataSource';
Expand All @@ -8,15 +8,10 @@ import { QueryEditor } from './QueryEditor';
import { QueryBuilder } from './QueryBuilder';
import { QueryEditorModeToggle } from './QueryEditorModeToggle';
import { GenericOptions, GrafanaQuery, QueryEditorMode } from '../types';
import { CodeEditor, InlineField, InlineSwitch, RadioButtonGroup } from '@grafana/ui';
import { CodeEditor, InlineField, InlineSwitch } from '@grafana/ui';

type Props = QueryEditorProps<DataSource, GrafanaQuery, GenericOptions>;

const queryTypes: Array<SelectableValue<string>> = [
{ label: 'Timeserie', value: 'timeserie' },
{ label: 'Table', value: 'table' },
];

function convertPayloadToObject(payload: string | { [key: string]: any }): { [key: string]: any } {
if (payload) {
if (typeof payload === "string") {
Expand Down Expand Up @@ -53,7 +48,6 @@ export const QueryEditorContainer: ComponentType<Props> = (props) => {
React.useEffect(() => {
onChange({
...query,
queryType: query.queryType ?? 'timeserie',
editorMode: query.editorMode ?? defaultEditorMode,
});
}, []);
Expand All @@ -68,35 +62,12 @@ export const QueryEditorContainer: ComponentType<Props> = (props) => {
[onChange, query]
);

const onQueryTypeChange = useCallback(
(newMetricEditorMode: string) => {
onChange({
...query,
queryType: newMetricEditorMode,
});
},
[onChange, query]
);

return (
<>
<EditorHeader>
<InlineField label="Mode">
<QueryEditorModeToggle size="md" mode={editorMode} onChange={onEditorModeChange}/>
</InlineField>
<InlineField
label="Format"
tooltip={
'This option only adds an expected response data type to the request, but the final returned data type is still determined by the server.'
}
>
<RadioButtonGroup<string>
options={queryTypes}
size="md"
value={query.queryType}
onChange={onQueryTypeChange}
/>
</InlineField>
<InlineField label="Raw query">
<InlineSwitch
sizes="md"
Expand Down

0 comments on commit a4aca41

Please sign in to comment.