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

[Infra UI] Update Processes tooltips #166251

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Expand Up @@ -6,105 +6,32 @@
*/

import React from 'react';
import { EuiText, EuiLink } from '@elastic/eui';
import { EuiText } from '@elastic/eui';
import { FormattedDate, FormattedMessage, FormattedTime } from '@kbn/i18n-react';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { useDateRangeProviderContext } from '../hooks/use_date_range';
import { Popover } from '../tabs/common/popover';

const DOCUMENTATION_LINK =
'https://www.elastic.co/guide/en/observability/current/view-infrastructure-metrics.html';
const SYSTEM_INTEGRATION_DOCS_LINK = 'https://docs.elastic.co/en/integrations/system';

const ProcessesExplanationTooltipContent = React.memo(() => {
const onClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
e.stopPropagation();
};

return (
<EuiText size="xs" onClick={onClick} style={{ width: 300 }}>
<p>
<FormattedMessage
id="xpack.infra.assetDetails.processes.tooltip.explanationLabel"
defaultMessage="The processes listed are based on an aggregation of the top CPU and the top memory consuming processes for the 1 minute preceding the end date of the selected time period. The number of top processes is configurable in the {systemIntegration}."
values={{
systemIntegration: (
<EuiLink
data-test-subj="infraAssetDetailsTooltipSystemIntegrationDocumentationLink"
href={SYSTEM_INTEGRATION_DOCS_LINK}
target="_blank"
>
<FormattedMessage
id="xpack.infra.assetDetails.processes.tooltip.systemIntegrationDocumentationLink"
defaultMessage="System Integration"
/>
</EuiLink>
),
}}
/>
</p>
<p>
<FormattedMessage
id="xpack.infra.assetDetails.processes.tooltip.documentationLabel"
defaultMessage="Please see the following {documentation} for more details on processes."
values={{
documentation: (
<EuiLink
data-test-subj="infraAssetDetailsTooltipDocumentationLink"
href={DOCUMENTATION_LINK}
target="_blank"
>
<FormattedMessage
id="xpack.infra.assetDetails.processes.tooltip.documentationLink"
defaultMessage="documentation"
/>
</EuiLink>
),
}}
/>
</p>
</EuiText>
);
});

