Chore: Improve typings in OptionsUI and Explore (#76245)

This commit is contained in:
Joao Silva 2023-10-11 11:43:25 +01:00 committed by GitHub
parent 50504ba008
commit 5f6fea33f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 37 deletions

View File

@ -1331,11 +1331,11 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "17"], [0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Do not use any type assertions.", "18"], [0, 0, 0, "Do not use any type assertions.", "18"],
[0, 0, 0, "Unexpected any. Specify a different type.", "19"], [0, 0, 0, "Unexpected any. Specify a different type.", "19"],
[0, 0, 0, "Do not use any type assertions.", "20"], [0, 0, 0, "Unexpected any. Specify a different type.", "20"],
[0, 0, 0, "Unexpected any. Specify a different type.", "21"], [0, 0, 0, "Do not use any type assertions.", "21"],
[0, 0, 0, "Do not use any type assertions.", "22"], [0, 0, 0, "Unexpected any. Specify a different type.", "22"],
[0, 0, 0, "Unexpected any. Specify a different type.", "23"], [0, 0, 0, "Do not use any type assertions.", "23"],
[0, 0, 0, "Do not use any type assertions.", "24"], [0, 0, 0, "Unexpected any. Specify a different type.", "24"],
[0, 0, 0, "Unexpected any. Specify a different type.", "25"], [0, 0, 0, "Unexpected any. Specify a different type.", "25"],
[0, 0, 0, "Do not use any type assertions.", "26"], [0, 0, 0, "Do not use any type assertions.", "26"],
[0, 0, 0, "Unexpected any. Specify a different type.", "27"], [0, 0, 0, "Unexpected any. Specify a different type.", "27"],
@ -1386,20 +1386,10 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "72"], [0, 0, 0, "Unexpected any. Specify a different type.", "72"],
[0, 0, 0, "Do not use any type assertions.", "73"], [0, 0, 0, "Do not use any type assertions.", "73"],
[0, 0, 0, "Unexpected any. Specify a different type.", "74"], [0, 0, 0, "Unexpected any. Specify a different type.", "74"],
[0, 0, 0, "Unexpected any. Specify a different type.", "75"], [0, 0, 0, "Do not use any type assertions.", "75"],
[0, 0, 0, "Do not use any type assertions.", "76"], [0, 0, 0, "Unexpected any. Specify a different type.", "76"],
[0, 0, 0, "Unexpected any. Specify a different type.", "77"], [0, 0, 0, "Do not use any type assertions.", "77"],
[0, 0, 0, "Do not use any type assertions.", "78"], [0, 0, 0, "Unexpected any. Specify a different type.", "78"]
[0, 0, 0, "Unexpected any. Specify a different type.", "79"],
[0, 0, 0, "Unexpected any. Specify a different type.", "80"],
[0, 0, 0, "Do not use any type assertions.", "81"],
[0, 0, 0, "Unexpected any. Specify a different type.", "82"],
[0, 0, 0, "Do not use any type assertions.", "83"],
[0, 0, 0, "Unexpected any. Specify a different type.", "84"],
[0, 0, 0, "Do not use any type assertions.", "85"],
[0, 0, 0, "Unexpected any. Specify a different type.", "86"],
[0, 0, 0, "Do not use any type assertions.", "87"],
[0, 0, 0, "Unexpected any. Specify a different type.", "88"]
], ],
"public/app/core/components/OptionsUI/slider.tsx:5381": [ "public/app/core/components/OptionsUI/slider.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"] [0, 0, 0, "Styles should be written using objects.", "0"]
@ -3811,9 +3801,6 @@ exports[`better eslint`] = {
"public/app/features/explore/ExplorePaneContainer.tsx:5381": [ "public/app/features/explore/ExplorePaneContainer.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"] [0, 0, 0, "Styles should be written using objects.", "0"]
], ],
"public/app/features/explore/ExploreQueryInspector.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/explore/FeatureTogglePage.tsx:5381": [ "public/app/features/explore/FeatureTogglePage.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"] [0, 0, 0, "Styles should be written using objects.", "0"]
], ],
@ -3994,11 +3981,7 @@ exports[`better eslint`] = {
"public/app/features/explore/TraceView/TraceView.tsx:5381": [ "public/app/features/explore/TraceView/TraceView.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"], [0, 0, 0, "Do not use any type assertions.", "2"]
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"]
], ],
"public/app/features/explore/TraceView/components/TracePageHeader/Actions/ActionButton.tsx:5381": [ "public/app/features/explore/TraceView/components/TracePageHeader/Actions/ActionButton.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"] [0, 0, 0, "Styles should be written using objects.", "0"]

View File

