From 700ccdd38811087ace7846533b48938a036d241d Mon Sep 17 00:00:00 2001 From: Lior Keren Date: Thu, 11 Jan 2024 10:39:25 +0200 Subject: [PATCH] feat(RHINENG-4796): HostDetail add PublicIP & FQDN Link to issue: https://issues.redhat.com/browse/RHINENG-4796 --- src/api/api.js | 6 +- .../GeneralInformation.test.js.snap | 300 +++++++++ .../InfrastructureCard/InfrastructureCard.js | 49 +- .../InfrastructureCard.test.js.snap | 608 ++++++++++++++++++ .../GeneralInfo/selectors/selectors.js | 10 +- 5 files changed, 964 insertions(+), 9 deletions(-) diff --git a/src/api/api.js b/src/api/api.js index 7aec7464c..9a761596e 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -164,7 +164,9 @@ export const calculateSystemProfile = ({ systemProfile['host_type'] = hostTypeFilter; } - return generateFilter({ system_profile: systemProfile }); + return generateFilter({ + system_profile: systemProfile, + }); }; export const filtersReducer = (acc, filter = {}) => ({ @@ -249,7 +251,7 @@ export async function getEntities( ), }; } catch (e) { - console.error(e); // eslint-disable-line + console.error(e); // eslint-disable-line } } diff --git a/src/components/GeneralInfo/GeneralInformation/__snapshots__/GeneralInformation.test.js.snap b/src/components/GeneralInfo/GeneralInformation/__snapshots__/GeneralInformation.test.js.snap index adf971aac..cd73472f9 100644 --- a/src/components/GeneralInfo/GeneralInformation/__snapshots__/GeneralInformation.test.js.snap +++ b/src/components/GeneralInfo/GeneralInformation/__snapshots__/GeneralInformation.test.js.snap @@ -368,6 +368,18 @@ exports[`GeneralInformation custom components should not render BiosCardWrapper > test-vendor +
+ Public IP +
+
+ Not available +
+
+ FQDN +
+
+ Not available +
test-vendor +
+ Public IP +
+
+ Not available +
+
+ FQDN +
+
+ Not available +
test-vendor +
+ Public IP +
+
+ Not available +
+
+ FQDN +
+
+ Not available +
test-vendor +
+ Public IP +
+
+ Not available +
+
+ FQDN +
+
+ Not available +
test-vendor +
+ Public IP +
+
+ Not available +
+
+ FQDN +
+
+ Not available +
test-vendor +
+ Public IP +
+
+ Not available +
+
+ FQDN +
+
+ Not available +
test-vendor +
+ Public IP +
+
+ Not available +
+
+ FQDN +
+
+ Not available +
test-vendor +
+ Public IP +
+
+ Not available +
+
+ FQDN +
+
+ Not available +
test-vendor +
+ Public IP +
+
+ Not available +
+
+ FQDN +
+
+ Not available +
test-vendor +
+ Public IP +
+
+ Not available +
+
+ FQDN +
+
+ Not available +
+
+ Public IP +
+
+
+ +
+
+
+ FQDN +
+
+
+ +
+
test-vendor +
+ Public IP +
+
+ Not available +
+
+ FQDN +
+
+ Not available +
( @@ -23,6 +25,18 @@ const InfrastructureCardCore = ({ items={[ ...(hasType ? [{ title: 'Type', value: infrastructure.type }] : []), ...(hasVendor ? [{ title: 'Vendor', value: infrastructure.vendor }] : []), + ...(hasPublicIp + ? [ + { + title: 'Public IP', + value: + Array.isArray(infrastructure.public_ipv4_addresses) && + infrastructure.public_ipv4_addresses.length > 0 + ? infrastructure.public_ipv4_addresses[0] + : 'Not available', + }, + ] + : []), ...(hasIPv4 ? [ { @@ -57,6 +71,18 @@ const InfrastructureCardCore = ({ }, ] : []), + ...(hasFqdn + ? [ + { + title: 'FQDN', + value: + Array.isArray(infrastructure.fqdn) && + infrastructure.fqdn.length > 0 + ? infrastructure.fqdn[0] + : 'Not available', + }, + ] + : []), ...(hasInterfaces ? [ { @@ -88,14 +114,18 @@ InfrastructureCardCore.propTypes = { infrastructure: PropTypes.shape({ type: PropTypes.string, vendor: PropTypes.string, + public_ipv4_addresses: PropTypes.arrayOf(PropTypes.string), ipv4: PropTypes.array, ipv6: PropTypes.array, + fqdn: PropTypes.arrayOf(PropTypes.string), nics: PropTypes.array, }), hasType: PropTypes.bool, hasVendor: PropTypes.bool, + hasPublicIp: PropTypes.bool, hasIPv4: PropTypes.bool, hasIPv6: PropTypes.bool, + hasFqdn: PropTypes.bool, hasInterfaces: PropTypes.bool, extra: PropTypes.arrayOf(extraShape), }; @@ -104,18 +134,25 @@ InfrastructureCardCore.defaultProps = { handleClick: () => undefined, hasType: true, hasVendor: true, + hasPublicIp: true, hasIPv4: true, hasIPv6: true, + hasFqdn: true, hasInterfaces: true, extra: [], }; -export const InfrastructureCard = connect( - ({ entityDetails: { entity }, systemProfileStore: { systemProfile } }) => ({ - detailLoaded: systemProfile && systemProfile.loaded, - infrastructure: infrastructureSelector(systemProfile, entity), - }) -)(InfrastructureCardCore); +const mapStateToProps = ({ + entityDetails: { entity }, + systemProfileStore: { systemProfile }, +}) => ({ + detailLoaded: systemProfile && systemProfile.loaded, + infrastructure: infrastructureSelector(systemProfile, entity), +}); + +export const InfrastructureCard = connect(mapStateToProps)( + InfrastructureCardCore +); InfrastructureCard.propTypes = InfrastructureCardCore.propTypes; InfrastructureCard.defaultProps = InfrastructureCardCore.defaultProps; diff --git a/src/components/GeneralInfo/InfrastructureCard/__snapshots__/InfrastructureCard.test.js.snap b/src/components/GeneralInfo/InfrastructureCard/__snapshots__/InfrastructureCard.test.js.snap index a06db08fe..0af4e3f7b 100644 --- a/src/components/GeneralInfo/InfrastructureCard/__snapshots__/InfrastructureCard.test.js.snap +++ b/src/components/GeneralInfo/InfrastructureCard/__snapshots__/InfrastructureCard.test.js.snap @@ -38,9 +38,11 @@ exports[`InfrastructureCard should not render hasIPv4 1`] = ` detailLoaded={false} extra={Array []} handleClick={[Function]} + hasFqdn={true} hasIPv4={false} hasIPv6={true} hasInterfaces={true} + hasPublicIp={true} hasType={true} hasVendor={true} store={ @@ -59,13 +61,16 @@ exports[`InfrastructureCard should not render hasIPv4 1`] = ` dispatch={[Function]} extra={Array []} handleClick={[Function]} + hasFqdn={true} hasIPv4={false} hasIPv6={true} hasInterfaces={true} + hasPublicIp={true} hasType={true} hasVendor={true} infrastructure={ Object { + "fqdn": undefined, "ipv4": Array [ "1", ], @@ -75,6 +80,7 @@ exports[`InfrastructureCard should not render hasIPv4 1`] = ` "nics": Array [ "test", ], + "public_ipv4_addresses": undefined, "type": "test-type", "vendor": "test-vendor", } @@ -102,6 +108,10 @@ exports[`InfrastructureCard should not render hasIPv4 1`] = ` "title": "Vendor", "value": "test-vendor", }, + Object { + "title": "Public IP", + "value": "Not available", + }, Object { "onClick": [Function], "plural": "addresses", @@ -110,6 +120,10 @@ exports[`InfrastructureCard should not render hasIPv4 1`] = ` "title": "IPv6 addresses", "value": 1, }, + Object { + "title": "FQDN", + "value": "Not available", + }, Object { "onClick": [Function], "singular": "NIC", @@ -226,6 +240,28 @@ exports[`InfrastructureCard should not render hasIPv4 1`] = ` test-vendor + +
+ Public IP +
+ + +
+ Not available +
+
+ +
+ FQDN +
+
+ +
+ Not available +
+
+ +
+ Public IP +
+
+ +
+ Not available +
+
+ +
+ FQDN +
+
+ +
+ Not available +
+
+ +
+ Public IP +
+
+ +
+ Not available +
+
+ +
+ FQDN +
+
+ +
+ Not available +
+
@@ -1012,9 +1186,11 @@ exports[`InfrastructureCard should not render hasType 1`] = ` detailLoaded={false} extra={Array []} handleClick={[Function]} + hasFqdn={true} hasIPv4={true} hasIPv6={true} hasInterfaces={true} + hasPublicIp={true} hasType={false} hasVendor={true} store={ @@ -1033,13 +1209,16 @@ exports[`InfrastructureCard should not render hasType 1`] = ` dispatch={[Function]} extra={Array []} handleClick={[Function]} + hasFqdn={true} hasIPv4={true} hasIPv6={true} hasInterfaces={true} + hasPublicIp={true} hasType={false} hasVendor={true} infrastructure={ Object { + "fqdn": undefined, "ipv4": Array [ "1", ], @@ -1049,6 +1228,7 @@ exports[`InfrastructureCard should not render hasType 1`] = ` "nics": Array [ "test", ], + "public_ipv4_addresses": undefined, "type": "test-type", "vendor": "test-vendor", } @@ -1072,6 +1252,10 @@ exports[`InfrastructureCard should not render hasType 1`] = ` "title": "Vendor", "value": "test-vendor", }, + Object { + "title": "Public IP", + "value": "Not available", + }, Object { "onClick": [Function], "plural": "addresses", @@ -1088,6 +1272,10 @@ exports[`InfrastructureCard should not render hasType 1`] = ` "title": "IPv6 addresses", "value": 1, }, + Object { + "title": "FQDN", + "value": "Not available", + }, Object { "onClick": [Function], "singular": "NIC", @@ -1182,6 +1370,28 @@ exports[`InfrastructureCard should not render hasType 1`] = ` test-vendor + +
+ Public IP +
+
+ +
+ Not available +
+
+ +
+ FQDN +
+
+ +
+ Not available +
+
+ +
+ Public IP +
+
+ +
+ Not available +
+
+ +
+ FQDN +
+
+ +
+ Not available +
+
+ +
+ Public IP +
+
+ +
+ + +
+ +
+
+
+
+
+ +
+ FQDN +
+
+ +
+ + +
+ +
+
+
+
+
+ +
+ Public IP +
+
+ +
+ Not available +
+
+ +
+ FQDN +
+
+ +
+ Not available +
+
+ +
+ Public IP +
+
+ +
+ Not available +
+
+ +
+ FQDN +
+
+ +
+ Not available +
+
+ +
+ Public IP +
+
+ +
+ Not available +
+
+ +
+ FQDN +
+
+ +
+ Not available +
+
+ +
+ Public IP +
+
+ +
+ Not available +
+
+ +
+ FQDN +
+
+ +
+ Not available +
+
({ type: @@ -84,9 +90,11 @@ export const infrastructureSelector = ( (facts?.rhsm?.IS_VIRTUAL ? 'virtual' : 'physical')) || undefined, vendor: infrastructure_vendor, + public_ipv4_addresses: public_ipv4_addresses, ipv4: network.ipv4, ipv6: network.ipv6, nics: network.interfaces, + fqdn: public_dns, }); export const configurationSelector = ({