From 4f13e78d117f915792953f6d6272b63722a0c4ca Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Wed, 15 Mar 2023 07:56:09 -0700 Subject: [PATCH] Chore: Avoid explicit React.FC when possible (round 2) (#64749) --- .betterer.results | 6 +- contribute/style-guides/styling.md | 2 +- .../plugins/add-support-for-variables.md | 2 +- .../plugins/custom-panel-option-editors.md | 8 +- .../ButtonCascader/ButtonCascader.tsx | 2 +- .../components/ContextMenu/ContextMenu.tsx | 4 +- .../ContextMenu/WithContextMenu.tsx | 2 +- .../components/DataLinks/DataLinkEditor.tsx | 72 ++++---- .../components/DataLinks/DataLinkInput.tsx | 9 +- .../DataLinks/DataLinkSuggestions.tsx | 14 +- .../DataLinksInlineEditor.tsx | 7 +- .../DataSourceSettings/BasicAuthSettings.tsx | 2 +- .../CustomHeadersSettings.tsx | 2 +- .../DataSourceHttpSettings.tsx | 2 +- .../DataSourceSettings/HttpProxySettings.tsx | 4 +- .../DataSourceSettings/TLSAuthSettings.tsx | 2 +- .../RelativeTimeRangePicker.test.tsx | 2 +- .../TimeRangePicker/TimePickerContent.tsx | 4 +- .../TimeZonePicker/TimeZoneOption.tsx | 4 +- .../src/components/FilterPill/FilterPill.tsx | 2 +- .../grafana-ui/src/components/Forms/Field.tsx | 4 +- .../grafana-ui/src/components/Forms/Label.tsx | 2 +- .../src/components/Forms/Legend.tsx | 2 +- .../RadioButtonList/RadioButtonList.story.tsx | 2 +- .../src/components/Graph/GraphContextMenu.tsx | 4 +- .../GraphTooltip/MultiModeGraphTooltip.tsx | 12 +- .../GraphTooltip/SingleModeGraphTooltip.tsx | 6 +- .../src/components/InfoBox/FeatureInfoBox.tsx | 2 +- .../src/components/Menu/MenuGroup.tsx | 2 +- .../src/components/Menu/SubMenu.tsx | 4 +- .../components/PanelChrome/ErrorIndicator.tsx | 2 +- .../PanelChrome/LoadingIndicator.tsx | 2 +- .../PluginSignatureBadge.tsx | 2 +- .../components/Segment/useExpandableLabel.tsx | 2 +- .../components/Select/DropdownIndicator.tsx | 2 +- .../src/components/VizTooltip/SeriesTable.tsx | 4 +- .../VizTooltip/VizTooltipContainer.tsx | 4 +- .../src/components/uPlot/PlotLegend.tsx | 4 +- .../uPlot/plugins/KeyboardPlugin.tsx | 4 +- .../uPlot/plugins/TooltipPlugin.tsx | 4 +- .../components/uPlot/plugins/ZoomPlugin.tsx | 4 +- .../src/options/builder/hideSeries.tsx | 4 +- .../src/options/builder/stacking.tsx | 7 +- .../src/themes/ThemeContext.test.tsx | 2 +- .../utils/storybook/ThemedDocsContainer.tsx | 3 +- .../core/components/OptionsUI/fieldColor.tsx | 9 +- .../app/core/components/OptionsUI/links.tsx | 8 +- .../app/core/components/OptionsUI/number.tsx | 8 +- .../app/core/components/OptionsUI/slider.tsx | 8 +- .../app/core/components/OptionsUI/stats.tsx | 4 +- .../QueryOperationAction.tsx | 8 +- .../QueryOperationRowHeader.tsx | 2 +- .../features/commandPalette/KBarResults.tsx | 2 +- .../CategoryHeader/CategoryHeader.tsx | 4 +- .../AddPanelWidget/AddPanelWidget.tsx | 2 +- .../DashboardSettings/ListNewButton.tsx | 2 +- .../LinksSettings/LinkSettingsEdit.tsx | 2 +- .../LinksSettings/LinkSettingsList.tsx | 2 +- .../PanelEditor/DynamicConfigValueEditor.tsx | 4 +- .../components/PanelEditor/OptionsPane.tsx | 4 +- .../PanelEditor/OptionsPaneOptions.tsx | 2 +- .../SaveDashboard/SaveDashboardButton.tsx | 11 +- .../SaveDashboard/SaveDashboardErrorProxy.tsx | 4 +- .../SaveDashboard/UnsavedChangesModal.tsx | 7 +- .../forms/SaveDashboardAsForm.tsx | 8 +- .../forms/SaveProvisionedDashboardForm.tsx | 2 +- .../SubMenu/DashboardLinksDashboard.tsx | 2 +- .../TransformationOperationRows.tsx | 4 +- .../components/VersionHistory/DiffTitle.tsx | 2 +- .../components/VersionHistory/DiffValues.tsx | 2 +- .../components/VersionHistory/DiffViewer.tsx | 2 +- .../VersionHistory/RevertDashboardModal.tsx | 2 +- .../VersionHistory/VersionHistoryButtons.tsx | 4 +- .../VersionHistoryComparison.tsx | 2 +- .../VersionHistory/VersionHistoryHeader.tsx | 4 +- .../dashboard/dashgrid/DashboardGrid.test.tsx | 2 +- .../SpanDetail/AccordianReferences.tsx | 4 +- .../LibraryPanelCard/LibraryPanelCard.tsx | 9 +- .../LibraryPanelsView/LibraryPanelsView.tsx | 4 +- .../sql/components/DatasetSelector.tsx | 9 +- .../plugins/sql/components/TableSelector.tsx | 2 +- .../visual-query-builder/VisualEditor.tsx | 9 +- .../FilterByValueTransformerEditor.tsx | 4 +- .../ValueMatchers/NoopMatcherEditor.tsx | 6 +- .../HeatmapTransformerEditor.tsx | 2 +- .../calculateHeatmap/editor/AxisEditor.tsx | 6 +- .../editors/GroupByTransformerEditor.tsx | 6 +- .../GroupingToMatrixTransformerEditor.tsx | 4 +- .../editors/HistogramTransformerEditor.tsx | 4 +- .../LabelsToFieldsTransformerEditor.tsx | 4 +- .../editors/LimitTransformerEditor.tsx | 5 +- .../editors/MergeTransformerEditor.tsx | 6 +- .../editors/ReduceTransformerEditor.tsx | 5 +- .../editors/SeriesToRowsTransformerEditor.tsx | 6 +- .../editors/SortByTransformerEditor.tsx | 6 +- .../ExtractFieldsTransformerEditor.tsx | 4 +- .../FieldLookupTransformerEditor.tsx | 6 +- .../spatial/SpatialTransformerEditor.tsx | 4 +- .../ArgQueryEditor/ArgQueryEditor.tsx | 4 +- .../components/ArgQueryEditor/QueryField.tsx | 2 +- .../LogsQueryEditor/FormatAsField.tsx | 2 +- .../LogsQueryEditor/LogsQueryEditor.tsx | 4 +- .../components/LogsQueryEditor/QueryField.tsx | 2 +- .../MetricsQueryEditor/AggregationField.tsx | 4 +- .../MetricsQueryEditor/DimensionFields.tsx | 2 +- .../MetricsQueryEditor/LegendFormatField.tsx | 2 +- .../MetricsQueryEditor/MetricNameField.tsx | 2 +- .../MetricNamespaceField.tsx | 4 +- .../MetricsQueryEditor/MetricsQueryEditor.tsx | 4 +- .../MetricsQueryEditor/TimeGrainField.tsx | 7 +- .../MetricsQueryEditor/TopField.tsx | 2 +- .../components/QueryEditor/QueryEditor.tsx | 8 +- .../azuremonitor/components/QueryHeader.tsx | 2 +- .../ResourceField/ResourceField.tsx | 6 +- .../components/ResourcePicker/EntryIcon.tsx | 2 +- .../components/ResourcePicker/NestedEntry.tsx | 4 +- .../components/ResourcePicker/NestedRow.tsx | 4 +- .../components/SubscriptionField.tsx | 4 +- .../SQLBuilderEditor/SQLBuilderSelectRow.tsx | 2 +- .../components/SQLBuilderEditor/SQLFilter.tsx | 4 +- .../SQLBuilderEditor/SQLGroupBy.tsx | 4 +- .../SQLBuilderEditor/SQLOrderByGroup.tsx | 2 +- .../graphite/components/FunctionEditor.tsx | 2 +- .../parca/QueryEditor/EditorRow.tsx | 2 +- .../parca/QueryEditor/EditorRows.tsx | 2 +- .../phlare/QueryEditor/EditorField.tsx | 2 +- .../phlare/QueryEditor/EditorRow.tsx | 2 +- .../phlare/QueryEditor/EditorRows.tsx | 2 +- .../components/PromExploreExtraField.tsx | 158 +++++++++--------- .../testdata/components/ErrorEditor.tsx | 2 +- .../panel/barchart/TickSpacingEditor.tsx | 2 +- .../panel/candlestick/CandlestickPanel.tsx | 4 +- .../plugins/panel/heatmap/HeatmapPanel.tsx | 4 +- .../state-timeline/StateTimelinePanel.tsx | 4 +- .../state-timeline/StateTimelineTooltip.tsx | 4 +- .../status-history/StatusHistoryPanel.tsx | 4 +- .../status-history/StatusHistoryTooltip.tsx | 4 +- .../plugins/AnnotationEditorPlugin.tsx | 2 +- .../timeseries/plugins/AnnotationsPlugin.tsx | 2 +- .../timeseries/plugins/ContextMenuPlugin.tsx | 8 +- .../timeseries/plugins/ExemplarMarker.tsx | 4 +- .../timeseries/plugins/ExemplarsPlugin.tsx | 4 +- .../timeseries/plugins/OutsideRangePlugin.tsx | 2 +- .../plugins/ThresholdControlsPlugin.tsx | 6 +- .../plugins/ThresholdDragHandle.tsx | 4 +- .../plugins/annotations/AnnotationEditor.tsx | 4 +- .../plugins/panel/xychart/XYChartPanel.old | 4 +- 147 files changed, 361 insertions(+), 446 deletions(-) diff --git a/.betterer.results b/.betterer.results index d10ae63961d..7434e2da655 100644 --- a/.betterer.results +++ b/.betterer.results @@ -3955,8 +3955,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], "public/app/features/transformers/FilterByValueTransformer/ValueMatchers/NoopMatcherEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/transformers/FilterByValueTransformer/ValueMatchers/RangeMatcherEditor.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -3974,9 +3973,6 @@ exports[`better eslint`] = { "public/app/features/transformers/FilterByValueTransformer/ValueMatchers/valueMatchersUI.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/transformers/calculateHeatmap/editor/AxisEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/transformers/calculateHeatmap/editor/helper.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], diff --git a/contribute/style-guides/styling.md b/contribute/style-guides/styling.md index c9d4c193be2..caf1b137f41 100644 --- a/contribute/style-guides/styling.md +++ b/contribute/style-guides/styling.md @@ -48,7 +48,7 @@ interface ComponentAProps { isActive: boolean; } -const ComponentA: React.FC = ({ isActive }) => { +const ComponentA = ({ isActive }: ComponentAProps) => { const theme = useTheme(); const styles = useStyles2(theme); diff --git a/docs/sources/developers/plugins/add-support-for-variables.md b/docs/sources/developers/plugins/add-support-for-variables.md index c8bc2a85358..c398b284fb4 100644 --- a/docs/sources/developers/plugins/add-support-for-variables.md +++ b/docs/sources/developers/plugins/add-support-for-variables.md @@ -143,7 +143,7 @@ Let's create a custom query editor to allow the user to edit the query model. onChange: (query: MyVariableQuery, definition: string) => void; } - export const VariableQueryEditor: React.FC = ({ onChange, query }) => { + export const VariableQueryEditor = ({ onChange, query }: VariableQueryProps) => { const [state, setState] = useState(query); const saveQuery = () => { diff --git a/docs/sources/developers/plugins/custom-panel-option-editors.md b/docs/sources/developers/plugins/custom-panel-option-editors.md index d943c6deb70..d0d4ab8e766 100644 --- a/docs/sources/developers/plugins/custom-panel-option-editors.md +++ b/docs/sources/developers/plugins/custom-panel-option-editors.md @@ -17,7 +17,7 @@ import React from 'react'; import { Button } from '@grafana/ui'; import { StandardEditorProps } from '@grafana/data'; -export const SimpleEditor: React.FC> = ({ value, onChange }) => { +export const SimpleEditor = ({ value, onChange }: StandardEditorProps) => { return ; }; ``` @@ -51,7 +51,9 @@ interface Settings { to: number; } -export const SimpleEditor: React.FC> = ({ item, value, onChange }) => { +type Props = StandardEditorProps; + +export const SimpleEditor = ({ item, value, onChange }: Props) => { const options: Array> = []; // Default values @@ -97,7 +99,7 @@ The editor context is available through the `context` prop. The data frames retu **SimpleEditor.tsx** ```ts -export const SimpleEditor: React.FC> = ({ item, value, onChange, context }) => { +export const SimpleEditor = ({ item, value, onChange, context }: StandardEditorProps) => { const options: SelectableValue[] = []; if (context.data) { diff --git a/packages/grafana-ui/src/components/ButtonCascader/ButtonCascader.tsx b/packages/grafana-ui/src/components/ButtonCascader/ButtonCascader.tsx index 365133b2584..5f6ae1f3adc 100644 --- a/packages/grafana-ui/src/components/ButtonCascader/ButtonCascader.tsx +++ b/packages/grafana-ui/src/components/ButtonCascader/ButtonCascader.tsx @@ -44,7 +44,7 @@ const getStyles = stylesFactory((theme: GrafanaTheme2) => { }; }); -export const ButtonCascader: React.FC = (props) => { +export const ButtonCascader = (props: ButtonCascaderProps) => { const { onChange, className, loadData, icon, buttonProps, hideDownIcon, variant, disabled, ...rest } = props; const theme = useTheme2(); const styles = getStyles(theme); diff --git a/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx b/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx index 04bf348225e..9a9fe8ff3ab 100644 --- a/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx +++ b/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx @@ -21,8 +21,8 @@ export interface ContextMenuProps { renderHeader?: () => React.ReactNode; } -export const ContextMenu: React.FC = React.memo( - ({ x, y, onClose, focusOnOpen = true, renderMenuItems, renderHeader }) => { +export const ContextMenu = React.memo( + ({ x, y, onClose, focusOnOpen = true, renderMenuItems, renderHeader }: ContextMenuProps) => { const menuRef = useRef(null); const [positionStyles, setPositionStyles] = useState({}); diff --git a/packages/grafana-ui/src/components/ContextMenu/WithContextMenu.tsx b/packages/grafana-ui/src/components/ContextMenu/WithContextMenu.tsx index 4809c7b42c7..a3fa1f9c452 100644 --- a/packages/grafana-ui/src/components/ContextMenu/WithContextMenu.tsx +++ b/packages/grafana-ui/src/components/ContextMenu/WithContextMenu.tsx @@ -11,7 +11,7 @@ export interface WithContextMenuProps { focusOnOpen?: boolean; } -export const WithContextMenu: React.FC = ({ children, renderMenuItems, focusOnOpen = true }) => { +export const WithContextMenu = ({ children, renderMenuItems, focusOnOpen = true }: WithContextMenuProps) => { const [isMenuOpen, setIsMenuOpen] = useState(false); const [menuPosition, setMenuPosition] = useState({ x: 0, y: 0 }); return ( diff --git a/packages/grafana-ui/src/components/DataLinks/DataLinkEditor.tsx b/packages/grafana-ui/src/components/DataLinks/DataLinkEditor.tsx index 46bad70bd34..a1701236958 100644 --- a/packages/grafana-ui/src/components/DataLinks/DataLinkEditor.tsx +++ b/packages/grafana-ui/src/components/DataLinks/DataLinkEditor.tsx @@ -30,48 +30,46 @@ const getStyles = (theme: GrafanaTheme2) => ({ `, }); -export const DataLinkEditor: React.FC = React.memo( - ({ index, value, onChange, suggestions, isLast }) => { - const styles = useStyles2(getStyles); +export const DataLinkEditor = React.memo(({ index, value, onChange, suggestions, isLast }: DataLinkEditorProps) => { + const styles = useStyles2(getStyles); - const onUrlChange = (url: string, callback?: () => void) => { - onChange(index, { ...value, url }, callback); - }; - const onTitleChange = (event: ChangeEvent) => { - onChange(index, { ...value, title: event.target.value }); - }; + const onUrlChange = (url: string, callback?: () => void) => { + onChange(index, { ...value, url }, callback); + }; + const onTitleChange = (event: ChangeEvent) => { + onChange(index, { ...value, title: event.target.value }); + }; - const onOpenInNewTabChanged = () => { - onChange(index, { ...value, targetBlank: !value.targetBlank }); - }; + const onOpenInNewTabChanged = () => { + onChange(index, { ...value, targetBlank: !value.targetBlank }); + }; - return ( -
- - - + return ( +
+ + + - - - + + + - - - + + + - {isLast && ( -
- With data links you can reference data variables like series name, labels and values. Type CMD+Space, - CTRL+Space, or $ to open variable suggestions. -
- )} -
- ); - } -); + {isLast && ( +
+ With data links you can reference data variables like series name, labels and values. Type CMD+Space, + CTRL+Space, or $ to open variable suggestions. +
+ )} +
+ ); +}); DataLinkEditor.displayName = 'DataLinkEditor'; diff --git a/packages/grafana-ui/src/components/DataLinks/DataLinkInput.tsx b/packages/grafana-ui/src/components/DataLinks/DataLinkInput.tsx index 6ed1b123202..97b9a6774dc 100644 --- a/packages/grafana-ui/src/components/DataLinks/DataLinkInput.tsx +++ b/packages/grafana-ui/src/components/DataLinks/DataLinkInput.tsx @@ -72,8 +72,13 @@ const getStyles = (theme: GrafanaTheme2) => ({ // This memoised also because rerendering the slate editor grabs focus which created problem in some cases this // was used and changes to different state were propagated here. -export const DataLinkInput: React.FC = memo( - ({ value, onChange, suggestions, placeholder = 'http://your-grafana.com/d/000000010/annotations' }) => { +export const DataLinkInput = memo( + ({ + value, + onChange, + suggestions, + placeholder = 'http://your-grafana.com/d/000000010/annotations', + }: DataLinkInputProps) => { const editorRef = useRef(null); const styles = useStyles2(getStyles); const [showingSuggestions, setShowingSuggestions] = useState(false); diff --git a/packages/grafana-ui/src/components/DataLinks/DataLinkSuggestions.tsx b/packages/grafana-ui/src/components/DataLinks/DataLinkSuggestions.tsx index 841d4c492bd..ecce2409816 100644 --- a/packages/grafana-ui/src/components/DataLinks/DataLinkSuggestions.tsx +++ b/packages/grafana-ui/src/components/DataLinks/DataLinkSuggestions.tsx @@ -53,7 +53,7 @@ const getStyles = (theme: GrafanaTheme2) => { }; }; -export const DataLinkSuggestions: React.FC = ({ suggestions, ...otherProps }) => { +export const DataLinkSuggestions = ({ suggestions, ...otherProps }: DataLinkSuggestionsProps) => { const ref = useRef(null); useClickAway(ref, () => { @@ -104,8 +104,16 @@ interface DataLinkSuggestionsListProps extends DataLinkSuggestionsProps { activeRef?: React.RefObject; } -const DataLinkSuggestionsList: React.FC = React.memo( - ({ activeIndex, activeIndexOffset, label, onClose, onSuggestionSelect, suggestions, activeRef: selectedRef }) => { +const DataLinkSuggestionsList = React.memo( + ({ + activeIndex, + activeIndexOffset, + label, + onClose, + onSuggestionSelect, + suggestions, + activeRef: selectedRef, + }: DataLinkSuggestionsListProps) => { const styles = useStyles2(getStyles); return ( diff --git a/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksInlineEditor.tsx b/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksInlineEditor.tsx index c0db22200d1..6670b573371 100644 --- a/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksInlineEditor.tsx +++ b/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksInlineEditor.tsx @@ -18,12 +18,7 @@ interface DataLinksInlineEditorProps { data: DataFrame[]; } -export const DataLinksInlineEditor: React.FC = ({ - links, - onChange, - getSuggestions, - data, -}) => { +export const DataLinksInlineEditor = ({ links, onChange, getSuggestions, data }: DataLinksInlineEditorProps) => { const theme = useTheme2(); const [editIndex, setEditIndex] = useState(null); const [isNew, setIsNew] = useState(false); diff --git a/packages/grafana-ui/src/components/DataSourceSettings/BasicAuthSettings.tsx b/packages/grafana-ui/src/components/DataSourceSettings/BasicAuthSettings.tsx index 434f5fec3b1..e03e2d9b5d1 100644 --- a/packages/grafana-ui/src/components/DataSourceSettings/BasicAuthSettings.tsx +++ b/packages/grafana-ui/src/components/DataSourceSettings/BasicAuthSettings.tsx @@ -6,7 +6,7 @@ import { SecretFormField } from '../SecretFormField/SecretFormField'; import { HttpSettingsProps } from './types'; -export const BasicAuthSettings: React.FC = ({ dataSourceConfig, onChange }) => { +export const BasicAuthSettings = ({ dataSourceConfig, onChange }: HttpSettingsProps) => { const password = dataSourceConfig.secureJsonData ? dataSourceConfig.secureJsonData.basicAuthPassword : ''; const onPasswordReset = () => { diff --git a/packages/grafana-ui/src/components/DataSourceSettings/CustomHeadersSettings.tsx b/packages/grafana-ui/src/components/DataSourceSettings/CustomHeadersSettings.tsx index 3716d3f1db5..77af3d52cc8 100644 --- a/packages/grafana-ui/src/components/DataSourceSettings/CustomHeadersSettings.tsx +++ b/packages/grafana-ui/src/components/DataSourceSettings/CustomHeadersSettings.tsx @@ -55,7 +55,7 @@ const getCustomHeaderRowStyles = stylesFactory(() => { }; }); -const CustomHeaderRow: React.FC = ({ header, onBlur, onChange, onRemove, onReset }) => { +const CustomHeaderRow = ({ header, onBlur, onChange, onRemove, onReset }: CustomHeaderRowProps) => { const styles = getCustomHeaderRowStyles(); return (
diff --git a/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx b/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx index 79819918e20..184b523972f 100644 --- a/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx +++ b/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx @@ -61,7 +61,7 @@ const HttpAccessHelp = () => ( const LABEL_WIDTH = 26; -export const DataSourceHttpSettings: React.FC = (props) => { +export const DataSourceHttpSettings = (props: HttpSettingsProps) => { const { defaultUrl, dataSourceConfig, diff --git a/packages/grafana-ui/src/components/DataSourceSettings/HttpProxySettings.tsx b/packages/grafana-ui/src/components/DataSourceSettings/HttpProxySettings.tsx index 125a9f7e356..33b6cc0b7fd 100644 --- a/packages/grafana-ui/src/components/DataSourceSettings/HttpProxySettings.tsx +++ b/packages/grafana-ui/src/components/DataSourceSettings/HttpProxySettings.tsx @@ -7,11 +7,11 @@ import { HttpSettingsBaseProps } from './types'; const LABEL_WIDTH = 26; -export const HttpProxySettings: React.FC = ({ +export const HttpProxySettings = ({ dataSourceConfig, onChange, showForwardOAuthIdentityOption = true, -}) => { +}: HttpSettingsBaseProps) => { return ( <>
diff --git a/packages/grafana-ui/src/components/DataSourceSettings/TLSAuthSettings.tsx b/packages/grafana-ui/src/components/DataSourceSettings/TLSAuthSettings.tsx index 9c29706f0c0..8b06ab0ef70 100644 --- a/packages/grafana-ui/src/components/DataSourceSettings/TLSAuthSettings.tsx +++ b/packages/grafana-ui/src/components/DataSourceSettings/TLSAuthSettings.tsx @@ -10,7 +10,7 @@ import { Tooltip } from '../Tooltip/Tooltip'; import { CertificationKey } from './CertificationKey'; import { HttpSettingsBaseProps } from './types'; -export const TLSAuthSettings: React.FC = ({ dataSourceConfig, onChange }) => { +export const TLSAuthSettings = ({ dataSourceConfig, onChange }: HttpSettingsBaseProps) => { const hasTLSCACert = dataSourceConfig.secureJsonFields && dataSourceConfig.secureJsonFields.tlsCACert; const hasTLSClientCert = dataSourceConfig.secureJsonFields && dataSourceConfig.secureJsonFields.tlsClientCert; const hasTLSClientKey = dataSourceConfig.secureJsonFields && dataSourceConfig.secureJsonFields.tlsClientKey; diff --git a/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.test.tsx b/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.test.tsx index 374dba3886e..d4b3b0c6226 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.test.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.test.tsx @@ -7,7 +7,7 @@ import { RelativeTimeRange } from '@grafana/data'; import { RelativeTimeRangePicker } from './RelativeTimeRangePicker'; function setup(initial: RelativeTimeRange = { from: 900, to: 0 }): RenderResult { - const StatefulPicker: React.FC<{}> = () => { + const StatefulPicker = () => { const [value, setValue] = useState(initial); return ; }; diff --git a/packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker/TimePickerContent.tsx b/packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker/TimePickerContent.tsx index 65f106b8f98..1f65228d284 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker/TimePickerContent.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker/TimePickerContent.tsx @@ -43,7 +43,7 @@ interface FormProps extends Omit { historyOptions?: TimeOption[]; } -export const TimePickerContentWithScreenSize: React.FC = (props) => { +export const TimePickerContentWithScreenSize = (props: PropsWithScreenSize) => { const { quickOptions = [], isReversed, @@ -174,7 +174,7 @@ const NarrowScreenForm = (props: FormProps) => { ); }; -const FullScreenForm: React.FC = (props) => { +const FullScreenForm = (props: FormProps) => { const { onChange, value, timeZone, fiscalYearStartMonth, isReversed, historyOptions } = props; const theme = useTheme2(); const styles = getFullScreenStyles(theme, props.hideQuickRanges); diff --git a/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOption.tsx b/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOption.tsx index 13c9fea1315..779b2b5e850 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOption.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOption.tsx @@ -26,7 +26,7 @@ export interface SelectableZone extends SelectableValue { searchIndex: string; } -export const WideTimeZoneOption: React.FC> = (props, ref) => { +export const WideTimeZoneOption = (props: PropsWithChildren) => { const { children, innerProps, innerRef, data, isSelected, isFocused } = props; const theme = useTheme2(); const styles = getStyles(theme); @@ -66,7 +66,7 @@ export const WideTimeZoneOption: React.FC> = (props, re ); }; -export const CompactTimeZoneOption: React.FC> = (props, ref) => { +export const CompactTimeZoneOption = (props: React.PropsWithChildren) => { const { children, innerProps, innerRef, data, isSelected, isFocused } = props; const theme = useTheme2(); const styles = getStyles(theme); diff --git a/packages/grafana-ui/src/components/FilterPill/FilterPill.tsx b/packages/grafana-ui/src/components/FilterPill/FilterPill.tsx index 6797f0cf3b9..60f0a013a1f 100644 --- a/packages/grafana-ui/src/components/FilterPill/FilterPill.tsx +++ b/packages/grafana-ui/src/components/FilterPill/FilterPill.tsx @@ -15,7 +15,7 @@ export interface FilterPillProps { icon?: IconName; } -export const FilterPill: React.FC = ({ label, selected, onClick, icon = 'check' }) => { +export const FilterPill = ({ label, selected, onClick, icon = 'check' }: FilterPillProps) => { const styles = useStyles2(getStyles); const clearButton = useStyles2(clearButtonStyles); return ( diff --git a/packages/grafana-ui/src/components/Forms/Field.tsx b/packages/grafana-ui/src/components/Forms/Field.tsx index a7c7b406c08..e6f32fca6e4 100644 --- a/packages/grafana-ui/src/components/Forms/Field.tsx +++ b/packages/grafana-ui/src/components/Forms/Field.tsx @@ -69,7 +69,7 @@ export const getFieldStyles = stylesFactory((theme: GrafanaTheme2) => { }; }); -export const Field: React.FC = ({ +export const Field = ({ label, description, horizontal, @@ -83,7 +83,7 @@ export const Field: React.FC = ({ validationMessageHorizontalOverflow, htmlFor, ...otherProps -}) => { +}: FieldProps) => { const theme = useTheme2(); const styles = getFieldStyles(theme); const inputId = htmlFor ?? getChildId(children); diff --git a/packages/grafana-ui/src/components/Forms/Label.tsx b/packages/grafana-ui/src/components/Forms/Label.tsx index ca1c6501232..7b842245351 100644 --- a/packages/grafana-ui/src/components/Forms/Label.tsx +++ b/packages/grafana-ui/src/components/Forms/Label.tsx @@ -46,7 +46,7 @@ export const getLabelStyles = stylesFactory((theme: GrafanaTheme2) => { }; }); -export const Label: React.FC = ({ children, description, className, category, ...labelProps }) => { +export const Label = ({ children, description, className, category, ...labelProps }: LabelProps) => { const theme = useTheme2(); const styles = getLabelStyles(theme); const categories = category?.map((c, i) => { diff --git a/packages/grafana-ui/src/components/Forms/Legend.tsx b/packages/grafana-ui/src/components/Forms/Legend.tsx index 16e97fa613e..70cc785a5da 100644 --- a/packages/grafana-ui/src/components/Forms/Legend.tsx +++ b/packages/grafana-ui/src/components/Forms/Legend.tsx @@ -20,7 +20,7 @@ export const getLegendStyles = (theme: GrafanaTheme2) => { }; }; -export const Legend: React.FC = ({ children, className, ...legendProps }) => { +export const Legend = ({ children, className, ...legendProps }: LabelProps) => { const styles = useStyles2(getLegendStyles); return ( diff --git a/packages/grafana-ui/src/components/Forms/RadioButtonList/RadioButtonList.story.tsx b/packages/grafana-ui/src/components/Forms/RadioButtonList/RadioButtonList.story.tsx index 51ac325ab50..f1e9b85e18b 100644 --- a/packages/grafana-ui/src/components/Forms/RadioButtonList/RadioButtonList.story.tsx +++ b/packages/grafana-ui/src/components/Forms/RadioButtonList/RadioButtonList.story.tsx @@ -115,7 +115,7 @@ DisabledList.args = { }; export const Dots: Story = () => { - const Wrapper: React.FC> = ({ title, children }) => ( + const Wrapper = ({ title, children }: React.PropsWithChildren<{ title: string }>) => (
{title}
{children} diff --git a/packages/grafana-ui/src/components/Graph/GraphContextMenu.tsx b/packages/grafana-ui/src/components/Graph/GraphContextMenu.tsx index 7bb65f25c96..e672881dcb7 100644 --- a/packages/grafana-ui/src/components/Graph/GraphContextMenu.tsx +++ b/packages/grafana-ui/src/components/Graph/GraphContextMenu.tsx @@ -32,14 +32,14 @@ export type GraphContextMenuProps = ContextMenuProps & { }; /** @internal */ -export const GraphContextMenu: React.FC = ({ +export const GraphContextMenu = ({ getContextMenuSource, timeZone, itemsGroup, dimensions, contextDimensions, ...otherProps -}) => { +}: GraphContextMenuProps) => { const source = getContextMenuSource(); // Do not render items that do not have label specified diff --git a/packages/grafana-ui/src/components/Graph/GraphTooltip/MultiModeGraphTooltip.tsx b/packages/grafana-ui/src/components/Graph/GraphTooltip/MultiModeGraphTooltip.tsx index 973d5e059d7..f071abdcea2 100644 --- a/packages/grafana-ui/src/components/Graph/GraphTooltip/MultiModeGraphTooltip.tsx +++ b/packages/grafana-ui/src/components/Graph/GraphTooltip/MultiModeGraphTooltip.tsx @@ -8,12 +8,12 @@ import { getMultiSeriesGraphHoverInfo } from '../utils'; import { GraphTooltipContentProps } from './types'; -export const MultiModeGraphTooltip: React.FC< - GraphTooltipContentProps & { - // We expect position to figure out correct values when not hovering over a datapoint - pos: FlotPosition; - } -> = ({ dimensions, activeDimensions, pos, timeZone }) => { +type Props = GraphTooltipContentProps & { + // We expect position to figure out correct values when not hovering over a datapoint + pos: FlotPosition; +}; + +export const MultiModeGraphTooltip = ({ dimensions, activeDimensions, pos, timeZone }: Props) => { let activeSeriesIndex: number | null = null; // when no x-axis provided, skip rendering if (activeDimensions.xAxis === null) { diff --git a/packages/grafana-ui/src/components/Graph/GraphTooltip/SingleModeGraphTooltip.tsx b/packages/grafana-ui/src/components/Graph/GraphTooltip/SingleModeGraphTooltip.tsx index 6335d6a7d76..3b5ad3b2ade 100644 --- a/packages/grafana-ui/src/components/Graph/GraphTooltip/SingleModeGraphTooltip.tsx +++ b/packages/grafana-ui/src/components/Graph/GraphTooltip/SingleModeGraphTooltip.tsx @@ -11,11 +11,7 @@ import { SeriesTable } from '../../VizTooltip'; import { GraphTooltipContentProps } from './types'; -export const SingleModeGraphTooltip: React.FC = ({ - dimensions, - activeDimensions, - timeZone, -}) => { +export const SingleModeGraphTooltip = ({ dimensions, activeDimensions, timeZone }: GraphTooltipContentProps) => { // not hovering over a point, skip rendering if ( activeDimensions.yAxis === null || diff --git a/packages/grafana-ui/src/components/InfoBox/FeatureInfoBox.tsx b/packages/grafana-ui/src/components/InfoBox/FeatureInfoBox.tsx index 845ed27687f..18683c539ec 100644 --- a/packages/grafana-ui/src/components/InfoBox/FeatureInfoBox.tsx +++ b/packages/grafana-ui/src/components/InfoBox/FeatureInfoBox.tsx @@ -47,7 +47,7 @@ interface FeatureBadgeProps { tooltip?: string; } -export const FeatureBadge: React.FC = ({ featureState, tooltip }) => { +export const FeatureBadge = ({ featureState, tooltip }: FeatureBadgeProps) => { const display = getPanelStateBadgeDisplayModel(featureState); return ; }; diff --git a/packages/grafana-ui/src/components/Menu/MenuGroup.tsx b/packages/grafana-ui/src/components/Menu/MenuGroup.tsx index 2054dde3b6c..d366016c6e8 100644 --- a/packages/grafana-ui/src/components/Menu/MenuGroup.tsx +++ b/packages/grafana-ui/src/components/Menu/MenuGroup.tsx @@ -25,7 +25,7 @@ export interface MenuGroupProps extends Partial { } /** @internal */ -export const MenuGroup: React.FC = ({ label, ariaLabel, children }) => { +export const MenuGroup = ({ label, ariaLabel, children }: MenuGroupProps) => { const styles = useStyles2(getStyles); const labelID = `group-label-${uniqueId()}`; diff --git a/packages/grafana-ui/src/components/Menu/SubMenu.tsx b/packages/grafana-ui/src/components/Menu/SubMenu.tsx index 56c8e3b3ad1..470baddcc56 100644 --- a/packages/grafana-ui/src/components/Menu/SubMenu.tsx +++ b/packages/grafana-ui/src/components/Menu/SubMenu.tsx @@ -28,8 +28,8 @@ export interface SubMenuProps { } /** @internal */ -export const SubMenu: React.FC = React.memo( - ({ items, isOpen, openedWithArrow, setOpenedWithArrow, close, customStyle }) => { +export const SubMenu = React.memo( + ({ items, isOpen, openedWithArrow, setOpenedWithArrow, close, customStyle }: SubMenuProps) => { const styles = useStyles2(getStyles); const localRef = useRef(null); const [handleKeys] = useMenuFocus({ diff --git a/packages/grafana-ui/src/components/PanelChrome/ErrorIndicator.tsx b/packages/grafana-ui/src/components/PanelChrome/ErrorIndicator.tsx index d18e460b6e8..d6881ff6ada 100644 --- a/packages/grafana-ui/src/components/PanelChrome/ErrorIndicator.tsx +++ b/packages/grafana-ui/src/components/PanelChrome/ErrorIndicator.tsx @@ -17,7 +17,7 @@ export type ErrorIndicatorProps = { /** * @internal */ -export const ErrorIndicator: React.FC = ({ error, onClick }) => { +export const ErrorIndicator = ({ error, onClick }: ErrorIndicatorProps) => { const styles = useStyles2(getStyles); if (!error) { diff --git a/packages/grafana-ui/src/components/PanelChrome/LoadingIndicator.tsx b/packages/grafana-ui/src/components/PanelChrome/LoadingIndicator.tsx index 610e0382fc8..e597c17ca3e 100644 --- a/packages/grafana-ui/src/components/PanelChrome/LoadingIndicator.tsx +++ b/packages/grafana-ui/src/components/PanelChrome/LoadingIndicator.tsx @@ -18,7 +18,7 @@ export type LoadingIndicatorProps = { /** * @internal */ -export const LoadingIndicator: React.FC = ({ onCancel, loading }) => { +export const LoadingIndicator = ({ onCancel, loading }: LoadingIndicatorProps) => { const styles = useStyles2(getStyles); if (!loading) { diff --git a/packages/grafana-ui/src/components/PluginSignatureBadge/PluginSignatureBadge.tsx b/packages/grafana-ui/src/components/PluginSignatureBadge/PluginSignatureBadge.tsx index 6913310a7df..7992353cf66 100644 --- a/packages/grafana-ui/src/components/PluginSignatureBadge/PluginSignatureBadge.tsx +++ b/packages/grafana-ui/src/components/PluginSignatureBadge/PluginSignatureBadge.tsx @@ -14,7 +14,7 @@ export interface PluginSignatureBadgeProps extends HTMLAttributes = ({ status, ...otherProps }) => { +export const PluginSignatureBadge = ({ status, ...otherProps }: PluginSignatureBadgeProps) => { const display = getSignatureDisplayModel(status); return ( = ({ Component, onClick, disabled }) => ( + const Label = ({ Component, onClick, disabled }: LabelProps) => (