2021-04-01 14:15:23 +02:00
|
|
|
import { css } from '@emotion/css';
|
2021-04-21 08:38:00 +01:00
|
|
|
import { noop } from 'lodash';
|
2022-04-22 14:33:13 +01:00
|
|
|
import React from 'react';
|
|
|
|
|
|
2022-11-03 13:54:18 +00:00
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
|
|
|
import { Icon, IconButton, useStyles2 } from '@grafana/ui';
|
2021-01-19 13:19:01 +01:00
|
|
|
|
|
|
|
|
type VersionHistoryHeaderProps = {
|
|
|
|
|
onClick?: () => void;
|
|
|
|
|
baseVersion?: number;
|
|
|
|
|
newVersion?: number;
|
|
|
|
|
isNewLatest?: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-15 07:56:09 -07:00
|
|
|
export const VersionHistoryHeader = ({
|
2021-01-19 13:19:01 +01:00
|
|
|
onClick = noop,
|
|
|
|
|
baseVersion = 0,
|
|
|
|
|
newVersion = 0,
|
|
|
|
|
isNewLatest = false,
|
2023-03-15 07:56:09 -07:00
|
|
|
}: VersionHistoryHeaderProps) => {
|
2022-11-03 13:54:18 +00:00
|
|
|
const styles = useStyles2(getStyles);
|
2021-03-25 11:51:09 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<h3 className={styles.header}>
|
2023-06-08 10:23:28 +02:00
|
|
|
<IconButton name="arrow-left" size="xl" onClick={onClick} tooltip="Reset version" />
|
2022-08-24 18:05:12 +02:00
|
|
|
<span>
|
|
|
|
|
Comparing {baseVersion} <Icon name="arrows-h" /> {newVersion}{' '}
|
|
|
|
|
{isNewLatest && <cite className="muted">(Latest)</cite>}
|
2021-01-19 13:19:01 +01:00
|
|
|
</span>
|
2021-03-25 11:51:09 +01:00
|
|
|
</h3>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-03 13:54:18 +00:00
|
|
|
const getStyles = (theme: GrafanaTheme2) => ({
|
2021-03-25 11:51:09 +01:00
|
|
|
header: css`
|
2022-11-03 13:54:18 +00:00
|
|
|
font-size: ${theme.typography.h3.fontSize};
|
2022-08-24 18:05:12 +02:00
|
|
|
display: flex;
|
2022-11-03 13:54:18 +00:00
|
|
|
gap: ${theme.spacing(2)};
|
|
|
|
|
margin-bottom: ${theme.spacing(3)};
|
2021-03-25 11:51:09 +01:00
|
|
|
`,
|
|
|
|
|
});
|