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 d6194a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 39 deletions.
13 changes: 5 additions & 8 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ paths:
post:
summary: List available metrics
description: >-
In `Panel > Queries` page. It will send the request to obtain the available metrics.
In `Panel > Queries` page. It will send the request to obtain the available metrics.
The request body will carry the current metric and payload. In
the `Builder` mode, if the `reloadMetric` value in the load
configuration is true, the api will also be triggered when the value is
Expand Down Expand Up @@ -77,10 +77,10 @@ paths:
type:
type: string
description: |-
If the value is select, the UI of the payload is a radio box.
If the value is multi-select, the UI of the payload is a multi selection box.
if the value is input, the UI of the payload is an input box.
if the value is textarea, the UI of the payload is a multiline input box.
If the value is select, the UI of the payload is a radio box.
If the value is multi-select, the UI of the payload is a multi selection box.
if the value is input, the UI of the payload is an input box.
if the value is textarea, the UI of the payload is a multiline input box.
The default is input.
enum:
- select
Expand Down 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

0 comments on commit d6194a7

Please sign in to comment.