mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* Performance: Standardize lodash imports to use destructured members Changes lodash imports of the form `import x from 'lodash/x'` to `import { x } from 'lodash'` to reduce bundle size. * Remove unnecessary _ import from Graph component * Enforce lodash import style * Fix remaining lodash imports
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
import { css } from '@emotion/css';
|
|
import { noop } from 'lodash';
|
|
import { GrafanaTheme } from '@grafana/data';
|
|
import { Icon, useStyles } from '@grafana/ui';
|
|
|
|
type VersionHistoryHeaderProps = {
|
|
isComparing?: boolean;
|
|
onClick?: () => void;
|
|
baseVersion?: number;
|
|
newVersion?: number;
|
|
isNewLatest?: boolean;
|
|
};
|
|
|
|
export const VersionHistoryHeader: React.FC<VersionHistoryHeaderProps> = ({
|
|
isComparing = false,
|
|
onClick = noop,
|
|
baseVersion = 0,
|
|
newVersion = 0,
|
|
isNewLatest = false,
|
|
}) => {
|
|
const styles = useStyles(getStyles);
|
|
|
|
return (
|
|
<h3 className={styles.header}>
|
|
<span onClick={onClick} className={isComparing ? 'pointer' : ''}>
|
|
Versions
|
|
</span>
|
|
{isComparing && (
|
|
<span>
|
|
<Icon name="angle-right" /> Comparing {baseVersion} <Icon name="arrows-h" /> {newVersion}{' '}
|
|
{isNewLatest && <cite className="muted">(Latest)</cite>}
|
|
</span>
|
|
)}
|
|
</h3>
|
|
);
|
|
};
|
|
|
|
const getStyles = (theme: GrafanaTheme) => ({
|
|
header: css`
|
|
font-size: ${theme.typography.heading.h3};
|
|
margin-bottom: ${theme.spacing.lg};
|
|
`,
|
|
});
|