-
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.
feat(THEEDGE-3581): add tab controls to display detail groups (#2079)
* feat(THEEDGE-3581): add tab controls to display detail groups; * feat(THEEDGE-3581): use new component; enable remove frm group and update action; * feat(THEEDGE-3581): add deviceGroupView * feat(THEEDGE-3581): add feature flag validation * feat(THEEDGE-3581): fix condition to display tabs when not edge enabled * feat(THEEDGE-3581): clean up comments and log * feat(THEEDGE-3581): clean up comments and log * feat(THEEDGE-3581): change behavior on catch
- Loading branch information
1 parent
acfffd4
commit 0c8907f
Showing
3 changed files
with
215 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { | ||
Bullseye, | ||
PageSection, | ||
Spinner, | ||
Tab, | ||
TabTitleText, | ||
Tabs, | ||
} from '@patternfly/react-core'; | ||
import React, { Suspense, lazy, useState } from 'react'; | ||
import { hybridInventoryTabKeys } from '../../Utilities/constants'; | ||
import GroupSystems from '../GroupSystems'; | ||
import PropTypes from 'prop-types'; | ||
import { usePermissionsWithContext } from '@redhat-cloud-services/frontend-components-utilities/RBACHook'; | ||
import { REQUIRED_PERMISSIONS_TO_READ_GROUP_HOSTS } from '../../constants'; | ||
import EdgeDeviceGroupiew from '../InventoryTabs/ImmutableDevices/EdgeDevicesGroupView'; | ||
import { EmptyStateNoAccessToSystems } from './EmptyStateNoAccess'; | ||
|
||
const GroupDetailInfo = lazy(() => import('./GroupDetailInfo')); | ||
|
||
const GroupTabDetailsWrapper = ({ | ||
groupId, | ||
groupName, | ||
activeTab, | ||
hasEdgeImages, | ||
}) => { | ||
const [tab, setTab] = useState(0); | ||
const { hasAccess: canViewHosts } = usePermissionsWithContext( | ||
REQUIRED_PERMISSIONS_TO_READ_GROUP_HOSTS(groupId) | ||
); | ||
|
||
const handleTabClick = (_event, tabIndex) => { | ||
setTab(tabIndex); | ||
}; | ||
|
||
const [activeTabKey, setActiveTabKey] = useState(0); | ||
|
||
return ( | ||
<Tabs | ||
activeKey={activeTabKey} | ||
onSelect={(event, value) => setActiveTabKey(value)} | ||
aria-label="Group tabs" | ||
role="region" | ||
inset={{ default: 'insetMd' }} // add extra space before the first tab (according to mocks) | ||
mountOnEnter | ||
unmountOnExit | ||
> | ||
<Tab eventKey={0} title="Systems" aria-label="Group systems tab"> | ||
<PageSection> | ||
{canViewHosts && hasEdgeImages ? ( | ||
<Tabs | ||
className="pf-m-light pf-c-table" | ||
activeKey={activeTab && tab == 0 ? activeTab : tab} | ||
onSelect={handleTabClick} | ||
aria-label="Hybrid inventory tabs" | ||
> | ||
<Tab | ||
eventKey={hybridInventoryTabKeys.conventional.key} | ||
title={<TabTitleText>Conventional (RPM-DNF)</TabTitleText>} | ||
> | ||
<GroupSystems groupName={groupName} groupId={groupId} /> | ||
</Tab> | ||
<Tab | ||
eventKey={hybridInventoryTabKeys.immutable.key} | ||
title={<TabTitleText>Immutable (OSTree)</TabTitleText>} | ||
> | ||
<EdgeDeviceGroupiew groupUUID={groupId} isSystemsView={true} /> | ||
</Tab> | ||
</Tabs> | ||
) : canViewHosts ? ( | ||
<GroupSystems groupName={groupName} groupId={groupId} /> | ||
) : ( | ||
<EmptyStateNoAccessToSystems /> | ||
)} | ||
</PageSection> | ||
</Tab> | ||
<Tab eventKey={1} title="Group info" aria-label="Group info tab"> | ||
{activeTabKey === 1 && ( // helps to lazy load the component | ||
<PageSection> | ||
<Suspense | ||
fallback={ | ||
<Bullseye> | ||
<Spinner /> | ||
</Bullseye> | ||
} | ||
> | ||
<GroupDetailInfo /> | ||
</Suspense> | ||
</PageSection> | ||
)} | ||
</Tab> | ||
</Tabs> | ||
); | ||
}; | ||
|
||
GroupTabDetailsWrapper.propTypes = { | ||
groupName: PropTypes.string.isRequired, | ||
groupId: PropTypes.string.isRequired, | ||
activeTab: PropTypes.string, | ||
hasEdgeImages: PropTypes.bool, | ||
}; | ||
export default GroupTabDetailsWrapper; |
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
31 changes: 31 additions & 0 deletions
31
src/components/InventoryTabs/ImmutableDevices/EdgeDevicesGroupView.js
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,31 @@ | ||
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, | ||
manageEdgeInventoryUrlName, | ||
} from '../../../Utilities/edge'; | ||
import { useLocation, useNavigate } from 'react-router-dom'; | ||
import { useDispatch } from 'react-redux'; | ||
|
||
const EdgeDeviceGroupiew = (props) => { | ||
const dispatch = useDispatch(); | ||
const notificationProp = getNotificationProp(dispatch); | ||
return ( | ||
<AsyncComponent | ||
appName="edge" | ||
module="./DevicesGroupDetail" | ||
ErrorComponent={<ErrorState />} | ||
navigateProp={useNavigate} | ||
locationProp={useLocation} | ||
showHeaderProp={false} | ||
pathPrefix={resolveRelPath('')} | ||
urlName={manageEdgeInventoryUrlName} | ||
notificationProp={notificationProp} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export default EdgeDeviceGroupiew; |