generated from RedHatInsights/frontend-starter-app
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(OCPADVISOR-135): workload detail page header (#630)
- Loading branch information
Showing
8 changed files
with
181 additions
and
75 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 |
---|---|---|
@@ -1,10 +1,48 @@ | ||
import React from 'react'; | ||
import PageHeader from '@redhat-cloud-services/frontend-components/PageHeader'; | ||
import { Flex, FlexItem, PageSection } from '@patternfly/react-core'; | ||
import Breadcrumbs from '../Breadcrumbs'; | ||
import WorkloadsHeader from '../WorkloadHeader'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export const Workload = () => { | ||
export const Workload = ({ workload, namespaceId, clusterId }) => { | ||
return ( | ||
<React.Fragment> | ||
<PageHeader className="pf-m-light ins-inventory-detail" /> | ||
<PageHeader className="pf-m-light ins-inventory-detail"> | ||
<Flex direction={{ default: 'column' }}> | ||
<FlexItem> | ||
<Breadcrumbs | ||
current={ | ||
workload?.data?.status === 'ok' | ||
? `${workload.data.cluster.display_name} | ${workload.data.namespace.name}` | ||
: `${clusterId} | ${namespaceId}` | ||
} | ||
/> | ||
<WorkloadsHeader /> | ||
</FlexItem> | ||
</Flex> | ||
</PageHeader> | ||
<PageSection>{/* <WorkloadRules workload={workload} /> */}</PageSection> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
Workload.propTypes = { | ||
clusterId: PropTypes.string.isRequired, | ||
namespaceId: PropTypes.string.isRequired, | ||
workload: PropTypes.shape({ | ||
isUninitialized: PropTypes.bool.isRequired, | ||
isFetching: PropTypes.bool.isRequired, | ||
data: PropTypes.shape({ | ||
namespace: PropTypes.shape({ | ||
uuid: PropTypes.string, | ||
name: PropTypes.string, | ||
}), | ||
cluster: PropTypes.shape({ | ||
uuid: PropTypes.string, | ||
display_name: PropTypes.string, | ||
}), | ||
status: PropTypes.string, | ||
}), | ||
}), | ||
}; |
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 |
---|---|---|
@@ -1,9 +1,37 @@ | ||
//Wrapper for API connection | ||
import React from 'react'; | ||
import React, { useEffect } from 'react'; | ||
import { Workload } from './Workload'; | ||
import { useParams } from 'react-router-dom'; | ||
import { useGetWorkloadByIdQuery } from '../../Services/SmartProxy'; | ||
import useChrome from '@redhat-cloud-services/frontend-components/useChrome'; | ||
|
||
const WorkloadWrapper = () => { | ||
return <Workload />; | ||
const chrome = useChrome(); | ||
const { namespaceId, clusterId } = useParams(); | ||
const workload = useGetWorkloadByIdQuery({ | ||
namespaceId, | ||
clusterId, | ||
}); | ||
|
||
useEffect(() => { | ||
workload.refetch(); | ||
}, [namespaceId, clusterId]); | ||
|
||
useEffect(() => { | ||
const subnav = `${ | ||
workload?.data?.status === 'ok' | ||
? `${workload?.data?.cluster.display_name} | ${workload?.data?.namespace.name} - Workloads` | ||
: `${clusterId} | ${namespaceId} - Workloads` | ||
}`; | ||
chrome.updateDocumentTitle(`${subnav} - OCP Advisor | Red Hat Insights`); | ||
}, [workload, namespaceId, clusterId]); | ||
|
||
return ( | ||
<Workload | ||
workload={workload} | ||
namespaceId={namespaceId} | ||
clusterId={clusterId} | ||
/> | ||
); | ||
}; | ||
|
||
export default WorkloadWrapper; |
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,84 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
Grid, | ||
GridItem, | ||
Stack, | ||
StackItem, | ||
Title, | ||
} from '@patternfly/react-core'; | ||
import Skeleton from '@redhat-cloud-services/frontend-components/Skeleton'; | ||
import { OneLineLoader } from '../../Utilities/Loaders'; | ||
import DateFormat from '@redhat-cloud-services/frontend-components/DateFormat'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export const WorkloadHeader = ({ workloadData, namespaceId, clusterId }) => { | ||
const { isUninitialized, isFetching, data: workload } = workloadData; | ||
return ( | ||
<Grid id="workload-header" md={12} hasGutter> | ||
<GridItem span={8}> | ||
<Title | ||
size="2xl" | ||
headingLevel="h1" | ||
id="cluster-header-title" | ||
ouiaId="cluster-name" | ||
> | ||
{isUninitialized || isFetching ? ( | ||
<> | ||
<Skeleton size="sm" /> | ||
<Skeleton size="sm" /> | ||
</> | ||
) : ( | ||
<> | ||
<p>{workload.cluster.display_name}</p> | ||
<p>{workload.namespace.name}</p> | ||
</> | ||
)} | ||
</Title> | ||
</GridItem> | ||
<GridItem> | ||
<Stack> | ||
<StackItem id="workload-header-uuid"> | ||
<span>Cluster UUID:</span> <span>{clusterId}</span>{' '} | ||
<span>Namespace UUID:</span> <span>{namespaceId}</span> | ||
</StackItem> | ||
<StackItem id="workload-header-last-seen"> | ||
<span>Last seen: </span> | ||
<span> | ||
{isUninitialized || isFetching ? ( | ||
<OneLineLoader /> | ||
) : workload?.metadata?.last_checked_at ? ( | ||
<DateFormat | ||
date={workload.metadata.last_checked_at} | ||
type="exact" | ||
/> | ||
) : ( | ||
<>Unknown</> | ||
)} | ||
</span> | ||
</StackItem> | ||
</Stack> | ||
</GridItem> | ||
</Grid> | ||
); | ||
}; | ||
|
||
WorkloadHeader.propTypes = { | ||
clusterId: PropTypes.string.isRequired, | ||
namespaceId: PropTypes.string.isRequired, | ||
workloadData: PropTypes.shape({ | ||
isUninitialized: PropTypes.bool.isRequired, | ||
isFetching: PropTypes.bool.isRequired, | ||
data: PropTypes.shape({ | ||
namespace: PropTypes.shape({ | ||
uuid: PropTypes.string, | ||
name: PropTypes.string, | ||
}), | ||
cluster: PropTypes.shape({ | ||
uuid: PropTypes.string, | ||
display_name: PropTypes.string, | ||
}), | ||
status: PropTypes.string, | ||
}), | ||
}), | ||
}; |
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,22 @@ | ||
import React from 'react'; | ||
import { WorkloadHeader } from './WorkloadHeader'; | ||
import { useParams } from 'react-router-dom'; | ||
import { useGetWorkloadByIdQuery } from '../../Services/SmartProxy'; | ||
|
||
const WorkloadsHeaderWrapper = () => { | ||
const { namespaceId, clusterId } = useParams(); | ||
const workloadData = useGetWorkloadByIdQuery({ | ||
namespaceId, | ||
clusterId, | ||
}); | ||
|
||
return ( | ||
<WorkloadHeader | ||
workloadData={workloadData} | ||
namespaceId={namespaceId} | ||
clusterId={clusterId} | ||
/> | ||
); | ||
}; | ||
|
||
export default WorkloadsHeaderWrapper; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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