Skip to content

Commit 81a9010

Browse files
committed
logo
1 parent 83f8989 commit 81a9010

File tree

6 files changed

+179
-11
lines changed

6 files changed

+179
-11
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
# Grafana Button Control Panel
22

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.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"@grafana/toolkit": "next",
2222
"@grafana/ui": "next",
2323
"@types/enzyme": "^3.10.5",
24+
"@types/enzyme-adapter-react-16": "^1.0.6",
25+
"@types/jest": "^25.2.3",
2426
"emotion": "10.0.27",
2527
"enzyme": "^3.11.0",
2628
"enzyme-adapter-react-16": "1.15.2"

src/buttonPanel.test.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ describe('button panel', () => {
6565
wrapper.setProps({ options: { buttons: buttons } });
6666

6767
const mockGet = jest.fn().mockReturnValue({ id: 1 });
68-
getDataSourceSrv.mockImplementation(() => ({ get: mockGet }));
68+
(getDataSourceSrv as jest.Mock<any>).mockImplementation(() => ({
69+
get: mockGet,
70+
}));
6971
const mockDataSourceRequest = jest.fn().mockReturnValue({
7072
status: status,
7173
statusText: statusText,
7274
});
73-
getBackendSrv.mockImplementation(() => ({
75+
(getBackendSrv as jest.Mock<any>).mockImplementation(() => ({
7476
datasourceRequest: mockDataSourceRequest,
7577
}));
7678
const mockEmit = jest.fn();
@@ -103,14 +105,16 @@ describe('button panel', () => {
103105
wrapper.setProps({ options: { buttons: buttons } });
104106

105107
const mockGet = jest.fn().mockReturnValue({ id: 1 });
106-
getDataSourceSrv.mockImplementation(() => ({ get: mockGet }));
108+
(getDataSourceSrv as jest.Mock<any>).mockImplementation(() => ({
109+
get: mockGet,
110+
}));
107111
const msg = 'msg';
108112
const mockDataSourceRequest = jest.fn().mockRejectedValue({
109113
status: statusError,
110114
statusText: statusText,
111115
data: { message: msg },
112116
});
113-
getBackendSrv.mockImplementation(() => ({
117+
(getBackendSrv as jest.Mock<any>).mockImplementation(() => ({
114118
datasourceRequest: mockDataSourceRequest,
115119
}));
116120
const mockEmit = jest.fn();

src/editor.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getBackendSrv } from '@grafana/runtime';
22
import { Button, Collapse, Field } from '@grafana/ui';
3-
import { mount, shallow } from 'enzyme';
3+
import { shallow } from 'enzyme';
44
import React from 'react';
55
import { Editor, EditorProps } from './editor';
66
jest.mock('@grafana/runtime');
@@ -37,9 +37,11 @@ describe('editor', () => {
3737
};
3838

3939
const mockGet = jest.fn().mockReturnValue([{ name: 'a' }]);
40-
getBackendSrv.mockImplementation(() => ({ get: mockGet }));
40+
(getBackendSrv as jest.Mock<any>).mockImplementation(() => ({
41+
get: mockGet,
42+
}));
4143

42-
const wrapper = mount(<Editor {...props} />);
44+
const wrapper = shallow(<Editor {...props} />);
4345
expect(wrapper.children()).toHaveLength(3);
4446
const collapse = wrapper.find(Collapse);
4547
expect(collapse).toHaveLength(2);

src/img/logo.svg

Lines changed: 131 additions & 1 deletion
Loading

yarn.lock

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,14 @@
14551455
dependencies:
14561456
"@types/node" "*"
14571457

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":
14591466
version "3.10.5"
14601467
resolved "https://registry.yarnpkg.com/@types/enzyme/-/enzyme-3.10.5.tgz#fe7eeba3550369eed20e7fb565bfb74eec44f1f0"
14611468
integrity sha512-R+phe509UuUYy9Tk0YlSbipRpfVtIzb/9BHn5pTEtjJTF5LXvUjrIQcZvNyANNEyFrd2YGs196PniNT1fgvOQA==
@@ -1615,7 +1622,7 @@
16151622
dependencies:
16161623
jest-diff "*"
16171624

1618-
"@types/jest@*":
1625+
"@types/jest@*", "@types/jest@^25.2.3":
16191626
version "25.2.3"
16201627
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-25.2.3.tgz#33d27e4c4716caae4eced355097a47ad363fdcaf"
16211628
integrity sha512-JXc1nK/tXHiDhV55dvfzqtmP4S3sy3T3ouV2tkViZgxY/zeUkcpQcQPGRlgF4KmWzWW5oiWYSZwtCB+2RsE4Fw==

0 commit comments

Comments
 (0)