Chore: Timeseries cleanup avoid React.FC (#62984)

timeseries FC
This commit is contained in:
Ryan McKinley
2023-02-06 13:53:56 -08:00
committed by GitHub
parent dc64c9d1d0
commit 5343255de8
5 changed files with 13 additions and 16 deletions
+2 -9
View File
@@ -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"],
@@ -52,7 +52,9 @@ const dotOptions: Array<SelectableValue<string>> = [
value: txt,
}));
export const LineStyleEditor: React.FC<FieldOverrideEditorProps<LineStyle, any>> = ({ value, onChange }) => {
type Props = FieldOverrideEditorProps<LineStyle, unknown>;
export const LineStyleEditor = ({ value, onChange }: Props) => {
const options = useMemo(() => (value?.fill === 'dash' ? dashOptions : dotOptions), [value]);
const current = useMemo(() => {
if (!value?.dash?.length) {
@@ -18,7 +18,9 @@ const GAPS_OPTIONS: Array<SelectableValue<boolean | number>> = [
},
];
export const SpanNullsEditor: React.FC<FieldOverrideEditorProps<boolean | number, any>> = ({ value, onChange }) => {
type Props = FieldOverrideEditorProps<boolean | number, unknown>;
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
@@ -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<SelectableValue<{ mode: GraphTresholdsStyleMode }>, any>
> = ({ item, value, onChange, id }) => {
type Props = FieldOverrideEditorProps<SelectableValue<{ mode: GraphTresholdsStyleMode }>, unknown>;
export const ThresholdsStyleEditor = ({ item, value, onChange, id }: Props) => {
const onChangeCb = useCallback(
(v: SelectableValue<GraphTresholdsStyleMode>) => {
onChange({
@@ -18,7 +18,7 @@ import { getTimezones, prepareGraphableFields, regenerateLinksSupplier } from '.
interface TimeSeriesPanelProps extends PanelProps<TimeSeriesOptions> {}
export const TimeSeriesPanel: React.FC<TimeSeriesPanelProps> = ({
export const TimeSeriesPanel = ({
data,
timeRange,
timeZone,
@@ -29,7 +29,7 @@ export const TimeSeriesPanel: React.FC<TimeSeriesPanelProps> = ({
onChangeTimeRange,
replaceVariables,
id,
}) => {
}: TimeSeriesPanelProps) => {
const { sync, canAddAnnotations, onThresholdsChange, canEditThresholds, showThresholds, onSplitOpen } =
usePanelContext();