|
| 1 | +import * as React from 'react'; |
| 2 | +import { Link } from 'react-router-dom-v5-compat'; |
| 3 | +import DevPreviewBadge from '../../../components/import/badges/DevPreviewBadge'; |
| 4 | +import { DEFAULT_NAMESPACE } from '../../utils/constants'; |
| 5 | +import { isApplicationRefreshing } from '../../utils/gitops'; |
| 6 | +import { useGitOpsTranslation } from '../../utils/hooks/useGitOpsTranslation'; |
| 7 | +import { Action, K8sModel, K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk'; |
| 8 | +import { Breadcrumb, BreadcrumbItem, Spinner, Title } from '@patternfly/react-core'; |
| 9 | +import ActionsDropdown from '../../utils/components/ActionDropDown/ActionDropDown'; |
| 10 | +import DetailsPageTitle, { PaneHeading } from '../../utils/components/DetailsPageTitle/DetailsPageTitle'; |
| 11 | +import './application-details-title.scss'; |
| 12 | + |
| 13 | +type ApplicationPageTitleProps = { |
| 14 | + obj: K8sResourceCommon; |
| 15 | + model: K8sModel; |
| 16 | + name: string; |
| 17 | + namespace: string; |
| 18 | + actions: Action[]; |
| 19 | +}; |
| 20 | + |
| 21 | +const ApplicationDetailsTitle: React.FC<ApplicationPageTitleProps> = ({ |
| 22 | + obj, |
| 23 | + model, |
| 24 | + name, |
| 25 | + namespace, |
| 26 | + actions, |
| 27 | +}) => { |
| 28 | + const { t } = useGitOpsTranslation(); |
| 29 | + |
| 30 | + // Determine if this is an ApplicationSet based on the model kind |
| 31 | + const isApplicationSet = model.kind === 'ApplicationSet'; |
| 32 | + const iconText = isApplicationSet ? 'AS' : 'A'; |
| 33 | + const iconTitle = isApplicationSet ? 'Argo CD ApplicationSet' : 'Argo CD Application'; |
| 34 | + |
| 35 | + return ( |
| 36 | + <> |
| 37 | + <div> |
| 38 | + <DetailsPageTitle |
| 39 | + breadcrumb={ |
| 40 | + <Breadcrumb className="pf-c-breadcrumb co-breadcrumb"> |
| 41 | + <BreadcrumbItem> |
| 42 | + <Link |
| 43 | + to={`/k8s/ns/${namespace || DEFAULT_NAMESPACE}/${ |
| 44 | + model.apiGroup + '~' + model.apiVersion + '~' + model.kind |
| 45 | + }`} |
| 46 | + > |
| 47 | + Argo CD {t(model.labelPlural)} |
| 48 | + </Link> |
| 49 | + </BreadcrumbItem> |
| 50 | + <BreadcrumbItem>Argo CD {t(model.labelPlural + ' Details')}</BreadcrumbItem> |
| 51 | + </Breadcrumb> |
| 52 | + } |
| 53 | + > |
| 54 | + <PaneHeading> |
| 55 | + <Title headingLevel="h1"> |
| 56 | + <span |
| 57 | + className="argocd-application-icon co-m-resource-icon co-m-resource-icon--lg" |
| 58 | + title={iconTitle} |
| 59 | + > |
| 60 | + {iconText} |
| 61 | + </span> |
| 62 | + <span className="co-resource-item__resource-name"> |
| 63 | + {name ?? obj?.metadata?.name}{' '} |
| 64 | + {isApplicationRefreshing(obj) ? <Spinner size="md" /> : <span></span>} |
| 65 | + </span> |
| 66 | + <span style={{ marginLeft: '10px', marginBottom: '3px' }}> |
| 67 | + <DevPreviewBadge /> |
| 68 | + </span> |
| 69 | + </Title> |
| 70 | + <div className="co-actions"> |
| 71 | + <ActionsDropdown actions={actions} isKebabToggle={false} /> |
| 72 | + </div> |
| 73 | + </PaneHeading> |
| 74 | + </DetailsPageTitle> |
| 75 | + </div> |
| 76 | + </> |
| 77 | + ); |
| 78 | +}; |
| 79 | + |
| 80 | +export default ApplicationDetailsTitle; |
0 commit comments