diff --git a/packages/grafana-data/package.json b/packages/grafana-data/package.json index 8ee15ddbf8a..e861c37063e 100644 --- a/packages/grafana-data/package.json +++ b/packages/grafana-data/package.json @@ -23,6 +23,7 @@ }, "dependencies": { "@braintree/sanitize-url": "5.0.2", + "@grafana/schema": "8.1.0-pre", "@types/d3-interpolate": "^1.3.1", "date-fns": "2.21.3", "eventemitter3": "4.0.7", diff --git a/packages/grafana-data/rollup.config.ts b/packages/grafana-data/rollup.config.ts index 830f86c88b4..64c9c3c9457 100644 --- a/packages/grafana-data/rollup.config.ts +++ b/packages/grafana-data/rollup.config.ts @@ -21,7 +21,11 @@ const buildCjsPackage = ({ env }) => { globals: {}, }, ], - external: ['lodash', 'rxjs'], // Use Lodash, rxjs from grafana + external: [ + 'lodash', + 'rxjs', + '@grafana/schema', // Load from host + ], plugins: [ json({ include: ['../../node_modules/moment-timezone/data/packed/latest.json'], diff --git a/packages/grafana-runtime/rollup.config.ts b/packages/grafana-runtime/rollup.config.ts index e6b71219a0b..5fa32f856b1 100644 --- a/packages/grafana-runtime/rollup.config.ts +++ b/packages/grafana-runtime/rollup.config.ts @@ -20,7 +20,7 @@ const buildCjsPackage = ({ env }) => { globals: {}, }, ], - external: ['lodash', 'react', '@grafana/ui', '@grafana/data', '@grafana/e2e-selectors'], // Use Lodash from grafana + external: ['lodash', 'react', '@grafana/ui', '@grafana/data', '@grafana/schema', '@grafana/e2e-selectors'], // Use Lodash from grafana plugins: [ commonjs({ include: /node_modules/, diff --git a/packages/grafana-schema/.eslintrc b/packages/grafana-schema/.eslintrc new file mode 100644 index 00000000000..7a796b6e54f --- /dev/null +++ b/packages/grafana-schema/.eslintrc @@ -0,0 +1,13 @@ +{ + "rules": { + "no-restricted-imports": ["error", { "patterns": ["@grafana/*"] }] + }, + "overrides": [ + { + "files": ["**/*.test.{ts,tsx}"], + "rules": { + "no-restricted-imports": "off" + } + } + ] +} diff --git a/packages/grafana-schema/CHANGELOG.md b/packages/grafana-schema/CHANGELOG.md new file mode 100644 index 00000000000..d224b5b5cac --- /dev/null +++ b/packages/grafana-schema/CHANGELOG.md @@ -0,0 +1,3 @@ +# (2021-10) + +First public release diff --git a/packages/grafana-schema/LICENSE_APACHE2 b/packages/grafana-schema/LICENSE_APACHE2 new file mode 100644 index 00000000000..373dde574a0 --- /dev/null +++ b/packages/grafana-schema/LICENSE_APACHE2 @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2015 Grafana Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/grafana-schema/README.md b/packages/grafana-schema/README.md new file mode 100644 index 00000000000..5632a8e953d --- /dev/null +++ b/packages/grafana-schema/README.md @@ -0,0 +1,5 @@ +# Grafana Schema Library + +> **@grafana/schema is currently in ALPHA**. + +This package holds the definitions for objects that should be stored in JSON configuration files diff --git a/packages/grafana-schema/api-extractor.json b/packages/grafana-schema/api-extractor.json new file mode 100644 index 00000000000..5e96b3b0b3c --- /dev/null +++ b/packages/grafana-schema/api-extractor.json @@ -0,0 +1,3 @@ +{ + "extends": "../../api-extractor.json" +} diff --git a/packages/grafana-schema/index.js b/packages/grafana-schema/index.js new file mode 100644 index 00000000000..5d1c92525d2 --- /dev/null +++ b/packages/grafana-schema/index.js @@ -0,0 +1,7 @@ +'use strict'; + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./index.production.js'); +} else { + module.exports = require('./index.development.js'); +} diff --git a/packages/grafana-schema/package.json b/packages/grafana-schema/package.json new file mode 100644 index 00000000000..0c1dc9ee5c4 --- /dev/null +++ b/packages/grafana-schema/package.json @@ -0,0 +1,42 @@ +{ + "author": "Grafana Labs", + "license": "Apache-2.0", + "name": "@grafana/schema", + "version": "8.1.0-pre", + "description": "Grafana Schema Library", + "keywords": [ + "typescript" + ], + "repository": { + "type": "git", + "url": "http://github.com/grafana/grafana.git", + "directory": "packages/grafana-schema" + }, + "main": "src/index.ts", + "types": "src/index.ts", + "scripts": { + "build": "grafana-toolkit package:build --scope=schema", + "bundle": "rollup -c rollup.config.ts", + "clean": "rimraf ./dist ./compiled", + "docsExtract": "mkdir -p ../../reports/docs && api-extractor run 2>&1 | tee ../../reports/docs/$(basename $(pwd)).log", + "typecheck": "tsc --noEmit" + }, + "dependencies": {}, + "devDependencies": { + "@grafana/tsconfig": "^1.0.0-rc1", + "@rollup/plugin-commonjs": "16.0.0", + "@rollup/plugin-json": "4.1.0", + "@rollup/plugin-node-resolve": "10.0.0", + "@types/rollup-plugin-visualizer": "2.6.0", + "pretty-format": "25.1.0", + "rollup": "2.33.3", + "rollup-plugin-sourcemaps": "0.6.3", + "rollup-plugin-terser": "7.0.2", + "rollup-plugin-typescript2": "0.29.0", + "rollup-plugin-visualizer": "4.2.0", + "typescript": "4.3.4" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/packages/grafana-schema/rollup.config.ts b/packages/grafana-schema/rollup.config.ts new file mode 100644 index 00000000000..5342797fe32 --- /dev/null +++ b/packages/grafana-schema/rollup.config.ts @@ -0,0 +1,33 @@ +import resolve from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; +import sourceMaps from 'rollup-plugin-sourcemaps'; +import { terser } from 'rollup-plugin-terser'; + +const pkg = require('./package.json'); + +const libraryName = pkg.name; + +const buildCjsPackage = ({ env }) => { + return { + input: `compiled/index.js`, + output: [ + { + file: `dist/index.${env}.js`, + name: libraryName, + format: 'cjs', + sourcemap: true, + exports: 'named', + globals: {}, + }, + ], + plugins: [ + commonjs({ + include: /node_modules/, + }), + resolve(), + sourceMaps(), + env === 'production' && terser(), + ], + }; +}; +export default [buildCjsPackage({ env: 'development' }), buildCjsPackage({ env: 'production' })]; diff --git a/packages/grafana-schema/src/index.ts b/packages/grafana-schema/src/index.ts new file mode 100644 index 00000000000..1a5564433cc --- /dev/null +++ b/packages/grafana-schema/src/index.ts @@ -0,0 +1,8 @@ +/** + * A library containing most of the static shapes required by Grafana. + * + * @packageDocumentation + */ +export * from './schema/legend.gen'; +export * from './schema/tooltip.gen'; +export * from './schema/text.gen'; diff --git a/packages/grafana-schema/src/schema/legend.cue b/packages/grafana-schema/src/schema/legend.cue new file mode 100644 index 00000000000..577833607e8 --- /dev/null +++ b/packages/grafana-schema/src/schema/legend.cue @@ -0,0 +1,13 @@ + + +LegendPlacement: "bottom" | "right" @cuetsy(targetType="type") + +LegendDisplayMode: "list" | "table" | "hidden" @cuetsy(targetType="enum") + +VizLegendOptions: { + displayMode: LegendDisplayMode + placement: LegendPlacement + asTable: bool | *false + isVisible: bool | *false + calcs: [...string] +} @cuetsy(targetType="interface") diff --git a/packages/grafana-ui/src/components/VizLegend/models.gen.ts b/packages/grafana-schema/src/schema/legend.gen.ts similarity index 79% rename from packages/grafana-ui/src/components/VizLegend/models.gen.ts rename to packages/grafana-schema/src/schema/legend.gen.ts index c5de02889aa..4f80864c9f3 100644 --- a/packages/grafana-ui/src/components/VizLegend/models.gen.ts +++ b/packages/grafana-schema/src/schema/legend.gen.ts @@ -3,14 +3,32 @@ // It is currenty hand written but will serve as the target for cuetsy //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +/** + * @public + */ export type LegendPlacement = 'bottom' | 'right'; + +/** + * @public + */ export enum LegendDisplayMode { Hidden = 'hidden', List = 'list', Table = 'table', } + +/** + * @public + */ export interface VizLegendOptions { calcs: string[]; displayMode: LegendDisplayMode; placement: LegendPlacement; } + +/** + * @public + */ +export interface OptionsWithLegend { + legend: VizLegendOptions; +} diff --git a/packages/grafana-schema/src/schema/text.cue b/packages/grafana-schema/src/schema/text.cue new file mode 100644 index 00000000000..18a35db70f6 --- /dev/null +++ b/packages/grafana-schema/src/schema/text.cue @@ -0,0 +1,7 @@ + +VizTextDisplayOptions: { + // Explicit title text size + titleSize?: number + // Explicit value text size + valueSize?: number +} @cuetsy(targetType="interface") diff --git a/packages/grafana-ui/src/options/models.gen.ts b/packages/grafana-schema/src/schema/text.gen.ts similarity index 52% rename from packages/grafana-ui/src/options/models.gen.ts rename to packages/grafana-schema/src/schema/text.gen.ts index 5fbfb5241d8..7c7671a9920 100644 --- a/packages/grafana-ui/src/options/models.gen.ts +++ b/packages/grafana-schema/src/schema/text.gen.ts @@ -1,5 +1,7 @@ -// TODO: this should be generated with cue -import { VizLegendOptions, VizTooltipOptions } from '../components'; +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// NOTE: This file will be auto generated from models.cue +// It is currenty hand written but will serve as the target for cuetsy +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Explicit control for visualization text settings @@ -12,20 +14,6 @@ export interface VizTextDisplayOptions { valueSize?: number; } -/** - * @public - */ -export interface OptionsWithLegend { - legend: VizLegendOptions; -} - -/** - * @public - */ -export interface OptionsWithTooltip { - tooltip: VizTooltipOptions; -} - /** * @public */ diff --git a/packages/grafana-schema/src/schema/tooltip.cue b/packages/grafana-schema/src/schema/tooltip.cue new file mode 100644 index 00000000000..2578e7fe44c --- /dev/null +++ b/packages/grafana-schema/src/schema/tooltip.cue @@ -0,0 +1,5 @@ +TooltipDisplayMode: "single" | "multi" | "none" @cuetsy(targetType="enum") + +VizTooltipOptions: { + mode: TooltipDisplayMode +} @cuetsy(targetType="interface") \ No newline at end of file diff --git a/packages/grafana-ui/src/components/VizTooltip/models.gen.ts b/packages/grafana-schema/src/schema/tooltip.gen.ts similarity index 84% rename from packages/grafana-ui/src/components/VizTooltip/models.gen.ts rename to packages/grafana-schema/src/schema/tooltip.gen.ts index 4efedeea71a..11f396de538 100644 --- a/packages/grafana-ui/src/components/VizTooltip/models.gen.ts +++ b/packages/grafana-schema/src/schema/tooltip.gen.ts @@ -18,3 +18,10 @@ export enum TooltipDisplayMode { export type VizTooltipOptions = { mode: TooltipDisplayMode; }; + +/** + * @public + */ +export interface OptionsWithTooltip { + tooltip: VizTooltipOptions; +} diff --git a/packages/grafana-schema/tsconfig.build.json b/packages/grafana-schema/tsconfig.build.json new file mode 100644 index 00000000000..9ec189c28ea --- /dev/null +++ b/packages/grafana-schema/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "exclude": ["dist", "node_modules", "**/*.test.ts*"], + "extends": "./tsconfig.json" +} diff --git a/packages/grafana-schema/tsconfig.json b/packages/grafana-schema/tsconfig.json new file mode 100644 index 00000000000..7bad1e46a47 --- /dev/null +++ b/packages/grafana-schema/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "declarationDir": "dist", + "outDir": "compiled", + "rootDirs": ["."] + }, + "exclude": ["dist", "node_modules"], + "extends": "@grafana/tsconfig", + "include": ["src/**/*.ts*"] +} diff --git a/packages/grafana-ui/package.json b/packages/grafana-ui/package.json index c34dfd3e1c7..de115c4becb 100644 --- a/packages/grafana-ui/package.json +++ b/packages/grafana-ui/package.json @@ -29,6 +29,7 @@ "@emotion/css": "11.1.3", "@emotion/react": "11.1.5", "@grafana/aws-sdk": "0.0.3", + "@grafana/schema": "8.1.0-pre", "@grafana/data": "8.1.0-pre", "@grafana/e2e-selectors": "8.1.0-pre", "@grafana/slate-react": "0.22.10-grafana", diff --git a/packages/grafana-ui/rollup.config.ts b/packages/grafana-ui/rollup.config.ts index b36ce5677cb..b74ff22e2cb 100644 --- a/packages/grafana-ui/rollup.config.ts +++ b/packages/grafana-ui/rollup.config.ts @@ -30,6 +30,7 @@ const buildCjsPackage = ({ env }) => { 'react-dom', '@grafana/aws-sdk', '@grafana/data', + '@grafana/schema', '@grafana/e2e-selectors', 'moment', 'jquery', // required to use jquery.plot, which is assigned externally diff --git a/packages/grafana-ui/src/components/Graph/Graph.story.internal.tsx b/packages/grafana-ui/src/components/Graph/Graph.story.internal.tsx index e90a6cc7ee5..08b1451d6c1 100644 --- a/packages/grafana-ui/src/components/Graph/Graph.story.internal.tsx +++ b/packages/grafana-ui/src/components/Graph/Graph.story.internal.tsx @@ -1,9 +1,10 @@ import React from 'react'; +import { TooltipDisplayMode } from '@grafana/schema'; import { dateTime, ArrayVector, FieldType, GraphSeriesXY, FieldColorModeId, getDisplayProcessor } from '@grafana/data'; import { Story } from '@storybook/react'; import { useTheme2 } from '../../themes'; import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; -import { VizTooltip, TooltipDisplayMode, VizTooltipContentProps } from '../VizTooltip'; +import { VizTooltip, VizTooltipContentProps } from '../VizTooltip'; import { JSONFormatter } from '../JSONFormatter/JSONFormatter'; import { GraphProps, Graph } from './Graph'; diff --git a/packages/grafana-ui/src/components/Graph/Graph.test.tsx b/packages/grafana-ui/src/components/Graph/Graph.test.tsx index 2f73d620567..68dcd1a3669 100644 --- a/packages/grafana-ui/src/components/Graph/Graph.test.tsx +++ b/packages/grafana-ui/src/components/Graph/Graph.test.tsx @@ -1,7 +1,8 @@ import React from 'react'; import { mount } from 'enzyme'; import Graph from './Graph'; -import { VizTooltip, TooltipDisplayMode } from '../VizTooltip'; +import { TooltipDisplayMode } from '@grafana/schema'; +import { VizTooltip } from '../VizTooltip'; import { GraphSeriesXY, FieldType, ArrayVector, dateTime, FieldColorModeId, DisplayProcessor } from '@grafana/data'; const display: DisplayProcessor = (v) => ({ numeric: v, text: String(v), color: 'red' }); diff --git a/packages/grafana-ui/src/components/Graph/Graph.tsx b/packages/grafana-ui/src/components/Graph/Graph.tsx index 05fde09f654..9ab60ab6b61 100644 --- a/packages/grafana-ui/src/components/Graph/Graph.tsx +++ b/packages/grafana-ui/src/components/Graph/Graph.tsx @@ -3,6 +3,7 @@ import $ from 'jquery'; import React, { PureComponent } from 'react'; import { uniqBy } from 'lodash'; // Types +import { TooltipDisplayMode } from '@grafana/schema'; import { TimeRange, GraphSeriesXY, TimeZone, createDimension } from '@grafana/data'; import { FlotPosition, FlotItem } from './types'; import { VizTooltipProps, VizTooltipContentProps, ActiveDimensions, VizTooltip } from '../VizTooltip'; @@ -10,7 +11,6 @@ import { GraphTooltip } from './GraphTooltip/GraphTooltip'; import { GraphContextMenu, GraphContextMenuProps, ContextDimensions } from './GraphContextMenu'; import { GraphDimensions } from './GraphTooltip/types'; import { graphTimeFormat, graphTickFormatter } from './utils'; -import { TooltipDisplayMode } from '../VizTooltip/models.gen'; export interface GraphProps { ariaLabel?: string; diff --git a/packages/grafana-ui/src/components/Graph/GraphWithLegend.story.internal.tsx b/packages/grafana-ui/src/components/Graph/GraphWithLegend.story.internal.tsx index 57f91a7c9ca..03748655594 100644 --- a/packages/grafana-ui/src/components/Graph/GraphWithLegend.story.internal.tsx +++ b/packages/grafana-ui/src/components/Graph/GraphWithLegend.story.internal.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { Story } from '@storybook/react'; import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; import { GraphWithLegend, GraphWithLegendProps } from './GraphWithLegend'; -import { LegendDisplayMode } from '../VizLegend/models.gen'; +import { LegendDisplayMode } from '@grafana/schema'; import { GraphSeriesXY, FieldType, ArrayVector, dateTime, FieldColorModeId } from '@grafana/data'; export default { diff --git a/packages/grafana-ui/src/components/Graph/GraphWithLegend.tsx b/packages/grafana-ui/src/components/Graph/GraphWithLegend.tsx index 4527541c104..f65a981fbfa 100644 --- a/packages/grafana-ui/src/components/Graph/GraphWithLegend.tsx +++ b/packages/grafana-ui/src/components/Graph/GraphWithLegend.tsx @@ -6,7 +6,7 @@ import { GraphSeriesValue } from '@grafana/data'; import { Graph, GraphProps } from './Graph'; import { VizLegendItem } from '../VizLegend/types'; -import { LegendDisplayMode, LegendPlacement } from '../VizLegend/models.gen'; +import { LegendDisplayMode, LegendPlacement } from '@grafana/schema'; import { VizLegend } from '../VizLegend/VizLegend'; import { CustomScrollbar } from '../CustomScrollbar/CustomScrollbar'; import { stylesFactory } from '../../themes'; diff --git a/packages/grafana-ui/src/components/GraphNG/GraphNG.story.internal.tsx b/packages/grafana-ui/src/components/GraphNG/GraphNG.story.internal.tsx index 3ca1cdbc5e7..ae37418ac46 100644 --- a/packages/grafana-ui/src/components/GraphNG/GraphNG.story.internal.tsx +++ b/packages/grafana-ui/src/components/GraphNG/GraphNG.story.internal.tsx @@ -2,7 +2,7 @@ import { FieldColorModeId, toDataFrame, dateTime } from '@grafana/data'; import React from 'react'; import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; import { GraphNGProps } from './GraphNG'; -import { LegendDisplayMode, LegendPlacement } from '../VizLegend/models.gen'; +import { LegendDisplayMode, LegendPlacement } from '@grafana/schema'; import { prepDataForStorybook } from '../../utils/storybook/data'; import { useTheme2 } from '../../themes'; import { Story } from '@storybook/react'; diff --git a/packages/grafana-ui/src/components/GraphNG/GraphNG.tsx b/packages/grafana-ui/src/components/GraphNG/GraphNG.tsx index 4fd09cd2387..f2f33232daa 100755 --- a/packages/grafana-ui/src/components/GraphNG/GraphNG.tsx +++ b/packages/grafana-ui/src/components/GraphNG/GraphNG.tsx @@ -13,7 +13,7 @@ import { } from '@grafana/data'; import { preparePlotFrame as defaultPreparePlotFrame } from './utils'; -import { VizLegendOptions } from '../VizLegend/models.gen'; +import { VizLegendOptions } from '@grafana/schema'; import { PanelContext, PanelContextRoot } from '../PanelChrome/PanelContext'; import { Subscription } from 'rxjs'; import { throttleTime } from 'rxjs/operators'; diff --git a/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts b/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts index 4ef51e62b29..c884ac1b7f9 100644 --- a/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts +++ b/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts @@ -1,5 +1,6 @@ import { cloneDeep, isNumber, omit } from 'lodash'; +import { OptionsWithTextFormatting } from '@grafana/schema'; import { convertOldAngularValueMappings, FieldColorModeId, @@ -16,7 +17,6 @@ import { ValueMapping, VizOrientation, } from '@grafana/data'; -import { OptionsWithTextFormatting } from '../../options'; export interface SingleStatBaseOptions extends OptionsWithTextFormatting { reduceOptions: ReduceDataOptions; diff --git a/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx b/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx index 9285f6db117..26fdd92a032 100644 --- a/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx +++ b/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx @@ -3,7 +3,7 @@ import { DataFrame, TimeRange } from '@grafana/data'; import { GraphNG, GraphNGProps } from '../GraphNG/GraphNG'; import { UPlotConfigBuilder } from '../uPlot/config/UPlotConfigBuilder'; import { PlotLegend } from '../uPlot/PlotLegend'; -import { LegendDisplayMode } from '../VizLegend/models.gen'; +import { LegendDisplayMode } from '@grafana/schema'; import { preparePlotConfigBuilder } from './utils'; import { withTheme2 } from '../../themes/ThemeContext'; import { PanelContext, PanelContextRoot } from '../PanelChrome/PanelContext'; diff --git a/packages/grafana-ui/src/components/VizLayout/VizLayout.tsx b/packages/grafana-ui/src/components/VizLayout/VizLayout.tsx index 9cd2b6a9ebc..d171e0889ad 100644 --- a/packages/grafana-ui/src/components/VizLayout/VizLayout.tsx +++ b/packages/grafana-ui/src/components/VizLayout/VizLayout.tsx @@ -1,7 +1,7 @@ import React, { FC, CSSProperties, ComponentType } from 'react'; import { useMeasure } from 'react-use'; import { CustomScrollbar } from '../CustomScrollbar/CustomScrollbar'; -import { LegendPlacement } from '..'; +import { LegendPlacement } from '@grafana/schema'; /** * @beta diff --git a/packages/grafana-ui/src/components/VizLegend/VizLegend.story.tsx b/packages/grafana-ui/src/components/VizLegend/VizLegend.story.tsx index 53f4d5354c5..b9bc1a66037 100644 --- a/packages/grafana-ui/src/components/VizLegend/VizLegend.story.tsx +++ b/packages/grafana-ui/src/components/VizLegend/VizLegend.story.tsx @@ -5,7 +5,7 @@ import {} from './VizLegendListItem'; import { DisplayValue, getColorForTheme, GrafanaTheme } from '@grafana/data'; import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; import { VizLegendItem } from './types'; -import { LegendDisplayMode, LegendPlacement } from './models.gen'; +import { LegendDisplayMode, LegendPlacement } from '@grafana/schema'; export default { title: 'Visualizations/VizLegend', diff --git a/packages/grafana-ui/src/components/VizLegend/VizLegend.tsx b/packages/grafana-ui/src/components/VizLegend/VizLegend.tsx index d1cffb0fc43..e034f85f37d 100644 --- a/packages/grafana-ui/src/components/VizLegend/VizLegend.tsx +++ b/packages/grafana-ui/src/components/VizLegend/VizLegend.tsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import { LegendProps, SeriesVisibilityChangeBehavior, VizLegendItem } from './types'; -import { LegendDisplayMode } from './models.gen'; +import { LegendDisplayMode } from '@grafana/schema'; import { VizLegendTable } from './VizLegendTable'; import { VizLegendList } from './VizLegendList'; import { DataHoverClearEvent, DataHoverEvent } from '@grafana/data'; diff --git a/packages/grafana-ui/src/components/VizLegend/models.cue b/packages/grafana-ui/src/components/VizLegend/models.cue deleted file mode 100644 index 8c3780d66ba..00000000000 --- a/packages/grafana-ui/src/components/VizLegend/models.cue +++ /dev/null @@ -1,15 +0,0 @@ -package grafanaschema - -LegendPlacement: "bottom" | "right" @cuetsy(targetType="type") -LegendDisplayMode: "list" | "table" | "hidden" @cuetsy(targetType="enum") - -VizLegendOptions: { - displayMode: LegendDisplayMode - placement: LegendPlacement - asTable: bool | *false - isVisible: bool | *false - calcs: [...string] - -} @cuetsy(targetType="interface") - -// TODO this excludes all the types that include function definitions \ No newline at end of file diff --git a/packages/grafana-ui/src/components/VizLegend/types.ts b/packages/grafana-ui/src/components/VizLegend/types.ts index 9f51d61cad7..23b1596a388 100644 --- a/packages/grafana-ui/src/components/VizLegend/types.ts +++ b/packages/grafana-ui/src/components/VizLegend/types.ts @@ -1,6 +1,7 @@ -import { DataFrameFieldIndex, DisplayValue } from '@grafana/data'; import React from 'react'; -import { LegendDisplayMode, LegendPlacement } from './models.gen'; + +import { DataFrameFieldIndex, DisplayValue } from '@grafana/data'; +import { LegendDisplayMode, LegendPlacement } from '@grafana/schema'; export enum SeriesVisibilityChangeBehavior { Isolate, diff --git a/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx b/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx index c5324bfa8aa..ffcc3de94fc 100644 --- a/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx +++ b/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx @@ -5,7 +5,7 @@ import { Dimensions, TimeZone } from '@grafana/data'; import { FlotPosition } from '../Graph/types'; import { VizTooltipContainer } from './VizTooltipContainer'; import { useStyles } from '../../themes'; -import { TooltipDisplayMode } from './models.gen'; +import { TooltipDisplayMode } from '@grafana/schema'; // Describes active dimensions user interacts with // It's a key-value pair where: diff --git a/packages/grafana-ui/src/components/VizTooltip/index.tsx b/packages/grafana-ui/src/components/VizTooltip/index.tsx index fcdd3363b83..e63d1b84131 100644 --- a/packages/grafana-ui/src/components/VizTooltip/index.tsx +++ b/packages/grafana-ui/src/components/VizTooltip/index.tsx @@ -1,4 +1,3 @@ export { VizTooltip, VizTooltipContentProps, VizTooltipProps, ActiveDimensions } from './VizTooltip'; export { VizTooltipContainer, VizTooltipContainerProps } from './VizTooltipContainer'; export { SeriesTable, SeriesTableRow, SeriesTableProps, SeriesTableRowProps } from './SeriesTable'; -export { TooltipDisplayMode, VizTooltipOptions } from './models.gen'; diff --git a/packages/grafana-ui/src/components/VizTooltip/models.cue b/packages/grafana-ui/src/components/VizTooltip/models.cue deleted file mode 100644 index ea157eb78aa..00000000000 --- a/packages/grafana-ui/src/components/VizTooltip/models.cue +++ /dev/null @@ -1,7 +0,0 @@ -package grafanaschema - -TooltipDisplayMode: "single" | "multi" | "none" @cuetsy(targetType="enum") - -VizTooltipOptions: { - mode: TooltipDisplayMode -} @cuetsy(targetType="interface") \ No newline at end of file diff --git a/packages/grafana-ui/src/components/index.ts b/packages/grafana-ui/src/components/index.ts index 3c7458379a0..67c9dfe4937 100644 --- a/packages/grafana-ui/src/components/index.ts +++ b/packages/grafana-ui/src/components/index.ts @@ -81,8 +81,6 @@ export { VizTooltip, VizTooltipContainer, SeriesTable, - VizTooltipOptions, - TooltipDisplayMode, SeriesTableProps, SeriesTableRow, SeriesTableRowProps, @@ -105,7 +103,6 @@ export { } from './PanelChrome'; export { VizLayout, VizLayoutComponentType, VizLayoutLegendProps, VizLayoutProps } from './VizLayout/VizLayout'; export { VizLegendItem, SeriesVisibilityChangeBehavior } from './VizLegend/types'; -export { LegendPlacement, LegendDisplayMode, VizLegendOptions } from './VizLegend/models.gen'; export { VizLegend } from './VizLegend/VizLegend'; export { VizLegendListItem } from './VizLegend/VizLegendListItem'; diff --git a/packages/grafana-ui/src/components/uPlot/PlotLegend.tsx b/packages/grafana-ui/src/components/uPlot/PlotLegend.tsx index bc109700961..ab77a7010f0 100644 --- a/packages/grafana-ui/src/components/uPlot/PlotLegend.tsx +++ b/packages/grafana-ui/src/components/uPlot/PlotLegend.tsx @@ -9,7 +9,7 @@ import { } from '@grafana/data'; import { UPlotConfigBuilder } from './config/UPlotConfigBuilder'; import { VizLegendItem } from '../VizLegend/types'; -import { VizLegendOptions } from '../VizLegend/models.gen'; +import { VizLegendOptions } from '@grafana/schema'; import { AxisPlacement } from './config'; import { VizLayout, VizLayoutLegendProps } from '../VizLayout/VizLayout'; import { VizLegend } from '../VizLegend/VizLegend'; diff --git a/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx b/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx index 4fac7b28959..5fe92461307 100644 --- a/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx +++ b/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useLayoutEffect, useState } from 'react'; import { Portal } from '../../Portal/Portal'; import { usePlotContext } from '../context'; +import { TooltipDisplayMode } from '@grafana/schema'; import { CartesianCoords2D, DashboardCursorSync, @@ -12,7 +13,7 @@ import { getFieldDisplayName, TimeZone, } from '@grafana/data'; -import { SeriesTable, SeriesTableRowProps, TooltipDisplayMode, VizTooltipContainer } from '../../VizTooltip'; +import { SeriesTable, SeriesTableRowProps, VizTooltipContainer } from '../../VizTooltip'; import { UPlotConfigBuilder } from '../config/UPlotConfigBuilder'; import { findMidPointYPosition, pluginLog } from '../utils'; import { useTheme2 } from '../../../themes/ThemeContext'; diff --git a/packages/grafana-ui/src/options/builder/legend.tsx b/packages/grafana-ui/src/options/builder/legend.tsx index fa88c5958db..c7cad82c20b 100644 --- a/packages/grafana-ui/src/options/builder/legend.tsx +++ b/packages/grafana-ui/src/options/builder/legend.tsx @@ -1,6 +1,5 @@ import { PanelOptionsEditorBuilder, standardEditorsRegistry, StatsPickerConfigSettings } from '@grafana/data'; -import { LegendDisplayMode } from '../../index'; -import { OptionsWithLegend } from '../models.gen'; +import { LegendDisplayMode, OptionsWithLegend } from '@grafana/schema'; /** * @alpha diff --git a/packages/grafana-ui/src/options/builder/text.tsx b/packages/grafana-ui/src/options/builder/text.tsx index 2523d45a6a6..fe7243bba2f 100644 --- a/packages/grafana-ui/src/options/builder/text.tsx +++ b/packages/grafana-ui/src/options/builder/text.tsx @@ -1,4 +1,4 @@ -import { OptionsWithTextFormatting } from '../models.gen'; +import { OptionsWithTextFormatting } from '@grafana/schema'; import { PanelOptionsEditorBuilder } from '@grafana/data'; /** diff --git a/packages/grafana-ui/src/options/builder/tooltip.tsx b/packages/grafana-ui/src/options/builder/tooltip.tsx index a5656da603c..db8554e1b34 100644 --- a/packages/grafana-ui/src/options/builder/tooltip.tsx +++ b/packages/grafana-ui/src/options/builder/tooltip.tsx @@ -1,4 +1,4 @@ -import { OptionsWithTooltip } from '../models.gen'; +import { OptionsWithTooltip } from '@grafana/schema'; import { PanelOptionsEditorBuilder } from '@grafana/data'; export function addTooltipOptions( diff --git a/packages/grafana-ui/src/options/index.ts b/packages/grafana-ui/src/options/index.ts index 9aa58e65759..444fcc34c54 100644 --- a/packages/grafana-ui/src/options/index.ts +++ b/packages/grafana-ui/src/options/index.ts @@ -1,5 +1,3 @@ // namespace is too big import * as commonOptionsBuilder from './builder'; export { commonOptionsBuilder }; - -export * from './models.gen'; diff --git a/packages/grafana-ui/tsconfig.json b/packages/grafana-ui/tsconfig.json index bbff3e2b9ca..4cf13343c7f 100644 --- a/packages/grafana-ui/tsconfig.json +++ b/packages/grafana-ui/tsconfig.json @@ -12,5 +12,5 @@ }, "exclude": ["dist", "node_modules"], "extends": "@grafana/tsconfig", - "include": ["src/**/*.ts*", "../../public/app/types/*.d.ts"] + "include": ["src/**/*.ts*", "../../public/app/types/*.d.ts", "../grafana-schema/src/schema/models.gen.ts"] } diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index c9a818cbca3..10291d19b5e 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -6,7 +6,8 @@ import { connect, ConnectedProps } from 'react-redux'; import AutoSizer from 'react-virtualized-auto-sizer'; import memoizeOne from 'memoize-one'; import { selectors } from '@grafana/e2e-selectors'; -import { ErrorBoundaryAlert, CustomScrollbar, Collapse, TooltipDisplayMode, withTheme2, Themeable2 } from '@grafana/ui'; +import { TooltipDisplayMode } from '@grafana/schema'; +import { ErrorBoundaryAlert, CustomScrollbar, Collapse, withTheme2, Themeable2 } from '@grafana/ui'; import { AbsoluteTimeRange, DataQuery, LoadingState, RawTimeRange, DataFrame, GrafanaTheme2 } from '@grafana/data'; import LogsContainer from './LogsContainer'; diff --git a/public/app/features/explore/ExploreGraphNGPanel.tsx b/public/app/features/explore/ExploreGraphNGPanel.tsx index d32a6348754..412f29d8e2c 100644 --- a/public/app/features/explore/ExploreGraphNGPanel.tsx +++ b/public/app/features/explore/ExploreGraphNGPanel.tsx @@ -16,17 +16,16 @@ import { import { DrawStyle, Icon, - LegendDisplayMode, PanelContext, PanelContextProvider, SeriesVisibilityChangeMode, TimeSeries, - TooltipDisplayMode, TooltipPlugin, useStyles2, useTheme2, ZoomPlugin, } from '@grafana/ui'; +import { LegendDisplayMode, TooltipDisplayMode } from '@grafana/schema'; import { defaultGraphConfig, getGraphFieldConfig } from 'app/plugins/panel/timeseries/config'; import { ContextMenuPlugin } from 'app/plugins/panel/timeseries/plugins/ContextMenuPlugin'; import { ExemplarsPlugin } from 'app/plugins/panel/timeseries/plugins/ExemplarsPlugin'; diff --git a/public/app/features/explore/Logs.tsx b/public/app/features/explore/Logs.tsx index dd4e4874896..bef95cd5183 100644 --- a/public/app/features/explore/Logs.tsx +++ b/public/app/features/explore/Logs.tsx @@ -2,7 +2,7 @@ import React, { PureComponent, createRef } from 'react'; import { css } from '@emotion/css'; import { capitalize } from 'lodash'; import memoizeOne from 'memoize-one'; - +import { TooltipDisplayMode } from '@grafana/schema'; import { rangeUtil, RawTimeRange, @@ -28,7 +28,6 @@ import { InlineFieldRow, InlineSwitch, withTheme2, - TooltipDisplayMode, Themeable2, } from '@grafana/ui'; import store from 'app/core/store'; diff --git a/public/app/features/explore/flotgraph/types.ts b/public/app/features/explore/flotgraph/types.ts index 568697270a4..59671e72581 100644 --- a/public/app/features/explore/flotgraph/types.ts +++ b/public/app/features/explore/flotgraph/types.ts @@ -1,4 +1,4 @@ -import { VizTooltipOptions, TooltipDisplayMode, LegendDisplayMode, LegendPlacement } from '@grafana/ui'; +import { VizTooltipOptions, TooltipDisplayMode, LegendDisplayMode, LegendPlacement } from '@grafana/schema'; import { YAxis } from '@grafana/data'; export interface SeriesOptions { diff --git a/public/app/features/sandbox/TestStuffPage.tsx b/public/app/features/sandbox/TestStuffPage.tsx index bc2d9d7c7fe..6f17f924e0f 100644 --- a/public/app/features/sandbox/TestStuffPage.tsx +++ b/public/app/features/sandbox/TestStuffPage.tsx @@ -1,3 +1,4 @@ +import { LegendDisplayMode } from '@grafana/schema'; import { ApplyFieldOverrideOptions, DataTransformerConfig, @@ -6,7 +7,7 @@ import { NavModelItem, PanelData, } from '@grafana/data'; -import { LegendDisplayMode, Table, TimeSeries } from '@grafana/ui'; +import { Table, TimeSeries } from '@grafana/ui'; import { config } from 'app/core/config'; import React, { FC, useMemo, useState } from 'react'; import { useObservable } from 'react-use'; diff --git a/public/app/plugins/panel/barchart/BarChart.tsx b/public/app/plugins/panel/barchart/BarChart.tsx index 95fe6332cf6..4cd8e3d2f0c 100644 --- a/public/app/plugins/panel/barchart/BarChart.tsx +++ b/public/app/plugins/panel/barchart/BarChart.tsx @@ -1,15 +1,8 @@ import React from 'react'; import { cloneDeep } from 'lodash'; import { DataFrame, TimeRange } from '@grafana/data'; -import { - GraphNG, - GraphNGProps, - LegendDisplayMode, - PlotLegend, - UPlotConfigBuilder, - usePanelContext, - useTheme2, -} from '@grafana/ui'; +import { GraphNG, GraphNGProps, PlotLegend, UPlotConfigBuilder, usePanelContext, useTheme2 } from '@grafana/ui'; +import { LegendDisplayMode } from '@grafana/schema'; import { BarChartOptions } from './types'; import { preparePlotConfigBuilder, preparePlotFrame } from './utils'; import { PropDiffFn } from '../../../../../packages/grafana-ui/src/components/GraphNG/GraphNG'; diff --git a/public/app/plugins/panel/barchart/BarChartPanel.tsx b/public/app/plugins/panel/barchart/BarChartPanel.tsx index 09cf1159fbc..41541603810 100755 --- a/public/app/plugins/panel/barchart/BarChartPanel.tsx +++ b/public/app/plugins/panel/barchart/BarChartPanel.tsx @@ -1,6 +1,7 @@ import React, { useMemo } from 'react'; +import { TooltipDisplayMode } from '@grafana/schema'; import { PanelProps, TimeRange, VizOrientation } from '@grafana/data'; -import { StackingMode, TooltipDisplayMode, TooltipPlugin, useTheme2 } from '@grafana/ui'; +import { StackingMode, TooltipPlugin, useTheme2 } from '@grafana/ui'; import { BarChartOptions } from './types'; import { BarChart } from './BarChart'; import { prepareGraphableFrames } from './utils'; diff --git a/public/app/plugins/panel/barchart/bars.ts b/public/app/plugins/panel/barchart/bars.ts index 813b1298d68..11e0732ea42 100644 --- a/public/app/plugins/panel/barchart/bars.ts +++ b/public/app/plugins/panel/barchart/bars.ts @@ -2,10 +2,10 @@ import uPlot, { Axis, AlignedData } from 'uplot'; import { pointWithin, Quadtree, Rect } from './quadtree'; import { distribute, SPACE_BETWEEN } from './distribute'; import { DataFrame, GrafanaTheme2 } from '@grafana/data'; +import { VizTextDisplayOptions } from '@grafana/schema'; import { calculateFontSize, PlotTooltipInterpolator, - VizTextDisplayOptions, StackingMode, BarValueVisibility, ScaleDirection, diff --git a/public/app/plugins/panel/barchart/types.ts b/public/app/plugins/panel/barchart/types.ts index 95f7216e41b..66aa1b26c54 100644 --- a/public/app/plugins/panel/barchart/types.ts +++ b/public/app/plugins/panel/barchart/types.ts @@ -1,14 +1,6 @@ +import { OptionsWithLegend, OptionsWithTextFormatting, OptionsWithTooltip } from '@grafana/schema'; import { VizOrientation } from '@grafana/data'; -import { - AxisConfig, - BarValueVisibility, - GraphGradientMode, - HideableFieldConfig, - OptionsWithLegend, - OptionsWithTextFormatting, - OptionsWithTooltip, - StackingMode, -} from '@grafana/ui'; +import { AxisConfig, BarValueVisibility, GraphGradientMode, HideableFieldConfig, StackingMode } from '@grafana/ui'; /** * @alpha diff --git a/public/app/plugins/panel/barchart/utils.test.ts b/public/app/plugins/panel/barchart/utils.test.ts index 3309e0bd767..6c3330dee45 100644 --- a/public/app/plugins/panel/barchart/utils.test.ts +++ b/public/app/plugins/panel/barchart/utils.test.ts @@ -1,4 +1,5 @@ import { prepareGraphableFrames, preparePlotConfigBuilder, preparePlotFrame } from './utils'; +import { LegendDisplayMode, TooltipDisplayMode } from '@grafana/schema'; import { createTheme, DefaultTimeZone, @@ -10,13 +11,7 @@ import { VizOrientation, } from '@grafana/data'; import { BarChartFieldConfig, BarChartOptions } from './types'; -import { - BarValueVisibility, - GraphGradientMode, - LegendDisplayMode, - StackingMode, - TooltipDisplayMode, -} from '@grafana/ui'; +import { BarValueVisibility, GraphGradientMode, StackingMode } from '@grafana/ui'; function mockDataFrame() { const df1 = new MutableDataFrame({ diff --git a/public/app/plugins/panel/histogram/Histogram.tsx b/public/app/plugins/panel/histogram/Histogram.tsx index 47690571789..dbe08ac5216 100644 --- a/public/app/plugins/panel/histogram/Histogram.tsx +++ b/public/app/plugins/panel/histogram/Histogram.tsx @@ -1,5 +1,6 @@ import React from 'react'; import uPlot, { AlignedData } from 'uplot'; +import { VizLegendOptions, LegendDisplayMode } from '@grafana/schema'; import { DataFrame, formattedValueToString, @@ -10,13 +11,11 @@ import { import { Themeable2, UPlotConfigBuilder, - VizLegendOptions, UPlotChart, VizLayout, AxisPlacement, ScaleDirection, ScaleOrientation, - LegendDisplayMode, PlotLegend, } from '@grafana/ui'; diff --git a/public/app/plugins/panel/histogram/models.gen.ts b/public/app/plugins/panel/histogram/models.gen.ts index 5bb4ecc6870..4cc57e51978 100644 --- a/public/app/plugins/panel/histogram/models.gen.ts +++ b/public/app/plugins/panel/histogram/models.gen.ts @@ -3,14 +3,8 @@ // It is currenty hand written but will serve as the target for cuetsy //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -import { - GraphGradientMode, - HideableFieldConfig, - LegendDisplayMode, - OptionsWithLegend, - OptionsWithTooltip, - TooltipDisplayMode, -} from '@grafana/ui'; +import { LegendDisplayMode, OptionsWithLegend, OptionsWithTooltip, TooltipDisplayMode } from '@grafana/schema'; +import { GraphGradientMode, HideableFieldConfig } from '@grafana/ui'; export const modelVersion = Object.freeze([1, 0]); diff --git a/public/app/plugins/panel/nodeGraph/Legend.tsx b/public/app/plugins/panel/nodeGraph/Legend.tsx index fa2c9126612..a46a12b51d7 100644 --- a/public/app/plugins/panel/nodeGraph/Legend.tsx +++ b/public/app/plugins/panel/nodeGraph/Legend.tsx @@ -4,7 +4,8 @@ import { Field, FieldColorModeId, getColorForTheme, GrafanaTheme } from '@grafan import { identity } from 'lodash'; import { Config } from './layout'; import { css } from '@emotion/css'; -import { Icon, LegendDisplayMode, useStyles, useTheme, VizLegend, VizLegendItem, VizLegendListItem } from '@grafana/ui'; +import { LegendDisplayMode } from '@grafana/schema'; +import { Icon, useStyles, useTheme, VizLegend, VizLegendItem, VizLegendListItem } from '@grafana/ui'; function getStyles() { return { diff --git a/public/app/plugins/panel/piechart/PieChart.tsx b/public/app/plugins/panel/piechart/PieChart.tsx index 2006f6cbd5d..e24dcf8d3b8 100644 --- a/public/app/plugins/panel/piechart/PieChart.tsx +++ b/public/app/plugins/panel/piechart/PieChart.tsx @@ -1,5 +1,5 @@ import React, { FC, useCallback } from 'react'; - +import { VizTooltipOptions } from '@grafana/schema'; import { FieldDisplay, FALLBACK_COLOR, @@ -9,7 +9,6 @@ import { DataHoverEvent, } from '@grafana/data'; import { - VizTooltipOptions, useTheme2, useStyles2, SeriesTableRowProps, diff --git a/public/app/plugins/panel/piechart/PieChartPanel.tsx b/public/app/plugins/panel/piechart/PieChartPanel.tsx index 4a7ef96d76d..42f6bb1f6d6 100644 --- a/public/app/plugins/panel/piechart/PieChartPanel.tsx +++ b/public/app/plugins/panel/piechart/PieChartPanel.tsx @@ -1,4 +1,5 @@ import React, { useEffect, useState } from 'react'; +import { LegendDisplayMode } from '@grafana/schema'; import { DataHoverClearEvent, DataHoverEvent, @@ -14,7 +15,6 @@ import { PieChart } from './PieChart'; import { PieChartLegendOptions, PieChartLegendValues, PieChartOptions } from './types'; import { Subscription } from 'rxjs'; import { - LegendDisplayMode, SeriesVisibilityChangeBehavior, usePanelContext, useTheme2, diff --git a/public/app/plugins/panel/piechart/migrations.test.ts b/public/app/plugins/panel/piechart/migrations.test.ts index 15badcbed69..1d63e0b4555 100644 --- a/public/app/plugins/panel/piechart/migrations.test.ts +++ b/public/app/plugins/panel/piechart/migrations.test.ts @@ -1,5 +1,5 @@ import { FieldColorModeId, FieldConfigProperty, FieldMatcherID, PanelModel } from '@grafana/data'; -import { LegendDisplayMode } from '@grafana/ui'; +import { LegendDisplayMode } from '@grafana/schema'; import { PieChartPanelChangedHandler } from './migrations'; import { PieChartLabels } from './types'; diff --git a/public/app/plugins/panel/piechart/migrations.ts b/public/app/plugins/panel/piechart/migrations.ts index 773e385b39b..1d12c83b6a1 100644 --- a/public/app/plugins/panel/piechart/migrations.ts +++ b/public/app/plugins/panel/piechart/migrations.ts @@ -1,5 +1,5 @@ import { FieldColorModeId, FieldConfigProperty, FieldMatcherID, PanelModel } from '@grafana/data'; -import { LegendDisplayMode } from '@grafana/ui'; +import { LegendDisplayMode } from '@grafana/schema'; import { PieChartOptions, PieChartLabels, PieChartLegendValues, PieChartType } from './types'; export const PieChartPanelChangedHandler = ( diff --git a/public/app/plugins/panel/piechart/module.tsx b/public/app/plugins/panel/piechart/module.tsx index 409aaa1fce9..b9daf3a5bf4 100644 --- a/public/app/plugins/panel/piechart/module.tsx +++ b/public/app/plugins/panel/piechart/module.tsx @@ -1,7 +1,8 @@ import { FieldColorModeId, FieldConfigProperty, PanelPlugin } from '@grafana/data'; import { PieChartPanel } from './PieChartPanel'; import { PieChartOptions, PieChartType, PieChartLabels, PieChartLegendValues } from './types'; -import { LegendDisplayMode, commonOptionsBuilder } from '@grafana/ui'; +import { LegendDisplayMode } from '@grafana/schema'; +import { commonOptionsBuilder } from '@grafana/ui'; import { PieChartPanelChangedHandler } from './migrations'; import { addStandardDataReduceOptions } from '../stat/types'; diff --git a/public/app/plugins/panel/piechart/types.ts b/public/app/plugins/panel/piechart/types.ts index 407c634704f..4e0a3f48e13 100644 --- a/public/app/plugins/panel/piechart/types.ts +++ b/public/app/plugins/panel/piechart/types.ts @@ -1,4 +1,5 @@ -import { OptionsWithTooltip, SingleStatBaseOptions, VizLegendOptions } from '@grafana/ui'; +import { VizLegendOptions, OptionsWithTooltip } from '@grafana/schema'; +import { SingleStatBaseOptions } from '@grafana/ui'; /** * @beta diff --git a/public/app/plugins/panel/state-timeline/TimelineChart.tsx b/public/app/plugins/panel/state-timeline/TimelineChart.tsx index e0ac00abf45..4d2ccfbba06 100755 --- a/public/app/plugins/panel/state-timeline/TimelineChart.tsx +++ b/public/app/plugins/panel/state-timeline/TimelineChart.tsx @@ -1,11 +1,11 @@ import React from 'react'; +import { LegendDisplayMode } from '@grafana/schema'; import { PanelContext, PanelContextRoot, GraphNG, GraphNGProps, BarValueVisibility, - LegendDisplayMode, UPlotConfigBuilder, VizLayout, VizLegend, diff --git a/public/app/plugins/panel/state-timeline/types.ts b/public/app/plugins/panel/state-timeline/types.ts index 6364dd4a778..9cda1c5d30a 100644 --- a/public/app/plugins/panel/state-timeline/types.ts +++ b/public/app/plugins/panel/state-timeline/types.ts @@ -1,4 +1,5 @@ -import { HideableFieldConfig, BarValueVisibility, OptionsWithLegend, OptionsWithTooltip } from '@grafana/ui'; +import { OptionsWithTooltip, OptionsWithLegend } from '@grafana/schema'; +import { HideableFieldConfig, BarValueVisibility } from '@grafana/ui'; /** * @alpha diff --git a/public/app/plugins/panel/state-timeline/utils.ts b/public/app/plugins/panel/state-timeline/utils.ts index dacdd01b271..0ab875dcc5e 100644 --- a/public/app/plugins/panel/state-timeline/utils.ts +++ b/public/app/plugins/panel/state-timeline/utils.ts @@ -1,4 +1,5 @@ import React from 'react'; +import { VizLegendOptions } from '@grafana/schema'; import { XYFieldMatchers } from '@grafana/ui/src/components/GraphNG/types'; import { ArrayVector, @@ -21,7 +22,6 @@ import { UPlotConfigBuilder, UPlotConfigPrepFn, VizLegendItem, - VizLegendOptions, } from '@grafana/ui'; import { getConfig, TimelineCoreOptions } from './timeline'; import { AxisPlacement, ScaleDirection, ScaleOrientation } from '@grafana/ui/src/components/uPlot/config'; diff --git a/public/app/plugins/panel/status-history/types.ts b/public/app/plugins/panel/status-history/types.ts index b9840d9fe31..bab48dc0a39 100644 --- a/public/app/plugins/panel/status-history/types.ts +++ b/public/app/plugins/panel/status-history/types.ts @@ -1,4 +1,5 @@ -import { HideableFieldConfig, BarValueVisibility, OptionsWithTooltip, OptionsWithLegend } from '@grafana/ui'; +import { HideableFieldConfig, BarValueVisibility } from '@grafana/ui'; +import { OptionsWithTooltip, OptionsWithLegend } from '@grafana/schema'; /** * @alpha diff --git a/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx b/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx index 47e7e91ff18..44590af243f 100644 --- a/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx +++ b/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx @@ -1,6 +1,7 @@ import { Field, PanelProps } from '@grafana/data'; import { config } from '@grafana/runtime'; -import { usePanelContext, TimeSeries, TooltipPlugin, ZoomPlugin, TooltipDisplayMode } from '@grafana/ui'; +import { TooltipDisplayMode } from '@grafana/schema'; +import { usePanelContext, TimeSeries, TooltipPlugin, ZoomPlugin } from '@grafana/ui'; import { getFieldLinksForExplore } from 'app/features/explore/utils/links'; import React, { useMemo } from 'react'; import { AnnotationsPlugin } from './plugins/AnnotationsPlugin'; diff --git a/public/app/plugins/panel/timeseries/migrations.ts b/public/app/plugins/panel/timeseries/migrations.ts index 82a3d77627d..badcdee201a 100644 --- a/public/app/plugins/panel/timeseries/migrations.ts +++ b/public/app/plugins/panel/timeseries/migrations.ts @@ -18,14 +18,13 @@ import { GraphFieldConfig, GraphGradientMode, GraphTresholdsStyleMode, - LegendDisplayMode, LineInterpolation, LineStyle, PointVisibility, ScaleDistribution, StackingMode, - TooltipDisplayMode, } from '@grafana/ui'; +import { LegendDisplayMode, TooltipDisplayMode } from '@grafana/schema'; import { TimeSeriesOptions } from './types'; import { omitBy, pickBy, isNil, isNumber, isString } from 'lodash'; import { defaultGraphConfig } from './config'; diff --git a/public/app/plugins/panel/timeseries/types.ts b/public/app/plugins/panel/timeseries/types.ts index 50d051c0d96..43cf99e0746 100644 --- a/public/app/plugins/panel/timeseries/types.ts +++ b/public/app/plugins/panel/timeseries/types.ts @@ -1,3 +1,3 @@ -import { OptionsWithLegend, OptionsWithTooltip } from '@grafana/ui'; +import { OptionsWithLegend, OptionsWithTooltip } from '@grafana/schema'; export interface TimeSeriesOptions extends OptionsWithLegend, OptionsWithTooltip {} diff --git a/public/app/plugins/panel/xychart/types.ts b/public/app/plugins/panel/xychart/types.ts index 1819749714d..d5ae63c076b 100644 --- a/public/app/plugins/panel/xychart/types.ts +++ b/public/app/plugins/panel/xychart/types.ts @@ -1,4 +1,4 @@ -import { OptionsWithTooltip, OptionsWithLegend } from '@grafana/ui'; +import { OptionsWithTooltip, OptionsWithLegend } from '@grafana/schema'; export interface XYDimensionConfig { frame: number; x?: string; // name | first