From fb1c98358c0a4e50e42ddee8671aced6f8b0c4ec Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 3 Mar 2021 19:20:22 -0500 Subject: [PATCH] [Fleet] Fix package version comparaison in the UI (#93498) (#93524) Co-authored-by: Nicolas Chaulet --- .../fleet/sections/epm/screens/detail/index.tsx | 3 ++- .../fleet/sections/epm/screens/detail/settings/settings.tsx | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx index 2d442744bb138..8b278204ca2c9 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx @@ -21,6 +21,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +import semverLt from 'semver/functions/lt'; import { useUIExtension } from '../../../../hooks/use_ui_extension'; import { PAGE_ROUTING_PATHS, PLUGIN_ID } from '../../../../constants'; @@ -80,7 +81,7 @@ export function Detail() { packageInfo && 'savedObject' in packageInfo && packageInfo.savedObject && - packageInfo.savedObject.attributes.version < packageInfo.latestVersion; + semverLt(packageInfo.savedObject.attributes.version, packageInfo.latestVersion); // Fetch package info const { data: packageInfoData, error: packageInfoError, isLoading } = useGetPackageInfoByKey( diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx index e69d148f89e0a..94c03f76cddaf 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx @@ -8,6 +8,8 @@ import React, { memo } from 'react'; import styled from 'styled-components'; import { FormattedMessage } from '@kbn/i18n/react'; +import semverLt from 'semver/functions/lt'; + import { EuiTitle, EuiFlexGroup, EuiFlexItem, EuiText, EuiSpacer } from '@elastic/eui'; import { InstallStatus, PackageInfo } from '../../../../../types'; @@ -57,7 +59,9 @@ export const SettingsPage: React.FC = memo(({ packageInfo }: Props) => { }); const { status: installationStatus, version: installedVersion } = getPackageInstallStatus(name); const packageHasUsages = !!packagePoliciesData?.total; - const updateAvailable = installedVersion && installedVersion < latestVersion ? true : false; + const updateAvailable = + installedVersion && semverLt(installedVersion, latestVersion) ? true : false; + const isViewingOldPackage = version < latestVersion; // hide install/remove options if the user has version of the package is installed // and this package is out of date or if they do have a version installed but it's not this one