[Fleet] Only display logs UI for agent >= 7.11 (#87926)

This commit is contained in:
Nicolas Chaulet 2021-01-13 07:30:21 -04:00 committed by GitHub
parent ff17581f45
commit 156fb3d33c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,6 +15,8 @@ import {
EuiFilterGroup,
EuiPanel,
EuiButtonEmpty,
EuiCallOut,
EuiLink,
} from '@elastic/eui';
import useMeasure from 'react-use/lib/useMeasure';
import { FormattedMessage } from '@kbn/i18n/react';
@ -184,7 +186,7 @@ export const AgentLogsUI: React.FunctionComponent<AgentLogsProps> = memo(({ agen
const [logsPanelRef, { height: logPanelHeight }] = useMeasure();
const agentVersion = agent.local_metadata?.elastic?.agent?.version;
const isLogLevelSelectionAvailable = useMemo(() => {
const isLogFeatureAvailable = useMemo(() => {
if (!agentVersion) {
return false;
}
@ -195,6 +197,31 @@ export const AgentLogsUI: React.FunctionComponent<AgentLogsProps> = memo(({ agen
return semverGte(agentVersionWithPrerelease, '7.11.0');
}, [agentVersion]);
if (!isLogFeatureAvailable) {
return (
<EuiCallOut
size="m"
color="warning"
title={
<FormattedMessage
id="xpack.fleet.agentLogs.oldAgentWarningTitle"
defaultMessage="The Logs view requires Elastic Agent 7.11 or higher. To upgrade an agent, go to the Actions menu, or {downloadLink} a newer version."
values={{
downloadLink: (
<EuiLink href="https://ela.st/download-elastic-agent" external target="_blank">
<FormattedMessage
id="xpack.fleet.agentLogs.downloadLink"
defaultMessage="download"
/>
</EuiLink>
),
}}
/>
}
/>
);
}
return (
<WrapperFlexGroup direction="column" gutterSize="m">
<EuiFlexItem grow={false}>
@ -271,11 +298,9 @@ export const AgentLogsUI: React.FunctionComponent<AgentLogsProps> = memo(({ agen
/>
</EuiPanel>
</EuiFlexItem>
{isLogLevelSelectionAvailable && (
<EuiFlexItem grow={false}>
<SelectLogLevel agent={agent} />
</EuiFlexItem>
)}
<EuiFlexItem grow={false}>
<SelectLogLevel agent={agent} />
</EuiFlexItem>
</WrapperFlexGroup>
);
});