import React from 'react'; import { css } from '@emotion/css'; import { dateTimeFormatTimeAgo, GrafanaTheme2 } from '@grafana/data'; import { useStyles2 } from '@grafana/ui'; import { Version } from '../types'; import { getLatestCompatibleVersion } from '../helpers'; interface Props { versions?: Version[]; installedVersion?: string; } export const VersionList = ({ versions = [], installedVersion }: Props) => { const styles = useStyles2(getStyles); const latestCompatibleVersion = getLatestCompatibleVersion(versions); if (versions.length === 0) { return

No version history was found.

; } return ( {versions.map((version) => { const isInstalledVersion = installedVersion === version.version; return ( {/* Version number */} {isInstalledVersion ? ( ) : version.version === latestCompatibleVersion?.version ? ( ) : ( )} {/* Last updated */} ); })}
Version Last updated
{version.version} (installed version){version.version} (latest compatible version){version.version} {dateTimeFormatTimeAgo(version.createdAt)}
); }; const getStyles = (theme: GrafanaTheme2) => ({ container: css` padding: ${theme.spacing(2, 4, 3)}; `, table: css` table-layout: fixed; width: 100%; td, th { padding: ${theme.spacing()} 0; } th { font-size: ${theme.typography.h5.fontSize}; } `, currentVersion: css` font-weight: ${theme.typography.fontWeightBold}; `, });