import { css, cx } from '@emotion/css';
import React from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { useStyles2, Icon, HorizontalGroup } from '@grafana/ui';
import { getLatestCompatibleVersion } from '../helpers';
import { CatalogPlugin } from '../types';
import { PluginDisabledBadge } from './Badges';
import { GetStartedWithPlugin } from './GetStartedWithPlugin';
import { InstallControls } from './InstallControls';
import { PluginDetailsHeaderDependencies } from './PluginDetailsHeaderDependencies';
import { PluginDetailsHeaderSignature } from './PluginDetailsHeaderSignature';
import { PluginLogo } from './PluginLogo';
type Props = {
currentUrl: string;
parentUrl: string;
plugin: CatalogPlugin;
};
export function PluginDetailsHeader({ plugin, currentUrl, parentUrl }: Props): React.ReactElement {
const styles = useStyles2(getStyles);
const latestCompatibleVersion = getLatestCompatibleVersion(plugin.details?.versions);
const version = plugin.installedVersion || latestCompatibleVersion?.version;
return (
{/* Title & navigation */}
{/* Org name */}
{plugin.orgName}
{/* Links */}
{plugin.details?.links.map((link: any) => (
{link.name}
))}
{/* Downloads */}
{plugin.downloads > 0 && (
{` ${new Intl.NumberFormat().format(plugin.downloads)}`}{' '}
)}
{/* Version */}
{Boolean(version) &&
{version}}
{/* Signature information */}
{plugin.isDisabled &&
}
{plugin.description}
);
}
export const getStyles = (theme: GrafanaTheme2) => {
return {
headerContainer: css`
display: flex;
margin-bottom: ${theme.spacing(3)};
margin-top: ${theme.spacing(3)};
min-height: 120px;
`,
headerWrapper: css`
margin-left: ${theme.spacing(3)};
`,
breadcrumb: css`
font-size: ${theme.typography.h2.fontSize};
li {
display: inline;
list-style: none;
&::after {
content: '/';
padding: 0 0.25ch;
}
&:last-child::after {
content: '';
}
}
`,
headerInformationRow: css`
display: flex;
align-items: center;
margin-top: ${theme.spacing()};
margin-bottom: ${theme.spacing()};
flex-flow: wrap;
& > * {
&::after {
content: '|';
padding: 0 ${theme.spacing()};
}
&:last-child::after {
content: '';
padding-right: 0;
}
}
font-size: ${theme.typography.h4.fontSize};
a {
&:hover {
text-decoration: underline;
}
}
`,
headerInformationRowSecondary: css`
font-size: ${theme.typography.body.fontSize};
`,
headerOrgName: css`
font-size: ${theme.typography.h4.fontSize};
`,
signature: css`
margin: ${theme.spacing(3)};
margin-bottom: 0;
`,
textUnderline: css`
text-decoration: underline;
`,
};
};