Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(RHINENG-8881): Add bootc card host detail page #2168

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/components/GeneralInfo/BootcImageCard/BootcImageCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import LoadingCard from '../LoadingCard';
import { bootcSelector } from '../selectors';
import { extraShape } from '../../../constants';

export const BootcImageCard = ({ handleClick, extra }) => {
const { detailLoaded, bootc } = useSelector(
({ systemProfileStore: { systemProfile } }) => ({
detailLoaded: systemProfile && systemProfile.loaded,
bootc: bootcSelector(systemProfile),
})
);

return (
<LoadingCard
title="BOOTC"
isLoading={!detailLoaded}
items={[
...[{ title: 'Booted Image', value: bootc.bootedImage }],
...[{ title: 'Booted Image Digest', value: bootc.bootedImageDigest }],
...[{ title: 'Staged Image', value: bootc.stagedImage }],
...[{ title: 'Staged Image Digest', value: bootc.stagedImageDigest }],
...[{ title: 'Rollback Image', value: bootc.rollbackImage }],
...[
{ title: 'Rollback Image Digest', value: bootc.rollbackImageDigest },
],
...extra.map(({ onClick, ...item }) => ({
...item,
...(onClick && { onClick: (e) => onClick(e, handleClick) }),
})),
]}
/>
);
};

BootcImageCard.propTypes = {
detailLoaded: PropTypes.bool,
handleClick: PropTypes.func,
bootc: PropTypes.shape({
bootedImage: PropTypes.string,
bootedImageDigest: PropTypes.string,
stagedImage: PropTypes.string,
stagedImageDigest: PropTypes.string,
rollbackImage: PropTypes.string,
rollbackImageDigest: PropTypes.string,
}),
extra: PropTypes.arrayOf(extraShape),
};
BootcImageCard.defaultProps = {
detailLoaded: false,
handleClick: () => undefined,
extra: [],
};
1 change: 1 addition & 0 deletions src/components/GeneralInfo/BootcImageCard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './BootcImageCard';
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import InfoTable from '../InfoTable';
import { OperatingSystemCard } from '../OperatingSystemCard';
import { SystemCard } from '../SystemCard';
import { BiosCard } from '../BiosCard';
import { BootcImageCard } from '../BootcImageCard';
import { InfrastructureCard } from '../InfrastructureCard';
import { ConfigurationCard } from '../ConfigurationCard';
import { SystemStatusCard } from '../SystemStatusCard';
Expand Down Expand Up @@ -92,6 +93,7 @@ class GeneralInformation extends Component {
SystemCardWrapper,
OperatingSystemCardWrapper,
BiosCardWrapper,
BootcImageCardWrapper,
InfrastructureCardWrapper,
ConfigurationCardWrapper,
SystemStatusCardWrapper,
Expand All @@ -101,7 +103,6 @@ class GeneralInformation extends Component {
entity,
} = this.props;
const Wrapper = store ? Provider : Fragment;

return (
<Wrapper {...(store && { store })}>
{entity?.system_profile?.operating_system?.name === 'CentOS Linux' && (
Expand Down Expand Up @@ -160,6 +161,14 @@ class GeneralInformation extends Component {
</GridItem>
)}

{this.props.isBootcHost && BootcImageCardWrapper && (
<GridItem>
<BootcImageCardWrapper
handleClick={this.handleModalToggle}
/>
</GridItem>
)}

{ConfigurationCardWrapper && (
<GridItem>
<ConfigurationCardWrapper
Expand Down Expand Up @@ -232,6 +241,10 @@ GeneralInformation.propTypes = {
PropTypes.bool,
]),
BiosCardWrapper: PropTypes.oneOfType([PropTypes.elementType, PropTypes.bool]),
BootcImageCardWrapper: PropTypes.oneOfType([
PropTypes.elementType,
PropTypes.bool,
]),
InfrastructureCardWrapper: PropTypes.oneOfType([
PropTypes.elementType,
PropTypes.bool,
Expand All @@ -257,12 +270,14 @@ GeneralInformation.propTypes = {
inventoryId: PropTypes.string.isRequired,
systemProfilePrefetched: PropTypes.bool,
showImageDetails: PropTypes.bool,
isBootcHost: PropTypes.bool,
};
GeneralInformation.defaultProps = {
entity: {},
SystemCardWrapper: SystemCard,
OperatingSystemCardWrapper: OperatingSystemCard,
BiosCardWrapper: BiosCard,
BootcImageCardWrapper: BootcImageCard,
InfrastructureCardWrapper: InfrastructureCard,
ConfigurationCardWrapper: ConfigurationCard,
SystemStatusCardWrapper: SystemStatusCard,
Expand Down
9 changes: 9 additions & 0 deletions src/components/GeneralInfo/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ export const biosSelector = ({
releaseDate: bios_release_date,
});

export const bootcSelector = ({ bootc_status } = {}) => ({
bootedImage: bootc_status?.booted?.image,
bootedImageDigest: bootc_status?.booted?.image_digest,
stagedImage: bootc_status?.staged?.image,
stagedImageDigest: bootc_status?.staged?.image_digest,
rollbackImage: bootc_status?.rollback?.image,
rollbackImageDigest: bootc_status?.rollback?.image_digest,
});

export const infrastructureSelector = (
{
infrastructure_type,
Expand Down
2 changes: 2 additions & 0 deletions src/components/SystemDetails/GeneralInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const GeneralInfoTab = (props) => {
({ systemProfileStore }) => systemProfileStore?.systemProfile
);
const isEdgeHost = systemProfile?.host_type === 'edge';
const isBootcHost = !!systemProfile.bootc_status;
const enableEdgeImageDetails = useFeatureFlag(
'edgeParity.inventory-system-detail'
);
Expand All @@ -19,6 +20,7 @@ const GeneralInfoTab = (props) => {
return (
<GeneralInformation
{...props}
isBootcHost={isBootcHost}
showImageDetails={
enableEdgeImageDetails && enableEdgeInventoryListDetails && isEdgeHost
}
Expand Down