From 5343255de80b9056d93f52cd2d7109d507300f74 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Mon, 6 Feb 2023 13:53:56 -0800 Subject: [PATCH] Chore: Timeseries cleanup avoid React.FC (#62984) timeseries FC --- .betterer.results | 11 ++--------- .../app/plugins/panel/timeseries/LineStyleEditor.tsx | 4 +++- .../app/plugins/panel/timeseries/SpanNullsEditor.tsx | 4 +++- .../panel/timeseries/ThresholdsStyleEditor.tsx | 6 +++--- .../app/plugins/panel/timeseries/TimeSeriesPanel.tsx | 4 ++-- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.betterer.results b/.betterer.results index 68b7f4f9017..f0cf511d4c4 100644 --- a/.betterer.results +++ b/.betterer.results @@ -7610,18 +7610,11 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Do not use any type assertions.", "3"] ], - "public/app/plugins/panel/timeseries/LineStyleEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/panel/timeseries/SpanNullsEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], + [0, 0, 0, "Do not use any type assertions.", "0"], [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.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"] - ], - "public/app/plugins/panel/timeseries/ThresholdsStyleEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "public/app/plugins/panel/timeseries/migrations.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], diff --git a/public/app/plugins/panel/timeseries/LineStyleEditor.tsx b/public/app/plugins/panel/timeseries/LineStyleEditor.tsx index 79be3044695..fba7f15f96c 100644 --- a/public/app/plugins/panel/timeseries/LineStyleEditor.tsx +++ b/public/app/plugins/panel/timeseries/LineStyleEditor.tsx @@ -52,7 +52,9 @@ const dotOptions: Array> = [ value: txt, })); -export const LineStyleEditor: React.FC> = ({ value, onChange }) => { +type Props = FieldOverrideEditorProps; + +export const LineStyleEditor = ({ value, onChange }: Props) => { const options = useMemo(() => (value?.fill === 'dash' ? dashOptions : dotOptions), [value]); const current = useMemo(() => { if (!value?.dash?.length) { diff --git a/public/app/plugins/panel/timeseries/SpanNullsEditor.tsx b/public/app/plugins/panel/timeseries/SpanNullsEditor.tsx index 119ff689238..1ee39c4f1a8 100644 --- a/public/app/plugins/panel/timeseries/SpanNullsEditor.tsx +++ b/public/app/plugins/panel/timeseries/SpanNullsEditor.tsx @@ -18,7 +18,9 @@ const GAPS_OPTIONS: Array> = [ }, ]; -export const SpanNullsEditor: React.FC> = ({ value, onChange }) => { +type Props = FieldOverrideEditorProps; + +export const SpanNullsEditor = ({ value, onChange }: Props) => { const isThreshold = typeof value === 'number'; const formattedTime = isThreshold ? rangeUtil.secondsToHms((value as number) / 1000) : undefined; GAPS_OPTIONS[2].value = isThreshold ? (value as number) : 3600000; // 1h diff --git a/public/app/plugins/panel/timeseries/ThresholdsStyleEditor.tsx b/public/app/plugins/panel/timeseries/ThresholdsStyleEditor.tsx index 417d8c10671..31f4c11a6bf 100644 --- a/public/app/plugins/panel/timeseries/ThresholdsStyleEditor.tsx +++ b/public/app/plugins/panel/timeseries/ThresholdsStyleEditor.tsx @@ -4,9 +4,9 @@ import { FieldOverrideEditorProps, SelectableValue } from '@grafana/data'; import { GraphTresholdsStyleMode } from '@grafana/schema'; import { Select } from '@grafana/ui'; -export const ThresholdsStyleEditor: React.FC< - FieldOverrideEditorProps, any> -> = ({ item, value, onChange, id }) => { +type Props = FieldOverrideEditorProps, unknown>; + +export const ThresholdsStyleEditor = ({ item, value, onChange, id }: Props) => { const onChangeCb = useCallback( (v: SelectableValue) => { onChange({ diff --git a/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx b/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx index 68cd8050659..c946985c2e2 100644 --- a/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx +++ b/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx @@ -18,7 +18,7 @@ import { getTimezones, prepareGraphableFields, regenerateLinksSupplier } from '. interface TimeSeriesPanelProps extends PanelProps {} -export const TimeSeriesPanel: React.FC = ({ +export const TimeSeriesPanel = ({ data, timeRange, timeZone, @@ -29,7 +29,7 @@ export const TimeSeriesPanel: React.FC = ({ onChangeTimeRange, replaceVariables, id, -}) => { +}: TimeSeriesPanelProps) => { const { sync, canAddAnnotations, onThresholdsChange, canEditThresholds, showThresholds, onSplitOpen } = usePanelContext();