Skip to content

Commit

Permalink
Fixes #36766 -Set disks to amount of disks instead of bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
chris1984 committed Sep 20, 2023
1 parent 506c528 commit f74ff35
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { propsToCamelCase } from 'foremanReact/common/helpers';
import { translate as __ } from 'foremanReact/common/I18n';
import {
DescriptionList,
Expand All @@ -14,8 +13,12 @@ import CardTemplate from 'foremanReact/components/HostDetails/Templates/CardItem
import { TranslatedPlural } from '../../../Table/components/TranslatedPlural';
import { hostIsNotRegistered } from '../hostDetailsHelpers';

const HostDisks = ({ totalDisks }) => {
if (!totalDisks) return null;
const HostDisks = ({ blockDevices }) => {
// blockDevices fact will look like this by default 'sr0,sda' and increment like sdb etc could be vda and go up too

Check failure on line 17 in webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js

View workflow job for this annotation

GitHub Actions / build

This line has a length of 117. Maximum allowed is 100
var disks = blockDevices.split(',')

Check failure on line 18 in webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js

View workflow job for this annotation

GitHub Actions / build

Unexpected var, use let or const instead

Check failure on line 18 in webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon
// We are filtering out the CDROM drive that gets added by default a lot of the time
var totalDisks = disks.filter(function(e) { return e !== 'sr0' }).length

Check failure on line 20 in webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js

View workflow job for this annotation

GitHub Actions / build

Unexpected var, use let or const instead

Check failure on line 20 in webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js

View workflow job for this annotation

GitHub Actions / build

Unexpected function expression

Check warning on line 20 in webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js

View workflow job for this annotation

GitHub Actions / build

Unexpected unnamed function

Check failure on line 20 in webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js

View workflow job for this annotation

GitHub Actions / build

Missing space before function parentheses

Check failure on line 20 in webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon

Check failure on line 20 in webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon
if (totalDisks.length === 0) return null;
return (
<>
<DescriptionListTerm>{__('Storage')}</DescriptionListTerm>
Expand All @@ -27,11 +30,11 @@ const HostDisks = ({ totalDisks }) => {
};

HostDisks.propTypes = {
totalDisks: PropTypes.number,
blockDevices: PropTypes.string,
};

HostDisks.defaultProps = {
totalDisks: null,
blockDevices: null,
};

const HwPropertiesCard = ({ isExpandedGlobal, hostDetails }) => {
Expand All @@ -41,8 +44,7 @@ const HwPropertiesCard = ({ isExpandedGlobal, hostDetails }) => {
const cpuCount = facts?.['cpu::cpu(s)'];
const cpuSockets = facts?.['cpu::cpu_socket(s)'];
const coreSocket = facts?.['cpu::core(s)_per_socket'];
const reportedFacts = propsToCamelCase(hostDetails?.reported_data || {});
const totalDisks = reportedFacts?.disksTotal;
const blockDevices = facts?.['blockdevices'];

Check failure on line 47 in webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js

View workflow job for this annotation

GitHub Actions / build

["blockdevices"] is better written in dot notation
const memory = facts?.['dmi::memory::maximum_capacity'];

return (
Expand Down Expand Up @@ -74,7 +76,7 @@ const HwPropertiesCard = ({ isExpandedGlobal, hostDetails }) => {
<DescriptionListDescription>{memory}</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<HostDisks totalDisks={totalDisks} />
<HostDisks totalDisks={blockDevices} />
</DescriptionListGroup>
</DescriptionList>
</CardTemplate>
Expand All @@ -90,9 +92,7 @@ HwPropertiesCard.propTypes = {
cpuSockets: PropTypes.number,
coreSocket: PropTypes.number,
memory: PropTypes.string,
}),
reported_data: PropTypes.shape({
totalDisks: PropTypes.number,
blockdevices: PropTypes.string,
}),
}),
};
Expand Down

0 comments on commit f74ff35

Please sign in to comment.