UI: Remove unused ErrorIndicator component (#75185)

Closes #75068
pull/75275/head
kay delaney 2 years ago committed by GitHub
parent 42cc6b1842
commit 70cb87380d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      packages/grafana-ui/src/components/PanelChrome/ErrorIndicator.tsx
  2. 20
      packages/grafana-ui/src/components/PanelChrome/PanelChrome.story.tsx
  3. 8
      packages/grafana-ui/src/components/PanelChrome/index.ts
  4. 2
      packages/grafana-ui/src/components/index.ts

@ -1,48 +0,0 @@
import { css, cx } from '@emotion/css';
import React from 'react';
import { useStyles2 } from '../../themes';
import { commonColorsPalette } from '../../themes/default';
import { Icon } from '../Icon/Icon';
import { Tooltip } from '../Tooltip/Tooltip';
/**
* @internal
*/
export type ErrorIndicatorProps = {
error?: string;
onClick?: () => void;
};
/**
* @internal
*/
export const ErrorIndicator = ({ error, onClick }: ErrorIndicatorProps) => {
const styles = useStyles2(getStyles);
if (!error) {
return null;
}
return (
<Tooltip theme="error" content={error}>
<Icon
onClick={onClick}
className={cx(styles.icon, { [styles.clickable]: !!onClick })}
size="sm"
name="exclamation-triangle"
/>
</Tooltip>
);
};
const getStyles = () => {
return {
clickable: css({
cursor: 'pointer',
}),
icon: css({
color: `${commonColorsPalette.red88}`,
}),
};
};

@ -186,16 +186,6 @@ export const Examples = () => {
menu, menu,
loadingState: LoadingState.Loading, loadingState: LoadingState.Loading,
})} })}
{renderPanel('Deprecated error indicator', {
title: 'Default title',
leftItems: [
<PanelChrome.ErrorIndicator
key="errorIndicator"
error="Error text"
onClick={action('ErrorIndicator: onClick fired')}
/>,
],
})}
{renderPanel('No padding, deprecated loading indicator', { {renderPanel('No padding, deprecated loading indicator', {
padding: 'none', padding: 'none',
title: 'Default title', title: 'Default title',
@ -359,15 +349,8 @@ const Default: ReactNode = [];
const LoadingIcon = [ const LoadingIcon = [
<PanelChrome.LoadingIndicator key="loadingIndicator" loading onCancel={action('LoadingIndicator: onCancel fired')} />, <PanelChrome.LoadingIndicator key="loadingIndicator" loading onCancel={action('LoadingIndicator: onCancel fired')} />,
]; ];
const ErrorIcon = [
<PanelChrome.ErrorIndicator
key="errorIndicator"
error="Error text"
onClick={action('ErrorIndicator: onClick fired')}
/>,
];
const leftItems = { LoadingIcon, ErrorIcon, Default }; const leftItems = { LoadingIcon, Default };
const description = const description =
'Description text with very long descriptive words that describe what is going on in the panel and not beyond. Or maybe beyond, not up to us.'; 'Description text with very long descriptive words that describe what is going on in the panel and not beyond. Or maybe beyond, not up to us.';
@ -381,7 +364,6 @@ Basic.argTypes = {
type: 'select', type: 'select',
labels: { labels: {
LoadingIcon: 'With loading icon', LoadingIcon: 'With loading icon',
ErrorIcon: 'With error icon',
Default: 'Default (no elements)', Default: 'Default (no elements)',
}, },
}, },

@ -1,6 +1,5 @@
import React from 'react'; import React from 'react';
import { ErrorIndicator } from './ErrorIndicator';
import { LoadingIndicator } from './LoadingIndicator'; import { LoadingIndicator } from './LoadingIndicator';
import { PanelChrome as PanelChromeComponent, PanelChromeProps } from './PanelChrome'; import { PanelChrome as PanelChromeComponent, PanelChromeProps } from './PanelChrome';
import { TitleItem } from './TitleItem'; import { TitleItem } from './TitleItem';
@ -15,7 +14,6 @@ export type { PanelChromeProps, PanelPadding } from './PanelChrome';
*/ */
export interface PanelChromeType extends React.FC<PanelChromeProps> { export interface PanelChromeType extends React.FC<PanelChromeProps> {
LoadingIndicator: typeof LoadingIndicator; LoadingIndicator: typeof LoadingIndicator;
ErrorIndicator: typeof ErrorIndicator;
TitleItem: typeof TitleItem; TitleItem: typeof TitleItem;
} }
@ -24,7 +22,6 @@ export interface PanelChromeType extends React.FC<PanelChromeProps> {
*/ */
export const PanelChrome = PanelChromeComponent as PanelChromeType; export const PanelChrome = PanelChromeComponent as PanelChromeType;
PanelChrome.LoadingIndicator = LoadingIndicator; PanelChrome.LoadingIndicator = LoadingIndicator;
PanelChrome.ErrorIndicator = ErrorIndicator;
PanelChrome.TitleItem = TitleItem; PanelChrome.TitleItem = TitleItem;
/** /**
@ -36,11 +33,6 @@ export {
type LoadingIndicatorProps as PanelChromeLoadingIndicatorProps, type LoadingIndicatorProps as PanelChromeLoadingIndicatorProps,
} from './LoadingIndicator'; } from './LoadingIndicator';
export {
ErrorIndicator as PanelChromeErrorIndicator,
type ErrorIndicatorProps as PanelChromeErrorIndicatorProps,
} from './ErrorIndicator';
export { PanelDescription } from './PanelDescription'; export { PanelDescription } from './PanelDescription';
export { usePanelContext, PanelContextProvider, type PanelContext, PanelContextRoot } from './PanelContext'; export { usePanelContext, PanelContextProvider, type PanelContext, PanelContextRoot } from './PanelContext';

@ -138,8 +138,6 @@ export {
type PanelChromeType, type PanelChromeType,
PanelChromeLoadingIndicator, PanelChromeLoadingIndicator,
type PanelChromeLoadingIndicatorProps, type PanelChromeLoadingIndicatorProps,
PanelChromeErrorIndicator,
type PanelChromeErrorIndicatorProps,
PanelContextProvider, PanelContextProvider,
type PanelContext, type PanelContext,
PanelContextRoot, PanelContextRoot,

Loading…
Cancel
Save