mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* Added labels * App page fixes * Switch to switch * wip * Updates * I am stuck * Minor tweak * This props interface could work * removed change * use new page extensions in plugin details page * add link separator, fix action button spacing * some renaming * Move PageInfo into it's own folder + add tests * add support for new props in old page header * remove PluginDetailsHeader as it's no longer used * Fix unit tests * fix some badge alignments * center align actions * badge alignment + only show downloads for community/commercial plugins * better link alignment * conditionally render description * move install control warnings to below subtitle + refactor Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import { capitalize } from 'lodash';
|
|
import React from 'react';
|
|
|
|
import { GrafanaTheme2, PluginSignatureType } from '@grafana/data';
|
|
import { useStyles2, Icon, Badge, IconName } from '@grafana/ui';
|
|
|
|
const SIGNATURE_ICONS: Record<string, IconName> = {
|
|
[PluginSignatureType.grafana]: 'grafana',
|
|
[PluginSignatureType.commercial]: 'shield',
|
|
[PluginSignatureType.community]: 'shield',
|
|
DEFAULT: 'shield-exclamation',
|
|
};
|
|
|
|
type Props = {
|
|
signatureType?: PluginSignatureType;
|
|
signatureOrg?: string;
|
|
};
|
|
|
|
// Shows more information about a valid signature
|
|
export function PluginSignatureDetailsBadge({ signatureType, signatureOrg = '' }: Props): React.ReactElement | null {
|
|
const styles = useStyles2(getStyles);
|
|
|
|
if (!signatureType && !signatureOrg) {
|
|
return null;
|
|
}
|
|
|
|
const signatureTypeText = signatureType === PluginSignatureType.grafana ? 'Grafana Labs' : capitalize(signatureType);
|
|
const signatureIcon = SIGNATURE_ICONS[signatureType || ''] || SIGNATURE_ICONS.DEFAULT;
|
|
|
|
return (
|
|
<>
|
|
<DetailsBadge>
|
|
<div className={styles.detailsWrapper}>
|
|
<strong className={styles.strong}>Level: </strong>
|
|
<Icon size="xs" name={signatureIcon} />
|
|
|
|
{signatureTypeText}
|
|
</div>
|
|
</DetailsBadge>
|
|
|
|
<DetailsBadge>
|
|
<strong className={styles.strong}>Signed by:</strong> {signatureOrg}
|
|
</DetailsBadge>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export const DetailsBadge = ({ children }: React.PropsWithChildren<{}>) => {
|
|
const styles = useStyles2(getStyles);
|
|
|
|
return <Badge color="green" className={styles.badge} text={children} />;
|
|
};
|
|
|
|
const getStyles = (theme: GrafanaTheme2) => ({
|
|
badge: css`
|
|
background-color: ${theme.colors.background.canvas};
|
|
border-color: ${theme.colors.border.strong};
|
|
color: ${theme.colors.text.secondary};
|
|
white-space: nowrap;
|
|
`,
|
|
detailsWrapper: css`
|
|
align-items: center;
|
|
display: flex;
|
|
`,
|
|
strong: css`
|
|
color: ${theme.colors.text.primary};
|
|
`,
|
|
icon: css`
|
|
margin-right: ${theme.spacing(0.5)};
|
|
`,
|
|
});
|