export const ProcessesExplanationMessage = () => {
const { getDateRangeInTimestamp } = useDateRangeProviderContext();
const dateFromRange = new Date(getDateRangeInTimestamp().to);

return (
<EuiFlexGroup gutterSize="xs" alignItems="baseline">
<EuiFlexItem grow={false}>
<EuiText size="xs" color="subdued">
<FormattedMessage
id="xpack.infra.assetDetails.overview.processesSectionTitle"
defaultMessage="Showing process data collected for the 1 minute preceding {date} @ {time}"
values={{
date: (
<FormattedDate value={dateFromRange} month="short" day="numeric" year="numeric" />
),
time: (
<FormattedTime
value={dateFromRange}
hour12={false}
hour="2-digit"
minute="2-digit"
second="2-digit"
/>
),
}}
/>
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<Popover
iconSize="s"
iconColor="subdued"
icon="iInCircle"
data-test-subj="infraAssetDetailsProcessesPopoverButton"
>
<ProcessesExplanationTooltipContent />
</Popover>
</EuiFlexItem>
</EuiFlexGroup>
<EuiText size="xs" color="subdued">
<FormattedMessage
id="xpack.infra.assetDetails.overview.processesSectionTitle"
defaultMessage="Showing process data collected for the 1 minute preceding {date} @ {time}"
values={{
date: <FormattedDate value={dateFromRange} month="short" day="numeric" year="numeric" />,
time: (
<FormattedTime
value={dateFromRange}
hour12={false}
hour="2-digit"
minute="2-digit"
second="2-digit"
/>
),
}}
/>
</EuiText>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import { EuiText, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';

const DOCUMENTATION_LINK =
'https://www.elastic.co/guide/en/observability/current/view-infrastructure-metrics.html';
const SYSTEM_INTEGRATION_DOCS_LINK = 'https://docs.elastic.co/en/integrations/system';

export const TopProcessesTooltipContent = React.memo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to name the file and component inside using the same name, but I'm not sure how strictly we follow this convention usually

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After moving the popup here I renamed it to TopProcessesTooltip which matches the file name

const onClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
e.stopPropagation();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify please why this is needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was added initially as a bug fix because of the table sorting issue with the tooltip there #161565 but in this case, I don't think we need it - removed 👍

};

return (
<EuiText size="xs" onClick={onClick} style={{ width: 300 }}>
<p>
<FormattedMessage
id="xpack.infra.assetDetails.processes.tooltip.topProcesses"
defaultMessage="The processes listed are based on an aggregation of the top CPU and the top memory consuming processes. It does not show all processes."
/>
</p>
<p>
<FormattedMessage
id="xpack.infra.assetDetails.processes.tooltip.label"
defaultMessage="The number of top processes is configurable in the {systemIntegration}."
values={{
systemIntegration: (
<EuiLink
data-test-subj="infraAssetDetailsTooltipSystemIntegrationDocumentationLink"
href={SYSTEM_INTEGRATION_DOCS_LINK}
target="_blank"
>
<FormattedMessage
id="xpack.infra.assetDetails.processes.tooltip.systemIntegrationDocumentationLink"
defaultMessage="System Integration"
/>
</EuiLink>
),
}}
/>
</p>
<p>
<FormattedMessage
id="xpack.infra.assetDetails.processes.tooltip.documentationLabel"
defaultMessage="Please see the following {documentation} for more details on processes."
values={{
documentation: (
<EuiLink
data-test-subj="infraAssetDetailsTooltipDocumentationLink"
href={DOCUMENTATION_LINK}
target="_blank"
>
<FormattedMessage
id="xpack.infra.assetDetails.processes.tooltip.documentationLink"
defaultMessage="documentation"
/>
</EuiLink>
),
}}
/>
</p>
</EuiText>
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
EuiSearchBar,
EuiEmptyPrompt,
EuiButton,
EuiIconTip,
EuiTitle,
Query,
EuiFlexGroup,
Expand All @@ -34,6 +33,8 @@ import { useAssetDetailsRenderPropsContext } from '../../hooks/use_asset_details
import { useDateRangeProviderContext } from '../../hooks/use_date_range';
import { ProcessesExplanationMessage } from '../../components/processes_explanation';
import { useAssetDetailsUrlState } from '../../hooks/use_asset_details_url_state';
import { TopProcessesTooltipContent } from '../../components/top_processes_tooltip';
import { Popover } from '../common/popover';

const options = Object.entries(STATE_NAMES).map(([value, view]: [string, string]) => ({
value,
Expand Down Expand Up @@ -119,23 +120,19 @@ export const Processes = () => {
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiIconTip
<Popover
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it makes sense to put the whole popover into the dedicated component instead of just its content. it would declutter a bit the parent component, and strictly speaking, there is no need to have the content separately as we don't use it anywhere else. wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes in this case it makes sense to keep the Popover inside the other component as the content is not used anywhere else 👍 Changed

aria-label={i18n.translate(
'xpack.infra.metrics.nodeDetails.processesHeader.tooltipLabel',
{
defaultMessage: 'More info',
}
)}
size="m"
type="iInCircle"
content={i18n.translate(
'xpack.infra.metrics.nodeDetails.processesHeader.tooltipBody',
{
defaultMessage:
'The table below aggregates the top CPU and top memory consuming processes. It does not display all processes.',
}
)}
/>
iconSize="m"
icon="iInCircle"
data-test-subj="infraAssetDetailsProcessesPopoverButton"
>
<TopProcessesTooltipContent />
</Popover>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
Expand Down