[Fleet] Do not show upgrade available on latest version of package (#110066) (#110102)

* fix: use package policy ID when checking hasUpgrade

* fix: latest package version broken link

* refactor: use set for collecting unique namespace values

Co-authored-by: Mark Hopkin <mark.hopkin@elastic.co>
This commit is contained in:
Kibana Machine 2021-08-25 15:14:17 -04:00 committed by GitHub
parent 807f647b87
commit 0360fc13d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View file

@ -63,12 +63,11 @@ export const PackagePoliciesTable: React.FunctionComponent<Props> = ({
// used in the InMemoryTable (flattens some values for search) as well as
// the list of options that will be used in the filters dropdowns
const [packagePolicies, namespaces] = useMemo((): [InMemoryPackagePolicy[], FilterOption[]] => {
const namespacesValues: string[] = [];
const inputTypesValues: string[] = [];
const namespacesValues: Set<string> = new Set();
const mappedPackagePolicies = originalPackagePolicies.map<InMemoryPackagePolicy>(
(packagePolicy) => {
if (packagePolicy.namespace && !namespacesValues.includes(packagePolicy.namespace)) {
namespacesValues.push(packagePolicy.namespace);
if (packagePolicy.namespace) {
namespacesValues.add(packagePolicy.namespace);
}
const updatableIntegrationRecord = updatableIntegrations.get(
@ -78,7 +77,7 @@ export const PackagePoliciesTable: React.FunctionComponent<Props> = ({
const hasUpgrade =
!!updatableIntegrationRecord &&
updatableIntegrationRecord.policiesToUpgrade.some(
({ id }) => id === packagePolicy.policy_id
({ pkgPolicyId }) => pkgPolicyId === packagePolicy.id
);
return {
@ -91,10 +90,11 @@ export const PackagePoliciesTable: React.FunctionComponent<Props> = ({
}
);
namespacesValues.sort(stringSortAscending);
inputTypesValues.sort(stringSortAscending);
const namespaceFilterOptions = [...namespacesValues]
.sort(stringSortAscending)
.map(toFilterOption);
return [mappedPackagePolicies, namespacesValues.map(toFilterOption)];
return [mappedPackagePolicies, namespaceFilterOptions];
}, [originalPackagePolicies, updatableIntegrations]);
const columns = useMemo(

View file

@ -48,8 +48,8 @@ const UpdatesAvailableMsg = () => (
);
const LatestVersionLink = ({ name, version }: { name: string; version: string }) => {
const { getPath } = useLink();
const settingsPath = getPath('integration_details_settings', {
const { getHref } = useLink();
const settingsPath = getHref('integration_details_settings', {
pkgkey: `${name}-${version}`,
});
return (