Skip to content

Commit 16d40a6

Browse files
authored
feat: added support for dashboard panels (#10)
* added timestamp column input in config * fix: dashboard panel fixes * fix: removed console log * fix: updated test cases with timestamp_column argument * chore: updated grafana plugin * chore: updated package lock file * chore: updated grafana/data, grafana/runtime, grafana/ui to 10.2.0 * chore: updated packages * fix: removed deprecated usage of DataQuery from grafana/data
1 parent 19ad370 commit 16d40a6

22 files changed

+2306
-3009
lines changed

.config/.cprc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"version": "2.5.1"
3+
}

.config/.eslintrc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@
22
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
33
*
44
* In order to extend the configuration follow the steps in
5-
* https://grafana.github.io/plugin-tools/docs/advanced-configuration#extending-the-eslint-config
5+
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-eslint-config
66
*/
7-
{
7+
{
88
"extends": ["@grafana/eslint-config"],
99
"root": true,
1010
"rules": {
1111
"react/prop-types": "off"
12-
}
12+
},
13+
"overrides": [
14+
{
15+
"plugins": ["deprecation"],
16+
"files": ["src/**/*.{ts,tsx}"],
17+
"rules": {
18+
"deprecation/deprecation": "warn"
19+
},
20+
"parserOptions": {
21+
"project": "./tsconfig.json"
22+
}
23+
}
24+
]
1325
}

.config/.prettierrc.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
*/
66

77
module.exports = {
8-
"endOfLine": "auto",
9-
"printWidth": 120,
10-
"trailingComma": "es5",
11-
"semi": true,
12-
"jsxSingleQuote": false,
13-
"singleQuote": true,
14-
"useTabs": false,
15-
"tabWidth": 2
16-
};
8+
endOfLine: 'auto',
9+
printWidth: 120,
10+
trailingComma: 'es5',
11+
semi: true,
12+
jsxSingleQuote: false,
13+
singleQuote: true,
14+
useTabs: false,
15+
tabWidth: 2,
16+
};

.config/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ set up the Jest DOM for the testing library and to apply some polyfills. ([link
5656

5757
#### ESM errors with Jest
5858

59-
A common issue found with the current jest config involves importing an npm package which only offers an ESM build. These packages cause jest to error with `SyntaxError: Cannot use import statement outside a module`. To work around this we provide a list of known packages to pass to the `[transformIgnorePatterns](https://jestjs.io/docs/configuration#transformignorepatterns-arraystring)` jest configuration property. If need be this can be extended in the following way:
59+
A common issue with the current jest config involves importing an npm package that only offers an ESM build. These packages cause jest to error with `SyntaxError: Cannot use import statement outside a module`. To work around this, we provide a list of known packages to pass to the `[transformIgnorePatterns](https://jestjs.io/docs/configuration#transformignorepatterns-arraystring)` jest configuration property. If need be, this can be extended in the following way:
6060

6161
```javascript
6262
process.env.TZ = 'UTC';
@@ -142,7 +142,7 @@ We need to update the `scripts` in the `package.json` to use the extended Webpac
142142

143143
### Configure grafana image to use when running docker
144144

145-
By default `grafana-enterprise` will be used as the docker image for all docker related commands. If you want to override this behaviour simply alter the `docker-compose.yaml` by adding the following build arg `grafana_image`.
145+
By default, `grafana-enterprise` will be used as the docker image for all docker related commands. If you want to override this behavior, simply alter the `docker-compose.yaml` by adding the following build arg `grafana_image`.
146146

147147
**Example:**
148148

@@ -159,6 +159,6 @@ services:
159159
grafana_image: ${GRAFANA_IMAGE:-grafana}
160160
```
161161
162-
In this example we are assigning the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will give you the possibility to set the value while running the docker-compose commands which might be convinent in some scenarios.
162+
In this example, we assign the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will allow you to set the value while running the docker-compose commands, which might be convenient in some scenarios.
163163

164164
---

.config/jest-setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
33
*
44
* In order to extend the configuration follow the steps in
5-
* https://grafana.github.io/plugin-tools/docs/advanced-configuration#extending-the-jest-config
5+
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-jest-config
66
*/
77

88
import '@testing-library/jest-dom';

.config/jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
33
*
44
* In order to extend the configuration follow the steps in
5-
* https://grafana.github.io/plugin-tools/docs/advanced-configuration#extending-the-jest-config
5+
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-jest-config
66
*/
77

88
const path = require('path');
@@ -25,7 +25,7 @@ module.exports = {
2525
'^.+\\.(t|j)sx?$': [
2626
'@swc/jest',
2727
{
28-
sourceMaps: true,
28+
sourceMaps: 'inline',
2929
jsc: {
3030
parser: {
3131
syntax: 'typescript',

.config/jest/utils.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@
88
* This utility function is useful in combination with jest `transformIgnorePatterns` config
99
* to transform specific packages (e.g.ES modules) in a projects node_modules folder.
1010
*/
11-
const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!(${moduleNames.join('|')})\/)`;
11+
const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`;
1212

1313
// Array of known nested grafana package dependencies that only bundle an ESM version
1414
const grafanaESModules = [
1515
'.pnpm', // Support using pnpm symlinked packages
16+
'@grafana/schema',
1617
'd3',
1718
'd3-color',
1819
'd3-force',
1920
'd3-interpolate',
2021
'd3-scale-chromatic',
2122
'ol',
2223
'react-colorful',
24+
'rxjs',
2325
'uuid',
2426
];
2527

2628
module.exports = {
2729
nodeModulesToTransform,
28-
grafanaESModules
29-
}
30+
grafanaESModules,
31+
};

.config/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
33
*
44
* In order to extend the configuration follow the steps in
5-
* https://grafana.github.io/plugin-tools/docs/advanced-configuration#extending-the-typescript-config
5+
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-typescript-config
66
*/
7-
{
7+
{
88
"compilerOptions": {
99
"alwaysStrict": true,
1010
"declaration": false,

.config/webpack/utils.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
import fs from 'fs';
2+
import process from 'process';
3+
import os from 'os';
24
import path from 'path';
3-
import util from 'util';
45
import { glob } from 'glob';
56
import { SOURCE_DIR } from './constants';
67

8+
export function isWSL() {
9+
if (process.platform !== 'linux') {
10+
return false;
11+
}
12+
13+
if (os.release().toLowerCase().includes('microsoft')) {
14+
return true;
15+
}
16+
17+
try {
18+
return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft');
19+
} catch {
20+
return false;
21+
}
22+
}
23+
724
export function getPackageJson() {
825
return require(path.resolve(process.cwd(), 'package.json'));
926
}
@@ -21,7 +38,8 @@ export function hasReadme() {
2138
export async function getEntries(): Promise<Record<string, string>> {
2239
const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true });
2340

24-
const plugins = await Promise.all(pluginsJson.map((pluginJson) => {
41+
const plugins = await Promise.all(
42+
pluginsJson.map((pluginJson) => {
2543
const folder = path.dirname(pluginJson);
2644
return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true });
2745
})

0 commit comments

Comments
 (0)