diff --git a/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.jsx b/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.jsx
index e2c1acfd69..6c93dabf18 100644
--- a/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.jsx
+++ b/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.jsx
@@ -2,10 +2,11 @@ import React from 'react';
import classNames from 'classnames';
import Table from '@common/Table';
+const upgradablePackagesDefault = [];
+
function UpgradablePackagesList({
hostname,
- upgradablePackages,
- relevantPatches,
+ upgradablePackages = upgradablePackagesDefault,
}) {
const config = {
pagination: true,
@@ -14,7 +15,7 @@ function UpgradablePackagesList({
{
title: 'Installed Packages',
key: 'installedPackage',
- render: (content, _) =>
{content}
,
+ render: (content, _) => {content}
,
},
{
title: 'Latest Package',
@@ -23,33 +24,26 @@ function UpgradablePackagesList({
},
{
title: 'Related Patches',
- key: 'advisory_name',
- render: (content, _) => {content}
,
+ key: 'patches',
+ render: (content, { to_package_id }) => (
+
+ {content.map(({ advisory }) => (
+
{advisory}
+ ))}
+
+ ),
},
],
};
- const relevantPatchesMap = relevantPatches.reduce(
- (m, p) => m.set(p.id, p),
- new Map()
- );
-
const data = upgradablePackages.map((up) => {
- const {
- name,
- from_version,
- from_release,
- to_version,
- to_release,
- arch,
- to_package_id,
- } = up;
+ const { name, from_version, from_release, to_version, to_release, arch } =
+ up;
return {
...up,
installedPackage: `${name}-${from_version}-${from_release}.${arch}`,
latestPackage: `${name}-${to_version}-${to_release}.${arch}`,
- ...relevantPatchesMap.get(to_package_id),
};
});
diff --git a/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.stories.jsx b/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.stories.jsx
index 52f7112344..a31d18a6dd 100644
--- a/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.stories.jsx
+++ b/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.stories.jsx
@@ -4,15 +4,16 @@ export default {
title: 'Components/UpgradablePackagesList',
component: UpgradablePackagesList,
argTypes: {
- upgradablePackages: {
- control: {
- type: 'array',
- },
+ hostname: {
+ type: 'string',
+ control: { type: 'text' },
+ description: 'The name of the host',
},
- relevantPatches: {
+ upgradablePackages: {
control: {
type: 'array',
},
+ description: 'List of upgradable packages',
},
},
};
@@ -33,6 +34,32 @@ export const Default = {
to_version: '3.1.2',
from_arch: 'x86_64',
to_arch: 'x86_64',
+ patches: [
+ {
+ issue_date: '2023-05-30',
+ last_modified_date: '2023-05-30',
+ advisory: 'SUSE-15-SP4-2023-2317',
+ type: 'bugfix',
+ synopsis: 'Recommended update for util-linux',
+ update_date: '2023-05-30',
+ },
+ {
+ issue_date: '2024-03-13',
+ last_modified_date: '2024-03-13',
+ advisory: 'SUSE-15-SP4-2024-877',
+ type: 'security_advisory',
+ synopsis: 'important: Security update for sudo',
+ update_date: '2024-03-13',
+ },
+ {
+ issue_date: '2024-03-13',
+ last_modified_date: '2024-03-13',
+ advisory: 'SUSE-15-SP4-2024-871',
+ type: 'security_advisory',
+ synopsis: 'important: Security update for vim',
+ update_date: '2024-03-13',
+ },
+ ],
},
{
from_epoch: ' ',
@@ -46,6 +73,16 @@ export const Default = {
to_version: '8.4p1',
from_arch: 'x86_64',
to_arch: 'x86_64',
+ patches: [
+ {
+ issue_date: '2024-03-11',
+ last_modified_date: '2024-03-11',
+ advisory: 'SUSE-15-SP4-2024-833',
+ type: 'security_advisory',
+ synopsis: 'moderate: Security update for openssl-1_1',
+ update_date: '2024-03-11',
+ },
+ ],
},
{
from_epoch: ' ',
@@ -59,6 +96,7 @@ export const Default = {
to_version: '5.15.2+kde294',
from_arch: 'x86_64',
to_arch: 'x86_64',
+ patches: [],
},
{
from_epoch: ' ',
@@ -72,6 +110,16 @@ export const Default = {
to_version: '3.6.15',
from_arch: 'x86_64',
to_arch: 'x86_64',
+ patches: [
+ {
+ issue_date: '2023-03-22',
+ last_modified_date: '2023-03-22',
+ advisory: 'SUSE-15-SP4-2023-868',
+ type: 'security_advisory',
+ synopsis: 'important: Security update for python3',
+ update_date: '2023-03-22',
+ },
+ ],
},
{
from_epoch: ' ',
@@ -85,71 +133,24 @@ export const Default = {
to_version: '5.15.2+kde294',
from_arch: 'x86_64',
to_arch: 'x86_64',
- },
- ],
- relevantPatches: [
- {
- date: '2023-03-22',
- advisory_name: 'SUSE-15-SP4-2023-868',
- advisory_type: 'security_advisory',
- advisory_status: 'stable',
- id: 2136,
- advisory_synopsis: 'important: Security update for python3',
- update_date: '2023-03-22',
- },
- {
- date: '2024-03-11',
- advisory_name: 'SUSE-15-SP4-2024-833',
- advisory_type: 'security_advisory',
- advisory_status: 'stable',
- id: 4244,
- advisory_synopsis: 'moderate: Security update for openssl-1_1',
- update_date: '2024-03-11',
- },
- {
- date: '2023-05-30',
- advisory_name: 'SUSE-15-SP4-2023-2317',
- advisory_type: 'bugfix',
- advisory_status: 'stable',
- id: 39543,
- advisory_synopsis: 'Recommended update for util-linux',
- update_date: '2023-05-30',
- },
- {
- date: '2024-03-13',
- advisory_name: 'SUSE-15-SP4-2024-877',
- advisory_type: 'security_advisory',
- advisory_status: 'stable',
- id: 4263,
- advisory_synopsis: 'important: Security update for sudo',
- update_date: '2024-03-13',
- },
- {
- date: '2024-03-13',
- advisory_name: 'SUSE-15-SP4-2024-871',
- advisory_type: 'security_advisory',
- advisory_status: 'stable',
- id: 4261,
- advisory_synopsis: 'important: Security update for vim',
- update_date: '2024-03-13',
- },
- {
- date: '2024-03-13',
- advisory_name: 'SUSE-15-SP4-2024-870',
- advisory_type: 'security_advisory',
- advisory_status: 'stable',
- id: 4260,
- advisory_synopsis: 'moderate: Security update for glibc',
- update_date: '2024-03-13',
- },
- {
- date: '2024-02-28',
- advisory_name: 'SUSE-15-SP4-2024-641',
- advisory_type: 'bugfix',
- advisory_status: 'stable',
- id: 4189,
- advisory_synopsis: 'Recommended update for gcc7',
- update_date: '2024-02-28',
+ patches: [
+ {
+ issue_date: '2024-03-13',
+ last_modified_date: '2024-03-13',
+ advisory: 'SUSE-15-SP4-2024-870',
+ type: 'security_advisory',
+ synopsis: 'moderate: Security update for glibc',
+ update_date: '2024-03-13',
+ },
+ {
+ issue_date: '2024-02-28',
+ last_modified_date: '2024-02-28',
+ advisory: 'SUSE-15-SP4-2024-641',
+ type: 'bugfix',
+ synopsis: 'Recommended update for gcc7',
+ update_date: '2024-02-28',
+ },
+ ],
},
],
},
diff --git a/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.test.jsx b/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.test.jsx
index 19b64b0f73..6d20b71a25 100644
--- a/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.test.jsx
+++ b/assets/js/common/UpgradablePackagesList/UpgradablePackagesList.test.jsx
@@ -6,27 +6,37 @@ import UpgradablePackagesList from './UpgradablePackagesList';
describe('UpgradablePackagesList component', () => {
it('should render the upgradable packages list', () => {
const hostname = 'Example Host';
+ const patches = [
+ {
+ issue_date: '2024-03-13',
+ last_modified_date: '2024-03-13',
+ advisory: 'SUSE-15-SP4-2024-870',
+ type: 'security_advisory',
+ synopsis: 'moderate: Security update for glibc',
+ update_date: '2024-03-13',
+ },
+ {
+ issue_date: '2024-02-28',
+ last_modified_date: '2024-02-28',
+ advisory: 'SUSE-15-SP4-2024-641',
+ type: 'bugfix',
+ synopsis: 'Recommended update for gcc7',
+ update_date: '2024-02-28',
+ },
+ ];
const upgradablePackage = {
from_epoch: ' ',
- to_release: '150300.3.30.1',
- name: 'openssh-server',
- from_release: '150300.3.15.4',
+ to_release: '150400.6.10.1',
+ name: 'libQt5Gui5',
+ from_release: '150400.6.3.1',
to_epoch: ' ',
arch: 'x86_64',
- to_package_id: 39543,
- from_version: '8.4p1',
- to_version: '8.4p1',
+ to_package_id: 38391,
+ from_version: '5.15.2+kde294',
+ to_version: '5.15.2+kde294',
from_arch: 'x86_64',
to_arch: 'x86_64',
- };
- const relevantPatch = {
- date: '2023-05-30',
- advisory_name: 'SUSE-15-SP4-2023-2317',
- advisory_type: 'bugfix',
- advisory_status: 'stable',
- id: 39543,
- advisory_synopsis: 'Recommended update for util-linux',
- update_date: '2023-05-30',
+ patches,
};
const expectedInstalledPackage = `${upgradablePackage.name}-${upgradablePackage.from_version}-${upgradablePackage.from_release}.${upgradablePackage.arch}`;
@@ -36,13 +46,14 @@ describe('UpgradablePackagesList component', () => {
);
expect(screen.getByText(hostname)).toBeVisible();
expect(screen.getByText(expectedInstalledPackage)).toBeVisible();
expect(screen.getByText(expectedLatestPackage)).toBeVisible();
- expect(screen.getByText(relevantPatch.advisory_name)).toBeVisible();
+ patches.forEach(({ advisory }) => {
+ expect(screen.getByText(advisory)).toBeVisible();
+ });
});
});