New Log Details: fix attribute extension links (#110119)
* New Log Details: fix attribute extension links * LogLineDetailsFields: do not render empty divs
This commit is contained in:
@@ -742,4 +742,26 @@ describe('LogLineDetails', () => {
|
|||||||
|
|
||||||
expect(screen.getByText('Could not retrieve trace.')).toBeInTheDocument();
|
expect(screen.getByText('Could not retrieve trace.')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('shows attribute extension links when they are available', () => {
|
||||||
|
const usePluginLinksMock = jest.fn().mockReturnValue({
|
||||||
|
links: [
|
||||||
|
{
|
||||||
|
type: 'link',
|
||||||
|
title: 'Open service overview for label',
|
||||||
|
path: 'https://example.com',
|
||||||
|
category: 'label',
|
||||||
|
icon: 'compass',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
setPluginLinksHook(usePluginLinksMock);
|
||||||
|
jest.requireMock('@grafana/runtime').usePluginLinks = usePluginLinksMock;
|
||||||
|
|
||||||
|
setup(undefined, { labels: { label: 'value' } });
|
||||||
|
|
||||||
|
expect(screen.getByText('label')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('value')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Open service overview for label')).toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export const LogLineDetailsComponent = memo(
|
|||||||
.map((label) => ({
|
.map((label) => ({
|
||||||
key: label,
|
key: label,
|
||||||
value: log.labels[label],
|
value: log.labels[label],
|
||||||
link: extensionLinks?.[label],
|
links: extensionLinks?.[label],
|
||||||
})),
|
})),
|
||||||
[extensionLinks, log.labels]
|
[extensionLinks, log.labels]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ export const LogLineDetailsField = ({
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className={styles.row} key={`${link.title}-${i}`}>
|
<div className={styles.row} key={`${link.title}-${i}`}>
|
||||||
<div className={disableActions ? styles.linkNoActions : styles.link}>
|
<div className={disableActions ? undefined : styles.link}>
|
||||||
<DataLinkButton
|
<DataLinkButton
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
// Show tooltip message if max number of pinned lines has been reached
|
// Show tooltip message if max number of pinned lines has been reached
|
||||||
@@ -359,7 +359,6 @@ export const LogLineDetailsField = ({
|
|||||||
})}
|
})}
|
||||||
{showFieldsStats && fieldStats && (
|
{showFieldsStats && fieldStats && (
|
||||||
<div className={styles.row}>
|
<div className={styles.row}>
|
||||||
<div />
|
|
||||||
<div className={disableActions ? undefined : styles.statsColumn}>
|
<div className={disableActions ? undefined : styles.statsColumn}>
|
||||||
<LogLabelStats
|
<LogLabelStats
|
||||||
className={styles.stats}
|
className={styles.stats}
|
||||||
@@ -400,10 +399,7 @@ const getFieldStyles = (theme: GrafanaTheme2) => ({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
link: css({
|
link: css({
|
||||||
gridColumn: 'span 3',
|
gridColumn: '2 / 4',
|
||||||
}),
|
|
||||||
linkNoActions: css({
|
|
||||||
gridColumn: 'span 2',
|
|
||||||
}),
|
}),
|
||||||
stats: css({
|
stats: css({
|
||||||
paddingRight: theme.spacing(1),
|
paddingRight: theme.spacing(1),
|
||||||
@@ -412,7 +408,7 @@ const getFieldStyles = (theme: GrafanaTheme2) => ({
|
|||||||
maxWidth: '50vh',
|
maxWidth: '50vh',
|
||||||
}),
|
}),
|
||||||
statsColumn: css({
|
statsColumn: css({
|
||||||
gridColumn: 'span 2',
|
gridColumn: '2 / 4',
|
||||||
}),
|
}),
|
||||||
valueContainer: css({
|
valueContainer: css({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
|||||||
Reference in New Issue
Block a user