Skip to content

Commit

Permalink
Merge pull request #42 from Clarity-89/remove-form
Browse files Browse the repository at this point in the history
Remove form
  • Loading branch information
Clarity-89 authored Feb 20, 2024
2 parents 6fd4eba + 863ce62 commit 44c83c5
Show file tree
Hide file tree
Showing 8 changed files with 14,458 additions and 14,887 deletions.
4 changes: 2 additions & 2 deletions .config/webpack/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from 'fs';
import path from 'path';
import util from 'util';
import { glob } from 'glob';
import { SOURCE_DIR } from './constants';

Expand All @@ -21,7 +20,8 @@ export function hasReadme() {
export async function getEntries(): Promise<Record<string, string>> {
const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true });

const plugins = await Promise.all(pluginsJson.map((pluginJson) => {
const plugins = await Promise.all(
pluginsJson.map((pluginJson) => {
const folder = path.dirname(pluginJson);
return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true });
})
Expand Down
2 changes: 1 addition & 1 deletion .config/webpack/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const config = async (env): Promise<Configuration> => ({
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
use: ['style-loader', 'css-loader'],
},
{
test: /\.s[ac]ss$/,
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ e2e-results/

.idea/
publish.md

.yarn/
7 changes: 7 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compressionLevel: mixed

enableGlobalCache: false

enableTelemetry: false

nodeLinker: node-modules
37 changes: 20 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
## 0.1.1

- Initial release
## 0.5.0
- Remove @grafana/ui Form usage
- Update React to v.18
- Remove unused dependencies

## 0.2.1
## 0.4.1
- Remove `grafanaVersion` from `plugin.json`
- Update `grafanaDependency` in `plugin.json`

- Update the plugin to be compatible with Grafana 8
- Add social sentiment endpoint support
## 0.4.0
- Update the plugin to be compatible with Grafana 10

## 0.3.0
- Store API token in secure field
- Temporarily disabled trades websocket endpoint due to proxy auth issue (quote query with dashboard refresh can be used as a workaround).
## 0.3.2
- Update dependencies

## 0.3.1
- Restore trades endpoint (websocket)

## 0.3.2
- Update dependencies
## 0.3.0
- Store API token in secure field
- Temporarily disabled trades websocket endpoint due to proxy auth issue (quote query with dashboard refresh can be used as a workaround).

## 0.4.0
- Update the plugin to be compatible with Grafana 10
## 0.4.1
- Remove `grafanaVersion` from `plugin.json`
- Update `grafanaDependency` in `plugin.json`
## 0.2.1
- Update the plugin to be compatible with Grafana 8
- Add social sentiment endpoint support

## 0.1.1
- Initial release
18 changes: 7 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clarity-89-finnhub-datasource",
"version": "0.4.1",
"version": "0.5.0",
"description": "Datasource plugin for Finnhub",
"scripts": {
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
Expand Down Expand Up @@ -34,7 +34,6 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^12.1.4",
"@types/jest": "^29.5.0",
"@types/lodash": "^4.14.194",
"@types/lodash.capitalize": "^4.2.7",
"@types/node": "^18.15.11",
"copy-webpack-plugin": "^11.0.0",
Expand Down Expand Up @@ -66,18 +65,15 @@
},
"dependencies": {
"@emotion/css": "^11.1.3",
"@grafana/data": "^10.0.1",
"@grafana/runtime": "^10.0.1",
"@grafana/ui": "^10.0.1",
"@grafana/data": "^10.3.3",
"@grafana/runtime": "^10.3.3",
"@grafana/ui": "^10.3.3",
"g": "^2.0.1",
"lerna": "^3.20.2",
"lodash.capitalize": "^4.2.1",
"moment": "^2.29.4",
"plop": "^2.6.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rxjs": "^7.5.1",
"tslib": "2.5.3"
},
"packageManager": "yarn@1.22.19"
"packageManager": "yarn@4.1.0"
}
94 changes: 41 additions & 53 deletions src/components/QueryEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ChangeEvent, FC } from 'react';
import capitalize from 'lodash.capitalize';
import { Form, Field, Input, Select } from '@grafana/ui';
import { Field, Input, Select } from '@grafana/ui';
import { QueryEditorProps, SelectableValue } from '@grafana/data';
import { DataSource } from '../DataSource';
import { defaultQuery, MyDataSourceOptions, MyQuery } from '../types';
Expand Down Expand Up @@ -68,59 +68,47 @@ export const QueryEditor: FC<Props> = ({ onChange, onRunQuery, query }) => {
const { queryText, symbol, type, resolution, metric } = { ...defaultQuery, ...query };

return (
<Form onSubmit={onRunQuery}>
{({ register, errors }) => {
return (
<>
<Field label="Data type">
<Select
data-testid="Data type"
onChange={onTypeChange}
options={dataTypes}
value={type}
defaultValue={type}
/>
</Field>
{type.value !== 'exchange' && (
<Field label="Symbol">
<Input
value={symbol}
name={'symbol'}
onChange={onValueChange}
onKeyDown={onKeyDown}
placeholder="Stock symbol"
/>
</Field>
)}
<form onSubmit={onRunQuery}>
<Field label="Data type">
<Select data-testid="Data type" onChange={onTypeChange} options={dataTypes} value={type} defaultValue={type} />
</Field>
{type.value !== 'exchange' && (
<Field label="Symbol">
<Input
value={symbol}
name={'symbol'}
onChange={onValueChange}
onKeyDown={onKeyDown}
placeholder="Stock symbol"
/>
</Field>
)}

{type.value === 'candle' && (
<Field label="Resolution">
<Select onChange={onResolutionChange} options={resolutions} value={resolution} />
</Field>
)}
{type.value === 'candle' && (
<Field label="Resolution">
<Select onChange={onResolutionChange} options={resolutions} value={resolution} />
</Field>
)}

{type.value === 'metric' && (
<Field label="Metric">
<Select onChange={onMetricChange} options={metricOptions} value={metric} defaultValue={metric} />
</Field>
)}
{type.value !== 'trades' && (
<Field
label="Free Query Text"
horizontal={false}
description="Experimental. Will override any selected values above."
>
<Input
value={queryText || ''}
onChange={onQueryTextChange}
onKeyDown={onKeyDown}
placeholder="Custom query e.g. 'earnings?symbol=AAPL'"
/>
</Field>
)}
</>
);
}}
</Form>
{type.value === 'metric' && (
<Field label="Metric">
<Select onChange={onMetricChange} options={metricOptions} value={metric} defaultValue={metric} />
</Field>
)}
{type.value !== 'trades' && (
<Field
label="Free Query Text"
horizontal={false}
description="Experimental. Will override any selected values above."
>
<Input
value={queryText || ''}
onChange={onQueryTextChange}
onKeyDown={onKeyDown}
placeholder="Custom query e.g. 'earnings?symbol=AAPL'"
/>
</Field>
)}
</form>
);
};
Loading

0 comments on commit 44c83c5

Please sign in to comment.