Fix type errors (tests are failed)
This commit is contained in:
@@ -42,7 +42,7 @@ const openInExplore = (problem: ProblemDTO, panelId: number, range: TimeRange) =
|
||||
};
|
||||
}
|
||||
|
||||
const state: ExploreUrlState = {
|
||||
const state: ExploreUrlState | any = {
|
||||
datasource: problem.datasource,
|
||||
context: 'explore',
|
||||
originPanelId: panelId,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import _ from 'lodash';
|
||||
import { Observable } from 'rxjs';
|
||||
import config from 'grafana/app/core/config';
|
||||
import { contextSrv } from 'grafana/app/core/core';
|
||||
import * as dateMath from 'grafana/app/core/utils/datemath';
|
||||
@@ -107,7 +106,7 @@ export class ZabbixDatasource extends DataSourceApi<ZabbixMetricsQuery, ZabbixDS
|
||||
* @param {Object} request Contains time range, targets and other info.
|
||||
* @return {Object} Grafana metrics object with timeseries data for each target.
|
||||
*/
|
||||
query(request: DataQueryRequest<any>): Promise<DataQueryResponse> | Observable<DataQueryResponse> {
|
||||
query(request: DataQueryRequest<ZabbixMetricsQuery>) {
|
||||
// Migrate old targets
|
||||
const requestTargets = request.targets.map(t => {
|
||||
// Prevent changes of original object
|
||||
|
||||
@@ -4,6 +4,12 @@ jest.mock('@grafana/runtime', () => ({
|
||||
getBackendSrv: () => ({
|
||||
datasourceRequest: jest.fn().mockResolvedValue({data: {result: ''}}),
|
||||
}),
|
||||
getBackendSrv: () => ({
|
||||
datasourceRequest: jest.fn().mockResolvedValue({ data: { result: '' } }),
|
||||
fetch: () => ({
|
||||
toPromise: () => jest.fn().mockResolvedValue({ data: { result: '' } })
|
||||
}),
|
||||
}),
|
||||
}), {virtual: true});
|
||||
|
||||
describe('Zabbix', () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { cx, css } from '@emotion/css';
|
||||
import { ZBX_ACK_ACTION_ADD_MESSAGE, ZBX_ACK_ACTION_ACK, ZBX_ACK_ACTION_CHANGE_SEVERITY, ZBX_ACK_ACTION_CLOSE } from '../../datasource-zabbix/constants';
|
||||
import { Button, VerticalGroup, Spinner, Modal, Input, Checkbox, RadioButtonGroup, stylesFactory, withTheme, Themeable, TextArea } from '@grafana/ui';
|
||||
import { Button, VerticalGroup, Spinner, Modal, Checkbox, RadioButtonGroup, stylesFactory, withTheme, Themeable, TextArea } from '@grafana/ui';
|
||||
import { FAIcon } from '../../components';
|
||||
import { GrafanaTheme } from '@grafana/data';
|
||||
|
||||
@@ -147,9 +147,9 @@ export class AckModalUnthemed extends PureComponent<Props, State> {
|
||||
const { canClose } = this.props;
|
||||
|
||||
const actions = [
|
||||
<Checkbox css="" key="ack" label="Acknowledge" value={this.state.acknowledge} onChange={this.onAcknowledgeToggle} />,
|
||||
<Checkbox translate="" key="ack" label="Acknowledge" value={this.state.acknowledge} onChange={this.onAcknowledgeToggle} />,
|
||||
<Checkbox
|
||||
css=""
|
||||
translate=""
|
||||
key="change-severity"
|
||||
label="Change severity"
|
||||
description=""
|
||||
@@ -166,7 +166,7 @@ export class AckModalUnthemed extends PureComponent<Props, State> {
|
||||
/>,
|
||||
canClose &&
|
||||
<Checkbox
|
||||
css=""
|
||||
translate=""
|
||||
key="close"
|
||||
label="Close problem"
|
||||
disabled={!canClose}
|
||||
@@ -205,7 +205,7 @@ export class AckModalUnthemed extends PureComponent<Props, State> {
|
||||
<div className={inputGroupClass}>
|
||||
<label className="gf-form-hint">
|
||||
<TextArea className={inputClass}
|
||||
css=""
|
||||
translate=""
|
||||
type="text"
|
||||
name="message"
|
||||
placeholder="Message"
|
||||
|
||||
@@ -10,21 +10,21 @@ import AlertAcknowledges from './AlertAcknowledges';
|
||||
import AlertIcon from './AlertIcon';
|
||||
import { ProblemDTO, ZBXTag } from '../../../datasource-zabbix/types';
|
||||
import { ModalController, Tooltip } from '../../../components';
|
||||
import { DataSourceRef } from '@grafana/data';
|
||||
|
||||
interface AlertCardProps {
|
||||
problem: ProblemDTO;
|
||||
panelOptions: ProblemsPanelOptions;
|
||||
onTagClick?: (tag: ZBXTag, datasource: string, ctrlKey?: boolean, shiftKey?: boolean) => void;
|
||||
onTagClick?: (tag: ZBXTag, datasource: DataSourceRef | string, ctrlKey?: boolean, shiftKey?: boolean) => void;
|
||||
onProblemAck?: (problem: ProblemDTO, data: AckProblemData) => Promise<any> | any;
|
||||
}
|
||||
|
||||
export default class AlertCard extends PureComponent<AlertCardProps> {
|
||||
|
||||
handleTagClick = (tag: ZBXTag, ctrlKey?: boolean, shiftKey?: boolean) => {
|
||||
handleTagClick = (tag: ZBXTag, datasource: DataSourceRef | string, ctrlKey?: boolean, shiftKey?: boolean) => {
|
||||
if (this.props.onTagClick) {
|
||||
this.props.onTagClick(tag, this.props.problem.datasource, ctrlKey, shiftKey);
|
||||
this.props.onTagClick(tag, datasource, ctrlKey, shiftKey);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ackProblem = (data: AckProblemData) => {
|
||||
const problem = this.props.problem;
|
||||
@@ -86,6 +86,7 @@ export default class AlertCard extends PureComponent<AlertCardProps> {
|
||||
<EventTag
|
||||
key={tag.tag + tag.value}
|
||||
tag={tag}
|
||||
datasource={problem.datasource}
|
||||
highlight={tag.tag === problem.correlation_tag}
|
||||
onClick={this.handleTagClick}
|
||||
/>
|
||||
|
||||
@@ -12,7 +12,7 @@ import { GFTimeRange, ProblemsPanelOptions, RTCell, RTResized, TriggerSeverity }
|
||||
import { ProblemDTO, ZBXAlert, ZBXEvent, ZBXTag } from '../../../datasource-zabbix/types';
|
||||
import { APIExecuteScriptResponse, ZBXScript } from '../../../datasource-zabbix/zabbix/connectors/zabbix_api/types';
|
||||
import { AckCell } from './AckCell';
|
||||
import { TimeRange } from "@grafana/data";
|
||||
import { DataSourceRef, TimeRange } from "@grafana/data";
|
||||
|
||||
export interface ProblemListProps {
|
||||
problems: ProblemDTO[];
|
||||
@@ -345,20 +345,20 @@ function LastChangeCell(props: RTCell<ProblemDTO>, customFormat?: string) {
|
||||
}
|
||||
|
||||
interface TagCellProps extends RTCell<ProblemDTO> {
|
||||
onTagClick: (tag: ZBXTag, datasource: string, ctrlKey?: boolean, shiftKey?: boolean) => void;
|
||||
onTagClick: (tag: ZBXTag, datasource: DataSourceRef | string, ctrlKey?: boolean, shiftKey?: boolean) => void;
|
||||
}
|
||||
|
||||
class TagCell extends PureComponent<TagCellProps> {
|
||||
handleTagClick = (tag: ZBXTag, ctrlKey?: boolean, shiftKey?: boolean) => {
|
||||
handleTagClick = (tag: ZBXTag, datasource: DataSourceRef | string, ctrlKey?: boolean, shiftKey?: boolean) => {
|
||||
if (this.props.onTagClick) {
|
||||
this.props.onTagClick(tag, this.props.original.datasource, ctrlKey, shiftKey);
|
||||
this.props.onTagClick(tag, datasource, ctrlKey, shiftKey);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const tags = this.props.value || [];
|
||||
return [
|
||||
tags.map(tag => <EventTag key={tag.tag + tag.value} tag={tag} onClick={this.handleTagClick}/>)
|
||||
tags.map(tag => <EventTag key={tag.tag + tag.value} tag={tag} datasource={this.props.original.datasource} onClick={this.handleTagClick}/>)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user