[Fleet] Do not show upgrade available on latest version of package (#110066)
* fix: use package policy ID when checking hasUpgrade * fix: latest package version broken link * refactor: use set for collecting unique namespace values
This commit is contained in:
parent
ec95785214
commit
f430411ba2
|
@ -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(
|
||||
|
|
|
@ -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 (
|
||||
|
|
Loading…
Reference in a new issue