Skip to content

Commit 8a98f0c

Browse files
authored
Merge pull request #48 from grafana/src/update-plugin-ui
Chore: Various changes to get plugin ui to compile with grafana 8 librarys
2 parents e7cc1c6 + 8d2d229 commit 8a98f0c

File tree

11 files changed

+3582
-2513
lines changed

11 files changed

+3582
-2513
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ workflows:
99
jobs:
1010
build:
1111
docker:
12-
- image: circleci/node:12-browsers-legacy
12+
- image: circleci/node:14-browsers-legacy
1313
steps:
1414
- checkout
1515
- run:

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
"storybook:build": "build-storybook"
1515
},
1616
"dependencies": {
17-
"@grafana/data": "^7.5.10",
18-
"@grafana/runtime": "^7.5.10",
19-
"@grafana/toolkit": "^7.5.10",
17+
"@grafana/data": "^8.4.7",
18+
"@grafana/runtime": "^8.4.7",
19+
"@grafana/toolkit": "^8.4.7",
2020
"@grafana/tsconfig": "^1.0.0-rc1",
21-
"@grafana/ui": "^7.5.10",
21+
"@grafana/ui": "^8.4.7",
2222
"@types/chance": "^1.1.0",
2323
"@types/memoize-one": "^5.1.2",
2424
"@types/react-calendar": "^3.1.2",
@@ -28,7 +28,7 @@
2828
"memoize-one": "^5.1.1",
2929
"rc-cascader": "1.0.1",
3030
"semver": "^7.3.5",
31-
"typescript": "4.0.2"
31+
"typescript": "^4.7.4"
3232
},
3333
"devDependencies": {
3434
"@babel/core": "^7.12.9",

src/components/AsyncButtonCascader/AsyncButtonCascader.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react';
22
import { Icon } from '@grafana/ui';
3-
import { css, cx } from 'emotion';
3+
import { css, cx } from '@emotion/css';
44

55
// @ts-ignore
66
import RCCascader, { CascaderOption } from 'rc-cascader';
7-
import { stylesFactory, useTheme } from '@grafana/ui';
8-
import { GrafanaTheme } from '@grafana/data';
7+
import { useTheme2 } from '@grafana/ui';
8+
import { GrafanaTheme2 } from '@grafana/data';
99

1010
export interface AsyncButtonCascaderProps {
1111
options: CascaderOption[];
@@ -19,7 +19,7 @@ export interface AsyncButtonCascaderProps {
1919
className?: string;
2020
}
2121

22-
const getStyles = stylesFactory((theme: GrafanaTheme) => {
22+
const getStyles = ((theme: GrafanaTheme2) => {
2323
return {
2424
popup: css`
2525
label: popup;
@@ -33,7 +33,7 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => {
3333

3434
export const AsyncButtonCascader: React.FC<AsyncButtonCascaderProps> = props => {
3535
const { onChange, className, loadData, ...rest } = props;
36-
const theme = useTheme();
36+
const theme = useTheme2();
3737
const styles = getStyles(theme);
3838

3939
return (

src/components/DataLinks/DataLink.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Dispatch, SetStateAction, useEffect, useState } from 'react';
2-
import { css } from 'emotion';
2+
import { css } from '@emotion/css';
33
import { VariableSuggestion, DataSourceInstanceSettings, DataSourceJsonData } from '@grafana/data';
44
import { Button, LegacyForms, DataLinkInput, stylesFactory } from '@grafana/ui';
55
const { FormField, Switch } = LegacyForms;

src/components/DataLinks/DataLinks.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { css } from 'emotion';
2+
import { css } from '@emotion/css';
33
import { Button, stylesFactory, useTheme } from '@grafana/ui';
44
import {
55
GrafanaTheme,

src/components/DatePicker/styles.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { GrafanaTheme } from '@grafana/data';
2-
import { stylesFactory } from '@grafana/ui';
3-
import { css } from 'emotion';
2+
import { css } from '@emotion/css';
43

5-
export const getStyles = stylesFactory((theme: GrafanaTheme) => {
4+
export const getStyles = ((theme: GrafanaTheme) => {
65
const containerBorder = theme.isDark
76
? theme.palette.dark9
87
: theme.palette.gray5;
@@ -51,7 +50,7 @@ export const getStyles = stylesFactory((theme: GrafanaTheme) => {
5150
};
5251
});
5352

54-
export const getBodyStyles = stylesFactory((theme: GrafanaTheme) => {
53+
export const getBodyStyles = ((theme: GrafanaTheme) => {
5554
const containerBorder = theme.isDark
5655
? theme.palette.dark9
5756
: theme.palette.gray5;

src/components/QueryEditorRow/QueryEditorRow.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import React, { FunctionComponent } from 'react';
1+
import React from 'react';
22

33
export interface QueryEditorRowProps {
44
label?: string;
55
className?: string;
66
noFillEnd?: boolean;
7+
children?: React.ReactNode;
78
};
89

9-
export const QueryEditorRow: FunctionComponent<QueryEditorRowProps> = props => {
10+
export const QueryEditorRow = (props: QueryEditorRowProps) => {
1011
const className: string = props.className ?? 'width-8';
1112
const noFillEnd: boolean = props.noFillEnd ?? false;
1213

src/test/mocks/DataQuery.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DataQuery, DataTopic } from '@grafana/data';
1+
import { DataQuery } from '@grafana/data';
22
import { Chance } from 'chance';
33
import { undefinedOr } from './utils';
44

@@ -7,6 +7,5 @@ export const mockDataQuery = (): DataQuery => ({
77
hide: false,
88
key: Chance().guid(),
99
queryType: Chance().word(),
10-
dataTopic: DataTopic.Annotations,
1110
datasource: undefinedOr(() => Chance().word()),
1211
});

src/test/mocks/Datasource.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export const mockDatasource = (): DataSourceWithBackend => ({
3838
interpolateVariablesInQueries: jest.fn(),
3939
annotations: {},
4040
annotationQuery: jest.fn(),
41-
channelSupport: { getChannelConfig: jest.fn(), getSupportedPaths: jest.fn() },
41+
streamOptionsProvider: jest.fn(),
42+
getRef: jest.fn(),
4243
});
4344

4445
const mockQueryHint = (): QueryHint => ({
@@ -67,4 +68,5 @@ export const mockDatasourceInstanceSettings = (): DataSourceInstanceSettings =>
6768
database: Chance().word(),
6869
basicAuth: Chance().word(),
6970
withCredentials: generateBoolean(),
71+
access: Chance().pickone(["direct", "proxy"]),
7072
});

src/test/setupTests.ts

+14
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
11
import '@testing-library/jest-dom';
2+
3+
Object.defineProperty(global, 'matchMedia', {
4+
writable: true,
5+
value: jest.fn().mockImplementation((query) => ({
6+
matches: false,
7+
media: query,
8+
onchange: null,
9+
addListener: jest.fn(), // deprecated
10+
removeListener: jest.fn(), // deprecated
11+
addEventListener: jest.fn(),
12+
removeEventListener: jest.fn(),
13+
dispatchEvent: jest.fn(),
14+
})),
15+
});

0 commit comments

Comments
 (0)