Skip to content

Commit

Permalink
[Fleet] Only display logs UI for agent >= 7.11 (#87926) (#88159)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Jan 13, 2021
1 parent e6017bd commit b9c97fb
Showing 1 changed file with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand All @@ -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}>
Expand Down Expand Up @@ -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>
);
});

0 comments on commit b9c97fb

Please sign in to comment.