diff --git a/.betterer.results b/.betterer.results index 5350fdb80f7..bbf353f4a14 100644 --- a/.betterer.results +++ b/.betterer.results @@ -2651,9 +2651,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], - "public/app/core/navigation/RouterDebugger.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/core/navigation/__mocks__/routeProps.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], diff --git a/packages/grafana-ui/src/components/Button/FullWidthButtonContainer.tsx b/packages/grafana-ui/src/components/Button/FullWidthButtonContainer.tsx index e49056997f1..48f9827a7be 100644 --- a/packages/grafana-ui/src/components/Button/FullWidthButtonContainer.tsx +++ b/packages/grafana-ui/src/components/Button/FullWidthButtonContainer.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import React, { FC } from 'react'; +import React from 'react'; import { stylesFactory } from '../../themes'; @@ -7,7 +7,7 @@ export interface Props { className?: string; } -export const FullWidthButtonContainer: FC = ({ className, children }) => { +export const FullWidthButtonContainer = ({ className, children }: React.PropsWithChildren) => { const styles = getStyles(); return
{children}
; diff --git a/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx b/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx index 12a22968f3a..0412ae0477e 100644 --- a/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx +++ b/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx @@ -21,7 +21,7 @@ interface State { hasEventListener: boolean; } -export class ClickOutsideWrapper extends PureComponent { +export class ClickOutsideWrapper extends PureComponent, State> { static defaultProps = { includeButtonPress: true, parent: typeof window !== 'undefined' ? window : null, diff --git a/packages/grafana-ui/src/components/Collapse/Collapse.tsx b/packages/grafana-ui/src/components/Collapse/Collapse.tsx index e2c02526585..76f1c0c9826 100644 --- a/packages/grafana-ui/src/components/Collapse/Collapse.tsx +++ b/packages/grafana-ui/src/components/Collapse/Collapse.tsx @@ -123,7 +123,7 @@ export const ControlledCollapse: FunctionComponent = ({ isOpen, onToggle, ); }; -export const Collapse: FunctionComponent = ({ +export const Collapse = ({ isOpen, label, loading, @@ -131,7 +131,7 @@ export const Collapse: FunctionComponent = ({ onToggle, className, children, -}) => { +}: React.PropsWithChildren) => { const style = useStyles2(getStyles); const onClickToggle = () => { if (onToggle) { diff --git a/packages/grafana-ui/src/components/ColorPicker/ColorPicker.tsx b/packages/grafana-ui/src/components/ColorPicker/ColorPicker.tsx index e88b8f0240f..71b0f25ccc1 100644 --- a/packages/grafana-ui/src/components/ColorPicker/ColorPicker.tsx +++ b/packages/grafana-ui/src/components/ColorPicker/ColorPicker.tsx @@ -27,7 +27,7 @@ type ColorPickerTriggerRenderer = (props: { }) => React.ReactNode; export const colorPickerFactory = ( - popover: React.ComponentType, + popover: React.ComponentType>, displayName = 'ColorPicker' ) => { return class ColorPicker extends Component { diff --git a/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx b/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx index e98548e1f5b..1ba0d5eb823 100644 --- a/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx +++ b/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx @@ -36,7 +36,7 @@ interface State { showConfirm: boolean; } -class UnThemedConfirmButton extends PureComponent { +class UnThemedConfirmButton extends PureComponent, State> { mainButtonRef = React.createRef(); confirmButtonRef = React.createRef(); state: State = { diff --git a/packages/grafana-ui/src/components/ConfirmButton/DeleteButton.tsx b/packages/grafana-ui/src/components/ConfirmButton/DeleteButton.tsx index 302f8523bf6..d09ecaa46e2 100644 --- a/packages/grafana-ui/src/components/ConfirmButton/DeleteButton.tsx +++ b/packages/grafana-ui/src/components/ConfirmButton/DeleteButton.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React from 'react'; import { ComponentSize } from '../../types/size'; import { Button } from '../Button'; @@ -17,7 +17,7 @@ export interface Props { closeOnConfirm?: boolean; } -export const DeleteButton: FC = ({ size, disabled, onConfirm, 'aria-label': ariaLabel, closeOnConfirm }) => { +export const DeleteButton = ({ size, disabled, onConfirm, 'aria-label': ariaLabel, closeOnConfirm }: Props) => { return ( component from `react-custom-scrollbars` */ -export const CustomScrollbar: FC = ({ +export const CustomScrollbar = ({ autoHide = false, autoHideTimeout = 200, setScrollTop, @@ -48,7 +48,7 @@ export const CustomScrollbar: FC = ({ scrollTop, onScroll, children, -}) => { +}: React.PropsWithChildren) => { const ref = useRef(null); const styles = useStyles2(getStyles); diff --git a/packages/grafana-ui/src/components/CustomScrollbar/ScrollIndicators.tsx b/packages/grafana-ui/src/components/CustomScrollbar/ScrollIndicators.tsx index 275250d7a49..eed018c3648 100644 --- a/packages/grafana-ui/src/components/CustomScrollbar/ScrollIndicators.tsx +++ b/packages/grafana-ui/src/components/CustomScrollbar/ScrollIndicators.tsx @@ -1,13 +1,13 @@ import { css, cx } from '@emotion/css'; import classNames from 'classnames'; -import React, { FC, useEffect, useRef, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { useStyles2 } from '../../themes'; import { Icon } from '../Icon/Icon'; -export const ScrollIndicators: FC = ({ children }) => { +export const ScrollIndicators = ({ children }: React.PropsWithChildren<{}>) => { const [showScrollTopIndicator, setShowTopScrollIndicator] = useState(false); const [showScrollBottomIndicator, setShowBottomScrollIndicator] = useState(false); const scrollTopMarker = useRef(null); diff --git a/packages/grafana-ui/src/components/DataLinks/DataLinksContextMenu.tsx b/packages/grafana-ui/src/components/DataLinks/DataLinksContextMenu.tsx index 2823c7c77c2..992ba6de058 100644 --- a/packages/grafana-ui/src/components/DataLinks/DataLinksContextMenu.tsx +++ b/packages/grafana-ui/src/components/DataLinks/DataLinksContextMenu.tsx @@ -20,7 +20,7 @@ export interface DataLinksContextMenuApi { targetClassName?: string; } -export const DataLinksContextMenu: React.FC = ({ children, links, style }) => { +export const DataLinksContextMenu = ({ children, links, style }: DataLinksContextMenuProps) => { const itemsGroup: MenuItemsGroup[] = [{ items: linkModelToContextMenuItems(links), label: 'Data links' }]; const linksCounter = itemsGroup[0].items.length; const renderMenuGroupItems = () => { diff --git a/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneDescription.tsx b/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneDescription.tsx index c9e4ff67451..2bed097ff01 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneDescription.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneDescription.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import React, { PropsWithChildren, useMemo } from 'react'; +import React, { useMemo } from 'react'; import { GrafanaTheme2, TimeZoneInfo } from '@grafana/data'; @@ -9,7 +9,7 @@ interface Props { info?: TimeZoneInfo; } -export const TimeZoneDescription: React.FC> = ({ info }) => { +export const TimeZoneDescription = ({ info }: Props) => { const styles = useStyles2(getStyles); const description = useDescription(info); diff --git a/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneGroup.tsx b/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneGroup.tsx index 0ca10f44f71..62479b92623 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneGroup.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneGroup.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import React, { PropsWithChildren } from 'react'; +import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; @@ -7,11 +7,12 @@ import { useStyles2 } from '../../../themes'; interface Props { label: string | undefined; + children?: React.ReactNode; } const stopPropagation = (event: React.MouseEvent) => event.stopPropagation(); -export const TimeZoneGroup: React.FC> = (props) => { +export const TimeZoneGroup = (props: Props) => { const { children, label } = props; const styles = useStyles2(getStyles); diff --git a/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOffset.tsx b/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOffset.tsx index a6e0722bfce..62465ed473d 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOffset.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOffset.tsx @@ -1,6 +1,6 @@ import { css, cx } from '@emotion/css'; import { isString } from 'lodash'; -import React, { PropsWithChildren } from 'react'; +import React from 'react'; import { GrafanaTheme2, TimeZone, dateTimeFormat } from '@grafana/data'; @@ -12,7 +12,7 @@ interface Props { className?: string; } -export const TimeZoneOffset: React.FC> = (props) => { +export const TimeZoneOffset = (props: Props) => { const { timestamp, timeZone, className } = props; const styles = useStyles2(getStyles); diff --git a/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOption.tsx b/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOption.tsx index 96bf32ee93d..af81d283343 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOption.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOption.tsx @@ -65,7 +65,7 @@ export const WideTimeZoneOption: React.FC> = (props, re ); }; -export const CompactTimeZoneOption: React.FC> = (props, ref) => { +export const CompactTimeZoneOption: React.FC> = (props, ref) => { const { children, innerProps, data, isSelected, isFocused } = props; const theme = useTheme2(); const styles = getStyles(theme); diff --git a/packages/grafana-ui/src/components/FileUpload/FileUpload.tsx b/packages/grafana-ui/src/components/FileUpload/FileUpload.tsx index e2c0d343437..35513b27382 100644 --- a/packages/grafana-ui/src/components/FileUpload/FileUpload.tsx +++ b/packages/grafana-ui/src/components/FileUpload/FileUpload.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import React, { FC, FormEvent, useCallback, useState } from 'react'; +import React, { FormEvent, useCallback, useState } from 'react'; import { v4 as uuidv4 } from 'uuid'; import { GrafanaTheme2 } from '@grafana/data'; @@ -25,13 +25,13 @@ export interface Props { showFileName?: boolean; } -export const FileUpload: FC = ({ +export const FileUpload = ({ onFileUpload, className, children = 'Upload file', accept = '*', size = 'md', -}) => { +}: React.PropsWithChildren) => { const style = useStyles2(getStyles(size)); const [fileName, setFileName] = useState(''); const id = uuidv4(); diff --git a/packages/grafana-ui/src/components/Forms/FieldValidationMessage.tsx b/packages/grafana-ui/src/components/Forms/FieldValidationMessage.tsx index 6080ffc9e5f..5b7c9719a52 100644 --- a/packages/grafana-ui/src/components/Forms/FieldValidationMessage.tsx +++ b/packages/grafana-ui/src/components/Forms/FieldValidationMessage.tsx @@ -72,7 +72,11 @@ export const getFieldValidationMessageStyles = stylesFactory((theme: GrafanaThem }; }); -export const FieldValidationMessage: React.FC = ({ children, horizontal, className }) => { +export const FieldValidationMessage = ({ + children, + horizontal, + className, +}: React.PropsWithChildren) => { const theme = useTheme2(); const styles = getFieldValidationMessageStyles(theme); const cssName = cx(horizontal ? styles.horizontal : styles.vertical, className); diff --git a/packages/grafana-ui/src/components/Forms/Form.tsx b/packages/grafana-ui/src/components/Forms/Form.tsx index a820f7396e5..f1cf70b3197 100644 --- a/packages/grafana-ui/src/components/Forms/Form.tsx +++ b/packages/grafana-ui/src/components/Forms/Form.tsx @@ -4,7 +4,7 @@ import { useForm, Mode, DeepPartial, UnpackNestedValue, SubmitHandler, FieldValu import { FormAPI } from '../../types'; -interface FormProps extends Omit, 'onSubmit'> { +interface FormProps extends Omit, 'onSubmit' | 'children'> { validateOn?: Mode; validateOnMount?: boolean; validateFieldsOnMount?: string | string[]; diff --git a/packages/grafana-ui/src/components/Forms/InlineSegmentGroup.tsx b/packages/grafana-ui/src/components/Forms/InlineSegmentGroup.tsx index e1a6f17b1c0..bfe5d1f8742 100644 --- a/packages/grafana-ui/src/components/Forms/InlineSegmentGroup.tsx +++ b/packages/grafana-ui/src/components/Forms/InlineSegmentGroup.tsx @@ -1,5 +1,5 @@ import { cx, css } from '@emotion/css'; -import React, { FC } from 'react'; +import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; @@ -11,7 +11,7 @@ export interface Props { } /** @beta */ -export const InlineSegmentGroup: FC = ({ children, className, grow, ...htmlProps }) => { +export const InlineSegmentGroup = ({ children, className, grow, ...htmlProps }: React.PropsWithChildren) => { const styles = useStyles2((theme) => getStyles(theme, grow)); 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 fa123bc12a0..51ac325ab50 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: string }> = ({ title, children }) => ( + const Wrapper: React.FC> = ({ title, children }) => (
{title}
{children} diff --git a/packages/grafana-ui/src/components/Graph/GraphTooltip/GraphTooltip.tsx b/packages/grafana-ui/src/components/Graph/GraphTooltip/GraphTooltip.tsx index 1e86a5da86e..53008e1dd68 100644 --- a/packages/grafana-ui/src/components/Graph/GraphTooltip/GraphTooltip.tsx +++ b/packages/grafana-ui/src/components/Graph/GraphTooltip/GraphTooltip.tsx @@ -1,18 +1,20 @@ import React from 'react'; +import { TooltipDisplayMode } from '@grafana/schema'; + import { VizTooltipContentProps } from '../../VizTooltip'; import { MultiModeGraphTooltip } from './MultiModeGraphTooltip'; import { SingleModeGraphTooltip } from './SingleModeGraphTooltip'; import { GraphDimensions } from './types'; -export const GraphTooltip: React.FC> = ({ - mode = 'single', +export const GraphTooltip = ({ + mode = TooltipDisplayMode.Single, dimensions, activeDimensions, pos, timeZone, -}) => { +}: VizTooltipContentProps) => { // When // [1] no active dimension or // [2] no xAxis position diff --git a/packages/grafana-ui/src/components/Layout/Layout.tsx b/packages/grafana-ui/src/components/Layout/Layout.tsx index 883d413b8cb..093bb54b6a3 100644 --- a/packages/grafana-ui/src/components/Layout/Layout.tsx +++ b/packages/grafana-ui/src/components/Layout/Layout.tsx @@ -30,7 +30,7 @@ export interface ContainerProps { shrink?: number; } -export const Layout: React.FC = ({ +export const Layout = ({ children, orientation = Orientation.Horizontal, spacing = 'sm', @@ -40,7 +40,7 @@ export const Layout: React.FC = ({ width = '100%', height = '100%', ...rest -}) => { +}: LayoutProps) => { const styles = useStyles2( useCallback( (theme) => getStyles(theme, orientation, spacing, justify, align, wrap), @@ -63,7 +63,7 @@ export const Layout: React.FC = ({ ); }; -export const HorizontalGroup: React.FC> = ({ +export const HorizontalGroup = ({ children, spacing, justify, @@ -71,7 +71,7 @@ export const HorizontalGroup: React.FC> = ({ wrap, width, height, -}) => ( +}: Omit) => ( > = ({ {children} ); -export const VerticalGroup: React.FC> = ({ +export const VerticalGroup = ({ children, spacing, justify, align, width, height, -}) => ( +}: Omit) => ( > ); -export const Container: React.FC = ({ children, padding, margin, grow, shrink }) => { +export const Container = ({ children, padding, margin, grow, shrink }: React.PropsWithChildren) => { const styles = useStyles2(useCallback((theme) => getContainerStyles(theme, padding, margin), [padding, margin])); return ( diff --git a/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.tsx b/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.tsx index 8450d68a767..1e80fe1902c 100644 --- a/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.tsx +++ b/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import React, { HTMLAttributes, SFC } from 'react'; +import React, { HTMLAttributes } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; @@ -16,7 +16,7 @@ export interface LoadingPlaceholderProps extends HTMLAttributes /** * @public */ -export const LoadingPlaceholder: SFC = ({ text, className, ...rest }) => { +export const LoadingPlaceholder = ({ text, className, ...rest }: LoadingPlaceholderProps) => { const styles = useStyles2(getStyles); return (
diff --git a/packages/grafana-ui/src/components/Modal/ModalHeader.tsx b/packages/grafana-ui/src/components/Modal/ModalHeader.tsx index 3eeaaffdaf7..5967dd1541e 100644 --- a/packages/grafana-ui/src/components/Modal/ModalHeader.tsx +++ b/packages/grafana-ui/src/components/Modal/ModalHeader.tsx @@ -15,7 +15,7 @@ interface Props { } /** @internal */ -export const ModalHeader: React.FC = ({ icon, iconTooltip, title, children, id }) => { +export const ModalHeader = ({ icon, iconTooltip, title, children, id }: React.PropsWithChildren) => { const styles = useStyles2(getModalStyles); return ( diff --git a/packages/grafana-ui/src/components/Modal/ModalTabContent.tsx b/packages/grafana-ui/src/components/Modal/ModalTabContent.tsx index 1c1bbb13d76..2919b8d381b 100644 --- a/packages/grafana-ui/src/components/Modal/ModalTabContent.tsx +++ b/packages/grafana-ui/src/components/Modal/ModalTabContent.tsx @@ -10,7 +10,7 @@ interface Props { } /** @internal */ -export const ModalTabContent: React.FC = ({ children }) => { +export const ModalTabContent = ({ children }: React.PropsWithChildren) => { return (
diff --git a/packages/grafana-ui/src/components/QueryEditor/EditorFieldGroup.tsx b/packages/grafana-ui/src/components/QueryEditor/EditorFieldGroup.tsx index bb397498e7a..d846a541415 100644 --- a/packages/grafana-ui/src/components/QueryEditor/EditorFieldGroup.tsx +++ b/packages/grafana-ui/src/components/QueryEditor/EditorFieldGroup.tsx @@ -4,6 +4,6 @@ import { Stack } from './Stack'; interface EditorFieldGroupProps {} -export const EditorFieldGroup: React.FC = ({ children }) => { +export const EditorFieldGroup = ({ children }: React.PropsWithChildren) => { return {children}; }; diff --git a/packages/grafana-ui/src/components/QueryEditor/EditorHeader.tsx b/packages/grafana-ui/src/components/QueryEditor/EditorHeader.tsx index 3fcb61e5fb0..bfa1d57dc0a 100644 --- a/packages/grafana-ui/src/components/QueryEditor/EditorHeader.tsx +++ b/packages/grafana-ui/src/components/QueryEditor/EditorHeader.tsx @@ -7,7 +7,7 @@ import { stylesFactory, useTheme2 } from '../../themes'; interface EditorHeaderProps {} -export const EditorHeader: React.FC = ({ children }) => { +export const EditorHeader = ({ children }: React.PropsWithChildren) => { const theme = useTheme2(); const styles = getStyles(theme); diff --git a/packages/grafana-ui/src/components/QueryEditor/EditorRow.tsx b/packages/grafana-ui/src/components/QueryEditor/EditorRow.tsx index 6c8f82fcdd0..f25cc9c1dd4 100644 --- a/packages/grafana-ui/src/components/QueryEditor/EditorRow.tsx +++ b/packages/grafana-ui/src/components/QueryEditor/EditorRow.tsx @@ -9,7 +9,7 @@ import { Stack } from './Stack'; interface EditorRowProps {} -export const EditorRow: React.FC = ({ children }) => { +export const EditorRow = ({ children }: React.PropsWithChildren) => { const styles = useStyles2(getStyles); return ( diff --git a/packages/grafana-ui/src/components/QueryEditor/EditorRows.tsx b/packages/grafana-ui/src/components/QueryEditor/EditorRows.tsx index d6f68923e2d..feed64809d0 100644 --- a/packages/grafana-ui/src/components/QueryEditor/EditorRows.tsx +++ b/packages/grafana-ui/src/components/QueryEditor/EditorRows.tsx @@ -4,7 +4,7 @@ import { Stack } from './Stack'; interface EditorRowsProps {} -export const EditorRows: React.FC = ({ children }) => { +export const EditorRows = ({ children }: React.PropsWithChildren) => { return ( {children} diff --git a/packages/grafana-ui/src/components/QueryEditor/Stack.tsx b/packages/grafana-ui/src/components/QueryEditor/Stack.tsx index 3143cfb473f..430c4f430aa 100644 --- a/packages/grafana-ui/src/components/QueryEditor/Stack.tsx +++ b/packages/grafana-ui/src/components/QueryEditor/Stack.tsx @@ -13,7 +13,7 @@ interface StackProps { flexGrow?: CSSProperties['flexGrow']; } -export const Stack: React.FC = ({ children, ...props }) => { +export const Stack = ({ children, ...props }: React.PropsWithChildren) => { const styles = useStyles2(useCallback((theme) => getStyles(theme, props), [props])); return
{children}
; diff --git a/packages/grafana-ui/src/components/Select/MultiValue.tsx b/packages/grafana-ui/src/components/Select/MultiValue.tsx index df7c65028f6..c06ec704f1e 100644 --- a/packages/grafana-ui/src/components/Select/MultiValue.tsx +++ b/packages/grafana-ui/src/components/Select/MultiValue.tsx @@ -9,7 +9,7 @@ interface MultiValueContainerProps { innerProps: JSX.IntrinsicElements['div']; } -export const MultiValueContainer: React.FC = ({ innerProps, children }) => { +export const MultiValueContainer = ({ innerProps, children }: React.PropsWithChildren) => { const theme = useTheme2(); const styles = getSelectStyles(theme); @@ -24,7 +24,7 @@ export type MultiValueRemoveProps = { innerProps: IconButtonProps; }; -export const MultiValueRemove: React.FC = ({ children, innerProps }) => { +export const MultiValueRemove = ({ children, innerProps }: React.PropsWithChildren) => { const theme = useTheme2(); const styles = getSelectStyles(theme); return ; diff --git a/packages/grafana-ui/src/components/Select/SelectMenu.tsx b/packages/grafana-ui/src/components/Select/SelectMenu.tsx index 9d7f4f4596e..a5d5d8bb814 100644 --- a/packages/grafana-ui/src/components/Select/SelectMenu.tsx +++ b/packages/grafana-ui/src/components/Select/SelectMenu.tsx @@ -1,6 +1,6 @@ import { cx } from '@emotion/css'; import { max } from 'lodash'; -import React, { FC, RefCallback } from 'react'; +import React, { RefCallback } from 'react'; import { MenuListProps } from 'react-select'; import { FixedSizeList as List } from 'react-window'; @@ -18,7 +18,7 @@ interface SelectMenuProps { innerProps: {}; } -export const SelectMenu: FC = ({ children, maxHeight, innerRef, innerProps }) => { +export const SelectMenu = ({ children, maxHeight, innerRef, innerProps }: React.PropsWithChildren) => { const theme = useTheme2(); const styles = getSelectStyles(theme); @@ -44,12 +44,7 @@ const VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER = 7; // // VIRTUAL_LIST_ITEM_HEIGHT and WIDTH_ESTIMATE_MULTIPLIER are both magic numbers. // Some characters (such as emojis and other unicode characters) may consist of multiple code points in which case the width would be inaccurate (but larger than needed). -export const VirtualizedSelectMenu: FC> = ({ - children, - maxHeight, - options, - getValue, -}) => { +export const VirtualizedSelectMenu = ({ children, maxHeight, options, getValue }: MenuListProps) => { const theme = useTheme2(); const styles = getSelectStyles(theme); const [value] = getValue(); @@ -91,7 +86,7 @@ interface SelectMenuOptionProps { data: SelectableValue; } -export const SelectMenuOptions: FC> = ({ +export const SelectMenuOptions = ({ children, data, innerProps, @@ -99,7 +94,7 @@ export const SelectMenuOptions: FC> = ({ isFocused, isSelected, renderOptionLabel, -}) => { +}: React.PropsWithChildren>) => { const theme = useTheme2(); const styles = getSelectStyles(theme); const icon = data.icon ? toIconName(data.icon) : undefined; diff --git a/packages/grafana-ui/src/components/Typeahead/Typeahead.tsx b/packages/grafana-ui/src/components/Typeahead/Typeahead.tsx index c9364afeeb4..080ad2cb822 100644 --- a/packages/grafana-ui/src/components/Typeahead/Typeahead.tsx +++ b/packages/grafana-ui/src/components/Typeahead/Typeahead.tsx @@ -209,10 +209,10 @@ interface PortalProps { style: string; } -class Portal extends PureComponent { +class Portal extends PureComponent, {}> { node: HTMLElement; - constructor(props: PortalProps) { + constructor(props: React.PropsWithChildren) { super(props); const { index = 0, origin = 'query', style } = props; this.node = document.createElement('div'); diff --git a/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx b/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx index c1319ab31a2..cbcced91f78 100644 --- a/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx +++ b/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx @@ -34,7 +34,7 @@ export interface VizTooltipProps { content?: React.ReactElement; /** Optional component to be used as a tooltip content */ - tooltipComponent?: React.ComponentType; + tooltipComponent?: React.ComponentType>; /** x/y position relative to the window */ position?: { x: number; y: number }; @@ -51,7 +51,7 @@ export interface VizTooltipProps { /** * @public */ -export const VizTooltip: React.FC = ({ content, position, offset }) => { +export const VizTooltip = ({ content, position, offset }: VizTooltipProps) => { const styles = useStyles(getStyles); if (position) { return ( diff --git a/packages/grafana-ui/src/components/uPlot/geometries/Marker.tsx b/packages/grafana-ui/src/components/uPlot/geometries/Marker.tsx index cd74a84e11b..7cad3518f9c 100644 --- a/packages/grafana-ui/src/components/uPlot/geometries/Marker.tsx +++ b/packages/grafana-ui/src/components/uPlot/geometries/Marker.tsx @@ -9,7 +9,7 @@ interface MarkerProps { // An abstraction over a component rendered within a chart canvas. // Marker is rendered with DOM coords of the chart bounding box. -export const Marker: React.FC = ({ x, y, children }) => { +export const Marker = ({ x, y, children }: React.PropsWithChildren) => { return (
= ({ children, left, top }) => { +export const XYCanvas = ({ children, left, top }: React.PropsWithChildren) => { const className = useMemo(() => { return css` position: absolute; diff --git a/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx b/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx index ac836367e4b..ea97ae9472b 100644 --- a/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx +++ b/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx @@ -4,12 +4,13 @@ import React from 'react'; import { RenderFunction } from '../../types'; -const StoryContainer: React.FC<{ width?: number; height?: number; showBoundaries: boolean }> = ({ - children, - width, - height, - showBoundaries, -}) => { +interface Props { + width?: number; + height?: number; + showBoundaries: boolean; +} + +const StoryContainer = ({ width, height, showBoundaries, children }: React.PropsWithChildren) => { const checkColor = '#f0f0f0'; const finalWidth = width ? `${width}px` : '100%'; const finalHeight = height !== 0 ? `${height}px` : 'auto'; diff --git a/public/app/core/components/ForgottenPassword/ForgottenPassword.tsx b/public/app/core/components/ForgottenPassword/ForgottenPassword.tsx index 23f68a715c2..00d0c51e1ec 100644 --- a/public/app/core/components/ForgottenPassword/ForgottenPassword.tsx +++ b/public/app/core/components/ForgottenPassword/ForgottenPassword.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import React, { FC, useState } from 'react'; +import React, { useState } from 'react'; import { GrafanaTheme } from '@grafana/data'; import { getBackendSrv } from '@grafana/runtime'; @@ -18,7 +18,7 @@ const paragraphStyles = (theme: GrafanaTheme) => css` display: block; `; -export const ForgottenPassword: FC = () => { +export const ForgottenPassword = () => { const [emailSent, setEmailSent] = useState(false); const styles = useStyles(paragraphStyles); const loginHref = `${config.appSubUrl}/login`; diff --git a/public/app/core/components/ForgottenPassword/SendResetMailPage.tsx b/public/app/core/components/ForgottenPassword/SendResetMailPage.tsx index 8c0e4797884..7a0938d3d9b 100644 --- a/public/app/core/components/ForgottenPassword/SendResetMailPage.tsx +++ b/public/app/core/components/ForgottenPassword/SendResetMailPage.tsx @@ -1,10 +1,10 @@ -import React, { FC } from 'react'; +import React from 'react'; import { LoginLayout, InnerBox } from '../Login/LoginLayout'; import { ForgottenPassword } from './ForgottenPassword'; -export const SendResetMailPage: FC = () => ( +export const SendResetMailPage = () => ( diff --git a/public/app/core/components/Login/LoginLayout.tsx b/public/app/core/components/Login/LoginLayout.tsx index 2cb85aa204b..a657683560a 100644 --- a/public/app/core/components/Login/LoginLayout.tsx +++ b/public/app/core/components/Login/LoginLayout.tsx @@ -1,5 +1,5 @@ import { cx, css, keyframes } from '@emotion/css'; -import React, { FC, useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { useStyles2, styleMixins } from '@grafana/ui'; @@ -11,7 +11,7 @@ import { Footer } from '../Footer/Footer'; interface InnerBoxProps { enterAnimation?: boolean; } -export const InnerBox: FC = ({ children, enterAnimation = true }) => { +export const InnerBox = ({ children, enterAnimation = true }: React.PropsWithChildren) => { const loginStyles = useStyles2(getLoginStyles); return
{children}
; }; @@ -21,7 +21,7 @@ export interface LoginLayoutProps { branding?: BrandingSettings; } -export const LoginLayout: FC = ({ children, branding }) => { +export const LoginLayout = ({ children, branding }: React.PropsWithChildren) => { const loginStyles = useStyles2(getLoginStyles); const [startAnim, setStartAnim] = useState(false); const subTitle = branding?.loginSubtitle ?? Branding.GetLoginSubTitle(); diff --git a/public/app/core/components/Login/LoginPage.tsx b/public/app/core/components/Login/LoginPage.tsx index 0e8bbbb3b82..a5e91e704ba 100644 --- a/public/app/core/components/Login/LoginPage.tsx +++ b/public/app/core/components/Login/LoginPage.tsx @@ -1,6 +1,6 @@ // Libraries import { css } from '@emotion/css'; -import React, { FC } from 'react'; +import React from 'react'; // Components import { HorizontalGroup, LinkButton } from '@grafana/ui'; @@ -20,7 +20,7 @@ const forgottenPasswordStyles = css` margin-top: 4px; `; -export const LoginPage: FC = () => { +export const LoginPage = () => { document.title = Branding.AppTitle; return ( diff --git a/public/app/core/components/Signup/VerifyEmail.tsx b/public/app/core/components/Signup/VerifyEmail.tsx index f01684bb50c..cbb2b7fc7f3 100644 --- a/public/app/core/components/Signup/VerifyEmail.tsx +++ b/public/app/core/components/Signup/VerifyEmail.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState } from 'react'; +import React, { useState } from 'react'; import { getBackendSrv } from '@grafana/runtime'; import { Form, Field, Input, Button, Legend, Container, HorizontalGroup, LinkButton } from '@grafana/ui'; @@ -9,7 +9,7 @@ interface EmailDTO { email: string; } -export const VerifyEmail: FC = () => { +export const VerifyEmail = () => { const notifyApp = useAppNotification(); const [emailSent, setEmailSent] = useState(false); diff --git a/public/app/core/components/Signup/VerifyEmailPage.tsx b/public/app/core/components/Signup/VerifyEmailPage.tsx index 8a3eacd13e1..259965a177a 100644 --- a/public/app/core/components/Signup/VerifyEmailPage.tsx +++ b/public/app/core/components/Signup/VerifyEmailPage.tsx @@ -1,10 +1,10 @@ -import React, { FC } from 'react'; +import React from 'react'; import { LoginLayout, InnerBox } from '../Login/LoginLayout'; import { VerifyEmail } from './VerifyEmail'; -export const VerifyEmailPage: FC = () => { +export const VerifyEmailPage = () => { return ( diff --git a/public/app/core/components/WithFeatureToggle.tsx b/public/app/core/components/WithFeatureToggle.tsx index 250697e0029..8980535db5c 100644 --- a/public/app/core/components/WithFeatureToggle.tsx +++ b/public/app/core/components/WithFeatureToggle.tsx @@ -1,10 +1,10 @@ -import React, { FunctionComponent } from 'react'; +import React from 'react'; export interface Props { featureToggle: boolean; } -export const WithFeatureToggle: FunctionComponent = ({ featureToggle, children }) => { +export const WithFeatureToggle = ({ featureToggle, children }: React.PropsWithChildren) => { if (featureToggle === true) { return <>{children}; } diff --git a/public/app/core/navigation/RouterDebugger.tsx b/public/app/core/navigation/RouterDebugger.tsx index 49d621ea7f9..b033c5cc57a 100644 --- a/public/app/core/navigation/RouterDebugger.tsx +++ b/public/app/core/navigation/RouterDebugger.tsx @@ -6,7 +6,7 @@ import { PageContents } from '../components/Page/PageContents'; import { RouteDescriptor } from './types'; -export const RouterDebugger: React.FC = () => { +export const RouterDebugger = () => { const manualRoutes: RouteDescriptor[] = []; return ( diff --git a/public/app/features/admin/LicenseChrome.tsx b/public/app/features/admin/LicenseChrome.tsx index ada9a83935d..dd4f38ae6d0 100644 --- a/public/app/features/admin/LicenseChrome.tsx +++ b/public/app/features/admin/LicenseChrome.tsx @@ -77,7 +77,7 @@ interface CircleProps { style?: React.CSSProperties; } -export const Circle: React.FC = ({ size, style, children }) => { +export const Circle = ({ size, style, children }: React.PropsWithChildren) => { return (
= ({ editionNotice }) => { +export const UpgradeInfo = ({ editionNotice }: UpgradeInfoProps) => { const styles = useStyles2(getStyles); return ( @@ -70,7 +70,7 @@ const getStyles = (theme: GrafanaTheme2) => { }; }; -const GetEnterprise: React.FC = () => { +const GetEnterprise = () => { return (

Get Grafana Enterprise

@@ -83,7 +83,7 @@ const GetEnterprise: React.FC = () => { ); }; -const CallToAction: React.FC = () => { +const CallToAction = () => { return ( { ); }; -const ServiceInfo: React.FC = () => { +const ServiceInfo = () => { return (

At your service

@@ -127,7 +127,7 @@ const ServiceInfo: React.FC = () => { ); }; -const FeatureInfo: React.FC = () => { +const FeatureInfo = () => { return (

Enhanced functionality

@@ -136,7 +136,7 @@ const FeatureInfo: React.FC = () => { ); }; -const FeatureListing: React.FC = () => { +const FeatureListing = () => { return ( @@ -182,7 +182,7 @@ interface ListProps { nested?: boolean; } -const List: React.FC = ({ children, nested }) => { +const List = ({ children, nested }: React.PropsWithChildren) => { const listStyle = css` display: flex; flex-direction: column; @@ -201,7 +201,7 @@ interface ItemProps { image?: string; } -const Item: React.FC = ({ children, title, image }) => { +const Item = ({ children, title, image }: React.PropsWithChildren) => { const imageUrl = image ? image : 'public/img/licensing/checkmark.svg'; const itemStyle = css` display: flex; diff --git a/public/app/features/admin/UserCreatePage.tsx b/public/app/features/admin/UserCreatePage.tsx index 427d4757210..bf7ce0077fd 100644 --- a/public/app/features/admin/UserCreatePage.tsx +++ b/public/app/features/admin/UserCreatePage.tsx @@ -23,7 +23,7 @@ const pageNav: NavModelItem = { breadcrumbs: [{ title: 'Server admin', url: 'admin/users' }], }; -const UserCreatePage: React.FC = () => { +const UserCreatePage = () => { const history = useHistory(); const onSubmit = useCallback( diff --git a/public/app/features/admin/UserOrgs.tsx b/public/app/features/admin/UserOrgs.tsx index c2833a90fca..b86799fbe01 100644 --- a/public/app/features/admin/UserOrgs.tsx +++ b/public/app/features/admin/UserOrgs.tsx @@ -462,7 +462,7 @@ export function ChangeOrgButton({ ); } -const ExternalUserTooltip: React.FC = () => { +const ExternalUserTooltip = () => { const theme = useTheme(); const styles = getTooltipStyles(theme); diff --git a/public/app/features/alerting/unified/AmRoutes.tsx b/public/app/features/alerting/unified/AmRoutes.tsx index dabe5b5aa8b..86f44c7d58e 100644 --- a/public/app/features/alerting/unified/AmRoutes.tsx +++ b/public/app/features/alerting/unified/AmRoutes.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Alert, LoadingPlaceholder, useStyles2, withErrorBoundary } from '@grafana/ui'; @@ -24,7 +24,7 @@ import { amRouteToFormAmRoute, formAmRouteToAmRoute, stringsToSelectableValues } import { isVanillaPrometheusAlertManagerDataSource } from './utils/datasource'; import { initialAsyncRequestState } from './utils/redux'; -const AmRoutes: FC = () => { +const AmRoutes = () => { const dispatch = useDispatch(); const styles = useStyles2(getStyles); const [isRootRouteEditMode, setIsRootRouteEditMode] = useState(false); diff --git a/public/app/features/alerting/unified/Receivers.tsx b/public/app/features/alerting/unified/Receivers.tsx index f73986b82ac..97d344de52b 100644 --- a/public/app/features/alerting/unified/Receivers.tsx +++ b/public/app/features/alerting/unified/Receivers.tsx @@ -1,6 +1,6 @@ import { css } from '@emotion/css'; import pluralize from 'pluralize'; -import React, { FC, useEffect } from 'react'; +import React, { useEffect } from 'react'; import { Redirect, Route, RouteChildrenProps, Switch, useLocation, useParams } from 'react-router-dom'; import { NavModelItem, GrafanaTheme2 } from '@grafana/data'; @@ -48,7 +48,7 @@ function NotificationError({ errorCount }: NotificationErrorProps) { ); } -const Receivers: FC = () => { +const Receivers = () => { const alertManagers = useAlertManagersByPermission('notification'); const [alertManagerSourceName, setAlertManagerSourceName] = useAlertManagerSourceName(alertManagers); const dispatch = useDispatch(); diff --git a/public/app/features/alerting/unified/RuleEditor.tsx b/public/app/features/alerting/unified/RuleEditor.tsx index a698b4af6e8..abc6aa8a5b8 100644 --- a/public/app/features/alerting/unified/RuleEditor.tsx +++ b/public/app/features/alerting/unified/RuleEditor.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React from 'react'; import { useAsync } from 'react-use'; import { NavModelItem } from '@grafana/data'; @@ -31,7 +31,7 @@ const getPageNav = (state: 'edit' | 'add') => { return undefined; }; -const RuleEditor: FC = ({ match }) => { +const RuleEditor = ({ match }: RuleEditorProps) => { const dispatch = useDispatch(); const { id } = match.params; const identifier = ruleId.tryParse(id, true); diff --git a/public/app/features/alerting/unified/Silences.tsx b/public/app/features/alerting/unified/Silences.tsx index 46f6cc58f58..051658c92dd 100644 --- a/public/app/features/alerting/unified/Silences.tsx +++ b/public/app/features/alerting/unified/Silences.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback, useEffect } from 'react'; +import React, { useCallback, useEffect } from 'react'; import { Redirect, Route, RouteChildrenProps, Switch, useLocation } from 'react-router-dom'; import { Alert, withErrorBoundary } from '@grafana/ui'; @@ -19,7 +19,7 @@ import { fetchAmAlertsAction, fetchSilencesAction } from './state/actions'; import { SILENCES_POLL_INTERVAL_MS } from './utils/constants'; import { AsyncRequestState, initialAsyncRequestState } from './utils/redux'; -const Silences: FC = () => { +const Silences = () => { const alertManagers = useAlertManagersByPermission('instance'); const [alertManagerSourceName, setAlertManagerSourceName] = useAlertManagerSourceName(alertManagers); diff --git a/public/app/features/alerting/unified/components/AlertingPageWrapper.tsx b/public/app/features/alerting/unified/components/AlertingPageWrapper.tsx index 84f0e367dec..4cecc7cb381 100644 --- a/public/app/features/alerting/unified/components/AlertingPageWrapper.tsx +++ b/public/app/features/alerting/unified/components/AlertingPageWrapper.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React from 'react'; import { NavModelItem } from '@grafana/data'; import { Page } from 'app/core/components/Page/Page'; @@ -9,7 +9,7 @@ interface Props { pageNav?: NavModelItem; } -export const AlertingPageWrapper: FC = ({ children, pageId, pageNav, isLoading }) => { +export const AlertingPageWrapper = ({ children, pageId, pageNav, isLoading }: React.PropsWithChildren) => { return ( {children} diff --git a/public/app/features/alerting/unified/components/Authorize.tsx b/public/app/features/alerting/unified/components/Authorize.tsx index 20506481e89..ee78e85db5f 100644 --- a/public/app/features/alerting/unified/components/Authorize.tsx +++ b/public/app/features/alerting/unified/components/Authorize.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React from 'react'; import { contextSrv } from 'app/core/services/context_srv'; import { AccessControlAction } from 'app/types'; @@ -8,7 +8,7 @@ type Props = { fallback?: boolean; }; -export const Authorize: FC = ({ actions, children, fallback = true }) => { +export const Authorize = ({ actions, children, fallback = true }: React.PropsWithChildren) => { if (actions.some((action) => contextSrv.hasAccess(action, fallback))) { return <>{children}; } else { diff --git a/public/app/features/alerting/unified/components/DetailsField.tsx b/public/app/features/alerting/unified/components/DetailsField.tsx index 28359475592..e7cd4aa2627 100644 --- a/public/app/features/alerting/unified/components/DetailsField.tsx +++ b/public/app/features/alerting/unified/components/DetailsField.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import React, { FC } from 'react'; +import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { useStyles2 } from '@grafana/ui'; @@ -10,7 +10,7 @@ interface Props { horizontal?: boolean; } -export const DetailsField: FC = ({ className, label, horizontal, children }) => { +export const DetailsField = ({ className, label, horizontal, children }: React.PropsWithChildren) => { const styles = useStyles2(getStyles); return ( diff --git a/public/app/features/alerting/unified/components/EmptyArea.tsx b/public/app/features/alerting/unified/components/EmptyArea.tsx index d0129033d24..8be4b4c3c35 100644 --- a/public/app/features/alerting/unified/components/EmptyArea.tsx +++ b/public/app/features/alerting/unified/components/EmptyArea.tsx @@ -1,10 +1,10 @@ import { css } from '@emotion/css'; -import React, { FC } from 'react'; +import React from 'react'; import { GrafanaTheme } from '@grafana/data'; import { useStyles } from '@grafana/ui'; -export const EmptyArea: FC = ({ children }) => { +export const EmptyArea = ({ children }: React.PropsWithChildren<{}>) => { const styles = useStyles(getStyles); return
{children}
; diff --git a/public/app/features/alerting/unified/components/InvalidIntervalWarning.tsx b/public/app/features/alerting/unified/components/InvalidIntervalWarning.tsx index eca95b7311a..05c1589ba47 100644 --- a/public/app/features/alerting/unified/components/InvalidIntervalWarning.tsx +++ b/public/app/features/alerting/unified/components/InvalidIntervalWarning.tsx @@ -1,9 +1,9 @@ -import React, { FC } from 'react'; +import React from 'react'; import { config } from '@grafana/runtime'; import { Alert } from '@grafana/ui'; -const EvaluationIntervalLimitExceeded: FC = () => ( +const EvaluationIntervalLimitExceeded = () => ( A minimum evaluation interval of {config.unifiedAlerting.minInterval} has been configured in Grafana. diff --git a/public/app/features/alerting/unified/components/StateColoredText.tsx b/public/app/features/alerting/unified/components/StateColoredText.tsx index 9e36f2d2d16..b695e723772 100644 --- a/public/app/features/alerting/unified/components/StateColoredText.tsx +++ b/public/app/features/alerting/unified/components/StateColoredText.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import React, { FC } from 'react'; +import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { useStyles2 } from '@grafana/ui'; @@ -9,7 +9,7 @@ type Props = { status: PromAlertingRuleState | 'neutral'; }; -export const StateColoredText: FC = ({ children, status }) => { +export const StateColoredText = ({ children, status }: React.PropsWithChildren) => { const styles = useStyles2(getStyles); return {children || status}; diff --git a/public/app/features/alerting/unified/components/StateTag.tsx b/public/app/features/alerting/unified/components/StateTag.tsx index 41376cf6171..d60a2af4f9a 100644 --- a/public/app/features/alerting/unified/components/StateTag.tsx +++ b/public/app/features/alerting/unified/components/StateTag.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import React, { FC } from 'react'; +import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { useStyles2 } from '@grafana/ui'; @@ -11,7 +11,7 @@ type Props = { size?: 'md' | 'sm'; }; -export const StateTag: FC = ({ children, state, size = 'md' }) => { +export const StateTag = ({ children, state, size = 'md' }: React.PropsWithChildren) => { const styles = useStyles2(getStyles); return {children || state}; diff --git a/public/app/features/alerting/unified/components/receivers/ReceiversSection.tsx b/public/app/features/alerting/unified/components/receivers/ReceiversSection.tsx index 9c096dc8b60..87acc6530be 100644 --- a/public/app/features/alerting/unified/components/receivers/ReceiversSection.tsx +++ b/public/app/features/alerting/unified/components/receivers/ReceiversSection.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import React, { FC } from 'react'; +import React from 'react'; import { Link } from 'react-router-dom'; import { GrafanaTheme2 } from '@grafana/data'; @@ -14,7 +14,7 @@ interface Props { showButton?: boolean; } -export const ReceiversSection: FC = ({ +export const ReceiversSection = ({ className, title, description, @@ -22,7 +22,7 @@ export const ReceiversSection: FC = ({ addButtonTo, children, showButton = true, -}) => { +}: React.PropsWithChildren) => { const styles = useStyles2(getStyles); return ( <> diff --git a/public/app/features/alerting/unified/components/receivers/form/CollapsibleSection.tsx b/public/app/features/alerting/unified/components/receivers/form/CollapsibleSection.tsx index 03972c6b410..bd424939cf4 100644 --- a/public/app/features/alerting/unified/components/receivers/form/CollapsibleSection.tsx +++ b/public/app/features/alerting/unified/components/receivers/form/CollapsibleSection.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import React, { FC, useState } from 'react'; +import React, { useState } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { IconSize, useStyles2 } from '@grafana/ui'; @@ -13,7 +13,13 @@ interface Props { size?: IconSize; } -export const CollapsibleSection: FC = ({ label, description, children, className, size = 'xl' }) => { +export const CollapsibleSection = ({ + label, + description, + children, + className, + size = 'xl', +}: React.PropsWithChildren) => { const styles = useStyles2(getStyles); const [isCollapsed, setIsCollapsed] = useState(true); diff --git a/public/app/features/alerting/unified/components/rule-editor/AnnotationsField.tsx b/public/app/features/alerting/unified/components/rule-editor/AnnotationsField.tsx index aea0da4ecb8..85993bd6450 100644 --- a/public/app/features/alerting/unified/components/rule-editor/AnnotationsField.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/AnnotationsField.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import React, { FC, useCallback } from 'react'; +import React, { useCallback } from 'react'; import { useFieldArray, useFormContext } from 'react-hook-form'; import { GrafanaTheme } from '@grafana/data'; @@ -9,7 +9,7 @@ import { RuleFormValues } from '../../types/rule-form'; import { AnnotationKeyInput } from './AnnotationKeyInput'; -const AnnotationsField: FC = () => { +const AnnotationsField = () => { const styles = useStyles(getStyles); const { control, diff --git a/public/app/features/alerting/unified/components/rule-editor/CloudEvaluationBehavior.tsx b/public/app/features/alerting/unified/components/rule-editor/CloudEvaluationBehavior.tsx index 1966f92fd60..406811583c7 100644 --- a/public/app/features/alerting/unified/components/rule-editor/CloudEvaluationBehavior.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/CloudEvaluationBehavior.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import React, { FC } from 'react'; +import React from 'react'; import { useFormContext } from 'react-hook-form'; import { GrafanaTheme } from '@grafana/data'; @@ -11,7 +11,7 @@ import { timeOptions } from '../../utils/time'; import { PreviewRule } from './PreviewRule'; import { RuleEditorSection } from './RuleEditorSection'; -export const CloudEvaluationBehavior: FC = () => { +export const CloudEvaluationBehavior = () => { const styles = useStyles(getStyles); const { register, diff --git a/public/app/features/alerting/unified/components/rule-editor/GrafanaEvaluationBehavior.tsx b/public/app/features/alerting/unified/components/rule-editor/GrafanaEvaluationBehavior.tsx index 317bb8b79ff..031afb34210 100644 --- a/public/app/features/alerting/unified/components/rule-editor/GrafanaEvaluationBehavior.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/GrafanaEvaluationBehavior.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import React, { FC, useState } from 'react'; +import React, { useState } from 'react'; import { RegisterOptions, useFormContext } from 'react-hook-form'; import { GrafanaTheme2 } from '@grafana/data'; @@ -75,7 +75,7 @@ export const evaluateEveryValidationOptions: RegisterOptions = { }, }; -export const GrafanaEvaluationBehavior: FC = () => { +export const GrafanaEvaluationBehavior = () => { const styles = useStyles2(getStyles); const [showErrorHandling, setShowErrorHandling] = useState(false); const { diff --git a/public/app/features/alerting/unified/components/rule-editor/NotificationsStep.tsx b/public/app/features/alerting/unified/components/rule-editor/NotificationsStep.tsx index 9e2d38c9695..288675efdc0 100644 --- a/public/app/features/alerting/unified/components/rule-editor/NotificationsStep.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/NotificationsStep.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import React, { FC, useState } from 'react'; +import React, { useState } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Card, Link, useStyles2, useTheme2 } from '@grafana/ui'; @@ -7,7 +7,7 @@ import { Card, Link, useStyles2, useTheme2 } from '@grafana/ui'; import LabelsField from './LabelsField'; import { RuleEditorSection } from './RuleEditorSection'; -export const NotificationsStep: FC = () => { +export const NotificationsStep = () => { const [hideFlowChart, setHideFlowChart] = useState(false); const styles = useStyles2(getStyles); const theme = useTheme2(); diff --git a/public/app/features/alerting/unified/components/rule-editor/QueryWrapper.tsx b/public/app/features/alerting/unified/components/rule-editor/QueryWrapper.tsx index 0fa08b0bbad..e24de45f826 100644 --- a/public/app/features/alerting/unified/components/rule-editor/QueryWrapper.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/QueryWrapper.tsx @@ -150,7 +150,7 @@ export const QueryWrapper: FC = ({ ); }; -export const EmptyQueryWrapper: FC<{}> = ({ children }) => { +export const EmptyQueryWrapper = ({ children }: React.PropsWithChildren<{}>) => { const styles = useStyles2(getStyles); return
{children}
; }; diff --git a/public/app/features/alerting/unified/components/rule-editor/RuleEditorSection.tsx b/public/app/features/alerting/unified/components/rule-editor/RuleEditorSection.tsx index 5ff3ffcc562..2941cfaff36 100644 --- a/public/app/features/alerting/unified/components/rule-editor/RuleEditorSection.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/RuleEditorSection.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import React, { FC } from 'react'; +import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { FieldSet, useStyles2 } from '@grafana/ui'; @@ -10,7 +10,12 @@ export interface RuleEditorSectionProps { description?: string; } -export const RuleEditorSection: FC = ({ title, stepNo, children, description }) => { +export const RuleEditorSection = ({ + title, + stepNo, + children, + description, +}: React.PropsWithChildren) => { const styles = useStyles2(getStyles); return ( diff --git a/public/app/features/alerting/unified/components/rule-editor/rule-types/DisabledTooltip.tsx b/public/app/features/alerting/unified/components/rule-editor/rule-types/DisabledTooltip.tsx index db6699e4617..bd72f7619b4 100644 --- a/public/app/features/alerting/unified/components/rule-editor/rule-types/DisabledTooltip.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/rule-types/DisabledTooltip.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React from 'react'; import { Tooltip } from '@grafana/ui'; @@ -6,7 +6,7 @@ type Props = { visible: boolean; }; -const DisabledTooltip: FC = ({ children, visible = false }) => { +const DisabledTooltip = ({ children, visible = false }: React.PropsWithChildren) => { if (!visible) { return <>{children}; } diff --git a/public/app/features/alerting/unified/components/rules/NoRulesCTA.tsx b/public/app/features/alerting/unified/components/rules/NoRulesCTA.tsx index 03ed69d6cf4..f38727ae1ea 100644 --- a/public/app/features/alerting/unified/components/rules/NoRulesCTA.tsx +++ b/public/app/features/alerting/unified/components/rules/NoRulesCTA.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React from 'react'; import { logInfo } from '@grafana/runtime'; import { CallToActionCard } from '@grafana/ui'; @@ -7,7 +7,7 @@ import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA'; import { LogMessages } from '../../Analytics'; import { useRulesAccess } from '../../utils/accessControlHooks'; -export const NoRulesSplash: FC = () => { +export const NoRulesSplash = () => { const { canCreateGrafanaRules, canCreateCloudRules } = useRulesAccess(); if (canCreateGrafanaRules || canCreateCloudRules) { diff --git a/public/app/features/alerting/unified/components/rules/StateHistory.tsx b/public/app/features/alerting/unified/components/rules/StateHistory.tsx index 2cac89d8a0a..e02df6a13d1 100644 --- a/public/app/features/alerting/unified/components/rules/StateHistory.tsx +++ b/public/app/features/alerting/unified/components/rules/StateHistory.tsx @@ -178,7 +178,7 @@ function renderTimestampCell(item: StateHistoryRow) { ); } -const LabelsWrapper: FC<{}> = ({ children }) => { +const LabelsWrapper = ({ children }: React.PropsWithChildren<{}>) => { const { wrapper } = useStyles2(getStyles); return
{children}
; }; diff --git a/public/app/features/correlations/components/Table/ExpanderCell.tsx b/public/app/features/correlations/components/Table/ExpanderCell.tsx index 0e0d2cf1a1d..fdf945490b1 100644 --- a/public/app/features/correlations/components/Table/ExpanderCell.tsx +++ b/public/app/features/correlations/components/Table/ExpanderCell.tsx @@ -10,13 +10,15 @@ const expanderContainerStyles = css` height: 100%; `; -export const ExpanderCell = ({ row }: CellProps) => ( -
- -
-); +export function ExpanderCell({ row }: CellProps) { + return ( +
+ +
+ ); +} diff --git a/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuTrigger.tsx b/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuTrigger.tsx index ccd804e1b1a..a00adc6be51 100644 --- a/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuTrigger.tsx +++ b/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuTrigger.tsx @@ -1,4 +1,4 @@ -import React, { FC, HTMLAttributes, MouseEvent, ReactElement, useCallback, useState } from 'react'; +import React, { HTMLAttributes, MouseEvent, ReactElement, useCallback, useState } from 'react'; import { CartesianCoords2D } from '@grafana/data'; @@ -7,11 +7,11 @@ interface PanelHeaderMenuTriggerApi { closeMenu: () => void; } -interface Props extends HTMLAttributes { +interface Props extends Omit, 'children'> { children: (props: PanelHeaderMenuTriggerApi) => ReactElement; } -export const PanelHeaderMenuTrigger: FC = ({ children, ...divProps }) => { +export const PanelHeaderMenuTrigger = ({ children, ...divProps }: Props) => { const [clickCoordinates, setClickCoordinates] = useState({ x: 0, y: 0 }); const [panelMenuOpen, setPanelMenuOpen] = useState(false); diff --git a/public/app/features/inspector/DetailText.tsx b/public/app/features/inspector/DetailText.tsx index 73342a1b584..6e2868daabf 100644 --- a/public/app/features/inspector/DetailText.tsx +++ b/public/app/features/inspector/DetailText.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import React, { FC } from 'react'; +import React from 'react'; import { GrafanaTheme } from '@grafana/data'; import { useStyles } from '@grafana/ui'; @@ -11,7 +11,7 @@ const getStyles = (theme: GrafanaTheme) => css` color: ${theme.colors.textWeak}; `; -export const DetailText: FC = ({ children }) => { +export const DetailText = ({ children }: React.PropsWithChildren<{}>) => { const collapsedTextStyles = useStyles(getStyles); return

{children}

; }; diff --git a/public/app/features/library-panels/components/DeleteLibraryPanelModal/DeleteLibraryPanelModal.tsx b/public/app/features/library-panels/components/DeleteLibraryPanelModal/DeleteLibraryPanelModal.tsx index 5ef9b35e88d..92dbf8fb666 100644 --- a/public/app/features/library-panels/components/DeleteLibraryPanelModal/DeleteLibraryPanelModal.tsx +++ b/public/app/features/library-panels/components/DeleteLibraryPanelModal/DeleteLibraryPanelModal.tsx @@ -51,9 +51,9 @@ export const DeleteLibraryPanelModal: FC = ({ libraryPanel, onDismiss, on ); }; -const LoadingIndicator: FC = () => Loading library panel...; +const LoadingIndicator = () => Loading library panel...; -const Confirm: FC = () => { +const Confirm = () => { const styles = useStyles(getModalStyles); return
Do you want to delete this panel?
; diff --git a/public/app/features/manage-dashboards/components/SnapshotListTable.tsx b/public/app/features/manage-dashboards/components/SnapshotListTable.tsx index 8eccb0b1513..f06b8bde962 100644 --- a/public/app/features/manage-dashboards/components/SnapshotListTable.tsx +++ b/public/app/features/manage-dashboards/components/SnapshotListTable.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState, useCallback } from 'react'; +import React, { useState, useCallback } from 'react'; import useAsync from 'react-use/lib/useAsync'; import { getBackendSrv, locationService } from '@grafana/runtime'; @@ -16,7 +16,7 @@ export function getSnapshots() { })); }); } -export const SnapshotListTable: FC = () => { +export const SnapshotListTable = () => { const [snapshots, setSnapshots] = useState([]); const [removeSnapshot, setRemoveSnapshot] = useState(); const currentPath = locationService.getLocation().pathname; diff --git a/public/app/features/panel/components/VizTypePicker/PanelTypeCard.tsx b/public/app/features/panel/components/VizTypePicker/PanelTypeCard.tsx index 7ab30364d90..4c6171e8e73 100644 --- a/public/app/features/panel/components/VizTypePicker/PanelTypeCard.tsx +++ b/public/app/features/panel/components/VizTypePicker/PanelTypeCard.tsx @@ -17,7 +17,7 @@ interface Props { description?: string; } -export const PanelTypeCard: React.FC = ({ +export const PanelTypeCard = ({ isCurrent, title, plugin, @@ -27,7 +27,7 @@ export const PanelTypeCard: React.FC = ({ showBadge, description, children, -}) => { +}: React.PropsWithChildren) => { const styles = useStyles2(getStyles); const isDisabled = disabled || plugin.state === PluginState.deprecated; const cssClass = cx({ @@ -157,7 +157,7 @@ interface PanelPluginBadgeProps { plugin: PanelPluginMeta; } -const PanelPluginBadge: React.FC = ({ plugin }) => { +const PanelPluginBadge = ({ plugin }: PanelPluginBadgeProps) => { if (isUnsignedPluginSignature(plugin.signature)) { return ; } diff --git a/public/app/features/plugins/admin/components/PluginSignatureDetailsBadge.tsx b/public/app/features/plugins/admin/components/PluginSignatureDetailsBadge.tsx index 158e0ed27b9..4ac1f84b56b 100644 --- a/public/app/features/plugins/admin/components/PluginSignatureDetailsBadge.tsx +++ b/public/app/features/plugins/admin/components/PluginSignatureDetailsBadge.tsx @@ -44,7 +44,7 @@ export function PluginSignatureDetailsBadge({ signatureType, signatureOrg = '' } ); } -export const DetailsBadge: React.FC = ({ children }) => { +export const DetailsBadge = ({ children }: React.PropsWithChildren<{}>) => { const styles = useStyles2(getStyles); return {children}} />; diff --git a/public/app/features/plugins/sql/components/ErrorBoundary.tsx b/public/app/features/plugins/sql/components/ErrorBoundary.tsx index b9194228532..4102bfbf932 100644 --- a/public/app/features/plugins/sql/components/ErrorBoundary.tsx +++ b/public/app/features/plugins/sql/components/ErrorBoundary.tsx @@ -4,8 +4,8 @@ type Props = { fallBackComponent?: React.ReactNode; }; -export class ErrorBoundary extends React.Component { - constructor(props: Props) { +export class ErrorBoundary extends React.Component, { hasError: boolean }> { + constructor(props: React.PropsWithChildren) { super(props); this.state = { hasError: false }; } diff --git a/public/app/features/profile/UserProfileEditForm.tsx b/public/app/features/profile/UserProfileEditForm.tsx index 5ecb9e596dc..a1b451bbbe6 100644 --- a/public/app/features/profile/UserProfileEditForm.tsx +++ b/public/app/features/profile/UserProfileEditForm.tsx @@ -91,7 +91,7 @@ export const UserProfileEditForm: FC = ({ user, isSavingUser, updateProfi export default UserProfileEditForm; -const InputSuffix: FC = () => { +const InputSuffix = () => { return disableLoginForm ? ( diff --git a/public/app/features/query/components/HelpToggle.tsx b/public/app/features/query/components/HelpToggle.tsx index e06fbbb38a8..82351816ff0 100644 --- a/public/app/features/query/components/HelpToggle.tsx +++ b/public/app/features/query/components/HelpToggle.tsx @@ -10,7 +10,7 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => ({ `, })); -export const HelpToggle: React.FunctionComponent = ({ children }) => { +export const HelpToggle = ({ children }: React.PropsWithChildren<{}>) => { const [isHelpVisible, setIsHelpVisible] = useState(false); const theme = useTheme(); const styles = getStyles(theme); diff --git a/public/app/features/sandbox/BenchmarksPage.tsx b/public/app/features/sandbox/BenchmarksPage.tsx index 7cc494ef0e9..8a9da1dd877 100644 --- a/public/app/features/sandbox/BenchmarksPage.tsx +++ b/public/app/features/sandbox/BenchmarksPage.tsx @@ -1,9 +1,9 @@ -import React, { FC } from 'react'; +import React from 'react'; import { VerticalGroup } from '@grafana/ui'; import { EmotionPerfTest } from '@grafana/ui/src/components/ThemeDemos/EmotionPerfTest'; -export const BenchmarksPage: FC = () => { +export const BenchmarksPage = () => { return ( diff --git a/public/app/features/sandbox/TestStuffPage.tsx b/public/app/features/sandbox/TestStuffPage.tsx index b07b6713842..b1bcff2d941 100644 --- a/public/app/features/sandbox/TestStuffPage.tsx +++ b/public/app/features/sandbox/TestStuffPage.tsx @@ -1,4 +1,4 @@ -import React, { FC, useMemo, useState } from 'react'; +import React, { useMemo, useState } from 'react'; import { useObservable } from 'react-use'; import AutoSizer from 'react-virtualized-auto-sizer'; @@ -26,7 +26,7 @@ interface State { data?: PanelData; } -export const TestStuffPage: FC = () => { +export const TestStuffPage = () => { const [state, setState] = useState(getDefaultState()); const { queryOptions, queryRunner } = state; diff --git a/public/app/features/search/components/SearchWrapper.tsx b/public/app/features/search/components/SearchWrapper.tsx index cb282f8b4d4..5e2b73f9be3 100644 --- a/public/app/features/search/components/SearchWrapper.tsx +++ b/public/app/features/search/components/SearchWrapper.tsx @@ -1,4 +1,4 @@ -import React, { FC, memo } from 'react'; +import React, { memo } from 'react'; import { config } from '@grafana/runtime'; import { useUrlParams } from 'app/core/navigation/hooks'; @@ -6,7 +6,7 @@ import { useUrlParams } from 'app/core/navigation/hooks'; import { DashboardSearch } from './DashboardSearch'; import { DashboardSearchModal } from './DashboardSearchModal'; -export const SearchWrapper: FC = memo(() => { +export const SearchWrapper = memo(() => { const [params] = useUrlParams(); const isOpen = params.get('search') === 'open'; const isTopnav = config.featureToggles.topnav; diff --git a/public/app/plugins/datasource/cloud-monitoring/components/AnnotationsHelp.tsx b/public/app/plugins/datasource/cloud-monitoring/components/AnnotationsHelp.tsx index befba24c1bb..a6811520410 100644 --- a/public/app/plugins/datasource/cloud-monitoring/components/AnnotationsHelp.tsx +++ b/public/app/plugins/datasource/cloud-monitoring/components/AnnotationsHelp.tsx @@ -1,6 +1,6 @@ -import React, { FC } from 'react'; +import React from 'react'; -export const AnnotationsHelp: FC = () => { +export const AnnotationsHelp = () => { return (
diff --git a/public/test/helpers/TestProvider.tsx b/public/test/helpers/TestProvider.tsx index 167735d9ada..c808eefd048 100644 --- a/public/test/helpers/TestProvider.tsx +++ b/public/test/helpers/TestProvider.tsx @@ -1,6 +1,6 @@ import React from 'react'; -const TestProvider: React.FC = ({ children }) => { +const TestProvider = ({ children }: React.PropsWithChildren<{}>) => { return <>{children}; };