Skip to content

Commit a61e1dd

Browse files
authored
[Fleet] Fix package version comparaison in the UI (#93498)
1 parent 60adc73 commit a61e1dd

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from '@elastic/eui';
2222
import { i18n } from '@kbn/i18n';
2323
import { FormattedMessage } from '@kbn/i18n/react';
24+
import semverLt from 'semver/functions/lt';
2425

2526
import { useUIExtension } from '../../../../hooks/use_ui_extension';
2627
import { PAGE_ROUTING_PATHS, PLUGIN_ID } from '../../../../constants';
@@ -80,7 +81,7 @@ export function Detail() {
8081
packageInfo &&
8182
'savedObject' in packageInfo &&
8283
packageInfo.savedObject &&
83-
packageInfo.savedObject.attributes.version < packageInfo.latestVersion;
84+
semverLt(packageInfo.savedObject.attributes.version, packageInfo.latestVersion);
8485

8586
// Fetch package info
8687
const { data: packageInfoData, error: packageInfoError, isLoading } = useGetPackageInfoByKey(

x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import React, { memo } from 'react';
99
import styled from 'styled-components';
1010
import { FormattedMessage } from '@kbn/i18n/react';
11+
import semverLt from 'semver/functions/lt';
12+
1113
import { EuiTitle, EuiFlexGroup, EuiFlexItem, EuiText, EuiSpacer } from '@elastic/eui';
1214

1315
import { InstallStatus, PackageInfo } from '../../../../../types';
@@ -57,7 +59,9 @@ export const SettingsPage: React.FC<Props> = memo(({ packageInfo }: Props) => {
5759
});
5860
const { status: installationStatus, version: installedVersion } = getPackageInstallStatus(name);
5961
const packageHasUsages = !!packagePoliciesData?.total;
60-
const updateAvailable = installedVersion && installedVersion < latestVersion ? true : false;
62+
const updateAvailable =
63+
installedVersion && semverLt(installedVersion, latestVersion) ? true : false;
64+
6165
const isViewingOldPackage = version < latestVersion;
6266
// hide install/remove options if the user has version of the package is installed
6367
// and this package is out of date or if they do have a version installed but it's not this one

0 commit comments

Comments
 (0)