@grafana/create-plugin 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # v1.8.0 (Tue Jul 11 2023)
2
+
3
+ :tada: This release contains work from a new contributor! :tada:
4
+
5
+ Thank you, Dominik Prokop ([@dprokop](https://github.com/dprokop)), for all your work!
6
+
7
+ #### 🚀 Enhancement
8
+
9
+ - Create Plugin: add readme best practice example [#298](https://github.com/grafana/plugin-tools/pull/298) ([@sympatheticmoose](https://github.com/sympatheticmoose))
10
+
11
+ #### 🐛 Bug Fix
12
+
13
+ - Create Plugin: Update scenes to latest version [#287](https://github.com/grafana/plugin-tools/pull/287) ([@dprokop](https://github.com/dprokop))
14
+
15
+ #### Authors: 2
16
+
17
+ - David Harris ([@sympatheticmoose](https://github.com/sympatheticmoose))
18
+ - Dominik Prokop ([@dprokop](https://github.com/dprokop))
19
+
20
+ ---
21
+
1
22
  # v1.7.0 (Wed Jul 05 2023)
2
23
 
3
24
  #### 🚀 Enhancement
package/CONTRIBUTING.md CHANGED
@@ -7,14 +7,14 @@ The following guidelines help you on how to start with the codebase and how to s
7
7
 
8
8
  ### Prerequisites
9
9
 
10
- You need to have `npm` or `yarn` installed.
10
+ You need to have `npm` installed.
11
11
 
12
12
  ### Installing
13
13
 
14
14
  ```bash
15
15
  git clone git@github.com:grafana/plugin-tools.git
16
16
  cd plugin-tools
17
- yarn install
17
+ npm install
18
18
  ```
19
19
 
20
20
  ## Overview
@@ -51,23 +51,23 @@ There are a collection of [commands](#commmands) to assist with developing `crea
51
51
  Below are the main commands used for developing `create-plugin`. They can be run by either `yarn workspace @grafana/create-plugin run <name_of_command>` or navigating to `packages/create-plugin` and running the command directly as detailed below.
52
52
 
53
53
  ```shell
54
- yarn build # used to build @grafana/create-plugin
54
+ npm run build # used to build @grafana/create-plugin
55
55
  ```
56
56
 
57
57
  ```shell
58
- yarn dev # watches for changes to files and rebuilds @grafana/create-plugin automatically
58
+ npm run dev # watches for changes to files and rebuilds @grafana/create-plugin automatically
59
59
  ```
60
60
 
61
61
  ```shell
62
- yarn dev-app # watches for changes and scaffolds an app plugin (in ./generated) for developing app configs
62
+ npm run dev-app # watches for changes and scaffolds an app plugin (in ./generated) for developing app configs
63
63
  ```
64
64
 
65
65
  ```shell
66
- yarn dev-panel # watches for changes and scaffolds an app plugin (in ./generated) for developing panel configs
66
+ npm run dev-panel # watches for changes and scaffolds an app plugin (in ./generated) for developing panel configs
67
67
  ```
68
68
 
69
69
  ```shell
70
- yarn dev-datasource # watches for changes and scaffolds an app plugin (in ./generated) for developing datasource configs
70
+ npm run dev-datasource # watches for changes and scaffolds an app plugin (in ./generated) for developing datasource configs
71
71
  ```
72
72
 
73
73
  ### Conventions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "directory": "packages/create-plugin",
@@ -66,5 +66,5 @@
66
66
  "engines": {
67
67
  "node": ">=16"
68
68
  },
69
- "gitHead": "ec3651f12b05d7e8e4da515d272bfc1c568d5f21"
69
+ "gitHead": "13c1b8968b648533b252637706d632235abaa18e"
70
70
  }
@@ -61,7 +61,8 @@
61
61
  "@grafana/data": "{{ grafanaVersion }}",
62
62
  "@grafana/runtime": "{{ grafanaVersion }}",
63
63
  "@grafana/ui": "{{ grafanaVersion }}",{{#if_eq pluginType "scenesapp"}}
64
- "@grafana/scenes": "^0.11.0",{{/if_eq}}
64
+ "@grafana/schema": "10.0.1",
65
+ "@grafana/scenes": "^0.19.0",{{/if_eq}}
65
66
  "react": "17.0.2",
66
67
  "react-dom": "17.0.2",{{#if isAppType}}
67
68
  "react-router-dom": "^5.2.0",
@@ -1,5 +1,50 @@
1
- <!-- This README file is going to be the one displayed on the Grafana.com website for your plugin -->
1
+ <!-- This README file is going to be the one displayed on the Grafana.com website for your plugin. Uncomment and replace the content here before publishing.
2
2
 
3
+ Remove any remaining comments before publishing as these may be displayed on Grafana.com -->
3
4
  # {{ titleCase pluginName }}
4
5
 
5
6
  {{ sentenceCase pluginDescription }}
7
+
8
+ <!-- To help maximize the impact of your README and improve usability for users, we propose the following loose structure:
9
+
10
+ **BEFORE YOU BEGIN**
11
+ - Ensure all links are absolute URLs so that they will work when the README is displayed within Grafana and Grafana.com
12
+ - Be inspired ✨
13
+ - [grafana-polystat-panel](https://github.com/grafana/grafana-polystat-panel)
14
+ - [volkovlabs-variable-panel](https://github.com/volkovlabs/volkovlabs-variable-panel)
15
+
16
+ **ADD SOME BADGES**
17
+
18
+ Badges convey useful information at a glance for users whether in the Catalog or viewing the source code. You can use the generator on [Shields.io](https://shields.io/badges/dynamic-json-badge) together with the Grafana.com API
19
+ to create dynamic badges that update automatically when you publish a new version to the marketplace.
20
+
21
+ - For the logo field use 'grafana'.
22
+ - Examples (label: query)
23
+ - Downloads: $.downloads
24
+ - Catalog Version: $.version
25
+ - Grafana Dependency: $.grafanaDependency
26
+ - Signature Type: $.versionSignatureType
27
+
28
+ Full example: ![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?logo=grafana&query=$.version&url=https://grafana.com/api/plugins/grafana-polystat-panel&label=Marketplace&prefix=v&color=F47A20)
29
+
30
+ Consider other [badges](https://shields.io/badges) as you feel appropriate for your project.
31
+
32
+ ## Overview / Introduction
33
+ Provide one or more paragraphs as an introduction to your plugin to help users understand why they should use it.
34
+
35
+ Consider including screenshots:
36
+ - in [plugin.json](https://grafana.com/docs/grafana/latest/developers/plugins/metadata/#info) include them as relative links.
37
+ - in the README ensure they are absolute URLs.
38
+
39
+ ## Requirements
40
+ List any requirements or dependencies they may need to run the plugin.
41
+
42
+ ## Getting Started
43
+ Provide a quick start on how to configure and use the plugin.
44
+
45
+ ## Documentation
46
+ If your project has dedicated documentation available for users, provide links here. For help in following Grafana's style recommendations for technical documentation, refer to our [Writer's Toolkit](https://grafana.com/docs/writers-toolkit/).
47
+
48
+ ## Contributing
49
+ Do you want folks to contribute to the plugin or provide feedback through specific means? If so, tell them how!
50
+ -->
@@ -1,4 +1,4 @@
1
- import { EmbeddedScene, SceneFlexLayout, SceneFlexItem, VizPanel } from '@grafana/scenes';
1
+ import { EmbeddedScene, SceneFlexLayout, SceneFlexItem, PanelBuilders } from '@grafana/scenes';
2
2
 
3
3
  export function getScene() {
4
4
  return new EmbeddedScene({
@@ -7,13 +7,7 @@ export function getScene() {
7
7
  new SceneFlexItem({
8
8
  width: '100%',
9
9
  height: 300,
10
- body: new VizPanel({
11
- title: 'Hello world panel',
12
- pluginId: 'text',
13
- options: {
14
- content: 'Hello world! ',
15
- },
16
- }),
10
+ body: PanelBuilders.text().setTitle('Hello world panel').setOption('content', 'Hello world!').build(),
17
11
  }),
18
12
  ],
19
13
  }),
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  CustomVariable,
3
3
  EmbeddedScene,
4
+ PanelBuilders,
4
5
  SceneControlsSpacer,
5
6
  SceneFlexItem,
6
7
  SceneFlexLayout,
@@ -10,7 +11,6 @@ import {
10
11
  SceneTimeRange,
11
12
  SceneVariableSet,
12
13
  VariableValueSelectors,
13
- VizPanel,
14
14
  } from '@grafana/scenes';
15
15
  import { DATASOURCE_REF } from '../../constants';
16
16
  import { CustomSceneObject } from './CustomSceneObject';
@@ -78,11 +78,11 @@ export function getBasicScene(templatised = true, seriesToShow = '__server_names
78
78
  body: new SceneFlexLayout({
79
79
  children: [
80
80
  new SceneFlexItem({
81
- body: new VizPanel({
82
- pluginId: 'timeseries',
81
+ minHeight: 300,
82
+ body: PanelBuilders.timeseries()
83
83
  // Title is using variable value
84
- title: templatised ? '${seriesToShow}' : seriesToShow,
85
- }),
84
+ .setTitle(templatised ? '${seriesToShow}' : seriesToShow)
85
+ .build(),
86
86
  }),
87
87
  ],
88
88
  }),
@@ -1,125 +1,95 @@
1
- import { ReducerID, ThresholdsMode } from '@grafana/data';
1
+ import { ReducerID } from '@grafana/data';
2
2
  import {
3
+ PanelBuilders,
3
4
  SceneByFrameRepeater,
4
5
  SceneDataNode,
5
6
  SceneDataTransformer,
6
7
  SceneFlexItem,
7
8
  SceneFlexLayout,
8
- VizPanel,
9
9
  } from '@grafana/scenes';
10
+ import { TableCellBackgroundDisplayMode, TableCellDisplayMode, ThresholdsMode } from '@grafana/schema';
10
11
 
11
12
  export function getRoomsTemperatureTable() {
12
- return new VizPanel({
13
- pluginId: 'table',
14
- $data: new SceneDataTransformer({
15
- transformations: [
16
- {
17
- id: 'reduce',
18
- options: {
19
- reducers: ['mean'],
20
- },
21
- },
22
- {
23
- id: 'organize',
24
- options: {
25
- excludeByName: {},
26
- indexByName: {},
27
- renameByName: {
28
- Field: 'Room',
29
- Mean: 'Average temperature',
30
- },
31
- },
13
+ const data = new SceneDataTransformer({
14
+ transformations: [
15
+ {
16
+ id: 'reduce',
17
+ options: {
18
+ reducers: ['mean'],
32
19
  },
33
- ],
34
- }),
35
- displayMode: 'transparent',
36
- title: 'Room temperature overview',
37
- hoverHeader: true,
38
- options: {
39
- sortBy: ['Average temperature'],
40
- },
41
- fieldConfig: {
42
- defaults: {
43
- custom: {
44
- align: 'auto',
45
- cellOptions: {
46
- type: 'auto',
20
+ },
21
+ {
22
+ id: 'organize',
23
+ options: {
24
+ excludeByName: {},
25
+ indexByName: {},
26
+ renameByName: {
27
+ Field: 'Room',
28
+ Mean: 'Average temperature',
47
29
  },
48
- inspect: false,
49
- },
50
- mappings: [],
51
- thresholds: {
52
- mode: ThresholdsMode.Absolute,
53
- steps: [
54
- {
55
- color: 'light-blue',
56
- value: 0,
57
- },
58
- {
59
- color: 'orange',
60
- value: 19,
61
- },
62
- {
63
- color: 'dark-red',
64
- value: 26,
65
- },
66
- ],
67
- },
68
- color: {
69
- mode: 'thresholds',
70
30
  },
71
31
  },
72
- overrides: [
32
+ ],
33
+ });
34
+ return PanelBuilders.table()
35
+ .setTitle('Room temperature overview')
36
+ .setData(data)
37
+ .setHoverHeader(true)
38
+ .setDisplayMode('transparent')
39
+ .setOption('sortBy', [{ displayName: 'Average temperature' }])
40
+ .setThresholds({
41
+ mode: ThresholdsMode.Absolute,
42
+ steps: [
73
43
  {
74
- matcher: {
75
- id: 'byName',
76
- options: 'Average temperature',
77
- },
78
- properties: [
79
- {
80
- id: 'unit',
81
- value: 'celsius',
82
- },
83
- {
84
- id: 'custom.cellOptions',
85
- value: {
86
- type: 'color-background',
87
- mode: 'basic',
88
- },
89
- },
90
- {
91
- id: 'custom.width',
92
- value: 200,
93
- },
94
- {
95
- id: 'custom.align',
96
- value: 'center',
97
- },
98
- ],
44
+ color: 'light-blue',
45
+ value: 0,
99
46
  },
100
47
  {
101
- matcher: {
102
- id: 'byName',
103
- options: 'Room',
104
- },
105
- properties: [
106
- {
107
- id: 'links',
108
- value: [
109
- {
110
- title: 'Go to room overview',
111
- url: '${__url.path}/room/${__value.text}/temperature${__url.params}',
112
- },
113
- ],
114
- },
115
- ],
48
+ color: 'orange',
49
+ value: 19,
50
+ },
51
+ {
52
+ color: 'dark-red',
53
+ value: 26,
116
54
  },
117
55
  ],
118
- },
119
- });
56
+ })
57
+ .setColor({ mode: 'thresholds' })
58
+ .setCustomFieldConfig('align', 'auto')
59
+ .setCustomFieldConfig('cellOptions', { type: TableCellDisplayMode.Auto })
60
+ .setCustomFieldConfig('inspect', false)
61
+ .setOverrides((b) =>
62
+ b
63
+ .matchFieldsWithName('Average temperature')
64
+ .overrideUnit('celsius')
65
+ .overrideCustomFieldConfig('cellOptions', {
66
+ type: TableCellDisplayMode.ColorBackground,
67
+ mode: TableCellBackgroundDisplayMode.Basic,
68
+ })
69
+ .overrideCustomFieldConfig('width', 200)
70
+ .overrideCustomFieldConfig('align', 'center')
71
+ .matchFieldsWithName('Room')
72
+ .overrideLinks([
73
+ { title: 'Go to room overview', url: '${__url.path}/room/${__value.text}/temperature${__url.params}' },
74
+ ])
75
+ )
76
+ .build();
120
77
  }
121
78
 
122
79
  export function getRoomsTemperatureStats() {
80
+ const stat = PanelBuilders.stat()
81
+ .setUnit('celsius')
82
+ .setLinks([
83
+ {
84
+ title: 'Go to room temperature overview',
85
+ url: '${__url.path}/room/${__field.name}/temperature${__url.params}',
86
+ },
87
+ {
88
+ title: 'Go to room humidity overview',
89
+ url: '${__url.path}/room/${__field.name}/humidity${__url.params}',
90
+ },
91
+ ]);
92
+
123
93
  return new SceneByFrameRepeater({
124
94
  body: new SceneFlexLayout({
125
95
  direction: 'row',
@@ -130,57 +100,32 @@ export function getRoomsTemperatureStats() {
130
100
  return new SceneFlexItem({
131
101
  height: '50%',
132
102
  minWidth: '20%',
133
- body: new VizPanel({
134
- title: frame.name,
135
- pluginId: 'stat',
136
-
137
- $data: new SceneDataNode({
138
- data: {
139
- ...data,
140
- series: [frame],
141
- },
142
- }),
143
- fieldConfig: {
144
- defaults: {
145
- unit: 'celsius',
146
- links: [
147
- {
148
- title: 'Go to room temperature overview',
149
- url: '${__url.path}/room/${__field.name}/temperature${__url.params}',
150
- },
151
- {
152
- title: 'Go to room humidity overview',
153
- url: '${__url.path}/room/${__field.name}/humidity${__url.params}',
154
- },
155
- ],
156
- },
157
- overrides: [],
158
- },
159
- }),
103
+ body: stat
104
+ .setTitle(frame.name || '')
105
+ .setData(
106
+ new SceneDataNode({
107
+ data: {
108
+ ...data,
109
+ series: [frame],
110
+ },
111
+ })
112
+ )
113
+ .build(),
160
114
  });
161
115
  },
162
116
  });
163
117
  }
164
118
 
165
119
  export function getRoomTemperatureStatPanel(reducers: ReducerID[]) {
166
- return new VizPanel({
167
- pluginId: 'stat',
168
- title: '',
169
- $data: new SceneDataTransformer({
170
- transformations: [
171
- {
172
- id: 'reduce',
173
- options: {
174
- reducers,
175
- },
120
+ const data = new SceneDataTransformer({
121
+ transformations: [
122
+ {
123
+ id: 'reduce',
124
+ options: {
125
+ reducers,
176
126
  },
177
- ],
178
- }),
179
- fieldConfig: {
180
- defaults: {
181
- unit: 'celsius',
182
127
  },
183
- overrides: [],
184
- },
128
+ ],
185
129
  });
130
+ return PanelBuilders.stat().setData(data).setUnit('celsius').build();
186
131
  }
@@ -3,12 +3,12 @@ import {
3
3
  EmbeddedScene,
4
4
  SceneFlexLayout,
5
5
  SceneQueryRunner,
6
- VizPanel,
7
6
  SceneTimeRange,
8
7
  SceneTimePicker,
9
8
  SceneControlsSpacer,
10
9
  SceneRefreshPicker,
11
10
  SceneFlexItem,
11
+ PanelBuilders,
12
12
  } from '@grafana/scenes';
13
13
  import { DATASOURCE_REF } from '../../constants';
14
14
  import { getRoomTemperatureStatPanel } from './panels';
@@ -29,17 +29,7 @@ export function getTemperatureOverviewScene(roomName: string) {
29
29
  children: [
30
30
  new SceneFlexItem({
31
31
  height: 500,
32
- body: new VizPanel({
33
- title: 'Temperature over time',
34
- pluginId: 'timeseries',
35
-
36
- fieldConfig: {
37
- defaults: {
38
- unit: 'celsius',
39
- },
40
- overrides: [],
41
- },
42
- }),
32
+ body: PanelBuilders.timeseries().setTitle('Temperature over time').setUnit('celsius').build(),
43
33
  }),
44
34
  new SceneFlexItem({
45
35
  body: new SceneFlexLayout({
@@ -79,17 +69,7 @@ export function getHumidityOverviewScene(roomName: string) {
79
69
  children: [
80
70
  new SceneFlexItem({
81
71
  height: 500,
82
- body: new VizPanel({
83
- title: 'Humidity readings over time',
84
- pluginId: 'timeseries',
85
-
86
- fieldConfig: {
87
- defaults: {
88
- unit: 'humidity',
89
- },
90
- overrides: [],
91
- },
92
- }),
72
+ body: PanelBuilders.timeseries().setTitle('Humidity over time').setUnit('humidity').build(),
93
73
  }),
94
74
  ],
95
75
  }),