2021-04-01 07:15:23 -05:00
|
|
|
import { css } from '@emotion/css';
|
2022-04-22 08:33:13 -05:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
|
2021-08-11 01:25:54 -05:00
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
|
|
import { useStyles2 } from '@grafana/ui';
|
2020-01-20 06:32:28 -06:00
|
|
|
|
2021-08-11 01:25:54 -05:00
|
|
|
const getStyles = (theme: GrafanaTheme2) => ({
|
2024-01-16 13:49:12 -06:00
|
|
|
metaContainer: css({
|
|
|
|
flex: 1,
|
|
|
|
color: theme.colors.text.secondary,
|
|
|
|
marginBottom: theme.spacing(2),
|
|
|
|
minWidth: '30%',
|
|
|
|
display: 'flex',
|
|
|
|
flexWrap: 'wrap',
|
|
|
|
}),
|
|
|
|
metaItem: css({
|
|
|
|
marginRight: theme.spacing(2),
|
|
|
|
marginTop: theme.spacing(0.5),
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
['.logs-meta-item__error']: {
|
|
|
|
color: theme.colors.error.text,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
metaLabel: css({
|
|
|
|
marginRight: `calc(${theme.spacing(2)} / 2)`,
|
|
|
|
fontSize: theme.typography.bodySmall.fontSize,
|
|
|
|
fontWeight: theme.typography.fontWeightMedium,
|
|
|
|
}),
|
|
|
|
metaValue: css({
|
|
|
|
fontFamily: theme.typography.fontFamilyMonospace,
|
|
|
|
fontSize: theme.typography.bodySmall.fontSize,
|
|
|
|
}),
|
2021-04-21 07:25:43 -05:00
|
|
|
});
|
2020-01-20 06:32:28 -06:00
|
|
|
|
2020-01-26 21:59:28 -06:00
|
|
|
export interface MetaItemProps {
|
2020-01-20 06:32:28 -06:00
|
|
|
label?: string;
|
2021-03-03 11:32:27 -06:00
|
|
|
value: string | JSX.Element;
|
2020-01-20 06:32:28 -06:00
|
|
|
}
|
|
|
|
|
2021-10-29 05:34:48 -05:00
|
|
|
const MetaInfoItem = memo(function MetaInfoItem(props: MetaItemProps) {
|
2021-08-11 01:25:54 -05:00
|
|
|
const style = useStyles2(getStyles);
|
2020-01-20 06:32:28 -06:00
|
|
|
const { label, value } = props;
|
|
|
|
|
|
|
|
return (
|
2022-03-18 14:44:51 -05:00
|
|
|
<div data-testid="meta-info-text-item" className={style.metaItem}>
|
2020-01-20 06:32:28 -06:00
|
|
|
{label && <span className={style.metaLabel}>{label}:</span>}
|
|
|
|
<span className={style.metaValue}>{value}</span>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2021-10-29 05:34:48 -05:00
|
|
|
interface MetaInfoTextProps {
|
2020-01-20 06:32:28 -06:00
|
|
|
metaItems: MetaItemProps[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export const MetaInfoText = memo(function MetaInfoText(props: MetaInfoTextProps) {
|
2021-08-11 01:25:54 -05:00
|
|
|
const style = useStyles2(getStyles);
|
2020-01-20 06:32:28 -06:00
|
|
|
const { metaItems } = props;
|
|
|
|
|
|
|
|
return (
|
2022-03-18 14:44:51 -05:00
|
|
|
<div className={style.metaContainer} data-testid="meta-info-text">
|
2020-01-20 06:32:28 -06:00
|
|
|
{metaItems.map((item, index) => (
|
|
|
|
<MetaInfoItem key={`${index}-${item.label}`} label={item.label} value={item.value} />
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|