From 7b7000c5bcb445dcf039d50ab4feed68842ef056 Mon Sep 17 00:00:00 2001 From: Lukas Siatka Date: Wed, 17 Jun 2020 10:08:19 +0200 Subject: [PATCH] Explore: updates ExploreItemState type, reduces strict null errors count to 702 (#25250) * Chore: changes null values to undefined in explore reducer * Chore: changes sortLogsResult param type from null to undefined * Chore: changes null values to undefined in explore reducer * Chore: updates strict null errors count * Revert "Chore: changes null values to undefined in explore reducer" This reverts commit b82d84161148dfba181425d625cc8c24df0cd757. * Revert "Chore: changes sortLogsResult param type from null to undefined" This reverts commit 21073b5d306ba6ba786617f8d575d5d95b438277. * Revert "Chore: changes null values to undefined in explore reducer" This reverts commit 798559688c31dbe1f3893bc933c0c36e882ab99e. * Chore: updates ExploreItemState type * Chore: updates initial ExploreItemState in Explore reducer * Chore: updates strict null errors count to 699 * Chore: changed ExploreMode and Emitter type in ExploreStateItem * Revert "Chore: changed ExploreMode and Emitter type in ExploreStateItem" This reverts commit 7e0e2027fcc245f208456d3b12806338a4aef9d7. --- public/app/features/explore/state/reducers.ts | 10 ++++++++-- public/app/types/explore.ts | 14 +++++++------- scripts/ci-frontend-metrics.sh | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/public/app/features/explore/state/reducers.ts b/public/app/features/explore/state/reducers.ts index 8bbcc66bea0..315c5a8eaa0 100644 --- a/public/app/features/explore/state/reducers.ts +++ b/public/app/features/explore/state/reducers.ts @@ -12,6 +12,7 @@ import { TimeZone, toLegacyResponseData, ExploreMode, + LogsDedupStrategy, } from '@grafana/data'; import { RefreshPicker } from '@grafana/ui'; import { LocationUpdate } from '@grafana/runtime'; @@ -69,6 +70,7 @@ import { } from './actionTypes'; import { ResultProcessor } from '../utils/ResultProcessor'; import { updateLocation } from '../../../core/actions'; +import { Emitter } from 'app/core/core'; export const DEFAULT_RANGE = { from: 'now-6h', @@ -105,7 +107,6 @@ export const makeExploreItemState = (): ExploreItemState => ({ to: null, }, scanning: false, - scanRange: null, showingGraph: true, showingTable: true, loading: false, @@ -114,11 +115,16 @@ export const makeExploreItemState = (): ExploreItemState => ({ update: makeInitialUpdateState(), latency: 0, supportedModes: [], - mode: null, + mode: (null as unknown) as ExploreMode, isLive: false, isPaused: false, urlReplaced: false, queryResponse: createEmptyQueryResponse(), + tableResult: null, + graphResult: null, + logsResult: null, + dedupStrategy: LogsDedupStrategy.none, + eventBridge: (null as unknown) as Emitter, }); export const createEmptyQueryResponse = (): PanelData => ({ diff --git a/public/app/types/explore.ts b/public/app/types/explore.ts index 3640c6875de..07f4654af87 100644 --- a/public/app/types/explore.ts +++ b/public/app/types/explore.ts @@ -66,7 +66,7 @@ export interface ExploreItemState { /** * True if the datasource is loading. `null` if the loading has not started yet. */ - datasourceLoading?: boolean; + datasourceLoading: boolean | null; /** * True if there is no datasource to be selected. */ @@ -74,11 +74,11 @@ export interface ExploreItemState { /** * Emitter to send events to the rest of Grafana. */ - eventBridge?: Emitter; + eventBridge: Emitter; /** * List of timeseries to be shown in the Explore graph result viewer. */ - graphResult?: GraphSeriesXY[]; + graphResult: GraphSeriesXY[] | null; /** * History of recent queries. Datasource-specific and initialized via localStorage. */ @@ -101,7 +101,7 @@ export interface ExploreItemState { /** * Log query result to be displayed in the logs result viewer. */ - logsResult?: LogsModel; + logsResult: LogsModel | null; /** * Time range for this Explore. Managed by the time picker and used by all query runs. @@ -112,7 +112,7 @@ export interface ExploreItemState { /** * True if scanning for more results is active. */ - scanning?: boolean; + scanning: boolean; /** * Current scanning range to be shown to the user while scanning is active. */ @@ -130,7 +130,7 @@ export interface ExploreItemState { /** * Table model that combines all query table results into a single table. */ - tableResult?: DataFrame; + tableResult: DataFrame | null; /** * React keys for rendering of QueryRows @@ -140,7 +140,7 @@ export interface ExploreItemState { /** * Current logs deduplication strategy */ - dedupStrategy?: LogsDedupStrategy; + dedupStrategy: LogsDedupStrategy; /** * Currently hidden log series diff --git a/scripts/ci-frontend-metrics.sh b/scripts/ci-frontend-metrics.sh index 18ad5153190..0eadafd94ab 100755 --- a/scripts/ci-frontend-metrics.sh +++ b/scripts/ci-frontend-metrics.sh @@ -2,7 +2,7 @@ echo -e "Collecting code stats (typescript errors & more)" -ERROR_COUNT_LIMIT=724 +ERROR_COUNT_LIMIT=702 DIRECTIVES_LIMIT=172 CONTROLLERS_LIMIT=139