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

refactor: drop Format (queryType) #346

Merged
merged 1 commit into from
Dec 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 0 additions & 3 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,6 @@ paths:
example: "upper_25"
refId:
type: string
type:
type: string
enum: ["timeseries", "table"]
payload:
description: arbitrary "additional data" the user can pass in
type: object
Expand Down
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