From de87cf58ca77e298f335a28f0e5d1db4ba898aab Mon Sep 17 00:00:00 2001 From: Julien Millau <995890+devnied@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:32:57 +0100 Subject: [PATCH] feat: replace obsolete components (#99) * feat: replace obsolete components * Fix: remove deprecated components --- .eslintcache | 1 - CHANGELOG.md | 5 +- package.json | 2 +- src/ConfigEditor.tsx | 191 ++++++++++++++++++++++--------------------- src/QueryEditor.tsx | 15 ++-- src/datasource.ts | 6 +- src/types.ts | 2 +- 7 files changed, 112 insertions(+), 110 deletions(-) delete mode 100644 .eslintcache diff --git a/.eslintcache b/.eslintcache deleted file mode 100644 index f2879e5..0000000 --- a/.eslintcache +++ /dev/null @@ -1 +0,0 @@ -[{"/Users/julien/Documents/grafana-plugins/snowflake-datasource/jest-setup.js":"1","/Users/julien/Documents/grafana-plugins/snowflake-datasource/jest.config.js":"2","/Users/julien/Documents/grafana-plugins/snowflake-datasource/src/ConfigEditor.tsx":"3","/Users/julien/Documents/grafana-plugins/snowflake-datasource/src/QueryEditor.tsx":"4","/Users/julien/Documents/grafana-plugins/snowflake-datasource/src/datasource.ts":"5","/Users/julien/Documents/grafana-plugins/snowflake-datasource/src/module.ts":"6","/Users/julien/Documents/grafana-plugins/snowflake-datasource/src/types.ts":"7","/Users/julien/Documents/grafana-plugins/snowflake-datasource/webpack.config.ts":"8"},{"size":77,"mtime":1703243544147,"results":"9","hashOfConfig":"10"},{"size":281,"mtime":1703243544147,"results":"11","hashOfConfig":"10"},{"size":8353,"mtime":1666283813168,"results":"12","hashOfConfig":"13"},{"size":4191,"mtime":1711659236656,"results":"14","hashOfConfig":"13"},{"size":1693,"mtime":1702514232896,"results":"15","hashOfConfig":"13"},{"size":412,"mtime":1664834195363,"results":"16","hashOfConfig":"13"},{"size":999,"mtime":1711554437236,"results":"17","hashOfConfig":"13"},{"size":1692,"mtime":1703586947713,"results":"18","hashOfConfig":"10"},{"filePath":"19","messages":"20","suppressedMessages":"21","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"hb3s7z",{"filePath":"22","messages":"23","suppressedMessages":"24","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"25","messages":"26","suppressedMessages":"27","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"r2ljv1",{"filePath":"28","messages":"29","suppressedMessages":"30","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"31","messages":"32","suppressedMessages":"33","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"34","messages":"35","suppressedMessages":"36","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"37","messages":"38","suppressedMessages":"39","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"40","messages":"41","suppressedMessages":"42","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/Users/julien/Documents/grafana-plugins/snowflake-datasource/jest-setup.js",["43"],[],"/Users/julien/Documents/grafana-plugins/snowflake-datasource/jest.config.js",["44"],[],"/Users/julien/Documents/grafana-plugins/snowflake-datasource/src/ConfigEditor.tsx",[],[],"/Users/julien/Documents/grafana-plugins/snowflake-datasource/src/QueryEditor.tsx",[],[],"/Users/julien/Documents/grafana-plugins/snowflake-datasource/src/datasource.ts",[],[],"/Users/julien/Documents/grafana-plugins/snowflake-datasource/src/module.ts",[],[],"/Users/julien/Documents/grafana-plugins/snowflake-datasource/src/types.ts",[],[],"/Users/julien/Documents/grafana-plugins/snowflake-datasource/webpack.config.ts",["45"],[],{"ruleId":null,"fatal":true,"severity":2,"message":"46","line":2,"column":1,"nodeType":null},{"ruleId":null,"fatal":true,"severity":2,"message":"47","line":7,"column":3,"nodeType":null},{"ruleId":null,"fatal":true,"severity":2,"message":"46","line":1,"column":1,"nodeType":null},"Parsing error: The keyword 'import' is reserved","Parsing error: Unexpected token ."] \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 29feace..6fde93f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ # Changelog -## 2.0.0 (not released yet) - +## 1.9.1 +### 🔨 Changed +- Remove deprecated UI components ## 1.9.0 diff --git a/package.json b/package.json index dd3d065..26cf9ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "michelin-snowflake-datasource", - "version": "2.0.0", + "version": "1.9.1", "description": "Data source for Snowflake", "scripts": { "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", diff --git a/src/ConfigEditor.tsx b/src/ConfigEditor.tsx index 546eb5e..5ae657f 100644 --- a/src/ConfigEditor.tsx +++ b/src/ConfigEditor.tsx @@ -1,14 +1,23 @@ import React, { ChangeEvent, PureComponent } from 'react'; -import {Checkbox, ControlledCollapse, LegacyForms} from '@grafana/ui'; +import { + Checkbox, + ControlledCollapse, + InlineField, + Input, + SecretInput, + SecretTextArea, + Switch +} from '@grafana/ui'; import { DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { SnowflakeOptions, SnowflakeSecureOptions } from './types'; -const { SecretFormField, FormField, Switch } = LegacyForms; - interface Props extends DataSourcePluginOptionsEditorProps {} interface State {} +const LABEL_WIDTH = 30 +const INPUT_WIDTH = 40 + export class ConfigEditor extends PureComponent { onAccountChange = (event: ChangeEvent) => { const { onOptionsChange, options } = this.props; @@ -21,7 +30,7 @@ export class ConfigEditor extends PureComponent { } // Sanitize value to avoid error - const regex = new RegExp('https?://'); + const regex = /https?:\/\//; value = value.replace(regex, ''); const jsonData = { @@ -139,7 +148,7 @@ export class ConfigEditor extends PureComponent { }); }; - onPrivateKeyChange = (event: ChangeEvent) => { + onPrivateKeyChange = (event: ChangeEvent) => { const { onOptionsChange, options } = this.props; onOptionsChange({ ...options, @@ -174,140 +183,134 @@ export class ConfigEditor extends PureComponent {

Connection

-
- + -
- -
- + + -
- -
+ + -
-
- {!jsonData.basicAuth && ( - + {!jsonData.basicAuth && ( + + - )} - {jsonData.basicAuth && ( - + )} + {jsonData.basicAuth && ( + + - )} -
-
- + )} + + -
+

Parameter configuration

-
- + -
+ -
- + -
+ -
- + -
+

Session configuration

-
- + -
+
-
- + -
+
-
- -
+ + +
); diff --git a/src/QueryEditor.tsx b/src/QueryEditor.tsx index d0c662f..fb93478 100644 --- a/src/QueryEditor.tsx +++ b/src/QueryEditor.tsx @@ -14,11 +14,12 @@ export class QueryEditor extends PureComponent { onQueryTextChange = (newQuery: string) => { const { onChange, query } = this.props; onChange({ ...query, queryText: newQuery }); + this.props.onRunQuery(); }; onFormat = () => { try { - let formatted = format(this.props.query.queryText || "", { + let formatted = format(this.props.query.queryText ?? "", { language: 'snowflake', denseOperators: false, keywordCase: 'upper', @@ -38,7 +39,7 @@ export class QueryEditor extends PureComponent { const { onChange, query } = this.props; onChange({ ...query, - queryType: value.value || 'table', + queryType: value.value ?? 'table', }); this.props.onRunQuery(); @@ -78,11 +79,11 @@ export class QueryEditor extends PureComponent { const query = defaults(this.props.query, defaultQuery); const { queryText, queryType, fillMode, timeColumns } = query; const selectedOption = this.options.find((options) => options.value === queryType) || this.options; - const selectedFillMode = this.optionsFillMode.find((options) => options.value === fillMode)?.value || this.optionsFillMode[0].value; + const selectedFillMode = this.optionsFillMode.find((options) => options.value === fillMode)?.value ?? this.optionsFillMode[0].value; return (
-
+
Query Type