setScrollElement(scrollElement)}
>
{showCommonLabels && !isAscending && renderCommonLabels()}
{showCommonLabels && isAscending && renderCommonLabels()}
>
);
};
const getStyles = (theme: GrafanaTheme2) => ({
container: css({
marginBottom: theme.spacing(1.5),
}),
labelContainer: css({
margin: theme.spacing(0, 0, 0.5, 0.5),
display: 'flex',
alignItems: 'center',
}),
labelContainerAscending: css({
margin: theme.spacing(0.5, 0, 0.5, 0),
}),
label: css({
marginRight: theme.spacing(0.5),
fontSize: theme.typography.bodySmall.fontSize,
fontWeight: theme.typography.fontWeightMedium,
}),
});
function getLogsPanelState(): LogsPermalinkUrlState | undefined {
const urlParams = urlUtil.getUrlSearchParams();
const panelStateEncoded = urlParams?.panelState;
if (
panelStateEncoded &&
Array.isArray(panelStateEncoded) &&
panelStateEncoded?.length > 0 &&
typeof panelStateEncoded[0] === 'string'
) {
try {
return JSON.parse(panelStateEncoded[0]);
} catch (e) {
console.error('error parsing logsPanelState', e);
}
}
return undefined;
}
async function copyDashboardUrl(row: LogRowModel, timeRange: TimeRange) {
// this is an extra check, to be sure that we are not
// creating permalinks for logs without an id-field.
// normally it should never happen, because we do not
// display the permalink button in such cases.
if (row.rowId === undefined || !row.dataFrame.refId) {
return;
}
// get panel state, add log-row-id
const panelState = {
logs: { id: row.uid },
};
// Grab the current dashboard URL
const currentURL = new URL(window.location.href);
// Add panel state containing the rowId, and absolute time range from the current query, but leave everything else the same, if the user is in edit mode when grabbing the link, that's what will be linked to, etc.
currentURL.searchParams.set('panelState', JSON.stringify(panelState));
currentURL.searchParams.set('from', toUtc(timeRange.from).valueOf().toString(10));
currentURL.searchParams.set('to', toUtc(timeRange.to).valueOf().toString(10));
await createAndCopyShortLink(currentURL.toString());
return Promise.resolve();
}