LogContext: Fix wrong width if lines are wrapped (#56650)

This commit is contained in:
Sven Grossmann
2022-10-10 16:31:14 +02:00
committed by GitHub
parent 65e56c9fb8
commit fb31daa92f
@@ -35,13 +35,13 @@ const getLogRowContextStyles = (theme: GrafanaTheme2, wrapLogMessage?: boolean)
const headerHeight = 40; const headerHeight = 40;
const logsHeight = 220; const logsHeight = 220;
const contextHeight = headerHeight + logsHeight; const contextHeight = headerHeight + logsHeight;
const width = wrapLogMessage ? '100%' : '75%';
const afterContext = wrapLogMessage const afterContext = wrapLogMessage
? css` ? css`
top: -${contextHeight}px; top: -${contextHeight}px;
` `
: css` : css`
margin-top: -${contextHeight}px; margin-top: -${contextHeight}px;
width: 75%;
`; `;
const beforeContext = wrapLogMessage const beforeContext = wrapLogMessage
@@ -50,9 +50,11 @@ const getLogRowContextStyles = (theme: GrafanaTheme2, wrapLogMessage?: boolean)
` `
: css` : css`
margin-top: 20px; margin-top: 20px;
width: 75%;
`; `;
return { return {
width: css`
width: ${width};
`,
commonStyles: css` commonStyles: css`
position: absolute; position: absolute;
height: ${contextHeight}px; height: ${contextHeight}px;
@@ -78,7 +80,7 @@ const getLogRowContextStyles = (theme: GrafanaTheme2, wrapLogMessage?: boolean)
`, `,
title: css` title: css`
position: absolute; position: absolute;
width: 75%; width: ${width};
margin-top: -${contextHeight + headerHeight}px; margin-top: -${contextHeight + headerHeight}px;
z-index: ${theme.zIndex.modal}; z-index: ${theme.zIndex.modal};
height: ${headerHeight}px; height: ${headerHeight}px;
@@ -297,7 +299,7 @@ export const LogRowContext: React.FunctionComponent<LogRowContextProps> = ({
document.removeEventListener('keydown', handleEscKeyDown, false); document.removeEventListener('keydown', handleEscKeyDown, false);
}; };
}, [onOutsideClick]); }, [onOutsideClick]);
const { afterContext, beforeContext, title, top, actions } = useStyles2((theme) => const { afterContext, beforeContext, title, top, actions, width } = useStyles2((theme) =>
getLogRowContextStyles(theme, wrapLogMessage) getLogRowContextStyles(theme, wrapLogMessage)
); );
@@ -311,7 +313,7 @@ export const LogRowContext: React.FunctionComponent<LogRowContextProps> = ({
rows={context.after} rows={context.after}
error={errors && errors.after} error={errors && errors.after}
row={row} row={row}
className={cx(afterContext, top)} className={cx(afterContext, top, width)}
shouldScrollToBottom shouldScrollToBottom
canLoadMoreRows={hasMoreContextRows ? hasMoreContextRows.after : false} canLoadMoreRows={hasMoreContextRows ? hasMoreContextRows.after : false}
onLoadMoreContext={onLoadMoreContext} onLoadMoreContext={onLoadMoreContext}
@@ -327,12 +329,12 @@ export const LogRowContext: React.FunctionComponent<LogRowContextProps> = ({
row={row} row={row}
rows={context.before} rows={context.before}
error={errors && errors.before} error={errors && errors.before}
className={beforeContext} className={cx(beforeContext, width)}
groupPosition={LogGroupPosition.Bottom} groupPosition={LogGroupPosition.Bottom}
logsSortOrder={logsSortOrder} logsSortOrder={logsSortOrder}
/> />
)} )}
<div className={title}> <div className={cx(title, width)}>
<h5>Log context</h5> <h5>Log context</h5>
<div className={actions}> <div className={actions}>
<IconButton size="lg" name="times" onClick={onOutsideClick} /> <IconButton size="lg" name="times" onClick={onOutsideClick} />