File tree Expand file tree Collapse file tree 6 files changed +179
-11
lines changed Expand file tree Collapse file tree 6 files changed +179
-11
lines changed Original file line number Diff line number Diff line change 1
1
# Grafana Button Control Panel
2
2
3
- Docs...
3
+ This panel allows you to create buttons and define actions for them. It can be
4
+ used to add controlling functionality to your dashboards. Actions are defined as
5
+ queries to Datasources.
6
+
7
+ Multiple buttons are allowed within a single panel, they can be arranged either
8
+ horizontally or vertically.
9
+
10
+ The query field is a JSON object, that depends on each Datasource type. You can
11
+ use Grafana's Query Inspector to find out what Grafana sends to each Datasource,
12
+ and copy those into the query field.
13
+
14
+ ## Examples
15
+
16
+ Query field to delete InfluxDB database:
17
+
18
+ ``` json
19
+ {
20
+ "query" : " drop databse 'foo'" ,
21
+ "rawQuery" : true ,
22
+ "resultFormat" : " time_series"
23
+ }
24
+ ```
25
+
26
+ ` refId ` , ` datasourceId ` are automatically sent, so you don't have to set them.
Original file line number Diff line number Diff line change 21
21
"@grafana/toolkit" : " next" ,
22
22
"@grafana/ui" : " next" ,
23
23
"@types/enzyme" : " ^3.10.5" ,
24
+ "@types/enzyme-adapter-react-16" : " ^1.0.6" ,
25
+ "@types/jest" : " ^25.2.3" ,
24
26
"emotion" : " 10.0.27" ,
25
27
"enzyme" : " ^3.11.0" ,
26
28
"enzyme-adapter-react-16" : " 1.15.2"
Original file line number Diff line number Diff line change @@ -65,12 +65,14 @@ describe('button panel', () => {
65
65
wrapper . setProps ( { options : { buttons : buttons } } ) ;
66
66
67
67
const mockGet = jest . fn ( ) . mockReturnValue ( { id : 1 } ) ;
68
- getDataSourceSrv . mockImplementation ( ( ) => ( { get : mockGet } ) ) ;
68
+ ( getDataSourceSrv as jest . Mock < any > ) . mockImplementation ( ( ) => ( {
69
+ get : mockGet ,
70
+ } ) ) ;
69
71
const mockDataSourceRequest = jest . fn ( ) . mockReturnValue ( {
70
72
status : status ,
71
73
statusText : statusText ,
72
74
} ) ;
73
- getBackendSrv . mockImplementation ( ( ) => ( {
75
+ ( getBackendSrv as jest . Mock < any > ) . mockImplementation ( ( ) => ( {
74
76
datasourceRequest : mockDataSourceRequest ,
75
77
} ) ) ;
76
78
const mockEmit = jest . fn ( ) ;
@@ -103,14 +105,16 @@ describe('button panel', () => {
103
105
wrapper . setProps ( { options : { buttons : buttons } } ) ;
104
106
105
107
const mockGet = jest . fn ( ) . mockReturnValue ( { id : 1 } ) ;
106
- getDataSourceSrv . mockImplementation ( ( ) => ( { get : mockGet } ) ) ;
108
+ ( getDataSourceSrv as jest . Mock < any > ) . mockImplementation ( ( ) => ( {
109
+ get : mockGet ,
110
+ } ) ) ;
107
111
const msg = 'msg' ;
108
112
const mockDataSourceRequest = jest . fn ( ) . mockRejectedValue ( {
109
113
status : statusError ,
110
114
statusText : statusText ,
111
115
data : { message : msg } ,
112
116
} ) ;
113
- getBackendSrv . mockImplementation ( ( ) => ( {
117
+ ( getBackendSrv as jest . Mock < any > ) . mockImplementation ( ( ) => ( {
114
118
datasourceRequest : mockDataSourceRequest ,
115
119
} ) ) ;
116
120
const mockEmit = jest . fn ( ) ;
Original file line number Diff line number Diff line change 1
1
import { getBackendSrv } from '@grafana/runtime' ;
2
2
import { Button , Collapse , Field } from '@grafana/ui' ;
3
- import { mount , shallow } from 'enzyme' ;
3
+ import { shallow } from 'enzyme' ;
4
4
import React from 'react' ;
5
5
import { Editor , EditorProps } from './editor' ;
6
6
jest . mock ( '@grafana/runtime' ) ;
@@ -37,9 +37,11 @@ describe('editor', () => {
37
37
} ;
38
38
39
39
const mockGet = jest . fn ( ) . mockReturnValue ( [ { name : 'a' } ] ) ;
40
- getBackendSrv . mockImplementation ( ( ) => ( { get : mockGet } ) ) ;
40
+ ( getBackendSrv as jest . Mock < any > ) . mockImplementation ( ( ) => ( {
41
+ get : mockGet ,
42
+ } ) ) ;
41
43
42
- const wrapper = mount ( < Editor { ...props } /> ) ;
44
+ const wrapper = shallow ( < Editor { ...props } /> ) ;
43
45
expect ( wrapper . children ( ) ) . toHaveLength ( 3 ) ;
44
46
const collapse = wrapper . find ( Collapse ) ;
45
47
expect ( collapse ) . toHaveLength ( 2 ) ;
Original file line number Diff line number Diff line change 1455
1455
dependencies:
1456
1456
"@types/node" "*"
1457
1457
1458
- "@types/enzyme@^3.10.5":
1458
+ "@types/enzyme-adapter-react-16@^1.0.6":
1459
+ version "1.0.6"
1460
+ resolved "https://registry.yarnpkg.com/@types/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.0.6.tgz#8aca7ae2fd6c7137d869b6616e696d21bb8b0cec"
1461
+ integrity sha512-VonDkZ15jzqDWL8mPFIQnnLtjwebuL9YnDkqeCDYnB4IVgwUm0mwKkqhrxLL6mb05xm7qqa3IE95m8CZE9imCg==
1462
+ dependencies:
1463
+ "@types/enzyme" "*"
1464
+
1465
+ "@types/enzyme@*", "@types/enzyme@^3.10.5":
1459
1466
version "3.10.5"
1460
1467
resolved "https://registry.yarnpkg.com/@types/enzyme/-/enzyme-3.10.5.tgz#fe7eeba3550369eed20e7fb565bfb74eec44f1f0"
1461
1468
integrity sha512-R+phe509UuUYy9Tk0YlSbipRpfVtIzb/9BHn5pTEtjJTF5LXvUjrIQcZvNyANNEyFrd2YGs196PniNT1fgvOQA==
1615
1622
dependencies:
1616
1623
jest-diff "*"
1617
1624
1618
- "@types/jest@*":
1625
+ "@types/jest@*", "@types/jest@^25.2.3" :
1619
1626
version "25.2.3"
1620
1627
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-25.2.3.tgz#33d27e4c4716caae4eced355097a47ad363fdcaf"
1621
1628
integrity sha512-JXc1nK/tXHiDhV55dvfzqtmP4S3sy3T3ouV2tkViZgxY/zeUkcpQcQPGRlgF4KmWzWW5oiWYSZwtCB+2RsE4Fw==
You can’t perform that action at this time.
0 commit comments