forked from redhat-developer/gitops-console-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetailsPageHeader.tsx
More file actions
130 lines (122 loc) · 3.83 KB
/
DetailsPageHeader.tsx
File metadata and controls
130 lines (122 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import * as React from 'react';
import { Link } from 'react-router-dom-v5-compat';
import TechPreviewBadge from 'src/components/import/badges/TechPreviewBadge';
import FavoriteButton from '@gitops/components/shared/FavoriteButton/FavoriteButton';
import ActionsDropdown from '@gitops/utils/components/ActionDropDown/ActionDropDown';
import { DEFAULT_NAMESPACE } from '@gitops/utils/constants';
import { isApplicationRefreshing } from '@gitops/utils/gitops';
import { useGitOpsTranslation } from '@gitops/utils/hooks/useGitOpsTranslation';
import { Action, K8sModel, K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk';
import {
ActionList,
ActionListGroup,
ActionListItem,
Breadcrumb,
BreadcrumbItem,
Flex,
PageBreadcrumb,
PageGroup,
PageSection,
Spinner,
Title,
} from '@patternfly/react-core';
import './details-page-header.scss';
const PaneHeading: React.FC = ({ children }) => (
<Flex
alignItems={{ default: 'alignItemsCenter' }}
justifyContent={{ default: 'justifyContentSpaceBetween' }}
>
{children}
</Flex>
);
type DetailsPageTitleProps = {
breadcrumb: React.ReactNode;
};
const DetailsPageTitle: React.FC<DetailsPageTitleProps> = ({ breadcrumb, children }) => (
<div>
<PageGroup>
<PageBreadcrumb>{breadcrumb}</PageBreadcrumb>
<PageSection className="details-page-title" hasBodyWrapper={false}>
{children}
</PageSection>
</PageGroup>
</div>
);
type DetailsPageHeaderProps = {
obj: K8sResourceCommon;
model: K8sModel;
name: string;
namespace: string;
actions: Action[];
iconText: string;
iconTitle: string;
};
const DetailsPageHeader: React.FC<DetailsPageHeaderProps> = ({
obj,
model,
name,
namespace,
actions,
iconText,
iconTitle,
}) => {
const { t } = useGitOpsTranslation();
return (
<>
<div>
<DetailsPageTitle
breadcrumb={
<Breadcrumb className="pf-c-breadcrumb co-breadcrumb">
<BreadcrumbItem>
<Link
to={`/k8s/ns/${namespace || DEFAULT_NAMESPACE}/${
model.apiGroup + '~' + model.apiVersion + '~' + model.kind
}`}
>
{t(model.labelPlural)}
</Link>
</BreadcrumbItem>
<BreadcrumbItem>{t(model.label + ' details')}</BreadcrumbItem>
</Breadcrumb>
}
>
<PaneHeading>
<Title headingLevel="h1" className="details-page-header">
<span
className="co-m-resource-icon co-m-resource-icon--lg argocd-resource-icon"
title={iconTitle}
>
{iconText}
</span>
<span className="co-resource-item__resource-name">
{name ?? obj?.metadata?.name}{' '}
{isApplicationRefreshing(obj) ? <Spinner size="md" /> : <span></span>}
</span>
<span
className="details-page-header__item"
style={{ marginLeft: '10px', marginBottom: '5px' }}
>
<TechPreviewBadge
tooltipContent={t(
'This details page is under tech preview, but not necessarily the resource it represents',
)}
/>
</span>
</Title>
<ActionList className="co-actions">
<ActionListGroup>
<ActionListItem>
<FavoriteButton defaultName={name ?? obj?.metadata?.name} />
</ActionListItem>
<ActionListItem>
<ActionsDropdown actions={actions} isKebabToggle={false} />
</ActionListItem>
</ActionListGroup>
</ActionList>
</PaneHeading>
</DetailsPageTitle>
</div>
</>
);
};
export default DetailsPageHeader;