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 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
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,78 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { EuiText, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
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';

export const TopProcessesTooltip = React.memo(() => {
return (
<Popover
aria-label={i18n.translate('xpack.infra.metrics.nodeDetails.processesHeader.tooltipLabel', {
defaultMessage: 'More info',
})}
iconSize="m"
icon="iInCircle"
data-test-subj="infraAssetDetailsProcessesPopoverButton"
>
<EuiText size="xs" 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>
</Popover>
);
});
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,7 @@ 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 { TopProcessesTooltip } from '../../components/top_processes_tooltip';

const options = Object.entries(STATE_NAMES).map(([value, view]: [string, string]) => ({
value,
Expand Down Expand Up @@ -119,23 +119,7 @@ export const Processes = () => {
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiIconTip
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.',
}
)}
/>
<TopProcessesTooltip />
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
Expand Down