From 57a36c599d045d25daceebe7772def9a74ea3d1f Mon Sep 17 00:00:00 2001 From: Hugo Bollon Date: Fri, 3 Nov 2023 11:40:35 +0100 Subject: [PATCH] feat!: rewrite plugin using React plugin framework --- .config/.eslintrc | 25 + .config/.prettierrc.js | 16 + .config/Dockerfile | 16 + .config/README.md | 164 + .config/jest-setup.js | 25 + .config/jest.config.js | 43 + .config/jest/mocks/react-inlinesvg.tsx | 25 + .config/jest/utils.js | 31 + .config/tsconfig.json | 26 + .config/types/custom.d.ts | 37 + .config/webpack/constants.ts | 2 + .config/webpack/utils.ts | 58 + .config/webpack/webpack.config.ts | 213 + .eslintrc | 13 +- .github/workflows/build.yml | 92 +- .github/workflows/is-compatible.yml | 19 + .github/workflows/release-please.yml | 43 +- .github/workflows/release.yml | 131 + .gitignore | 64 +- .nvmrc | 1 + .prettierrc.js | 3 +- .yarnrc.yml | 1 + Makefile | 2 +- cypress.json | 3 + cypress/integration/01-smoke.spec.ts | 10 + docker-compose.yaml | 16 + img/overview.png | Bin 285523 -> 0 bytes img/singlestat-reduce.png | Bin 11553 -> 0 bytes img/singlestat-transform.png | Bin 33045 -> 0 bytes img/table.png | Bin 88803 -> 0 bytes jest-setup.js | 2 + jest.config.js | 14 +- openapi.yaml | 340 - package.json | 94 +- src/ConfigEditor.tsx | 21 - src/QueryEditor.tsx | 86 - src/README.md | 51 + src/components/ConfigEditor.tsx | 20 + src/components/QueryEditor.tsx | 63 + src/css/json-editor.css | 7 - src/{DataSource.ts => datasource.ts} | 34 +- src/format.ts | 4 - src/img/json-logo.svg | 26 - src/img/logo.svg | 97 + src/module.ts | 11 +- src/plugin.json | 19 +- src/types.ts | 9 +- tsconfig.json | 11 +- yarn.lock | 27559 ++++++++++++----------- 49 files changed, 15977 insertions(+), 13570 deletions(-) create mode 100644 .config/.eslintrc create mode 100644 .config/.prettierrc.js create mode 100644 .config/Dockerfile create mode 100644 .config/README.md create mode 100644 .config/jest-setup.js create mode 100644 .config/jest.config.js create mode 100644 .config/jest/mocks/react-inlinesvg.tsx create mode 100644 .config/jest/utils.js create mode 100644 .config/tsconfig.json create mode 100644 .config/types/custom.d.ts create mode 100644 .config/webpack/constants.ts create mode 100644 .config/webpack/utils.ts create mode 100644 .config/webpack/webpack.config.ts create mode 100644 .github/workflows/is-compatible.yml create mode 100644 .github/workflows/release.yml create mode 100644 .nvmrc create mode 100644 .yarnrc.yml create mode 100644 cypress.json create mode 100644 cypress/integration/01-smoke.spec.ts create mode 100644 docker-compose.yaml delete mode 100644 img/overview.png delete mode 100644 img/singlestat-reduce.png delete mode 100644 img/singlestat-transform.png delete mode 100644 img/table.png create mode 100644 jest-setup.js delete mode 100644 openapi.yaml delete mode 100644 src/ConfigEditor.tsx delete mode 100644 src/QueryEditor.tsx create mode 100644 src/README.md create mode 100644 src/components/ConfigEditor.tsx create mode 100644 src/components/QueryEditor.tsx delete mode 100644 src/css/json-editor.css rename src/{DataSource.ts => datasource.ts} (90%) delete mode 100644 src/format.ts delete mode 100644 src/img/json-logo.svg create mode 100644 src/img/logo.svg mode change 100755 => 100644 src/plugin.json diff --git a/.config/.eslintrc b/.config/.eslintrc new file mode 100644 index 0000000..1486ed2 --- /dev/null +++ b/.config/.eslintrc @@ -0,0 +1,25 @@ +/* + * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ + * + * In order to extend the configuration follow the steps in + * https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-eslint-config + */ +{ + "extends": ["@grafana/eslint-config"], + "root": true, + "rules": { + "react/prop-types": "off" + }, + "overrides": [ + { + "plugins": ["deprecation"], + "files": ["src/**/*.{ts,tsx}"], + "rules": { + "deprecation/deprecation": "warn" + }, + "parserOptions": { + "project": "./tsconfig.json" + } + } + ] +} diff --git a/.config/.prettierrc.js b/.config/.prettierrc.js new file mode 100644 index 0000000..bf506f5 --- /dev/null +++ b/.config/.prettierrc.js @@ -0,0 +1,16 @@ +/* + * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ + * + * In order to extend the configuration follow the steps in .config/README.md + */ + +module.exports = { + endOfLine: 'auto', + printWidth: 120, + trailingComma: 'es5', + semi: true, + jsxSingleQuote: false, + singleQuote: true, + useTabs: false, + tabWidth: 2, +}; diff --git a/.config/Dockerfile b/.config/Dockerfile new file mode 100644 index 0000000..35d89bd --- /dev/null +++ b/.config/Dockerfile @@ -0,0 +1,16 @@ +ARG grafana_version=latest +ARG grafana_image=grafana-enterprise + +FROM grafana/${grafana_image}:${grafana_version} + +# Make it as simple as possible to access the grafana instance for development purposes +# Do NOT enable these settings in a public facing / production grafana instance +ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin" +ENV GF_AUTH_ANONYMOUS_ENABLED "true" +ENV GF_AUTH_BASIC_ENABLED "false" +# Set development mode so plugins can be loaded without the need to sign +ENV GF_DEFAULT_APP_MODE "development" + +# Inject livereload script into grafana index.html +USER root +RUN sed -i 's/<\/body><\/html>/