diff --git a/package.json b/package.json index 7e84069..a16fb25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "meteostat-grafama", - "version": "0.1.4", + "name": "meteostat-grafana", + "version": "0.1.5", "description": "Access historic weather data using the meteostat API", "scripts": { "build": "grafana-toolkit plugin:build && cp DOC.md dist/README.md", diff --git a/src/QueryEditor.tsx b/src/QueryEditor.tsx index ac3b102..e9966aa 100644 --- a/src/QueryEditor.tsx +++ b/src/QueryEditor.tsx @@ -1,12 +1,14 @@ import defaults from 'lodash/defaults'; import React, { ChangeEvent, PureComponent } from 'react'; -import { AsyncSelect, Button, LegacyForms } from '@grafana/ui'; +import { MultiSelect, InlineFieldRow, InlineField, AsyncSelect, Input } from '@grafana/ui'; import { QueryEditorProps, SelectableValue } from '@grafana/data'; import { DataSource } from './DataSource'; import { defaultQuery, MyDataSourceOptions, MyQuery, PropertiesMap } from './types'; -const { FormField, Select } = LegacyForms; +// This is a temporary work-around for a styling issue related to the new Input component. +// For more information, refer to https://github.com/grafana/grafana/issues/26512. +import {} from '@emotion/core'; type Props = QueryEditorProps; @@ -48,25 +50,9 @@ export class QueryEditor extends PureComponent { onRunQuery(); }; - onPropertyChange = (event: SelectableValue, index: number) => { + onPropertiesChange = (v: Array>) => { const { onChange, query, onRunQuery } = this.props; - const properties = JSON.parse(JSON.stringify(query.properties)); - properties[index] = event.value; - onChange({ ...query, properties }); - onRunQuery(); - }; - - onPropertyRemoved = (index: number) => { - const { onChange, query, onRunQuery } = this.props; - const propertiesBefore = query.properties.slice(0, index); - const propertiesAfter = query.properties.slice(index + 1); - onChange({ ...query, properties: [...propertiesBefore, ...propertiesAfter] }); - onRunQuery(); - }; - - onAddProperty = () => { - const { onChange, query, onRunQuery } = this.props; - onChange({ ...query, properties: [...query.properties, ''] }); + onChange({ ...query, properties: v.map(_ => _.value!) ?? [] }); onRunQuery(); }; @@ -74,55 +60,41 @@ export class QueryEditor extends PureComponent { const query = defaults(this.props.query, defaultQuery); const { station, latitude, longitude, properties } = query; - const renderProperties = properties.map((property, index) => { - return ( -
- + + + + + + + + this.onPropertiesChange(v)} + placeholder="Property" + options={Object.values(PropertiesMap)} /> -
- Properties - {renderProperties} - - - + + + ); } } diff --git a/src/plugin.json b/src/plugin.json index 618977e..a04c9cf 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -38,7 +38,7 @@ "updated": "%TODAY%" }, "dependencies": { - "grafanaDependency": "6.5.x", + "grafanaDependency": "7.3.x", "plugins": [] }, "routes": [