mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { GrafanaTheme } from '@grafana/data';
|
||||
import { Icon, InfoBox, stylesFactory, useTheme } from '@grafana/ui';
|
||||
import { css, cx } from '@emotion/css';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import { GrafanaTheme } from '@grafana/data';
|
||||
import { Icon, InfoBox, stylesFactory, useTheme } from '@grafana/ui';
|
||||
|
||||
const getStyles = stylesFactory((theme: GrafanaTheme) => ({
|
||||
infoBox: css`
|
||||
margin-top: ${theme.spacing.xs};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { DataQueryRequest, dateTime, LoadingState, PanelData, toDataFrame } from '@grafana/data';
|
||||
|
||||
import { filterPanelDataToQuery } from './QueryEditorRow';
|
||||
|
||||
function makePretendRequest(requestId: string, subRequests?: DataQueryRequest[]): DataQueryRequest {
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
// Libraries
|
||||
import React, { PureComponent, ReactNode } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { cloneDeep, has } from 'lodash';
|
||||
import React, { PureComponent, ReactNode } from 'react';
|
||||
|
||||
// Utils & Services
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
import { AngularComponent, getAngularLoader } from '@grafana/runtime';
|
||||
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
import { ErrorBoundaryAlert, HorizontalGroup } from '@grafana/ui';
|
||||
import {
|
||||
CoreApp,
|
||||
DataQuery,
|
||||
@@ -21,17 +18,22 @@ import {
|
||||
TimeRange,
|
||||
toLegacyResponseData,
|
||||
} from '@grafana/data';
|
||||
import { QueryEditorRowHeader } from './QueryEditorRowHeader';
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
import { AngularComponent, getAngularLoader } from '@grafana/runtime';
|
||||
import { ErrorBoundaryAlert, HorizontalGroup } from '@grafana/ui';
|
||||
import { OperationRowHelp } from 'app/core/components/QueryOperationRow/OperationRowHelp';
|
||||
import { QueryOperationAction } from 'app/core/components/QueryOperationRow/QueryOperationAction';
|
||||
import {
|
||||
QueryOperationRow,
|
||||
QueryOperationRowRenderProps,
|
||||
} from 'app/core/components/QueryOperationRow/QueryOperationRow';
|
||||
import { QueryOperationAction } from 'app/core/components/QueryOperationRow/QueryOperationAction';
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
import { PanelModel } from 'app/features/dashboard/state/PanelModel';
|
||||
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
|
||||
import { OperationRowHelp } from 'app/core/components/QueryOperationRow/OperationRowHelp';
|
||||
import { PanelModel } from 'app/features/dashboard/state/PanelModel';
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
|
||||
import { RowActionComponents } from './QueryActionComponent';
|
||||
import { QueryEditorRowHeader } from './QueryEditorRowHeader';
|
||||
import { QueryErrorAlert } from './QueryErrorAlert';
|
||||
|
||||
interface Props<TQuery extends DataQuery> {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import React from 'react';
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { Props, QueryEditorRowHeader } from './QueryEditorRowHeader';
|
||||
import React from 'react';
|
||||
|
||||
import { DataSourceInstanceSettings } from '@grafana/data';
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
import { mockDataSource } from 'app/features/alerting/unified/mocks';
|
||||
import { DataSourceType } from 'app/features/alerting/unified/utils/datasource';
|
||||
|
||||
import { Props, QueryEditorRowHeader } from './QueryEditorRowHeader';
|
||||
|
||||
const mockDS = mockDataSource({
|
||||
name: 'CloudManager',
|
||||
type: DataSourceType.Alertmanager,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import React, { ReactNode, useState } from 'react';
|
||||
import { css, cx } from '@emotion/css';
|
||||
import React, { ReactNode, useState } from 'react';
|
||||
|
||||
import { DataQuery, DataSourceInstanceSettings, GrafanaTheme } from '@grafana/data';
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
import { DataSourcePicker } from '@grafana/runtime';
|
||||
import { Icon, Input, FieldValidationMessage, useStyles } from '@grafana/ui';
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
|
||||
export interface Props<TQuery extends DataQuery = DataQuery> {
|
||||
query: TQuery;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Libraries
|
||||
import React, { PureComponent } from 'react';
|
||||
import { DragDropContext, DragStart, Droppable, DropResult } from 'react-beautiful-dnd';
|
||||
|
||||
// Types
|
||||
import {
|
||||
CoreApp,
|
||||
DataQuery,
|
||||
@@ -10,10 +9,10 @@ import {
|
||||
HistoryItem,
|
||||
PanelData,
|
||||
} from '@grafana/data';
|
||||
import { QueryEditorRow } from './QueryEditorRow';
|
||||
import { DragDropContext, DragStart, Droppable, DropResult } from 'react-beautiful-dnd';
|
||||
import { getDataSourceSrv, reportInteraction } from '@grafana/runtime';
|
||||
|
||||
import { QueryEditorRow } from './QueryEditorRow';
|
||||
|
||||
interface Props {
|
||||
// The query configuration
|
||||
queries: DataQuery[];
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { css } from '@emotion/css';
|
||||
import React from 'react';
|
||||
|
||||
import { DataQueryError, GrafanaTheme2 } from '@grafana/data';
|
||||
import { Icon, useStyles2 } from '@grafana/ui';
|
||||
import { css } from '@emotion/css';
|
||||
|
||||
export interface Props {
|
||||
error: DataQueryError;
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
// Libraries
|
||||
import { css } from '@emotion/css';
|
||||
import React, { PureComponent } from 'react';
|
||||
// Components
|
||||
import { Unsubscribable } from 'rxjs';
|
||||
|
||||
import {
|
||||
DataQuery,
|
||||
DataSourceApi,
|
||||
DataSourceInstanceSettings,
|
||||
getDefaultTimeRange,
|
||||
LoadingState,
|
||||
PanelData,
|
||||
} from '@grafana/data';
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
import { DataSourcePicker, getDataSourceSrv } from '@grafana/runtime';
|
||||
import {
|
||||
Button,
|
||||
CustomScrollbar,
|
||||
@@ -10,33 +21,21 @@ import {
|
||||
ScrollbarPosition,
|
||||
stylesFactory,
|
||||
} from '@grafana/ui';
|
||||
import { DataSourcePicker, getDataSourceSrv } from '@grafana/runtime';
|
||||
import { QueryEditorRows } from './QueryEditorRows';
|
||||
// Services
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
import config from 'app/core/config';
|
||||
// Types
|
||||
import {
|
||||
DataQuery,
|
||||
DataSourceApi,
|
||||
DataSourceInstanceSettings,
|
||||
getDefaultTimeRange,
|
||||
LoadingState,
|
||||
PanelData,
|
||||
} from '@grafana/data';
|
||||
import { PluginHelp } from 'app/core/components/PluginHelp/PluginHelp';
|
||||
import config from 'app/core/config';
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
import { addQuery } from 'app/core/utils/query';
|
||||
import { Unsubscribable } from 'rxjs';
|
||||
import { dataSource as expressionDatasource } from 'app/features/expressions/ExpressionDatasource';
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
import { PanelQueryRunner } from '../state/PanelQueryRunner';
|
||||
import { QueryGroupOptionsEditor } from './QueryGroupOptions';
|
||||
import { DashboardQueryEditor, isSharedDashboardQuery } from 'app/plugins/datasource/dashboard';
|
||||
import { css } from '@emotion/css';
|
||||
import { QueryGroupOptions } from 'app/types';
|
||||
import { GroupActionComponents } from './QueryActionComponent';
|
||||
|
||||
import { PanelQueryRunner } from '../state/PanelQueryRunner';
|
||||
import { updateQueries } from '../state/updateQueries';
|
||||
|
||||
import { GroupActionComponents } from './QueryActionComponent';
|
||||
import { QueryEditorRows } from './QueryEditorRows';
|
||||
import { QueryGroupOptionsEditor } from './QueryGroupOptions';
|
||||
|
||||
interface Props {
|
||||
queryRunner: PanelQueryRunner;
|
||||
options: QueryGroupOptions;
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
// Libraries
|
||||
import { css } from '@emotion/css';
|
||||
import React, { PureComponent, ChangeEvent, FocusEvent } from 'react';
|
||||
|
||||
// Utils
|
||||
import { rangeUtil, PanelData, DataSourceApi } from '@grafana/data';
|
||||
|
||||
// Components
|
||||
import { Switch, Input, InlineField, InlineFormLabel, stylesFactory } from '@grafana/ui';
|
||||
|
||||
// Types
|
||||
import { QueryOperationRow } from 'app/core/components/QueryOperationRow/QueryOperationRow';
|
||||
import { config } from 'app/core/config';
|
||||
import { css } from '@emotion/css';
|
||||
import { QueryGroupOptions } from 'app/types';
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { AlertState, AlertStateInfo, getDefaultTimeRange, TimeRange } from '@grafana/data';
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
|
||||
import { DashboardQueryRunnerOptions } from './types';
|
||||
import { AlertStatesWorker } from './AlertStatesWorker';
|
||||
import { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
|
||||
import * as store from '../../../../store/store';
|
||||
|
||||
import { AlertStatesWorker } from './AlertStatesWorker';
|
||||
import { DashboardQueryRunnerOptions } from './types';
|
||||
|
||||
jest.mock('@grafana/runtime', () => ({
|
||||
...(jest.requireActual('@grafana/runtime') as unknown as object),
|
||||
getBackendSrv: () => backendSrv,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { DashboardQueryRunnerOptions, DashboardQueryRunnerWorker, DashboardQueryRunnerWorkerResult } from './types';
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
|
||||
import { DashboardQueryRunnerOptions, DashboardQueryRunnerWorker, DashboardQueryRunnerWorkerResult } from './types';
|
||||
import { emptyResult, handleDashboardQueryRunnerWorkerError } from './utils';
|
||||
|
||||
export class AlertStatesWorker implements DashboardQueryRunnerWorker {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { Observable, of, throwError } from 'rxjs';
|
||||
|
||||
import { getDefaultTimeRange } from '@grafana/data';
|
||||
|
||||
import { AnnotationsQueryRunner } from './AnnotationsQueryRunner';
|
||||
import { AnnotationQueryRunnerOptions } from './types';
|
||||
import { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
|
||||
import * as store from '../../../../store/store';
|
||||
import * as annotationsSrv from '../../../annotations/executeAnnotationQuery';
|
||||
import { Observable, of, throwError } from 'rxjs';
|
||||
|
||||
import { AnnotationsQueryRunner } from './AnnotationsQueryRunner';
|
||||
import { toAsyncOfResult } from './testHelpers';
|
||||
import { AnnotationQueryRunnerOptions } from './types';
|
||||
|
||||
function getDefaultOptions(): AnnotationQueryRunnerOptions {
|
||||
const annotation: any = {};
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
||||
import { AnnotationEvent, DataSourceApi } from '@grafana/data';
|
||||
|
||||
import { AnnotationQueryRunner, AnnotationQueryRunnerOptions } from './types';
|
||||
import { PanelModel } from '../../../dashboard/state';
|
||||
import { executeAnnotationQuery } from '../../../annotations/executeAnnotationQuery';
|
||||
import { PanelModel } from '../../../dashboard/state';
|
||||
|
||||
import { AnnotationQueryRunner, AnnotationQueryRunnerOptions } from './types';
|
||||
import { handleAnnotationQueryRunnerError } from './utils';
|
||||
|
||||
export class AnnotationsQueryRunner implements AnnotationQueryRunner {
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import { Subject, throwError } from 'rxjs';
|
||||
import { delay } from 'rxjs/operators';
|
||||
|
||||
import { AnnotationQuery } from '@grafana/data';
|
||||
import { setDataSourceSrv } from '@grafana/runtime';
|
||||
|
||||
import { AnnotationsWorker } from './AnnotationsWorker';
|
||||
import * as annotationsSrv from '../../../annotations/executeAnnotationQuery';
|
||||
import { getDefaultOptions, LEGACY_DS_NAME, NEXT_GEN_DS_NAME, toAsyncOfResult } from './testHelpers';
|
||||
import { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
|
||||
import * as annotationsSrv from '../../../annotations/executeAnnotationQuery';
|
||||
|
||||
import { AnnotationsWorker } from './AnnotationsWorker';
|
||||
import { createDashboardQueryRunner, setDashboardQueryRunnerFactory } from './DashboardQueryRunner';
|
||||
import { emptyResult } from './utils';
|
||||
import { getDefaultOptions, LEGACY_DS_NAME, NEXT_GEN_DS_NAME, toAsyncOfResult } from './testHelpers';
|
||||
import { DashboardQueryRunnerOptions, DashboardQueryRunnerWorkerResult } from './types';
|
||||
import { AnnotationQuery } from '@grafana/data';
|
||||
import { delay } from 'rxjs/operators';
|
||||
import { emptyResult } from './utils';
|
||||
|
||||
function getTestContext(dataSourceSrvRejects = false) {
|
||||
jest.clearAllMocks();
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { from, merge, Observable, of } from 'rxjs';
|
||||
import { catchError, filter, finalize, map, mergeAll, mergeMap, reduce, takeUntil } from 'rxjs/operators';
|
||||
import { getDataSourceSrv } from '@grafana/runtime';
|
||||
import { AnnotationQuery, DataSourceApi } from '@grafana/data';
|
||||
|
||||
import { AnnotationQuery, DataSourceApi } from '@grafana/data';
|
||||
import { getDataSourceSrv } from '@grafana/runtime';
|
||||
|
||||
import { AnnotationQueryFinished, AnnotationQueryStarted } from '../../../../types/events';
|
||||
|
||||
import { AnnotationsQueryRunner } from './AnnotationsQueryRunner';
|
||||
import { getDashboardQueryRunner } from './DashboardQueryRunner';
|
||||
import { LegacyAnnotationQueryRunner } from './LegacyAnnotationQueryRunner';
|
||||
import {
|
||||
AnnotationQueryRunner,
|
||||
DashboardQueryRunnerOptions,
|
||||
@@ -11,10 +17,6 @@ import {
|
||||
DashboardQueryRunnerWorkerResult,
|
||||
} from './types';
|
||||
import { emptyResult, handleDatasourceSrvError, translateQueryResult } from './utils';
|
||||
import { LegacyAnnotationQueryRunner } from './LegacyAnnotationQueryRunner';
|
||||
import { AnnotationsQueryRunner } from './AnnotationsQueryRunner';
|
||||
import { AnnotationQueryFinished, AnnotationQueryStarted } from '../../../../types/events';
|
||||
import { getDashboardQueryRunner } from './DashboardQueryRunner';
|
||||
|
||||
export class AnnotationsWorker implements DashboardQueryRunnerWorker {
|
||||
constructor(
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { throwError } from 'rxjs';
|
||||
import { delay, first } from 'rxjs/operators';
|
||||
import { setDataSourceSrv } from '@grafana/runtime';
|
||||
import { AlertState, AlertStateInfo } from '@grafana/data';
|
||||
|
||||
import * as annotationsSrv from '../../../annotations/executeAnnotationQuery';
|
||||
import { getDefaultOptions, LEGACY_DS_NAME, NEXT_GEN_DS_NAME, toAsyncOfResult } from './testHelpers';
|
||||
import { backendSrv } from '../../../../core/services/backend_srv';
|
||||
import { DashboardQueryRunner, DashboardQueryRunnerResult } from './types';
|
||||
import { AlertState, AlertStateInfo } from '@grafana/data';
|
||||
import { setDataSourceSrv } from '@grafana/runtime';
|
||||
|
||||
import { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
|
||||
import { backendSrv } from '../../../../core/services/backend_srv';
|
||||
import * as annotationsSrv from '../../../annotations/executeAnnotationQuery';
|
||||
|
||||
import { createDashboardQueryRunner } from './DashboardQueryRunner';
|
||||
import { getDefaultOptions, LEGACY_DS_NAME, NEXT_GEN_DS_NAME, toAsyncOfResult } from './testHelpers';
|
||||
import { DashboardQueryRunner, DashboardQueryRunnerResult } from './types';
|
||||
|
||||
jest.mock('@grafana/runtime', () => ({
|
||||
...(jest.requireActual('@grafana/runtime') as unknown as object),
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
import { merge, Observable, ReplaySubject, Subject, Subscription, timer, Unsubscribable } from 'rxjs';
|
||||
import { finalize, map, mapTo, mergeAll, reduce, share, takeUntil } from 'rxjs/operators';
|
||||
import { AnnotationQuery } from '@grafana/data';
|
||||
|
||||
import { AnnotationQuery } from '@grafana/data';
|
||||
import { RefreshEvent } from '@grafana/runtime';
|
||||
import { config } from 'app/core/config';
|
||||
import { dedupAnnotations } from 'app/features/annotations/events_processing';
|
||||
|
||||
import { getTimeSrv, TimeSrv } from '../../../dashboard/services/TimeSrv';
|
||||
import { DashboardModel } from '../../../dashboard/state';
|
||||
|
||||
import { AlertStatesWorker } from './AlertStatesWorker';
|
||||
import { AnnotationsWorker } from './AnnotationsWorker';
|
||||
import { SnapshotWorker } from './SnapshotWorker';
|
||||
import { UnifiedAlertStatesWorker } from './UnifiedAlertStatesWorker';
|
||||
import {
|
||||
DashboardQueryRunner,
|
||||
DashboardQueryRunnerOptions,
|
||||
@@ -10,15 +20,7 @@ import {
|
||||
DashboardQueryRunnerWorker,
|
||||
DashboardQueryRunnerWorkerResult,
|
||||
} from './types';
|
||||
import { AlertStatesWorker } from './AlertStatesWorker';
|
||||
import { SnapshotWorker } from './SnapshotWorker';
|
||||
import { AnnotationsWorker } from './AnnotationsWorker';
|
||||
import { getAnnotationsByPanelId } from './utils';
|
||||
import { DashboardModel } from '../../../dashboard/state';
|
||||
import { getTimeSrv, TimeSrv } from '../../../dashboard/services/TimeSrv';
|
||||
import { RefreshEvent } from '@grafana/runtime';
|
||||
import { config } from 'app/core/config';
|
||||
import { UnifiedAlertStatesWorker } from './UnifiedAlertStatesWorker';
|
||||
|
||||
class DashboardQueryRunnerImpl implements DashboardQueryRunner {
|
||||
private readonly results: ReplaySubject<DashboardQueryRunnerWorkerResult>;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { getDefaultTimeRange } from '@grafana/data';
|
||||
|
||||
import { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
|
||||
import * as store from '../../../../store/store';
|
||||
|
||||
import { LegacyAnnotationQueryRunner } from './LegacyAnnotationQueryRunner';
|
||||
import { AnnotationQueryRunnerOptions } from './types';
|
||||
import { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
|
||||
import * as store from '../../../../store/store';
|
||||
|
||||
function getDefaultOptions(annotationQuery?: jest.Mock): AnnotationQueryRunnerOptions {
|
||||
const annotation: any = {};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { from, Observable, of } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { AnnotationEvent, DataSourceApi } from '@grafana/data';
|
||||
|
||||
import { AnnotationQueryRunner, AnnotationQueryRunnerOptions } from './types';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AnnotationEvent, getDefaultTimeRange } from '@grafana/data';
|
||||
|
||||
import { DashboardQueryRunnerOptions } from './types';
|
||||
import { SnapshotWorker } from './SnapshotWorker';
|
||||
import { DashboardQueryRunnerOptions } from './types';
|
||||
|
||||
function getDefaultOptions(): DashboardQueryRunnerOptions {
|
||||
const dashboard: any = {};
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Observable, of } from 'rxjs';
|
||||
|
||||
import { AnnotationEvent } from '@grafana/data';
|
||||
|
||||
import { DashboardModel } from '../../../dashboard/state';
|
||||
|
||||
import { DashboardQueryRunnerOptions, DashboardQueryRunnerWorker, DashboardQueryRunnerWorkerResult } from './types';
|
||||
import { emptyResult, getAnnotationsByPanelId, translateQueryResult } from './utils';
|
||||
import { DashboardModel } from '../../../dashboard/state';
|
||||
|
||||
export class SnapshotWorker implements DashboardQueryRunnerWorker {
|
||||
canWork({ dashboard }: DashboardQueryRunnerOptions): boolean {
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
|
||||
import { AlertState, getDefaultTimeRange, TimeRange } from '@grafana/data';
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
import { Annotation } from 'app/features/alerting/unified/utils/constants';
|
||||
import { PromAlertingRuleState, PromRuleDTO, PromRulesResponse, PromRuleType } from 'app/types/unified-alerting-dto';
|
||||
|
||||
import { DashboardQueryRunnerOptions } from './types';
|
||||
import { UnifiedAlertStatesWorker } from './UnifiedAlertStatesWorker';
|
||||
import { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
|
||||
import * as store from '../../../../store/store';
|
||||
import { PromAlertingRuleState, PromRuleDTO, PromRulesResponse, PromRuleType } from 'app/types/unified-alerting-dto';
|
||||
import { Annotation } from 'app/features/alerting/unified/utils/constants';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
|
||||
import { UnifiedAlertStatesWorker } from './UnifiedAlertStatesWorker';
|
||||
import { DashboardQueryRunnerOptions } from './types';
|
||||
|
||||
jest.mock('@grafana/runtime', () => ({
|
||||
...(jest.requireActual('@grafana/runtime') as unknown as object),
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { DashboardQueryRunnerOptions, DashboardQueryRunnerWorker, DashboardQueryRunnerWorkerResult } from './types';
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { emptyResult, handleDashboardQueryRunnerWorkerError } from './utils';
|
||||
import { PromAlertingRuleState, PromRulesResponse } from 'app/types/unified-alerting-dto';
|
||||
|
||||
import { AlertState, AlertStateInfo } from '@grafana/data';
|
||||
import { isAlertingRule } from 'app/features/alerting/unified/utils/rules';
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
import { Annotation } from 'app/features/alerting/unified/utils/constants';
|
||||
import { isAlertingRule } from 'app/features/alerting/unified/utils/rules';
|
||||
import { PromAlertingRuleState, PromRulesResponse } from 'app/types/unified-alerting-dto';
|
||||
|
||||
import { DashboardQueryRunnerOptions, DashboardQueryRunnerWorker, DashboardQueryRunnerWorkerResult } from './types';
|
||||
import { emptyResult, handleDashboardQueryRunnerWorkerError } from './utils';
|
||||
|
||||
export class UnifiedAlertStatesWorker implements DashboardQueryRunnerWorker {
|
||||
// maps dashboard uid to wether it has alert rules.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { asyncScheduler, Observable, of, scheduled } from 'rxjs';
|
||||
import { DashboardQueryRunnerOptions } from './types';
|
||||
|
||||
import { AnnotationEvent, getDefaultTimeRange } from '@grafana/data';
|
||||
|
||||
import { DashboardQueryRunnerOptions } from './types';
|
||||
|
||||
// function that creates an async of result Observable
|
||||
export function toAsyncOfResult(result: any): Observable<any> {
|
||||
return scheduled(of(result), asyncScheduler);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { AlertStateInfo, AnnotationEvent, AnnotationQuery, DataSourceApi, TimeRange } from '@grafana/data';
|
||||
|
||||
import { DashboardModel } from '../../../dashboard/state';
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { Observable, of } from 'rxjs';
|
||||
|
||||
import { AnnotationEvent, AnnotationQuery, DataFrame, DataFrameView, DataSourceApi } from '@grafana/data';
|
||||
import { config, toDataQueryError } from '@grafana/runtime';
|
||||
|
||||
import { dispatch } from 'app/store/store';
|
||||
|
||||
import { createErrorNotification } from '../../../../core/copy/appNotification';
|
||||
import { notifyApp } from '../../../../core/reducers/appNotification';
|
||||
|
||||
import { DashboardQueryRunnerWorkerResult } from './types';
|
||||
|
||||
export function handleAnnotationQueryRunnerError(err: any): Observable<AnnotationEvent[]> {
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
const applyFieldOverridesMock = jest.fn(); // needs to be first in this file
|
||||
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
// Importing this way to be able to spy on grafana/data
|
||||
import * as grafanaData from '@grafana/data';
|
||||
import { DashboardModel } from '../../dashboard/state/index';
|
||||
import { setDataSourceSrv, setEchoSrv } from '@grafana/runtime';
|
||||
|
||||
import { Echo } from '../../../core/services/echo/Echo';
|
||||
import { emptyResult } from './DashboardQueryRunner/utils';
|
||||
import { DashboardModel } from '../../dashboard/state/index';
|
||||
|
||||
import {
|
||||
createDashboardQueryRunner,
|
||||
setDashboardQueryRunnerFactory,
|
||||
} from './DashboardQueryRunner/DashboardQueryRunner';
|
||||
import { emptyResult } from './DashboardQueryRunner/utils';
|
||||
import { PanelQueryRunner } from './PanelQueryRunner';
|
||||
|
||||
jest.mock('@grafana/data', () => ({
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
// Libraries
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { MonoTypeOperatorFunction, Observable, of, ReplaySubject, Unsubscribable } from 'rxjs';
|
||||
import { map, mergeMap } from 'rxjs/operators';
|
||||
|
||||
// Services & Utils
|
||||
import { getTemplateSrv } from '@grafana/runtime';
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
import { preProcessPanelData, runRequest } from './runRequest';
|
||||
import { isSharedDashboardQuery, runSharedRequest } from '../../../plugins/datasource/dashboard';
|
||||
|
||||
// Types
|
||||
import {
|
||||
applyFieldOverrides,
|
||||
compareArrayValues,
|
||||
@@ -33,11 +25,17 @@ import {
|
||||
toDataFrame,
|
||||
transformDataFrame,
|
||||
} from '@grafana/data';
|
||||
import { getTemplateSrv } from '@grafana/runtime';
|
||||
import { StreamingDataFrame } from 'app/features/live/data/StreamingDataFrame';
|
||||
import { isStreamingDataFrame } from 'app/features/live/data/utils';
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
|
||||
import { isSharedDashboardQuery, runSharedRequest } from '../../../plugins/datasource/dashboard';
|
||||
import { PanelModel } from '../../dashboard/state';
|
||||
|
||||
import { getDashboardQueryRunner } from './DashboardQueryRunner/DashboardQueryRunner';
|
||||
import { mergePanelAndDashData } from './mergePanelAndDashData';
|
||||
import { PanelModel } from '../../dashboard/state';
|
||||
import { isStreamingDataFrame } from 'app/features/live/data/utils';
|
||||
import { StreamingDataFrame } from 'app/features/live/data/StreamingDataFrame';
|
||||
import { preProcessPanelData, runRequest } from './runRequest';
|
||||
|
||||
export interface QueryRunnerOptions<
|
||||
TQuery extends DataQuery = DataQuery,
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { from, Observable, ReplaySubject, Unsubscribable } from 'rxjs';
|
||||
import { first } from 'rxjs/operators';
|
||||
|
||||
import {
|
||||
CoreApp,
|
||||
DataQueryRequest,
|
||||
@@ -12,9 +16,7 @@ import {
|
||||
} from '@grafana/data';
|
||||
import { getTemplateSrv } from '@grafana/runtime';
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { from, Observable, ReplaySubject, Unsubscribable } from 'rxjs';
|
||||
import { first } from 'rxjs/operators';
|
||||
|
||||
import { getNextRequestId } from './PanelQueryRunner';
|
||||
import { setStructureRevision } from './processing/revision';
|
||||
import { preProcessPanelData, runRequest } from './runRequest';
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { AlertState, getDefaultTimeRange, LoadingState, PanelData, toDataFrame } from '@grafana/data';
|
||||
import { mergePanelAndDashData } from './mergePanelAndDashData';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
|
||||
import { AlertState, getDefaultTimeRange, LoadingState, PanelData, toDataFrame } from '@grafana/data';
|
||||
|
||||
import { mergePanelAndDashData } from './mergePanelAndDashData';
|
||||
|
||||
function getTestContext() {
|
||||
const timeRange = getDefaultTimeRange();
|
||||
const panelData: PanelData = {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { combineLatest, Observable, of } from 'rxjs';
|
||||
import { ArrayDataFrame, PanelData } from '@grafana/data';
|
||||
import { DashboardQueryRunnerResult } from './DashboardQueryRunner/types';
|
||||
import { mergeMap } from 'rxjs/operators';
|
||||
|
||||
import { ArrayDataFrame, PanelData } from '@grafana/data';
|
||||
|
||||
import { DashboardQueryRunnerResult } from './DashboardQueryRunner/types';
|
||||
|
||||
export function mergePanelAndDashData(
|
||||
panelObservable: Observable<PanelData>,
|
||||
dashObservable: Observable<DashboardQueryRunnerResult>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
import { MonoTypeOperatorFunction } from 'rxjs';
|
||||
import { finalize } from 'rxjs/operators';
|
||||
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
|
||||
export function cancelNetworkRequestsOnUnsubscribe<T>(
|
||||
backendSrv: BackendSrv,
|
||||
requestId: string | undefined
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { MetaAnalyticsEventName, reportMetaAnalytics } from '@grafana/runtime';
|
||||
import { CoreApp, DataFrame, DataQueryRequest, DataSourceApi, dateTime, LoadingState, PanelData } from '@grafana/data';
|
||||
import { emitDataRequestEvent } from './queryAnalytics';
|
||||
import { MetaAnalyticsEventName, reportMetaAnalytics } from '@grafana/runtime';
|
||||
|
||||
import { DashboardModel } from '../../dashboard/state';
|
||||
|
||||
import { emitDataRequestEvent } from './queryAnalytics';
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { getDashboardSrv } from '../../dashboard/services/DashboardSrv';
|
||||
import { PanelData, LoadingState, DataSourceApi, CoreApp, urlUtil } from '@grafana/data';
|
||||
import { reportMetaAnalytics, MetaAnalyticsEventName, DataRequestEventPayload } from '@grafana/runtime';
|
||||
|
||||
import { getDashboardSrv } from '../../dashboard/services/DashboardSrv';
|
||||
|
||||
export function emitDataRequestEvent(datasource: DataSourceApi) {
|
||||
let done = false;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Observable, Subscriber, Subscription } from 'rxjs';
|
||||
|
||||
import {
|
||||
DataFrame,
|
||||
DataQueryRequest,
|
||||
@@ -8,12 +10,13 @@ import {
|
||||
LoadingState,
|
||||
PanelData,
|
||||
} from '@grafana/data';
|
||||
import { Observable, Subscriber, Subscription } from 'rxjs';
|
||||
import { runRequest } from './runRequest';
|
||||
import { deepFreeze } from '../../../../test/core/redux/reducerTester';
|
||||
import { DashboardModel } from '../../dashboard/state/DashboardModel';
|
||||
import { setEchoSrv } from '@grafana/runtime';
|
||||
|
||||
import { deepFreeze } from '../../../../test/core/redux/reducerTester';
|
||||
import { Echo } from '../../../core/services/echo/Echo';
|
||||
import { DashboardModel } from '../../dashboard/state/DashboardModel';
|
||||
|
||||
import { runRequest } from './runRequest';
|
||||
|
||||
jest.mock('app/core/services/backend_srv');
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Libraries
|
||||
import { from, merge, Observable, of, timer } from 'rxjs';
|
||||
import { isString, map as isArray } from 'lodash';
|
||||
import { from, merge, Observable, of, timer } from 'rxjs';
|
||||
import { catchError, map, mapTo, share, takeUntil, tap } from 'rxjs/operators';
|
||||
|
||||
// Utils & Services
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
// Types
|
||||
import {
|
||||
DataFrame,
|
||||
@@ -21,11 +21,13 @@ import {
|
||||
toDataFrame,
|
||||
} from '@grafana/data';
|
||||
import { toDataQueryError } from '@grafana/runtime';
|
||||
import { emitDataRequestEvent } from './queryAnalytics';
|
||||
import { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
import { dataSource as expressionDatasource } from 'app/features/expressions/ExpressionDatasource';
|
||||
import { ExpressionQuery } from 'app/features/expressions/types';
|
||||
|
||||
import { cancelNetworkRequestsOnUnsubscribe } from './processing/canceler';
|
||||
import { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
|
||||
import { emitDataRequestEvent } from './queryAnalytics';
|
||||
|
||||
type MapOfResponsePackets = { [str: string]: DataQueryResponse };
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
DataSourceWithQueryImportSupport,
|
||||
} from '@grafana/data';
|
||||
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
|
||||
|
||||
import { updateQueries } from './updateQueries';
|
||||
|
||||
const oldUidDS = {
|
||||
|
||||
Reference in New Issue
Block a user