@ -69,7 +69,7 @@ export const getAllOptionEditors = () => {
id: 'text', id: 'text',
name: 'Text', name: 'Text',
description: 'Allows string values input', description: 'Allows string values input',
editor: StringValueEditor as any, editor: StringValueEditor,
}; };
const strings: StandardEditorsRegistryItem<string[]> = { const strings: StandardEditorsRegistryItem<string[]> = {
@ -155,28 +155,28 @@ export const getAllOptionEditors = () => {
id: 'timezone', id: 'timezone',
name: 'Time zone', name: 'Time zone',
description: 'Time zone selection', description: 'Time zone selection',
editor: TimeZonePicker as any, editor: TimeZonePicker,
}; };
const fieldName: StandardEditorsRegistryItem<string, FieldNamePickerConfigSettings> = { const fieldName: StandardEditorsRegistryItem<string, FieldNamePickerConfigSettings> = {
id: 'field-name', id: 'field-name',
name: 'Field name', name: 'Field name',
description: 'Allows selecting a field name from a data frame', description: 'Allows selecting a field name from a data frame',
editor: FieldNamePicker as any, editor: FieldNamePicker,
}; };
const dashboardPicker: StandardEditorsRegistryItem<string, DashboardPickerOptions> = { const dashboardPicker: StandardEditorsRegistryItem<string, DashboardPickerOptions> = {
id: 'dashboard-uid', id: 'dashboard-uid',
name: 'Dashboard', name: 'Dashboard',
description: 'Select dashboard', description: 'Select dashboard',
editor: DashboardPicker as any, editor: DashboardPicker,
}; };
const mappings: StandardEditorsRegistryItem<ValueMapping[]> = { const mappings: StandardEditorsRegistryItem<ValueMapping[]> = {
id: 'mappings', id: 'mappings',
name: 'Mappings', name: 'Mappings',
description: 'Allows defining value mappings', description: 'Allows defining value mappings',
editor: ValueMappingsEditor as any, editor: ValueMappingsEditor,
}; };
const thresholds: StandardEditorsRegistryItem<ThresholdsConfig> = { const thresholds: StandardEditorsRegistryItem<ThresholdsConfig> = {

View File

@ -3,6 +3,7 @@ import { connect, ConnectedProps } from 'react-redux';
import { CoreApp, LoadingState, TimeZone } from '@grafana/data'; import { CoreApp, LoadingState, TimeZone } from '@grafana/data';
import { reportInteraction } from '@grafana/runtime/src'; import { reportInteraction } from '@grafana/runtime/src';
import { defaultTimeZone } from '@grafana/schema';
import { TabbedContainer, TabConfig } from '@grafana/ui'; import { TabbedContainer, TabConfig } from '@grafana/ui';
import { ExploreDrawer } from 'app/features/explore/ExploreDrawer'; import { ExploreDrawer } from 'app/features/explore/ExploreDrawer';
import { InspectDataTab } from 'app/features/inspector/InspectDataTab'; import { InspectDataTab } from 'app/features/inspector/InspectDataTab';
@ -39,7 +40,7 @@ export function ExploreQueryInspector(props: Props) {
label: 'Stats', label: 'Stats',
value: 'stats', value: 'stats',
icon: 'chart-line', icon: 'chart-line',
content: <InspectStatsTab data={queryResponse!} timeZone={queryResponse?.request?.timezone as TimeZone} />, content: <InspectStatsTab data={queryResponse!} timeZone={queryResponse?.request?.timezone ?? defaultTimeZone} />,
}; };
const jsonTab: TabConfig = { const jsonTab: TabConfig = {

View File

@ -18,7 +18,7 @@ import {
import { getTemplateSrv } from '@grafana/runtime'; import { getTemplateSrv } from '@grafana/runtime';
import { DataQuery } from '@grafana/schema'; import { DataQuery } from '@grafana/schema';
import { useStyles2 } from '@grafana/ui'; import { useStyles2 } from '@grafana/ui';
import { getTraceToLogsOptions, TraceToLogsData } from 'app/core/components/TraceToLogs/TraceToLogsSettings'; import { getTraceToLogsOptions } from 'app/core/components/TraceToLogs/TraceToLogsSettings';
import { TraceToMetricsData } from 'app/core/components/TraceToMetrics/TraceToMetricsSettings'; import { TraceToMetricsData } from 'app/core/components/TraceToMetrics/TraceToMetricsSettings';
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv'; import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
import { getTimeZone } from 'app/features/profile/state/selectors'; import { getTimeZone } from 'app/features/profile/state/selectors';
@ -112,8 +112,9 @@ export function TraceView(props: Props) {
); );
const instanceSettings = getDatasourceSrv().getInstanceSettings(datasource?.name); const instanceSettings = getDatasourceSrv().getInstanceSettings(datasource?.name);
const traceToLogsOptions = getTraceToLogsOptions(instanceSettings?.jsonData as TraceToLogsData); const traceToLogsOptions = getTraceToLogsOptions(instanceSettings?.jsonData);
const traceToMetricsOptions = (instanceSettings?.jsonData as TraceToMetricsData)?.tracesToMetrics; const traceToMetrics: TraceToMetricsData | undefined = instanceSettings?.jsonData;
const traceToMetricsOptions = traceToMetrics?.tracesToMetrics;
const spanBarOptions: SpanBarOptionsData | undefined = instanceSettings?.jsonData; const spanBarOptions: SpanBarOptionsData | undefined = instanceSettings?.jsonData;
const createSpanLink = useMemo( const createSpanLink = useMemo(
@ -261,7 +262,6 @@ function useFocusSpanLink(options: {
link, link,
internalLink: link.internal!, internalLink: link.internal!,
scopedVars: {}, scopedVars: {},
range: {} as any,
field: {} as Field, field: {} as Field,
onClickFn: sameTrace onClickFn: sameTrace
? () => setFocusedSpanId(focusedSpanId === spanId ? undefined : spanId) ? () => setFocusedSpanId(focusedSpanId === spanId ? undefined : spanId)