mirror of
https://github.com/grafana/grafana.git
synced 2024-12-24 16:10:22 -06:00
Chore: fix some more types (#76535)
* clean up some e2e/runtime types * fix some stories * some more fixes * fix route props * update unit tests * update more unit tests * don't throw here
This commit is contained in:
parent
272a901e5e
commit
ced065c7e9
@ -5,24 +5,8 @@
|
||||
//
|
||||
exports[`better eslint`] = {
|
||||
value: `{
|
||||
"e2e/cypress/support/index.d.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"e2e/utils/flows/addDataSource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"e2e/utils/support/scenarioContext.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"e2e/utils/support/types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "6"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "7"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-data/src/dataframe/ArrayDataFrame.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -732,31 +716,15 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"]
|
||||
],
|
||||
"packages/grafana-runtime/src/services/live.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-runtime/src/utils/DataSourceWithBackend.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
|
||||
],
|
||||
"packages/grafana-runtime/src/utils/plugin.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-runtime/src/utils/queryResponse.test.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
|
||||
],
|
||||
"packages/grafana-runtime/src/utils/queryResponse.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
],
|
||||
"packages/grafana-runtime/src/utils/queryResponse.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-schema/src/veneer/common.types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@ -816,12 +784,6 @@ exports[`better eslint`] = {
|
||||
"packages/grafana-ui/src/components/Drawer/Drawer.tsx:5381": [
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Forms/FieldArray.story.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Forms/Legacy/Input/Input.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
@ -871,28 +833,16 @@ exports[`better eslint`] = {
|
||||
"packages/grafana-ui/src/components/InfoBox/InfoBox.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/JSONFormatter/JSONFormatter.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/JSONFormatter/json_explorer/json_explorer.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Layout/Layout.story.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/MatchersUI/FieldValueMatcher.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/MatchersUI/fieldMatchersUI.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Menu/MenuGroup.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Menu/MenuItem.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Menu/SubMenu.tsx:5381": [
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"],
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"]
|
||||
@ -901,9 +851,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Monaco/CodeEditor.tsx:5381": [
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
|
||||
@ -922,11 +870,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/QueryField/QueryField.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Segment/SegmentAsync.story.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Segment/SegmentSelect.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
@ -1040,14 +984,6 @@ exports[`better eslint`] = {
|
||||
"packages/grafana-ui/src/components/Tags/Tag.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/TimeSeries/utils.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
@ -1556,10 +1492,6 @@ exports[`better eslint`] = {
|
||||
"public/app/core/navigation/GrafanaRouteError.tsx:5381": [
|
||||
[0, 0, 0, "Styles should be written using objects.", "0"]
|
||||
],
|
||||
"public/app/core/navigation/__mocks__/routeProps.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/core/navigation/types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
|
2
e2e/cypress/support/index.d.ts
vendored
2
e2e/cypress/support/index.d.ts
vendored
@ -8,7 +8,7 @@ interface CompareScreenshotsConfig {
|
||||
declare namespace Cypress {
|
||||
interface Chainable {
|
||||
compareScreenshots(config: CompareScreenshotsConfig | string): Chainable;
|
||||
logToConsole(message: string, optional?: any): void;
|
||||
logToConsole(message: string, optional?: unknown): void;
|
||||
readProvisions(filePaths: string[]): Chainable;
|
||||
getJSONFilesFromDir(dirPath: string): Chainable;
|
||||
startBenchmarking(testName: string): void;
|
||||
|
@ -2,8 +2,6 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { e2e } from '../index';
|
||||
|
||||
import { DeleteDataSourceConfig } from './deleteDataSource';
|
||||
|
||||
export interface AddDataSourceConfig {
|
||||
basicAuth: boolean;
|
||||
basicAuthPassword: string;
|
||||
@ -96,7 +94,7 @@ export const addDataSource = (config?: Partial<AddDataSourceConfig>) => {
|
||||
return cy.url().then(() => {
|
||||
e2e.getScenarioContext().then(({ addedDataSources }) => {
|
||||
e2e.setScenarioContext({
|
||||
addedDataSources: [...addedDataSources, { name } as DeleteDataSourceConfig],
|
||||
addedDataSources: [...addedDataSources, { name, id: '' }],
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -9,7 +9,6 @@ export interface ScenarioContext {
|
||||
lastAddedDataSource: string; // @todo rename to `lastAddedDataSourceName`
|
||||
lastAddedDataSourceId: string;
|
||||
hasChangedUserPreferences: boolean;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
const scenarioContext: ScenarioContext = {
|
||||
@ -50,9 +49,7 @@ export const setScenarioContext = (newContext: Partial<ScenarioContext>): Cypres
|
||||
.wrap(
|
||||
{
|
||||
setScenarioContext: () => {
|
||||
Object.entries(newContext).forEach(([key, value]) => {
|
||||
scenarioContext[key] = value;
|
||||
});
|
||||
Object.assign(scenarioContext, newContext);
|
||||
},
|
||||
},
|
||||
{ log: false }
|
||||
|
@ -17,7 +17,7 @@ export type TypeSelectors<S> = S extends StringSelector
|
||||
? E2EFunction
|
||||
: S extends UrlSelector
|
||||
? E2EVisit & Omit<E2EFunctions<S>, 'url'>
|
||||
: S extends Record<any, any>
|
||||
: S extends Record<string, string | FunctionSelector | CssSelector | UrlSelector | Selectors>
|
||||
? E2EFunctions<S>
|
||||
: S;
|
||||
|
||||
@ -32,7 +32,7 @@ export type E2EFactoryArgs<S extends Selectors> = { selectors: S };
|
||||
export type CypressOptions = Partial<Cypress.Loggable & Cypress.Timeoutable & Cypress.Withinable & Cypress.Shadow>;
|
||||
|
||||
const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, selectors: S): E2EFunctions<S> => {
|
||||
const logOutput = (data: any) => cy.logToConsole('Retrieving Selector:', data);
|
||||
const logOutput = (data: unknown) => cy.logToConsole('Retrieving Selector:', data);
|
||||
const keys = Object.keys(selectors);
|
||||
for (let index = 0; index < keys.length; index++) {
|
||||
const key = keys[index];
|
||||
@ -80,7 +80,7 @@ const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, sele
|
||||
e2eObjects[key] = function (textOrOptions?: string | CypressOptions, options?: CypressOptions) {
|
||||
// the input can only be ()
|
||||
if (arguments.length === 0) {
|
||||
const selector = value(undefined as unknown as string);
|
||||
const selector = value('');
|
||||
|
||||
logOutput(selector);
|
||||
return cy.get(selector);
|
||||
@ -97,7 +97,7 @@ const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, sele
|
||||
logOutput(selector);
|
||||
return cy.get(selector);
|
||||
}
|
||||
const selector = value(undefined as unknown as string);
|
||||
const selector = value('');
|
||||
|
||||
logOutput(selector);
|
||||
return cy.get(selector, textOrOptions);
|
||||
|
@ -79,7 +79,7 @@ export interface GrafanaLiveSrv {
|
||||
*
|
||||
* @alpha -- experimental
|
||||
*/
|
||||
publish(address: LiveChannelAddress, data: unknown): Promise<any>;
|
||||
publish(address: LiveChannelAddress, data: unknown): Promise<unknown>;
|
||||
}
|
||||
|
||||
let singletonInstance: GrafanaLiveSrv;
|
||||
|
@ -11,6 +11,7 @@ import {
|
||||
createDataFrame,
|
||||
AdHocVariableFilter,
|
||||
ScopedVars,
|
||||
getDefaultTimeRange,
|
||||
} from '@grafana/data';
|
||||
|
||||
import { config } from '../config';
|
||||
@ -61,6 +62,15 @@ jest.mock('../services', () => ({
|
||||
jest.mock('./publicDashboardQueryHandler');
|
||||
|
||||
describe('DataSourceWithBackend', () => {
|
||||
beforeEach(async () => {
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date('2023-10-13'));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
test('check the executed queries', () => {
|
||||
const { mock, ds } = createMockDatasource();
|
||||
ds.query({
|
||||
@ -70,6 +80,7 @@ describe('DataSourceWithBackend', () => {
|
||||
dashboardUID: 'dashA',
|
||||
panelId: 123,
|
||||
filters: [{ key: 'key1', operator: '=', value: 'val1' }],
|
||||
range: getDefaultTimeRange(),
|
||||
queryGroupId: 'abc',
|
||||
} as DataQueryRequest);
|
||||
|
||||
@ -79,6 +90,7 @@ describe('DataSourceWithBackend', () => {
|
||||
expect(args).toMatchInlineSnapshot(`
|
||||
{
|
||||
"data": {
|
||||
"from": "1697133600000",
|
||||
"queries": [
|
||||
{
|
||||
"applyTemplateVariablesCalled": true,
|
||||
@ -111,6 +123,7 @@ describe('DataSourceWithBackend', () => {
|
||||
"refId": "B",
|
||||
},
|
||||
],
|
||||
"to": "1697155200000",
|
||||
},
|
||||
"headers": {
|
||||
"X-Dashboard-Uid": "dashA",
|
||||
@ -135,6 +148,7 @@ describe('DataSourceWithBackend', () => {
|
||||
targets: [{ refId: 'A' }, { refId: 'B', datasource: { type: '__expr__' } }],
|
||||
dashboardUID: 'dashA',
|
||||
panelId: 123,
|
||||
range: getDefaultTimeRange(),
|
||||
queryGroupId: 'abc',
|
||||
} as DataQueryRequest);
|
||||
|
||||
@ -144,6 +158,7 @@ describe('DataSourceWithBackend', () => {
|
||||
expect(args).toMatchInlineSnapshot(`
|
||||
{
|
||||
"data": {
|
||||
"from": "1697133600000",
|
||||
"queries": [
|
||||
{
|
||||
"applyTemplateVariablesCalled": true,
|
||||
@ -167,6 +182,7 @@ describe('DataSourceWithBackend', () => {
|
||||
"refId": "B",
|
||||
},
|
||||
],
|
||||
"to": "1697155200000",
|
||||
},
|
||||
"headers": {
|
||||
"X-Dashboard-Uid": "dashA",
|
||||
@ -190,6 +206,7 @@ describe('DataSourceWithBackend', () => {
|
||||
ds.query({
|
||||
maxDataPoints: 10,
|
||||
intervalMs: 5000,
|
||||
range: getDefaultTimeRange(),
|
||||
targets: [{ refId: 'A' }, { refId: 'B', datasource: { type: 'sample' } }],
|
||||
} as DataQueryRequest);
|
||||
|
||||
@ -205,6 +222,7 @@ describe('DataSourceWithBackend', () => {
|
||||
targets: [{ refId: 'A' }, { refId: 'B', datasource: { type: 'sample' } }],
|
||||
hideFromInspector: true,
|
||||
dashboardUID: 'dashA',
|
||||
range: getDefaultTimeRange(),
|
||||
panelId: 123,
|
||||
} as DataQueryRequest);
|
||||
|
||||
@ -214,6 +232,7 @@ describe('DataSourceWithBackend', () => {
|
||||
expect(args).toMatchInlineSnapshot(`
|
||||
{
|
||||
"data": {
|
||||
"from": "1697133600000",
|
||||
"queries": [
|
||||
{
|
||||
"applyTemplateVariablesCalled": true,
|
||||
@ -240,6 +259,7 @@ describe('DataSourceWithBackend', () => {
|
||||
"refId": "B",
|
||||
},
|
||||
],
|
||||
"to": "1697155200000",
|
||||
},
|
||||
"headers": {
|
||||
"X-Dashboard-Uid": "dashA",
|
||||
@ -353,6 +373,7 @@ describe('DataSourceWithBackend', () => {
|
||||
dashboardUID: 'dashA',
|
||||
panelId: 123,
|
||||
queryGroupId: 'abc',
|
||||
range: getDefaultTimeRange(),
|
||||
} as DataQueryRequest;
|
||||
|
||||
ds.query(request);
|
||||
@ -371,6 +392,7 @@ describe('DataSourceWithBackend', () => {
|
||||
dashboardUID: 'dashA',
|
||||
panelId: 123,
|
||||
queryGroupId: 'abc',
|
||||
range: getDefaultTimeRange(),
|
||||
} as DataQueryRequest;
|
||||
|
||||
ds.query(request);
|
||||
|
@ -190,12 +190,11 @@ class DataSourceWithBackend<
|
||||
return of({ data: [] });
|
||||
}
|
||||
|
||||
const body: any = { queries };
|
||||
|
||||
if (range) {
|
||||
body.from = range.from.valueOf().toString();
|
||||
body.to = range.to.valueOf().toString();
|
||||
}
|
||||
const body = {
|
||||
queries,
|
||||
from: range?.from.valueOf().toString(),
|
||||
to: range?.to.valueOf().toString(),
|
||||
};
|
||||
|
||||
if (config.featureToggles.queryOverLive) {
|
||||
return getGrafanaLiveSrv().getQueryData({
|
||||
|
@ -31,10 +31,10 @@ export const SystemJS = window.System;
|
||||
* @param options - plugin styling for light and dark theme.
|
||||
* @public
|
||||
*/
|
||||
export async function loadPluginCss(options: PluginCssOptions): Promise<any> {
|
||||
export async function loadPluginCss(options: PluginCssOptions): Promise<System.Module | void> {
|
||||
try {
|
||||
const cssPath = config.bootData.user.theme === 'light' ? options.light : options.dark;
|
||||
return await SystemJS.import(cssPath);
|
||||
return SystemJS.import(cssPath);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
@ -262,13 +262,13 @@ describe('Query Response parser', () => {
|
||||
data: {
|
||||
results: {
|
||||
X: {
|
||||
series: [{ name: 'Requests/s', points: [[13.594958983547151, 1611839862951]] }] as any,
|
||||
series: [{ target: '', datapoints: [[13.594958983547151, 1611839862951]] }],
|
||||
},
|
||||
B: {
|
||||
series: [{ name: 'Requests/s', points: [[13.594958983547151, 1611839862951]] }] as any,
|
||||
series: [{ target: '', datapoints: [[13.594958983547151, 1611839862951]] }],
|
||||
},
|
||||
A: {
|
||||
series: [{ name: 'Requests/s', points: [[13.594958983547151, 1611839862951]] }] as any,
|
||||
series: [{ target: '', datapoints: [[13.594958983547151, 1611839862951]] }],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -73,10 +73,11 @@ export function toDataQueryResponse(
|
||||
}
|
||||
|
||||
// If the response isn't in a correct shape we just ignore the data and pass empty DataQueryResponse.
|
||||
if ((res as FetchResponse).data?.results) {
|
||||
const results = (res as FetchResponse).data.results;
|
||||
const fetchResponse = res as FetchResponse;
|
||||
if (fetchResponse.data?.results) {
|
||||
const results = fetchResponse.data.results;
|
||||
const refIDs = queries?.length ? queries.map((q) => q.refId) : Object.keys(results);
|
||||
const cachedResponse = isCachedResponse(res as FetchResponse);
|
||||
const cachedResponse = isCachedResponse(fetchResponse);
|
||||
const data: DataResponse[] = [];
|
||||
|
||||
for (const refId of refIDs) {
|
||||
@ -144,7 +145,7 @@ export function toDataQueryResponse(
|
||||
}
|
||||
|
||||
// When it is not an OK response, make sure the error gets added
|
||||
if ((res as FetchResponse).status && (res as FetchResponse).status !== 200) {
|
||||
if (fetchResponse.status && fetchResponse.status !== 200) {
|
||||
if (rsp.state !== LoadingState.Error) {
|
||||
rsp.state = LoadingState.Error;
|
||||
}
|
||||
|
@ -89,6 +89,9 @@ const ButtonSelectComponent = <T,>(props: Props<T>) => {
|
||||
|
||||
ButtonSelectComponent.displayName = 'ButtonSelect';
|
||||
|
||||
// needed to properly forward the generic type through React.memo
|
||||
// see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/37087#issuecomment-656596623
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
export const ButtonSelect = React.memo(ButtonSelectComponent) as typeof ButtonSelectComponent;
|
||||
|
||||
const getStyles = (theme: GrafanaTheme2) => {
|
||||
|
@ -9,7 +9,7 @@ import { withStoryContainer } from '../../utils/storybook/withStoryContainer';
|
||||
import { FieldArray } from './FieldArray';
|
||||
import mdx from './FieldArray.mdx';
|
||||
|
||||
export default {
|
||||
const meta: Meta = {
|
||||
title: 'Forms/FieldArray',
|
||||
component: FieldArray,
|
||||
decorators: [withStoryContainer],
|
||||
@ -25,7 +25,9 @@ export default {
|
||||
containerWidth: { control: { type: 'range', min: 100, max: 500, step: 10 } },
|
||||
containerHeight: { control: { type: 'range', min: 100, max: 500, step: 10 } },
|
||||
},
|
||||
} as Meta;
|
||||
};
|
||||
|
||||
export default meta;
|
||||
|
||||
export const Simple: Story = (args) => {
|
||||
const defaultValues: FieldValues = {
|
||||
|
@ -7,7 +7,7 @@ interface Props {
|
||||
json: {};
|
||||
config?: JsonExplorerConfig;
|
||||
open?: number;
|
||||
onDidRender?: (formattedJson: any) => void;
|
||||
onDidRender?: (formattedJson: {}) => void;
|
||||
}
|
||||
|
||||
export class JSONFormatter extends PureComponent<Props> {
|
||||
|
@ -8,7 +8,7 @@ import { withStoryContainer } from '../../utils/storybook/withStoryContainer';
|
||||
import { Layout, LayoutProps } from './Layout';
|
||||
import mdx from './Layout.mdx';
|
||||
|
||||
export default {
|
||||
const meta: Meta = {
|
||||
title: 'Layout/Groups',
|
||||
component: Layout,
|
||||
decorators: [withStoryContainer],
|
||||
@ -56,7 +56,9 @@ export default {
|
||||
},
|
||||
},
|
||||
},
|
||||
} as Meta;
|
||||
};
|
||||
|
||||
export default meta;
|
||||
|
||||
export const Horizontal: Story<LayoutProps> = (args) => {
|
||||
return (
|
||||
|
@ -9,7 +9,7 @@ import { useStyles2 } from '../../themes';
|
||||
import { MenuItemProps } from './MenuItem';
|
||||
|
||||
/** @internal */
|
||||
export interface MenuItemsGroup<T = any> {
|
||||
export interface MenuItemsGroup<T = unknown> {
|
||||
/** Label for the menu items group */
|
||||
label?: string;
|
||||
/** Aria label for accessibility support */
|
||||
|
@ -14,7 +14,7 @@ import { SubMenu } from './SubMenu';
|
||||
export type MenuItemElement = HTMLAnchorElement & HTMLButtonElement & HTMLDivElement;
|
||||
|
||||
/** @internal */
|
||||
export interface MenuItemProps<T = any> {
|
||||
export interface MenuItemProps<T = unknown> {
|
||||
/** Label of the menu item */
|
||||
label: string;
|
||||
/** Aria label for accessibility support */
|
||||
|
@ -33,7 +33,7 @@ export class ModalsProvider extends Component<ModalsProviderProps, ModalsContext
|
||||
};
|
||||
}
|
||||
|
||||
showModal = (component: React.ComponentType<any>, props: any) => {
|
||||
showModal = <T,>(component: React.ComponentType<T>, props: T) => {
|
||||
this.setState({
|
||||
component,
|
||||
props,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { css, cx } from '@emotion/css';
|
||||
import classnames from 'classnames';
|
||||
import { debounce } from 'lodash';
|
||||
import React, { Context, PureComponent } from 'react';
|
||||
import React, { PureComponent } from 'react';
|
||||
import { Value } from 'slate';
|
||||
import Plain from 'slate-plain-serializer';
|
||||
import { Editor, EventHook, Plugin } from 'slate-react';
|
||||
@ -67,8 +67,8 @@ export class UnThemedQueryField extends PureComponent<QueryFieldProps, QueryFiel
|
||||
mounted = false;
|
||||
editor: Editor | null = null;
|
||||
|
||||
constructor(props: QueryFieldProps, context: Context<any>) {
|
||||
super(props, context);
|
||||
constructor(props: QueryFieldProps) {
|
||||
super(props);
|
||||
|
||||
this.runOnChangeDebounced = debounce(this.runOnChange, 500);
|
||||
|
||||
|
@ -22,7 +22,12 @@ const loadOptions = <T,>(options: T): Promise<T> => new Promise((res) => setTime
|
||||
const loadOptionsErr = (): Promise<Array<SelectableValue<string>>> =>
|
||||
new Promise((_, rej) => setTimeout(() => rej(Error('Could not find data')), 2000));
|
||||
|
||||
const SegmentFrame = ({ loadOptions, children }: any) => (
|
||||
const SegmentFrame = ({
|
||||
loadOptions,
|
||||
children,
|
||||
}: React.PropsWithChildren<{
|
||||
loadOptions: (options: Array<SelectableValue<string>>) => Promise<Array<SelectableValue<string>>>;
|
||||
}>) => (
|
||||
<>
|
||||
<SegmentSection label="Segment Name">
|
||||
{children}
|
||||
|
@ -174,8 +174,8 @@ export const ThemeDemo = () => {
|
||||
<CollapsableSection label="Shadows" isOpen={true}>
|
||||
<DemoBox bg={t.colors.background.primary}>
|
||||
<HorizontalGroup>
|
||||
{Object.keys(t.shadows).map((key) => (
|
||||
<ShadowDemo name={key} shadow={(t.shadows as any)[key]} key={key} />
|
||||
{Object.entries(t.shadows).map(([key, value]) => (
|
||||
<ShadowDemo name={key} shadow={value} key={key} />
|
||||
))}
|
||||
</HorizontalGroup>
|
||||
</DemoBox>
|
||||
|
@ -4,7 +4,7 @@ import { DataFrame, TimeRange } from '@grafana/data';
|
||||
|
||||
import { withTheme2 } from '../../themes/ThemeContext';
|
||||
import { GraphNG, GraphNGProps, PropDiffFn } from '../GraphNG/GraphNG';
|
||||
import { PanelContext, PanelContextRoot } from '../PanelChrome/PanelContext';
|
||||
import { PanelContextRoot } from '../PanelChrome/PanelContext';
|
||||
import { hasVisibleLegendSeries, PlotLegend } from '../uPlot/PlotLegend';
|
||||
import { UPlotConfigBuilder } from '../uPlot/config/UPlotConfigBuilder';
|
||||
|
||||
@ -16,10 +16,10 @@ type TimeSeriesProps = Omit<GraphNGProps, 'prepConfig' | 'propsToDiff' | 'render
|
||||
|
||||
export class UnthemedTimeSeries extends Component<TimeSeriesProps> {
|
||||
static contextType = PanelContextRoot;
|
||||
panelContext: PanelContext = {} as PanelContext;
|
||||
declare context: React.ContextType<typeof PanelContextRoot>;
|
||||
|
||||
prepConfig = (alignedFrame: DataFrame, allFrames: DataFrame[], getTimeRange: () => TimeRange) => {
|
||||
const { eventBus, eventsScope, sync } = this.context as PanelContext;
|
||||
const { eventBus, eventsScope, sync } = this.context;
|
||||
const { theme, timeZone, renderers, tweakAxis, tweakScale } = this.props;
|
||||
|
||||
return preparePlotConfigBuilder({
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { createMemoryHistory } from 'history';
|
||||
import { merge } from 'lodash';
|
||||
import { match } from 'react-router-dom';
|
||||
|
||||
import { GrafanaRouteComponentProps } from '../types';
|
||||
|
||||
@ -14,12 +15,12 @@ export function getRouteComponentProps<T extends {} = {}, Q extends Record<strin
|
||||
state: {},
|
||||
search: '',
|
||||
},
|
||||
match: { params: {} } as any,
|
||||
match: { params: {} } as match<T>,
|
||||
route: {
|
||||
path: '',
|
||||
component: () => null,
|
||||
},
|
||||
queryParams: {} as any,
|
||||
queryParams: {} as Q,
|
||||
};
|
||||
|
||||
return merge(overrides, defaults);
|
||||
|
@ -130,7 +130,7 @@ describe('InfluxDataSource Backend Mode', () => {
|
||||
...queryOptions,
|
||||
targets: [...queryOptions.targets, { ...influxQuery, adhocFilters }],
|
||||
};
|
||||
await ctx.ds.query(req);
|
||||
ctx.ds.query(req);
|
||||
});
|
||||
|
||||
it('should add adhocFilters to the tags in the query', () => {
|
||||
@ -244,6 +244,7 @@ describe('InfluxDataSource Backend Mode', () => {
|
||||
|
||||
it('should render chained regex variables with floating point number', () => {
|
||||
ds.metricFindQuery(`SELECT sum("piece_count") FROM "rp"."pdata" WHERE diameter <= $maxSED`, {
|
||||
...queryOptions,
|
||||
scopedVars: { maxSED: { text: '8.1', value: '8.1' } },
|
||||
});
|
||||
const qe = `SELECT sum("piece_count") FROM "rp"."pdata" WHERE diameter <= 8.1`;
|
||||
@ -253,6 +254,7 @@ describe('InfluxDataSource Backend Mode', () => {
|
||||
|
||||
it('should render chained regex variables with URL', () => {
|
||||
ds.metricFindQuery('SHOW TAG VALUES WITH KEY = "agent_url" WHERE agent_url =~ /^$var1$/', {
|
||||
...queryOptions,
|
||||
scopedVars: {
|
||||
var1: {
|
||||
text: 'https://aaaa-aa-aaa.bbb.ccc.ddd:8443/ggggg',
|
||||
@ -269,6 +271,7 @@ describe('InfluxDataSource Backend Mode', () => {
|
||||
ds.metricFindQuery(
|
||||
'SELECT sum("piece_count") FROM "rp"."pdata" WHERE diameter <= $maxSED AND agent_url =~ /^$var1$/',
|
||||
{
|
||||
...queryOptions,
|
||||
scopedVars: {
|
||||
var1: {
|
||||
text: 'https://aaaa-aa-aaa.bbb.ccc.ddd:8443/ggggg',
|
||||
|
Loading…
Reference in New Issue
Block a user