Chore: some type fixes (#69860)
* some type fixes * restore empty object * undo 1 fix for now * commit betterer update * explicitly type slug and uid as string | undefined
This commit is contained in:
+13
-66
@@ -2006,23 +2006,13 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"]
|
||||
],
|
||||
"public/app/features/annotations/components/AnnotationResultMapper.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/annotations/events_processing.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/annotations/executeAnnotationQuery.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/annotations/standardAnnotationSupport.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, "Do not use any type assertions.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
|
||||
],
|
||||
"public/app/features/canvas/element.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@@ -2031,9 +2021,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
],
|
||||
"public/app/features/canvas/elements/notFound.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/canvas/runtime/element.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
@@ -2161,9 +2148,7 @@ exports[`better eslint`] = {
|
||||
"public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx: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, "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.", "2"]
|
||||
],
|
||||
"public/app/features/dashboard/components/PanelEditor/types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@@ -2198,9 +2183,6 @@ exports[`better eslint`] = {
|
||||
"public/app/features/dashboard/components/ShareModal/ShareExport.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.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"],
|
||||
@@ -2231,8 +2213,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"]
|
||||
],
|
||||
"public/app/features/dashboard/dashgrid/DashboardGrid.tsx: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.", "0"]
|
||||
],
|
||||
"public/app/features/dashboard/dashgrid/DashboardPanel.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@@ -2255,9 +2236,7 @@ exports[`better eslint`] = {
|
||||
"public/app/features/dashboard/services/DashboardLoaderSrv.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, "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.", "2"]
|
||||
],
|
||||
"public/app/features/dashboard/services/PublicDashboardDataSource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
@@ -2439,48 +2418,22 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/dashboard/state/reducers.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/dashboard/utils/getPanelMenu.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"],
|
||||
[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.", "0"]
|
||||
],
|
||||
"public/app/features/dashboard/utils/getPanelMenu.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "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.", "6"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "10"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "15"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"]
|
||||
],
|
||||
"public/app/features/dashboard/utils/panelMerge.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, "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, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "8"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
],
|
||||
"public/app/features/datasources/components/BasicSettings.tsx:5381": [
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
|
||||
@@ -2508,10 +2461,8 @@ exports[`better eslint`] = {
|
||||
],
|
||||
"public/app/features/datasources/state/actions.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, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"]
|
||||
],
|
||||
"public/app/features/datasources/state/navModel.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
@@ -2550,11 +2501,7 @@ exports[`better eslint`] = {
|
||||
],
|
||||
"public/app/features/dimensions/utils.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, "Unexpected any. Specify a different type.", "2"]
|
||||
],
|
||||
"public/app/features/explore/ElapsedTime.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/features/explore/ExplorePage.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
|
||||
@@ -130,7 +130,7 @@ export class AnnotationFieldMapper extends PureComponent<Props, State> {
|
||||
let value = first ? first[row.key] : '';
|
||||
if (value && row.key.startsWith('time')) {
|
||||
const fmt = getValueFormat('dateTimeAsIso');
|
||||
value = formattedValueToString(fmt(value as number));
|
||||
value = formattedValueToString(fmt(value));
|
||||
}
|
||||
if (value === null || value === undefined) {
|
||||
value = ''; // empty string
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, mergeMap } from 'rxjs/operators';
|
||||
|
||||
import { CoreApp, DataQueryRequest, DataSourceApi, rangeUtil, ScopedVars } from '@grafana/data';
|
||||
import { AnnotationQuery, CoreApp, DataQueryRequest, DataSourceApi, rangeUtil, ScopedVars } from '@grafana/data';
|
||||
|
||||
import { runRequest } from '../query/state/runRequest';
|
||||
|
||||
@@ -16,7 +16,7 @@ function getNextRequestId() {
|
||||
export function executeAnnotationQuery(
|
||||
options: AnnotationQueryOptions,
|
||||
datasource: DataSourceApi,
|
||||
savedJsonAnno: any
|
||||
savedJsonAnno: AnnotationQuery
|
||||
): Observable<AnnotationQueryResponse> {
|
||||
const processor = {
|
||||
...standardAnnotationSupport,
|
||||
|
||||
@@ -35,7 +35,7 @@ export const standardAnnotationSupport: AnnotationSupport = {
|
||||
mappings: {},
|
||||
};
|
||||
}
|
||||
return json as AnnotationQuery;
|
||||
return json;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -218,7 +218,7 @@ export function getAnnotationsFromData(
|
||||
};
|
||||
|
||||
for (const f of fields) {
|
||||
let v: any = undefined;
|
||||
let v = undefined;
|
||||
|
||||
if (f.text) {
|
||||
v = f.text; // TODO support templates!
|
||||
@@ -236,7 +236,7 @@ export function getAnnotationsFromData(
|
||||
if (f.split && typeof v === 'string') {
|
||||
v = v.split(',');
|
||||
}
|
||||
(anno as any)[f.key] = v;
|
||||
anno[f.key] = v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@ import React, { PureComponent } from 'react';
|
||||
|
||||
import { CanvasElementItem, CanvasElementProps } from '../element';
|
||||
|
||||
interface NotFoundConfig {
|
||||
orig?: any;
|
||||
}
|
||||
|
||||
class NotFoundDisplay extends PureComponent<CanvasElementProps<NotFoundConfig>> {
|
||||
class NotFoundDisplay extends PureComponent<CanvasElementProps> {
|
||||
render() {
|
||||
const { config } = this.props;
|
||||
return (
|
||||
@@ -18,7 +14,7 @@ class NotFoundDisplay extends PureComponent<CanvasElementProps<NotFoundConfig>>
|
||||
}
|
||||
}
|
||||
|
||||
export const notFoundItem: CanvasElementItem<NotFoundConfig> = {
|
||||
export const notFoundItem: CanvasElementItem = {
|
||||
id: 'not-found',
|
||||
name: 'Not found',
|
||||
description: 'Display when element type is not found in the registry',
|
||||
|
||||
@@ -152,10 +152,10 @@ export function fillOptionsPaneItems(
|
||||
supplier: PanelOptionsSupplier<any>,
|
||||
access: NestedValueAccess,
|
||||
getOptionsPaneCategory: categoryGetter,
|
||||
context: StandardEditorContext<any, any>,
|
||||
context: StandardEditorContext<any>,
|
||||
parentCategory?: OptionsPaneCategoryDescriptor
|
||||
) {
|
||||
const builder = new PanelOptionsEditorBuilder<any>();
|
||||
const builder = new PanelOptionsEditorBuilder();
|
||||
supplier(builder, context);
|
||||
|
||||
for (const pluginOption of builder.getItems()) {
|
||||
|
||||
@@ -155,10 +155,16 @@ export class ShareSnapshot extends PureComponent<Props, State> {
|
||||
});
|
||||
|
||||
// remove template queries
|
||||
dash.getVariables().forEach((variable: any) => {
|
||||
variable.query = '';
|
||||
variable.options = variable.current ? [variable.current] : [];
|
||||
variable.refresh = VariableRefresh.never;
|
||||
dash.getVariables().forEach((variable) => {
|
||||
if ('query' in variable) {
|
||||
variable.query = '';
|
||||
}
|
||||
if ('options' in variable) {
|
||||
variable.options = variable.current ? [variable.current] : [];
|
||||
}
|
||||
if ('refresh' in variable) {
|
||||
variable.refresh = VariableRefresh.never;
|
||||
}
|
||||
});
|
||||
|
||||
// snapshot single panel
|
||||
|
||||
@@ -272,10 +272,10 @@ export class DashboardGrid extends PureComponent<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
interface GrafanaGridItemProps extends Record<string, any> {
|
||||
interface GrafanaGridItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
gridWidth?: number;
|
||||
gridPos?: GridPos;
|
||||
isViewing: string;
|
||||
isViewing: boolean;
|
||||
windowHeight: number;
|
||||
windowWidth: number;
|
||||
children: any;
|
||||
@@ -306,8 +306,15 @@ const GrafanaGridItem = React.forwardRef<HTMLDivElement, GrafanaGridItemProps>((
|
||||
style.width = '100%';
|
||||
} else {
|
||||
// Normal grid layout. The grid framework passes width and height directly to children as style props.
|
||||
width = parseFloat(props.style.width);
|
||||
height = parseFloat(props.style.height);
|
||||
if (props.style) {
|
||||
const { width: styleWidth, height: styleHeight } = props.style;
|
||||
if (styleWidth != null) {
|
||||
width = typeof styleWidth === 'number' ? styleWidth : parseFloat(styleWidth);
|
||||
}
|
||||
if (styleHeight != null) {
|
||||
height = typeof styleHeight === 'number' ? styleHeight : parseFloat(styleHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// props.children[0] is our main children. RGL adds the drag handle at props.children[1]
|
||||
|
||||
@@ -34,18 +34,18 @@ export class DashboardLoaderSrv {
|
||||
};
|
||||
}
|
||||
|
||||
loadDashboard(type: UrlQueryValue, slug: any, uid: any): Promise<DashboardDTO> {
|
||||
loadDashboard(type: UrlQueryValue, slug: string | undefined, uid: string | undefined): Promise<DashboardDTO> {
|
||||
let promise;
|
||||
|
||||
if (type === 'script') {
|
||||
if (type === 'script' && slug) {
|
||||
promise = this._loadScriptedDashboard(slug);
|
||||
} else if (type === 'snapshot') {
|
||||
} else if (type === 'snapshot' && slug) {
|
||||
promise = backendSrv.get('/api/snapshots/' + slug).catch(() => {
|
||||
return this._dashboardLoadFailed('Snapshot not found', true);
|
||||
});
|
||||
} else if (type === 'ds') {
|
||||
} else if (type === 'ds' && slug) {
|
||||
promise = this._loadFromDatasource(slug); // explore dashboards as code
|
||||
} else if (type === 'public') {
|
||||
} else if (type === 'public' && uid) {
|
||||
promise = backendSrv
|
||||
.getPublicDashboardByUid(uid)
|
||||
.then((result) => {
|
||||
@@ -70,7 +70,7 @@ export class DashboardLoaderSrv {
|
||||
},
|
||||
};
|
||||
});
|
||||
} else {
|
||||
} else if (uid) {
|
||||
promise = backendSrv
|
||||
.getDashboardByUid(uid)
|
||||
.then((result) => {
|
||||
@@ -83,6 +83,8 @@ export class DashboardLoaderSrv {
|
||||
.catch(() => {
|
||||
return this._dashboardLoadFailed('Not found', true);
|
||||
});
|
||||
} else {
|
||||
throw new Error('Dashboard uid or slug required');
|
||||
}
|
||||
|
||||
promise.then((result: DashboardDTO) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||
|
||||
import { PanelPlugin } from '@grafana/data';
|
||||
import { AngularComponent } from '@grafana/runtime';
|
||||
import { Dashboard, defaultDashboard } from '@grafana/schema';
|
||||
import { defaultDashboard } from '@grafana/schema';
|
||||
import { processAclItems } from 'app/core/utils/acl';
|
||||
import { DashboardAclDTO, DashboardInitError, DashboardInitPhase, DashboardState } from 'app/types';
|
||||
|
||||
@@ -38,10 +38,8 @@ const dashboardSlice = createSlice({
|
||||
state.initPhase = DashboardInitPhase.Failed;
|
||||
state.initError = action.payload;
|
||||
state.getModel = () => {
|
||||
// TODO this is a type conflict,
|
||||
// we need to fix the defaultDashboard init type when generated by cue
|
||||
return new DashboardModel(
|
||||
{ ...(defaultDashboard as Dashboard), title: 'Dashboard init failed' },
|
||||
{ ...defaultDashboard, title: 'Dashboard init failed' },
|
||||
{ canSave: false, canEdit: false }
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Store } from 'redux';
|
||||
|
||||
import {
|
||||
dateTime,
|
||||
FieldType,
|
||||
@@ -8,7 +10,7 @@ import {
|
||||
PluginExtensionTypes,
|
||||
toDataFrame,
|
||||
} from '@grafana/data';
|
||||
import { getPluginExtensions } from '@grafana/runtime';
|
||||
import { AngularComponent, getPluginExtensions } from '@grafana/runtime';
|
||||
import config from 'app/core/config';
|
||||
import * as actions from 'app/features/explore/state/main';
|
||||
import { setStore } from 'app/store/store';
|
||||
@@ -292,9 +294,9 @@ describe('getPanelMenu()', () => {
|
||||
describe('when panel is in view mode', () => {
|
||||
it('should return the correct panel menu items', () => {
|
||||
const getExtendedMenu = () => [{ text: 'Toggle legend', shortcut: 'p l', click: jest.fn() }];
|
||||
const ctrl: any = { getExtendedMenu };
|
||||
const scope: any = { $$childHead: { ctrl } };
|
||||
const angularComponent: any = { getScope: () => scope };
|
||||
const ctrl = { getExtendedMenu };
|
||||
const scope = { $$childHead: { ctrl } };
|
||||
const angularComponent = { getScope: () => scope } as AngularComponent;
|
||||
const panel = new PanelModel({ isViewing: true });
|
||||
const dashboard = createDashboardModelFixture({});
|
||||
|
||||
@@ -363,7 +365,7 @@ describe('getPanelMenu()', () => {
|
||||
const windowOpen = jest.fn();
|
||||
let event: any;
|
||||
let explore: PanelMenuItem;
|
||||
let navigateSpy: any;
|
||||
let navigateSpy: jest.SpyInstance;
|
||||
|
||||
beforeAll(() => {
|
||||
const panel = new PanelModel({});
|
||||
@@ -378,7 +380,7 @@ describe('getPanelMenu()', () => {
|
||||
preventDefault: jest.fn(),
|
||||
};
|
||||
|
||||
setStore({ dispatch: jest.fn() } as any);
|
||||
setStore({ dispatch: jest.fn() } as unknown as Store);
|
||||
});
|
||||
|
||||
it('should navigate to url without subUrl', () => {
|
||||
|
||||
@@ -36,7 +36,7 @@ export function getPanelMenu(
|
||||
panel: PanelModel,
|
||||
angularComponent?: AngularComponent | null
|
||||
): PanelMenuItem[] {
|
||||
const onViewPanel = (event: React.MouseEvent<any>) => {
|
||||
const onViewPanel = (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
locationService.partial({
|
||||
viewPanel: panel.id,
|
||||
@@ -44,7 +44,7 @@ export function getPanelMenu(
|
||||
reportInteraction('dashboards_panelheader_menu', { item: 'view' });
|
||||
};
|
||||
|
||||
const onEditPanel = (event: React.MouseEvent<any>) => {
|
||||
const onEditPanel = (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
locationService.partial({
|
||||
editPanel: panel.id,
|
||||
@@ -53,19 +53,19 @@ export function getPanelMenu(
|
||||
reportInteraction('dashboards_panelheader_menu', { item: 'edit' });
|
||||
};
|
||||
|
||||
const onSharePanel = (event: React.MouseEvent<any>) => {
|
||||
const onSharePanel = (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
sharePanel(dashboard, panel);
|
||||
reportInteraction('dashboards_panelheader_menu', { item: 'share' });
|
||||
};
|
||||
|
||||
const onAddLibraryPanel = (event: React.MouseEvent<any>) => {
|
||||
const onAddLibraryPanel = (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
addLibraryPanel(dashboard, panel);
|
||||
reportInteraction('dashboards_panelheader_menu', { item: 'createLibraryPanel' });
|
||||
};
|
||||
|
||||
const onUnlinkLibraryPanel = (event: React.MouseEvent<any>) => {
|
||||
const onUnlinkLibraryPanel = (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
unlinkLibraryPanel(panel);
|
||||
reportInteraction('dashboards_panelheader_menu', { item: 'unlinkLibraryPanel' });
|
||||
@@ -79,29 +79,29 @@ export function getPanelMenu(
|
||||
reportInteraction('dashboards_panelheader_menu', { item: 'inspect', tab: tab ?? InspectTab.Data });
|
||||
};
|
||||
|
||||
const onMore = (event: React.MouseEvent<any>) => {
|
||||
const onMore = (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
const onDuplicatePanel = (event: React.MouseEvent<any>) => {
|
||||
const onDuplicatePanel = (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
duplicatePanel(dashboard, panel);
|
||||
reportInteraction('dashboards_panelheader_menu', { item: 'duplicate' });
|
||||
};
|
||||
|
||||
const onCopyPanel = (event: React.MouseEvent<any>) => {
|
||||
const onCopyPanel = (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
copyPanel(panel);
|
||||
reportInteraction('dashboards_panelheader_menu', { item: 'copy' });
|
||||
};
|
||||
|
||||
const onRemovePanel = (event: React.MouseEvent<any>) => {
|
||||
const onRemovePanel = (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
removePanel(dashboard, panel, true);
|
||||
reportInteraction('dashboards_panelheader_menu', { item: 'remove' });
|
||||
};
|
||||
|
||||
const onNavigateToExplore = (event: React.MouseEvent<any>) => {
|
||||
const onNavigateToExplore = (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
const openInNewWindow =
|
||||
event.ctrlKey || event.metaKey ? (url: string) => window.open(`${config.appSubUrl}${url}`) : undefined;
|
||||
@@ -161,20 +161,20 @@ export function getPanelMenu(
|
||||
if (panel.plugin && !panel.plugin.meta.skipDataQuery) {
|
||||
inspectMenu.push({
|
||||
text: t('panel.header-menu.inspect-data', `Data`),
|
||||
onClick: (e: React.MouseEvent<any>) => onInspectPanel(InspectTab.Data),
|
||||
onClick: (e: React.MouseEvent) => onInspectPanel(InspectTab.Data),
|
||||
});
|
||||
|
||||
if (dashboard.meta.canEdit) {
|
||||
inspectMenu.push({
|
||||
text: t('panel.header-menu.query', `Query`),
|
||||
onClick: (e: React.MouseEvent<any>) => onInspectPanel(InspectTab.Query),
|
||||
onClick: (e: React.MouseEvent) => onInspectPanel(InspectTab.Query),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
inspectMenu.push({
|
||||
text: t('panel.header-menu.inspect-json', `Panel JSON`),
|
||||
onClick: (e: React.MouseEvent<any>) => onInspectPanel(InspectTab.JSON),
|
||||
onClick: (e: React.MouseEvent) => onInspectPanel(InspectTab.JSON),
|
||||
});
|
||||
|
||||
menu.push({
|
||||
|
||||
@@ -16,14 +16,14 @@ const mutableKeys = new Set<keyof PanelModel>(['gridPos', 'title', 'description'
|
||||
|
||||
export function mergePanels(current: PanelModel[], data: IPanelModel[]): PanelMergeInfo {
|
||||
const panels: PanelModel[] = [];
|
||||
const info = {
|
||||
const info: PanelMergeInfo = {
|
||||
changed: false,
|
||||
actions: {
|
||||
add: [] as number[],
|
||||
remove: [] as number[],
|
||||
replace: [] as number[],
|
||||
update: [] as number[],
|
||||
noop: [] as number[],
|
||||
add: [],
|
||||
remove: [],
|
||||
replace: [],
|
||||
update: [],
|
||||
noop: [],
|
||||
},
|
||||
panels,
|
||||
};
|
||||
@@ -110,7 +110,7 @@ export function mergePanels(current: PanelModel[], data: IPanelModel[]): PanelMe
|
||||
}
|
||||
|
||||
// Since +- Infinity are saved as null in JSON, we need to make them equal here also
|
||||
function infinityEqualsNull(a: any, b: any) {
|
||||
function infinityEqualsNull(a: unknown, b: unknown) {
|
||||
if (a == null && (b === Infinity || b === -Infinity || b == null)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DataSourcePluginMeta, DataSourceSettings, locationUtil } from '@grafana/data';
|
||||
import { DataSourcePluginMeta, DataSourceSettings, locationUtil, TestDataSourceResponse } from '@grafana/data';
|
||||
import {
|
||||
config,
|
||||
DataSourceWithBackend,
|
||||
@@ -79,14 +79,8 @@ const parseHealthCheckError = (errorResponse: any): parseDataSourceSaveResponse
|
||||
return { message, details };
|
||||
};
|
||||
|
||||
const parseHealthCheckSuccess = (response: any): parseDataSourceSaveResponse => {
|
||||
let message: string | undefined;
|
||||
let status: string;
|
||||
let details: { message?: string; verboseMessage?: string };
|
||||
|
||||
status = response.status;
|
||||
message = response.message;
|
||||
details = response.details;
|
||||
const parseHealthCheckSuccess = (response: TestDataSourceResponse): parseDataSourceSaveResponse => {
|
||||
const { details, message, status } = response;
|
||||
|
||||
return { status, message, details };
|
||||
};
|
||||
@@ -282,7 +276,7 @@ export function updateDataSource(dataSource: DataSourceSettings) {
|
||||
) => {
|
||||
try {
|
||||
await api.updateDataSource(dataSource);
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
const formattedError = parseHealthCheckError(err);
|
||||
|
||||
dispatch(testDataSourceFailed(formattedError));
|
||||
|
||||
@@ -120,7 +120,7 @@ export function getLastNotNullFieldValue<T>(field: Field): T {
|
||||
if (calcs) {
|
||||
const v = calcs[ReducerID.lastNotNull];
|
||||
if (v != null) {
|
||||
return v as T;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ const INTERVAL = 150;
|
||||
export interface ElapsedTimeProps extends Omit<TimeProps, 'timeInMs'> {
|
||||
// Use this to reset the timer. Any value is allowed just need to be !== from the previous.
|
||||
// Keep in mind things like [] !== [] or {} !== {}.
|
||||
resetKey?: any;
|
||||
resetKey?: unknown;
|
||||
}
|
||||
|
||||
export const ElapsedTime = ({ resetKey, humanize, className }: ElapsedTimeProps) => {
|
||||
|
||||
+3
-5
@@ -195,8 +195,7 @@ export default class ListView extends React.Component<TListViewProps> {
|
||||
this._htmlTopOffset = -1;
|
||||
this._windowScrollListenerAdded = false;
|
||||
// _htmlElm is only relevant if props.windowScroller is true
|
||||
// eslint-disable-next-line
|
||||
this._htmlElm = document.documentElement as any;
|
||||
this._htmlElm = document.documentElement;
|
||||
this._wrapperElm = undefined;
|
||||
this._itemHolderElm = undefined;
|
||||
}
|
||||
@@ -379,8 +378,7 @@ export default class ListView extends React.Component<TListViewProps> {
|
||||
const nodes = this._itemHolderElm.childNodes;
|
||||
const max = nodes.length;
|
||||
for (let i = 0; i < max; i++) {
|
||||
// eslint-disable-next-line
|
||||
const node: HTMLElement = nodes[i] as any;
|
||||
const node = nodes[i] as HTMLElement;
|
||||
// use `.getAttribute(...)` instead of `.dataset` for jest / JSDOM
|
||||
const itemKey = node.getAttribute('data-item-key');
|
||||
if (!itemKey) {
|
||||
@@ -492,7 +490,7 @@ export default class ListView extends React.Component<TListViewProps> {
|
||||
wrapperProps.style.overflowY = 'auto';
|
||||
}
|
||||
const scrollerStyle = {
|
||||
position: 'relative' as 'relative',
|
||||
position: 'relative' as const,
|
||||
height: this._yPositions.getEstimatedHeight(),
|
||||
};
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user