Skip to content

Commit

Permalink
[Fleet] Fix package version comparaison in the UI (#93498) (#93524)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
  • Loading branch information
kibanamachine and nchaulet authored Mar 4, 2021
1 parent 2faf3f4 commit fb1c983
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -57,7 +59,9 @@ export const SettingsPage: React.FC<Props> = 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
Expand Down

0 comments on commit fb1c983

Please sign in to comment.