mirror of https://github.com/grafana/grafana.git
WIP Chore: reduce strict errors (#40462)
* Chore: reduce strict error in ngReact * Chore: reduce strict errors for ShareModal * Chore: reduce strict errors in VersioHistory * Chore: reduce strict error in ExpressionDatasource * Chore: reduce strict error in DashboardWatcher * Chore: reduce strict error in PluginPage * Chore: reduce strict errors for guard * Chore: update threshold * Chore: reduce strict errors in Graph * Chore: reduce threshold * Apply suggestions from code review Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com> * Chore: reduce strict errors in TimeSeries * Chore: reduce threshold * Chore: reduce strict errors in polyfill * Chore: reduce threshold * Chore: update after PR comments * Update public/app/features/plugins/PluginPage.tsx Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com> * Update public/app/features/plugins/PluginPage.tsx Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com> * Chore: changes after PR comments Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com> Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
This commit is contained in:
parent
4fc86594c0
commit
09bb890092
|
|
@ -5,7 +5,15 @@ import {
|
||||||
identityOverrideProcessor,
|
identityOverrideProcessor,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { graphFieldOptions, HorizontalGroup, IconButton, Input, RadioButtonGroup, Tooltip } from '../..';
|
import {
|
||||||
|
GraphFieldConfig,
|
||||||
|
graphFieldOptions,
|
||||||
|
HorizontalGroup,
|
||||||
|
IconButton,
|
||||||
|
Input,
|
||||||
|
RadioButtonGroup,
|
||||||
|
Tooltip,
|
||||||
|
} from '../..';
|
||||||
import { StackingConfig, StackingMode } from '@grafana/schema';
|
import { StackingConfig, StackingMode } from '@grafana/schema';
|
||||||
|
|
||||||
export const StackingEditor: React.FC<FieldOverrideEditorProps<StackingConfig, any>> = ({
|
export const StackingEditor: React.FC<FieldOverrideEditorProps<StackingConfig, any>> = ({
|
||||||
|
|
@ -49,7 +57,7 @@ export const StackingEditor: React.FC<FieldOverrideEditorProps<StackingConfig, a
|
||||||
};
|
};
|
||||||
|
|
||||||
export function addStackingConfig(
|
export function addStackingConfig(
|
||||||
builder: FieldConfigEditorBuilder<{ stacking: StackingConfig }>,
|
builder: FieldConfigEditorBuilder<GraphFieldConfig>,
|
||||||
defaultConfig?: StackingConfig,
|
defaultConfig?: StackingConfig,
|
||||||
category = ['Graph styles']
|
category = ['Graph styles']
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,16 @@
|
||||||
// - reactDirective (factory for creating specific directives that correspond to reactComponent directives)
|
// - reactDirective (factory for creating specific directives that correspond to reactComponent directives)
|
||||||
|
|
||||||
import { kebabCase } from 'lodash';
|
import { kebabCase } from 'lodash';
|
||||||
import React from 'react';
|
import React, { ComponentType } from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import angular, { auto } from 'angular';
|
import angular, { auto } from 'angular';
|
||||||
|
|
||||||
// get a react component from name (components can be an angular injectable e.g. value, factory or
|
// get a react component from name (components can be an angular injectable e.g. value, factory or
|
||||||
// available on window
|
// available on window
|
||||||
function getReactComponent(name: string, $injector: auto.IInjectorService) {
|
function getReactComponent(name: string | Function, $injector: auto.IInjectorService): ComponentType {
|
||||||
// if name is a function assume it is component and return it
|
// if name is a function assume it is component and return it
|
||||||
if (angular.isFunction(name)) {
|
if (angular.isFunction(name)) {
|
||||||
return name;
|
return (name as unknown) as ComponentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a React component name must be specified
|
// a React component name must be specified
|
||||||
|
|
@ -46,7 +46,7 @@ function getReactComponent(name: string, $injector: auto.IInjectorService) {
|
||||||
throw Error('Cannot find react component ' + name);
|
throw Error('Cannot find react component ' + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return reactComponent;
|
return (reactComponent as unknown) as ComponentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wraps a function with scope.$apply, if already applied just return
|
// wraps a function with scope.$apply, if already applied just return
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import React, { FormEvent, PureComponent } from 'react';
|
import React, { FormEvent, PureComponent } from 'react';
|
||||||
import { ClipboardButton, Field, Modal, RadioButtonGroup, Switch, TextArea } from '@grafana/ui';
|
import { ClipboardButton, Field, Modal, RadioButtonGroup, Switch, TextArea } from '@grafana/ui';
|
||||||
import { AppEvents, SelectableValue } from '@grafana/data';
|
import { AppEvents, SelectableValue } from '@grafana/data';
|
||||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
|
||||||
import { appEvents } from 'app/core/core';
|
import { appEvents } from 'app/core/core';
|
||||||
import { buildIframeHtml } from './utils';
|
import { buildIframeHtml } from './utils';
|
||||||
|
import { ShareModalTabProps } from './types';
|
||||||
|
|
||||||
const themeOptions: Array<SelectableValue<string>> = [
|
const themeOptions: Array<SelectableValue<string>> = [
|
||||||
{ label: 'Current', value: 'current' },
|
{ label: 'Current', value: 'current' },
|
||||||
|
|
@ -11,10 +11,7 @@ const themeOptions: Array<SelectableValue<string>> = [
|
||||||
{ label: 'Light', value: 'light' },
|
{ label: 'Light', value: 'light' },
|
||||||
];
|
];
|
||||||
|
|
||||||
interface Props {
|
interface Props extends ShareModalTabProps {}
|
||||||
dashboard: DashboardModel;
|
|
||||||
panel?: PanelModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
useCurrentTimeRange: boolean;
|
useCurrentTimeRange: boolean;
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,14 @@ import React, { PureComponent } from 'react';
|
||||||
import { saveAs } from 'file-saver';
|
import { saveAs } from 'file-saver';
|
||||||
import { getBackendSrv } from 'app/core/services/backend_srv';
|
import { getBackendSrv } from 'app/core/services/backend_srv';
|
||||||
import { Button, Field, Modal, Switch } from '@grafana/ui';
|
import { Button, Field, Modal, Switch } from '@grafana/ui';
|
||||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
|
||||||
import { DashboardExporter } from 'app/features/dashboard/components/DashExportModal';
|
import { DashboardExporter } from 'app/features/dashboard/components/DashExportModal';
|
||||||
import { appEvents } from 'app/core/core';
|
import { appEvents } from 'app/core/core';
|
||||||
import { ShowModalReactEvent } from 'app/types/events';
|
import { ShowModalReactEvent } from 'app/types/events';
|
||||||
import { ViewJsonModal } from './ViewJsonModal';
|
import { ViewJsonModal } from './ViewJsonModal';
|
||||||
import { config } from '@grafana/runtime';
|
import { config } from '@grafana/runtime';
|
||||||
|
import { ShareModalTabProps } from './types';
|
||||||
|
|
||||||
interface Props {
|
interface Props extends ShareModalTabProps {}
|
||||||
dashboard: DashboardModel;
|
|
||||||
panel?: PanelModel;
|
|
||||||
onDismiss(): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
shareExternally: boolean;
|
shareExternally: boolean;
|
||||||
|
|
@ -124,7 +120,7 @@ export class ShareExport extends PureComponent<Props, State> {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this.props.onDismiss();
|
this.props.onDismiss?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { PanelModel } from 'app/features/dashboard/state';
|
|
||||||
import { AddLibraryPanelContents } from 'app/features/library-panels/components/AddLibraryPanelModal/AddLibraryPanelModal';
|
import { AddLibraryPanelContents } from 'app/features/library-panels/components/AddLibraryPanelModal/AddLibraryPanelModal';
|
||||||
|
import { ShareModalTabProps } from './types';
|
||||||
|
|
||||||
interface Props {
|
interface Props extends ShareModalTabProps {
|
||||||
onDismiss?: () => void;
|
|
||||||
panel?: PanelModel;
|
|
||||||
initialFolderId?: number;
|
initialFolderId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@ import React from 'react';
|
||||||
import { shallow, ShallowWrapper } from 'enzyme';
|
import { shallow, ShallowWrapper } from 'enzyme';
|
||||||
import { setTemplateSrv } from '@grafana/runtime';
|
import { setTemplateSrv } from '@grafana/runtime';
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import { ShareLink, Props, State } from './ShareLink';
|
import { Props, ShareLink, State } from './ShareLink';
|
||||||
import { initTemplateSrv } from '../../../../../test/helpers/initTemplateSrv';
|
import { initTemplateSrv } from '../../../../../test/helpers/initTemplateSrv';
|
||||||
import { variableAdapters } from '../../../variables/adapters';
|
import { variableAdapters } from '../../../variables/adapters';
|
||||||
import { createQueryVariableAdapter } from '../../../variables/query/adapter';
|
import { createQueryVariableAdapter } from '../../../variables/query/adapter';
|
||||||
|
import { PanelModel } from '../../state';
|
||||||
|
|
||||||
jest.mock('app/features/dashboard/services/TimeSrv', () => ({
|
jest.mock('app/features/dashboard/services/TimeSrv', () => ({
|
||||||
getTimeSrv: () => ({
|
getTimeSrv: () => ({
|
||||||
|
|
@ -108,7 +109,7 @@ describe('ShareModal', () => {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
ctx.mount({
|
ctx.mount({
|
||||||
panel: { id: 22, options: {}, fieldConfig: { defaults: {}, overrides: [] } },
|
panel: new PanelModel({ id: 22, options: {}, fieldConfig: { defaults: {}, overrides: [] } }),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -121,7 +122,7 @@ describe('ShareModal', () => {
|
||||||
it('should generate render url', async () => {
|
it('should generate render url', async () => {
|
||||||
mockLocationHref('http://dashboards.grafana.com/d/abcdefghi/my-dash');
|
mockLocationHref('http://dashboards.grafana.com/d/abcdefghi/my-dash');
|
||||||
ctx.mount({
|
ctx.mount({
|
||||||
panel: { id: 22, options: {}, fieldConfig: { defaults: {}, overrides: [] } },
|
panel: new PanelModel({ id: 22, options: {}, fieldConfig: { defaults: {}, overrides: [] } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
await ctx.wrapper?.instance().buildUrl();
|
await ctx.wrapper?.instance().buildUrl();
|
||||||
|
|
@ -134,7 +135,7 @@ describe('ShareModal', () => {
|
||||||
it('should generate render url for scripted dashboard', async () => {
|
it('should generate render url for scripted dashboard', async () => {
|
||||||
mockLocationHref('http://dashboards.grafana.com/dashboard/script/my-dash.js');
|
mockLocationHref('http://dashboards.grafana.com/dashboard/script/my-dash.js');
|
||||||
ctx.mount({
|
ctx.mount({
|
||||||
panel: { id: 22, options: {}, fieldConfig: { defaults: {}, overrides: [] } },
|
panel: new PanelModel({ id: 22, options: {}, fieldConfig: { defaults: {}, overrides: [] } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
await ctx.wrapper?.instance().buildUrl();
|
await ctx.wrapper?.instance().buildUrl();
|
||||||
|
|
@ -166,7 +167,7 @@ describe('ShareModal', () => {
|
||||||
it('should remove editPanel from image url when is first param in querystring', async () => {
|
it('should remove editPanel from image url when is first param in querystring', async () => {
|
||||||
mockLocationHref('http://server/#!/test?editPanel=1');
|
mockLocationHref('http://server/#!/test?editPanel=1');
|
||||||
ctx.mount({
|
ctx.mount({
|
||||||
panel: { id: 1, options: {}, fieldConfig: { defaults: {}, overrides: [] } },
|
panel: new PanelModel({ id: 1, options: {}, fieldConfig: { defaults: {}, overrides: [] } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
await ctx.wrapper?.instance().buildUrl();
|
await ctx.wrapper?.instance().buildUrl();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { selectors as e2eSelectors } from '@grafana/e2e-selectors';
|
import { selectors as e2eSelectors } from '@grafana/e2e-selectors';
|
||||||
import { Field, RadioButtonGroup, Switch, ClipboardButton, Icon, Input, FieldSet, Alert } from '@grafana/ui';
|
import { Alert, ClipboardButton, Field, FieldSet, Icon, Input, RadioButtonGroup, Switch } from '@grafana/ui';
|
||||||
import { SelectableValue, PanelModel, AppEvents } from '@grafana/data';
|
import { AppEvents, SelectableValue } from '@grafana/data';
|
||||||
import { DashboardModel } from 'app/features/dashboard/state';
|
|
||||||
import { buildImageUrl, buildShareUrl } from './utils';
|
import { buildImageUrl, buildShareUrl } from './utils';
|
||||||
import { appEvents } from 'app/core/core';
|
import { appEvents } from 'app/core/core';
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
|
import { ShareModalTabProps } from './types';
|
||||||
|
|
||||||
const themeOptions: Array<SelectableValue<string>> = [
|
const themeOptions: Array<SelectableValue<string>> = [
|
||||||
{ label: 'Current', value: 'current' },
|
{ label: 'Current', value: 'current' },
|
||||||
|
|
@ -13,10 +13,7 @@ const themeOptions: Array<SelectableValue<string>> = [
|
||||||
{ label: 'Light', value: 'light' },
|
{ label: 'Light', value: 'light' },
|
||||||
];
|
];
|
||||||
|
|
||||||
export interface Props {
|
export interface Props extends ShareModalTabProps {}
|
||||||
dashboard: DashboardModel;
|
|
||||||
panel?: PanelModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
useCurrentTimeRange: boolean;
|
useCurrentTimeRange: boolean;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { Button, ClipboardButton, Icon, Spinner, Select, Input, LinkButton, Field, Modal } from '@grafana/ui';
|
import { Button, ClipboardButton, Field, Icon, Input, LinkButton, Modal, Select, Spinner } from '@grafana/ui';
|
||||||
import { AppEvents, SelectableValue } from '@grafana/data';
|
import { AppEvents, SelectableValue } from '@grafana/data';
|
||||||
import { getBackendSrv } from '@grafana/runtime';
|
import { getBackendSrv } from '@grafana/runtime';
|
||||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
||||||
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||||
import { appEvents } from 'app/core/core';
|
import { appEvents } from 'app/core/core';
|
||||||
import { VariableRefresh } from '../../../variables/types';
|
import { VariableRefresh } from '../../../variables/types';
|
||||||
|
import { ShareModalTabProps } from './types';
|
||||||
|
|
||||||
const snapshotApiUrl = '/api/snapshots';
|
const snapshotApiUrl = '/api/snapshots';
|
||||||
|
|
||||||
|
|
@ -16,11 +17,7 @@ const expireOptions: Array<SelectableValue<number>> = [
|
||||||
{ label: '7 Days', value: 60 * 60 * 24 * 7 },
|
{ label: '7 Days', value: 60 * 60 * 24 * 7 },
|
||||||
];
|
];
|
||||||
|
|
||||||
interface Props {
|
interface Props extends ShareModalTabProps {}
|
||||||
dashboard: DashboardModel;
|
|
||||||
panel?: PanelModel;
|
|
||||||
onDismiss(): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { PanelModel } from '@grafana/data';
|
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
||||||
import { DashboardModel, PanelModel as InternalPanelModel } from 'app/features/dashboard/state';
|
|
||||||
|
|
||||||
export interface ShareModalTabProps {
|
export interface ShareModalTabProps {
|
||||||
dashboard: DashboardModel;
|
dashboard: DashboardModel;
|
||||||
|
|
@ -8,13 +7,8 @@ export interface ShareModalTabProps {
|
||||||
onDismiss?(): void;
|
onDismiss?(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShareModalTabPropsWithInternalModel = ShareModalTabProps & { panel?: InternalPanelModel };
|
|
||||||
export type ShareModalTab =
|
|
||||||
| React.ComponentType<ShareModalTabProps>
|
|
||||||
| React.ComponentType<ShareModalTabPropsWithInternalModel>;
|
|
||||||
|
|
||||||
export interface ShareModalTabModel {
|
export interface ShareModalTabModel {
|
||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
component: ShareModalTab;
|
component: React.ComponentType<ShareModalTabProps>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { getDiffText, getDiffOperationText, jsonDiff, Diff } from './utils';
|
import { Diff, getDiffOperationText, getDiffText, jsonDiff } from './utils';
|
||||||
|
|
||||||
describe('getDiffOperationText', () => {
|
describe('getDiffOperationText', () => {
|
||||||
const cases = [
|
const cases = [
|
||||||
|
|
@ -13,9 +13,13 @@ describe('getDiffOperationText', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
type DiffTextCase = [Partial<Diff>, string];
|
||||||
describe('getDiffText', () => {
|
describe('getDiffText', () => {
|
||||||
const addEmptyArray = [{ op: 'add', value: [], path: ['annotations', 'list'], startLineNumber: 24 }, 'added list'];
|
const addEmptyArray: DiffTextCase = [
|
||||||
const addArrayNumericProp = [
|
{ op: 'add', value: [], path: ['annotations', 'list'], startLineNumber: 24 },
|
||||||
|
'added list',
|
||||||
|
];
|
||||||
|
const addArrayNumericProp: DiffTextCase = [
|
||||||
{
|
{
|
||||||
op: 'add',
|
op: 'add',
|
||||||
value: ['tag'],
|
value: ['tag'],
|
||||||
|
|
@ -23,7 +27,7 @@ describe('getDiffText', () => {
|
||||||
},
|
},
|
||||||
'added item 3',
|
'added item 3',
|
||||||
];
|
];
|
||||||
const addArrayProp = [
|
const addArrayProp: DiffTextCase = [
|
||||||
{
|
{
|
||||||
op: 'add',
|
op: 'add',
|
||||||
value: [{ name: 'dummy target 1' }, { name: 'dummy target 2' }],
|
value: [{ name: 'dummy target 1' }, { name: 'dummy target 2' }],
|
||||||
|
|
@ -31,7 +35,7 @@ describe('getDiffText', () => {
|
||||||
},
|
},
|
||||||
'added 2 targets',
|
'added 2 targets',
|
||||||
];
|
];
|
||||||
const addValueNumericProp = [
|
const addValueNumericProp: DiffTextCase = [
|
||||||
{
|
{
|
||||||
op: 'add',
|
op: 'add',
|
||||||
value: 'foo',
|
value: 'foo',
|
||||||
|
|
@ -39,7 +43,7 @@ describe('getDiffText', () => {
|
||||||
},
|
},
|
||||||
'added item 3',
|
'added item 3',
|
||||||
];
|
];
|
||||||
const addValueProp = [
|
const addValueProp: DiffTextCase = [
|
||||||
{
|
{
|
||||||
op: 'add',
|
op: 'add',
|
||||||
value: 'foo',
|
value: 'foo',
|
||||||
|
|
@ -48,11 +52,11 @@ describe('getDiffText', () => {
|
||||||
'added targets',
|
'added targets',
|
||||||
];
|
];
|
||||||
|
|
||||||
const removeEmptyArray = [
|
const removeEmptyArray: DiffTextCase = [
|
||||||
{ op: 'remove', originalValue: [], path: ['annotations', 'list'], startLineNumber: 24 },
|
{ op: 'remove', originalValue: [], path: ['annotations', 'list'], startLineNumber: 24 },
|
||||||
'deleted list',
|
'deleted list',
|
||||||
];
|
];
|
||||||
const removeArrayNumericProp = [
|
const removeArrayNumericProp: DiffTextCase = [
|
||||||
{
|
{
|
||||||
op: 'remove',
|
op: 'remove',
|
||||||
originalValue: ['tag'],
|
originalValue: ['tag'],
|
||||||
|
|
@ -60,7 +64,7 @@ describe('getDiffText', () => {
|
||||||
},
|
},
|
||||||
'deleted item 3',
|
'deleted item 3',
|
||||||
];
|
];
|
||||||
const removeArrayProp = [
|
const removeArrayProp: DiffTextCase = [
|
||||||
{
|
{
|
||||||
op: 'remove',
|
op: 'remove',
|
||||||
originalValue: [{ name: 'dummy target 1' }, { name: 'dummy target 2' }],
|
originalValue: [{ name: 'dummy target 1' }, { name: 'dummy target 2' }],
|
||||||
|
|
@ -68,7 +72,7 @@ describe('getDiffText', () => {
|
||||||
},
|
},
|
||||||
'deleted 2 targets',
|
'deleted 2 targets',
|
||||||
];
|
];
|
||||||
const removeValueNumericProp = [
|
const removeValueNumericProp: DiffTextCase = [
|
||||||
{
|
{
|
||||||
op: 'remove',
|
op: 'remove',
|
||||||
originalValue: 'foo',
|
originalValue: 'foo',
|
||||||
|
|
@ -76,7 +80,7 @@ describe('getDiffText', () => {
|
||||||
},
|
},
|
||||||
'deleted item 3',
|
'deleted item 3',
|
||||||
];
|
];
|
||||||
const removeValueProp = [
|
const removeValueProp: DiffTextCase = [
|
||||||
{
|
{
|
||||||
op: 'remove',
|
op: 'remove',
|
||||||
originalValue: 'foo',
|
originalValue: 'foo',
|
||||||
|
|
@ -84,7 +88,7 @@ describe('getDiffText', () => {
|
||||||
},
|
},
|
||||||
'deleted targets',
|
'deleted targets',
|
||||||
];
|
];
|
||||||
const replaceValueNumericProp = [
|
const replaceValueNumericProp: DiffTextCase = [
|
||||||
{
|
{
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
originalValue: 'foo',
|
originalValue: 'foo',
|
||||||
|
|
@ -93,7 +97,7 @@ describe('getDiffText', () => {
|
||||||
},
|
},
|
||||||
'changed item 3',
|
'changed item 3',
|
||||||
];
|
];
|
||||||
const replaceValueProp = [
|
const replaceValueProp: DiffTextCase = [
|
||||||
{
|
{
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
originalValue: 'foo',
|
originalValue: 'foo',
|
||||||
|
|
@ -120,8 +124,8 @@ describe('getDiffText', () => {
|
||||||
|
|
||||||
test.each(cases)(
|
test.each(cases)(
|
||||||
'returns a semantic message based on the type of diff, the values and the location of the change',
|
'returns a semantic message based on the type of diff, the values and the location of the change',
|
||||||
(diff: Diff, expected: string) => {
|
(diff: Partial<Diff>, expected: string) => {
|
||||||
expect(getDiffText(diff)).toBe(expected);
|
expect(getDiffText((diff as unknown) as Diff)).toBe(expected);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { SelectableValue, QueryEditorProps } from '@grafana/data';
|
import { DataSourceApi, QueryEditorProps, SelectableValue } from '@grafana/data';
|
||||||
import { InlineField, Select } from '@grafana/ui';
|
import { InlineField, Select } from '@grafana/ui';
|
||||||
import { ExpressionDatasourceApi } from './ExpressionDatasource';
|
|
||||||
import { Resample } from './components/Resample';
|
import { Resample } from './components/Resample';
|
||||||
import { Reduce } from './components/Reduce';
|
import { Reduce } from './components/Reduce';
|
||||||
import { Math } from './components/Math';
|
import { Math } from './components/Math';
|
||||||
|
|
@ -9,7 +8,7 @@ import { ClassicConditions } from './components/ClassicConditions';
|
||||||
import { getDefaults } from './utils/expressionTypes';
|
import { getDefaults } from './utils/expressionTypes';
|
||||||
import { ExpressionQuery, ExpressionQueryType, gelTypes } from './types';
|
import { ExpressionQuery, ExpressionQueryType, gelTypes } from './types';
|
||||||
|
|
||||||
type Props = QueryEditorProps<ExpressionDatasourceApi, ExpressionQuery>;
|
type Props = QueryEditorProps<DataSourceApi<ExpressionQuery>, ExpressionQuery>;
|
||||||
|
|
||||||
const labelWidth = 14;
|
const labelWidth = 14;
|
||||||
export class ExpressionQueryEditor extends PureComponent<Props> {
|
export class ExpressionQueryEditor extends PureComponent<Props> {
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class DashboardWatcher {
|
||||||
};
|
};
|
||||||
this.leave();
|
this.leave();
|
||||||
if (uid) {
|
if (uid) {
|
||||||
this.subscription = live.getStream(this.channel).subscribe(this.observer);
|
this.subscription = live.getStream<DashboardEvent>(this.channel).subscribe(this.observer);
|
||||||
}
|
}
|
||||||
this.uid = uid;
|
this.uid = uid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import {
|
||||||
GrafanaTheme2,
|
GrafanaTheme2,
|
||||||
NavModel,
|
NavModel,
|
||||||
NavModelItem,
|
NavModelItem,
|
||||||
|
PanelPluginMeta,
|
||||||
PluginDependencies,
|
PluginDependencies,
|
||||||
PluginInclude,
|
PluginInclude,
|
||||||
PluginIncludeType,
|
PluginIncludeType,
|
||||||
|
|
@ -17,10 +18,9 @@ import {
|
||||||
PluginSignatureType,
|
PluginSignatureType,
|
||||||
PluginType,
|
PluginType,
|
||||||
UrlQueryMap,
|
UrlQueryMap,
|
||||||
PanelPluginMeta,
|
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { AppNotificationSeverity } from 'app/types';
|
import { AppNotificationSeverity } from 'app/types';
|
||||||
import { Alert, LinkButton, PluginSignatureBadge, Tooltip, Badge, useStyles2, Icon } from '@grafana/ui';
|
import { Alert, Badge, Icon, LinkButton, PluginSignatureBadge, Tooltip, useStyles2 } from '@grafana/ui';
|
||||||
|
|
||||||
import Page from 'app/core/components/Page/Page';
|
import Page from 'app/core/components/Page/Page';
|
||||||
import { getPluginSettings } from './PluginSettingsCache';
|
import { getPluginSettings } from './PluginSettingsCache';
|
||||||
|
|
@ -490,22 +490,29 @@ export function getLoadingNav(): NavModel {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadPlugin(pluginId: string): Promise<GrafanaPlugin> {
|
export async function loadPlugin(pluginId: string): Promise<GrafanaPlugin> {
|
||||||
return getPluginSettings(pluginId).then((info) => {
|
const info = await getPluginSettings(pluginId);
|
||||||
if (info.type === PluginType.app) {
|
let result: GrafanaPlugin | undefined;
|
||||||
return importAppPlugin(info);
|
|
||||||
}
|
if (info.type === PluginType.app) {
|
||||||
if (info.type === PluginType.datasource) {
|
result = await importAppPlugin(info);
|
||||||
return importDataSourcePlugin(info);
|
}
|
||||||
}
|
if (info.type === PluginType.datasource) {
|
||||||
if (info.type === PluginType.panel) {
|
result = await importDataSourcePlugin(info);
|
||||||
return importPanelPluginFromMeta(info as PanelPluginMeta);
|
}
|
||||||
}
|
if (info.type === PluginType.panel) {
|
||||||
if (info.type === PluginType.renderer) {
|
const panelPlugin = await importPanelPluginFromMeta(info as PanelPluginMeta);
|
||||||
return Promise.resolve({ meta: info } as GrafanaPlugin);
|
result = (panelPlugin as unknown) as GrafanaPlugin;
|
||||||
}
|
}
|
||||||
return Promise.reject('Unknown Plugin type: ' + info.type);
|
if (info.type === PluginType.renderer) {
|
||||||
});
|
result = { meta: info } as GrafanaPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
throw new Error('Unknown Plugin type: ' + info.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
type PluginSignatureDetailsBadgeProps = {
|
type PluginSignatureDetailsBadgeProps = {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import {
|
||||||
DataSourceApi,
|
DataSourceApi,
|
||||||
DataSourceJsonData,
|
DataSourceJsonData,
|
||||||
MetricFindValue,
|
MetricFindValue,
|
||||||
QueryEditorProps,
|
|
||||||
StandardVariableQuery,
|
StandardVariableQuery,
|
||||||
StandardVariableSupport,
|
StandardVariableSupport,
|
||||||
VariableModel,
|
VariableModel,
|
||||||
|
|
@ -86,7 +85,7 @@ interface DataSourceWithCustomVariableSupport<
|
||||||
> extends DataSourceApi<TQuery, TOptions> {
|
> extends DataSourceApi<TQuery, TOptions> {
|
||||||
variables: {
|
variables: {
|
||||||
getType(): VariableSupportType;
|
getType(): VariableSupportType;
|
||||||
editor: ComponentType<QueryEditorProps<any, TQuery, TOptions, VariableQuery>>;
|
editor: VariableQueryEditorType;
|
||||||
query(request: DataQueryRequest<TQuery>): Observable<DataQueryResponse>;
|
query(request: DataQueryRequest<TQuery>): Observable<DataQueryResponse>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +183,7 @@ export function isQueryEditor<
|
||||||
>(
|
>(
|
||||||
component: VariableQueryEditorType,
|
component: VariableQueryEditorType,
|
||||||
datasource: DataSourceApi<TQuery, TOptions>
|
datasource: DataSourceApi<TQuery, TOptions>
|
||||||
): component is ComponentType<QueryEditorProps<DataSourceApi<TQuery, TOptions>, TQuery, TOptions, any>> {
|
): component is VariableQueryEditorType {
|
||||||
if (!component) {
|
if (!component) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import 'vendor/flot/jquery.flot.dashes';
|
||||||
import './jquery.flot.events';
|
import './jquery.flot.events';
|
||||||
|
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import { min as _min, max as _max, clone, find, isUndefined, map, toNumber, sortBy as _sortBy, flatten } from 'lodash';
|
import { clone, find, flatten, isUndefined, map, max as _max, min as _min, sortBy as _sortBy, toNumber } from 'lodash';
|
||||||
import { tickStep } from 'app/core/utils/ticks';
|
import { tickStep } from 'app/core/utils/ticks';
|
||||||
import { coreModule, updateLegendValues } from 'app/core/core';
|
import { coreModule, updateLegendValues } from 'app/core/core';
|
||||||
import GraphTooltip from './graph_tooltip';
|
import GraphTooltip from './graph_tooltip';
|
||||||
|
|
@ -37,6 +37,7 @@ import {
|
||||||
getTimeField,
|
getTimeField,
|
||||||
getValueFormat,
|
getValueFormat,
|
||||||
hasLinks,
|
hasLinks,
|
||||||
|
LegacyEventHandler,
|
||||||
LegacyGraphHoverClearEvent,
|
LegacyGraphHoverClearEvent,
|
||||||
LegacyGraphHoverEvent,
|
LegacyGraphHoverEvent,
|
||||||
LinkModelSupplier,
|
LinkModelSupplier,
|
||||||
|
|
@ -67,7 +68,13 @@ class GraphElement {
|
||||||
timeRegionManager: TimeRegionManager;
|
timeRegionManager: TimeRegionManager;
|
||||||
declare legendElem: HTMLElement;
|
declare legendElem: HTMLElement;
|
||||||
|
|
||||||
constructor(private scope: any, private elem: JQuery, private timeSrv: TimeSrv) {
|
constructor(
|
||||||
|
private scope: any,
|
||||||
|
private elem: JQuery & {
|
||||||
|
bind(eventType: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; // need to extend with Plot
|
||||||
|
},
|
||||||
|
private timeSrv: TimeSrv
|
||||||
|
) {
|
||||||
this.ctrl = scope.ctrl;
|
this.ctrl = scope.ctrl;
|
||||||
this.contextMenu = scope.ctrl.contextMenuCtrl;
|
this.contextMenu = scope.ctrl.contextMenuCtrl;
|
||||||
this.dashboard = this.ctrl.dashboard;
|
this.dashboard = this.ctrl.dashboard;
|
||||||
|
|
@ -167,7 +174,7 @@ class GraphElement {
|
||||||
ReactDOM.unmountComponentAtNode(this.legendElem);
|
ReactDOM.unmountComponentAtNode(this.legendElem);
|
||||||
}
|
}
|
||||||
|
|
||||||
onGraphHoverClear(event: any, info: any) {
|
onGraphHoverClear(handler: LegacyEventHandler<any>) {
|
||||||
if (this.plot) {
|
if (this.plot) {
|
||||||
this.tooltip.clear(this.plot);
|
this.tooltip.clear(this.plot);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,11 @@ window.matchMedia = (mediaQueryString) => {
|
||||||
let mql = oMatchMedia(mediaQueryString);
|
let mql = oMatchMedia(mediaQueryString);
|
||||||
|
|
||||||
if (!mql.addEventListener) {
|
if (!mql.addEventListener) {
|
||||||
|
// @ts-ignore
|
||||||
mql.addEventListener = (type: string, listener: MqlListener) => {
|
mql.addEventListener = (type: string, listener: MqlListener) => {
|
||||||
mql.addListener(listener);
|
mql.addListener(listener);
|
||||||
};
|
};
|
||||||
|
// @ts-ignore
|
||||||
mql.removeEventListener = (type: string, listener: MqlListener) => {
|
mql.removeEventListener = (type: string, listener: MqlListener) => {
|
||||||
mql.removeListener(listener);
|
mql.removeListener(listener);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ set -e
|
||||||
|
|
||||||
echo -e "Collecting code stats (typescript errors & more)"
|
echo -e "Collecting code stats (typescript errors & more)"
|
||||||
|
|
||||||
ERROR_COUNT_LIMIT=39
|
ERROR_COUNT_LIMIT=24
|
||||||
ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --strict true | grep -oP 'Found \K(\d+)')"
|
ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --strict true | grep -oP 'Found \K(\d+)')"
|
||||||
|
|
||||||
if [ "$ERROR_COUNT" -gt $ERROR_COUNT_LIMIT ]; then
|
if [ "$ERROR_COUNT" -gt $ERROR_COUNT_LIMIT ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue