-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(InventoryGroupDetails): THEEDGE-3707 implement edge group details…
… expostion (#2092) Implements https://issues.redhat.com/browse/THEEDGE-3707 * fix(InventoryGroupDetails): THEEDGE-3707 implement edge group details expostion * fix: Center spinner, console error --------- Co-authored-by: Georgii Karataev <[email protected]>
- Loading branch information
Showing
5 changed files
with
96 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import AsyncComponent from '@redhat-cloud-services/frontend-components/AsyncComponent'; | ||
import ErrorState from '@redhat-cloud-services/frontend-components/ErrorState'; | ||
import { resolveRelPath } from '../../Utilities/path'; | ||
import { getNotificationProp } from '../../Utilities/edge'; | ||
import { useLocation, useNavigate, useParams } from 'react-router-dom'; | ||
import { useDispatch } from 'react-redux'; | ||
|
||
const EdgeGroupsDetailsView = (props) => { | ||
const dispatch = useDispatch(); | ||
const notificationProp = getNotificationProp(dispatch); | ||
return ( | ||
<AsyncComponent | ||
appName="edge" | ||
module="./GroupsDetails" | ||
ErrorComponent={<ErrorState />} | ||
navigateProp={useNavigate} | ||
locationProp={useLocation} | ||
paramsProp={useParams} | ||
notificationProp={notificationProp} | ||
pathPrefix={resolveRelPath('')} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export default EdgeGroupsDetailsView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { inventoryHasConventionalSystems } from '../Utilities/conventional'; | ||
import { inventoryHasEdgeSystems } from '../Utilities/edge'; | ||
import useEdgeGroups from '../Utilities/hooks/useEdgeGroups'; | ||
import useFeatureFlag from '../Utilities/useFeatureFlag'; | ||
import PropTypes from 'prop-types'; | ||
import { Bullseye, Spinner } from '@patternfly/react-core'; | ||
import EdgeGroupsDetailsView from '../components/InventoryGroupDetail/EdgeGroupDetails'; | ||
import InventoryGroupDetail from './InventoryGroupDetail'; | ||
|
||
const InventoryOrEdgeGroupDetailsView = () => { | ||
const [enforceEdgeGroups, isLoading] = useEdgeGroups(); | ||
const [hasConventionalSystems, setHasConventionalSystems] = useState(true); | ||
const [hasEdgeDevices, setHasEdgeDevices] = useState(true); | ||
const edgeParityInventoryListEnabled = useFeatureFlag( | ||
'edgeParity.inventory-list' | ||
); | ||
|
||
useEffect(() => { | ||
try { | ||
(async () => { | ||
const hasConventionalSystems = await inventoryHasConventionalSystems(); | ||
if (edgeParityInventoryListEnabled) { | ||
const hasEdgeSystems = await inventoryHasEdgeSystems(); | ||
setHasConventionalSystems(hasConventionalSystems); | ||
setHasEdgeDevices(hasEdgeSystems); | ||
} | ||
})(); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}, []); | ||
|
||
const GroupsDetailComponents = enforceEdgeGroups | ||
? EdgeGroupsDetailsView | ||
: InventoryGroupDetail; | ||
if (!isLoading) { | ||
return ( | ||
<GroupsDetailComponents | ||
hasConventionalSystems={hasConventionalSystems} | ||
hasEdgeDevices={hasEdgeDevices} | ||
/> | ||
); | ||
} else { | ||
return ( | ||
<Bullseye> | ||
<Spinner /> | ||
</Bullseye> | ||
); | ||
} | ||
}; | ||
|
||
InventoryOrEdgeGroupDetailsView.prototype = { | ||
enforceEdgeGroups: PropTypes.bool, | ||
isLoading: PropTypes.bool, | ||
}; | ||
|
||
export default InventoryOrEdgeGroupDetailsView; |