Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Logs UI] Log stream row rendering (#60773) #61953

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React, { useCallback } from 'react';
import { EuiButtonIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';

import { LogEntryColumnContent } from './log_entry_column';
import {
euiStyled,
ActionMenu,
Section,
SectionTitle,
SectionLinks,
SectionLink,
} from '../../../../../observability/public';

interface LogEntryActionsColumnProps {
isHovered: boolean;
isMenuOpen: boolean;
onOpenMenu: () => void;
onCloseMenu: () => void;
onViewDetails: () => void;
}

const MENU_LABEL = i18n.translate('xpack.infra.logEntryItemView.logEntryActionsMenuToolTip', {
defaultMessage: 'View Details',
});

const LOG_DETAILS_LABEL = i18n.translate('xpack.infra.logs.logEntryActionsDetailsButton', {
defaultMessage: 'View actions for line',
});

export const LogEntryActionsColumn: React.FC<LogEntryActionsColumnProps> = ({
isHovered,
isMenuOpen,
onOpenMenu,
onCloseMenu,
onViewDetails,
}) => {
const handleClickViewDetails = useCallback(() => {
onCloseMenu();
onViewDetails();
}, [onCloseMenu, onViewDetails]);

const button = (
<ButtonWrapper>
<EuiButtonIcon
aria-label={MENU_LABEL}
color="ghost"
iconType="boxesHorizontal"
onClick={onOpenMenu}
/>
</ButtonWrapper>
);

return (
<ActionsColumnContent>
{isHovered || isMenuOpen ? (
<AbsoluteWrapper>
<ActionMenu closePopover={onCloseMenu} isOpen={isMenuOpen} button={button}>
<Section>
<SectionTitle>
<FormattedMessage
id="xpack.infra.logs.logEntryActionsMenuTitle"
defaultMessage="Log line details"
/>
</SectionTitle>
<SectionLinks>
<SectionLink label={LOG_DETAILS_LABEL} onClick={handleClickViewDetails} />
</SectionLinks>
</Section>
</ActionMenu>
</AbsoluteWrapper>
) : null}
</ActionsColumnContent>
);
};

const ActionsColumnContent = euiStyled(LogEntryColumnContent)`
overflow: hidden;
user-select: none;
`;

const ButtonWrapper = euiStyled.div`
background: ${props => props.theme.eui.euiColorPrimary};
border-radius: 50%;
`;

// this prevents the button from influencing the line height
const AbsoluteWrapper = euiStyled.div`
overflow: hidden;
position: absolute;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ describe('LogEntryFieldColumn', () => {
columnValue={column}
highlights={[]}
isActiveHighlight={false}
isHighlighted={false}
isHovered={false}
wrapMode="pre-wrapped"
/>,
{ wrappingComponent: EuiThemeProvider } as any // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/36075
Expand Down Expand Up @@ -58,8 +56,6 @@ describe('LogEntryFieldColumn', () => {
columnValue={column}
highlights={[]}
isActiveHighlight={false}
isHighlighted={false}
isHovered={false}
wrapMode="pre-wrapped"
/>,
{ wrappingComponent: EuiThemeProvider } as any // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/36075
Expand All @@ -81,8 +77,6 @@ describe('LogEntryFieldColumn', () => {
columnValue={column}
highlights={[]}
isActiveHighlight={false}
isHighlighted={false}
isHovered={false}
wrapMode="pre-wrapped"
/>,
{ wrappingComponent: EuiThemeProvider } as any // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/36075
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { ActiveHighlightMarker, highlightFieldValue, HighlightMarker } from './h
import { LogEntryColumnContent } from './log_entry_column';
import { LogColumn } from '../../../../common/http_api';
import {
hoveredContentStyle,
longWrappedContentStyle,
preWrappedContentStyle,
unwrappedContentStyle,
Expand All @@ -24,17 +23,13 @@ interface LogEntryFieldColumnProps {
columnValue: LogColumn;
highlights: LogColumn[];
isActiveHighlight: boolean;
isHighlighted: boolean;
isHovered: boolean;
wrapMode: WrapMode;
}

export const LogEntryFieldColumn: React.FunctionComponent<LogEntryFieldColumnProps> = ({
columnValue,
highlights: [firstHighlight], // we only support one highlight for now
isActiveHighlight,
isHighlighted,
isHovered,
wrapMode,
}) => {
const value = useMemo(() => {
Expand Down Expand Up @@ -63,11 +58,7 @@ export const LogEntryFieldColumn: React.FunctionComponent<LogEntryFieldColumnPro
)
);

return (
<FieldColumnContent isHighlighted={isHighlighted} isHovered={isHovered} wrapMode={wrapMode}>
{formattedValue}
</FieldColumnContent>
);
return <FieldColumnContent wrapMode={wrapMode}>{formattedValue}</FieldColumnContent>;
};

const CommaSeparatedLi = euiStyled.li`
Expand All @@ -81,15 +72,12 @@ const CommaSeparatedLi = euiStyled.li`
`;

interface LogEntryColumnContentProps {
isHighlighted: boolean;
isHovered: boolean;
wrapMode: WrapMode;
}

const FieldColumnContent = euiStyled(LogEntryColumnContent)<LogEntryColumnContentProps>`
text-overflow: ellipsis;

${props => (props.isHovered || props.isHighlighted ? hoveredContentStyle : '')};
${props =>
props.wrapMode === 'long'
? longWrappedContentStyle
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
import { ActiveHighlightMarker, highlightFieldValue, HighlightMarker } from './highlighting';
import { LogEntryColumnContent } from './log_entry_column';
import {
hoveredContentStyle,
longWrappedContentStyle,
preWrappedContentStyle,
unwrappedContentStyle,
Expand All @@ -30,13 +29,11 @@ interface LogEntryMessageColumnProps {
columnValue: LogColumn;
highlights: LogColumn[];
isActiveHighlight: boolean;
isHighlighted: boolean;
isHovered: boolean;
wrapMode: WrapMode;
}

export const LogEntryMessageColumn = memo<LogEntryMessageColumnProps>(
({ columnValue, highlights, isActiveHighlight, isHighlighted, isHovered, wrapMode }) => {
({ columnValue, highlights, isActiveHighlight, wrapMode }) => {
const message = useMemo(
() =>
isMessageColumn(columnValue)
Expand All @@ -45,24 +42,16 @@ export const LogEntryMessageColumn = memo<LogEntryMessageColumnProps>(
[columnValue, highlights, isActiveHighlight]
);

return (
<MessageColumnContent isHighlighted={isHighlighted} isHovered={isHovered} wrapMode={wrapMode}>
{message}
</MessageColumnContent>
);
return <MessageColumnContent wrapMode={wrapMode}>{message}</MessageColumnContent>;
}
);

interface MessageColumnContentProps {
isHovered: boolean;
isHighlighted: boolean;
wrapMode: WrapMode;
}

const MessageColumnContent = euiStyled(LogEntryColumnContent)<MessageColumnContentProps>`
text-overflow: ellipsis;

${props => (props.isHovered || props.isHighlighted ? hoveredContentStyle : '')};
${props =>
props.wrapMode === 'long'
? longWrappedContentStyle
Expand Down
Loading