1- import type { FunctionComponent } from 'react' ;
1+ import type { FunctionComponent , ReactNode } from 'react' ;
22import {
33 Button ,
44 ButtonProps ,
@@ -10,15 +10,15 @@ import {
1010 PageBreadcrumb ,
1111 PageSection ,
1212 Split ,
13- SplitItem ,
13+ SplitItem
1414} from '@patternfly/react-core' ;
1515import { ExternalLinkAltIcon } from '@patternfly/react-icons' ;
1616import { createUseStyles } from 'react-jss' ;
1717
1818/** extends ButtonProps */
19- export interface PageHeaderLinkProps extends ButtonProps {
19+ export interface PageHeaderLinkProps extends Omit < ButtonProps , 'label' > {
2020 /** Title for the link */
21- label : string ;
21+ label : ReactNode ;
2222 /** Indicates if the link points to an external page */
2323 isExternal ?: boolean ;
2424}
@@ -48,7 +48,7 @@ export interface PageHeaderProps extends React.PropsWithChildren {
4848
4949const useStyles = createUseStyles ( {
5050 iconMinWidth : {
51- minWidth : '48px' ,
51+ minWidth : '48px'
5252 }
5353} ) ;
5454
@@ -57,41 +57,39 @@ export const PageHeader: FunctionComponent<PageHeaderProps> = ({
5757 subtitle,
5858 linkProps,
5959 icon,
60- label,
60+ label : labelProp ,
6161 breadcrumbs = null ,
6262 actionMenu,
6363 ouiaId = 'PageHeader' ,
6464 children = null ,
6565 headingClassname = subtitle ? 'pf-v6-u-mb-sm' : ''
6666} : PageHeaderProps ) => {
6767 const classes = useStyles ( ) ;
68- const { isExternal = false , ...linkRestProps } = linkProps ?? { } ;
69- const showSplitRow = title || label || actionMenu ;
68+ const { isExternal = false , label = String ( linkProps ?. label ) , ...linkRestProps } = linkProps ?? { } ;
69+ const showSplitRow = title || labelProp || actionMenu ;
7070 const showMainFlex = showSplitRow || subtitle || linkProps ;
7171
7272 return (
7373 < >
74- { breadcrumbs && (
75- < PageBreadcrumb >
76- { breadcrumbs }
77- </ PageBreadcrumb >
78- ) }
74+ { breadcrumbs && < PageBreadcrumb > { breadcrumbs } </ PageBreadcrumb > }
7975 < PageSection hasBodyWrapper = { false } >
80- { ( showMainFlex || icon ) &&
76+ { ( showMainFlex || icon ) && (
8177 < Flex >
8278 { icon && (
8379 < >
8480 < FlexItem alignSelf = { { default : 'alignSelfCenter' } } className = { classes . iconMinWidth } >
8581 { icon }
8682 </ FlexItem >
87- < Divider orientation = { {
88- default : 'vertical' ,
89- } } />
83+ < Divider
84+ orientation = { {
85+ default : 'vertical'
86+ } }
87+ />
9088 </ >
9189 ) }
92- { ( showMainFlex ) && (
90+ { showMainFlex && (
9391 < FlexItem flex = { { default : 'flex_1' } } >
94- { ( showSplitRow ) && (
92+ { showSplitRow && (
9593 < Split hasGutter >
9694 { title && (
9795 < SplitItem >
@@ -100,17 +98,9 @@ export const PageHeader: FunctionComponent<PageHeaderProps> = ({
10098 </ Content >
10199 </ SplitItem >
102100 ) }
103- { label && (
104- < SplitItem >
105- { label }
106- </ SplitItem >
107- ) }
101+ { labelProp && < SplitItem > { labelProp } </ SplitItem > }
108102 < SplitItem isFilled />
109- { actionMenu && (
110- < SplitItem >
111- { actionMenu }
112- </ SplitItem >
113- ) }
103+ { actionMenu && < SplitItem > { actionMenu } </ SplitItem > }
114104 </ Split >
115105 ) }
116106 { subtitle && (
@@ -119,18 +109,27 @@ export const PageHeader: FunctionComponent<PageHeaderProps> = ({
119109 </ Content >
120110 ) }
121111 { linkProps && (
122- < Button variant = { ButtonVariant . link } component = "a" ouiaId = { `${ ouiaId } -link-button` } isInline icon = { isExternal ? < ExternalLinkAltIcon className = 'pf-v6-u-ml-sm' /> : null } iconPosition = "end" { ...linkRestProps } >
112+ < Button
113+ variant = { ButtonVariant . link }
114+ component = "a"
115+ ouiaId = { `${ ouiaId } -link-button` }
116+ isInline
117+ icon = { isExternal ? < ExternalLinkAltIcon className = "pf-v6-u-ml-sm" /> : null }
118+ iconPosition = "end"
119+ label = { label as string }
120+ { ...linkRestProps }
121+ >
123122 { linkProps . label }
124123 </ Button >
125124 ) }
126125 </ FlexItem >
127126 ) }
128127 </ Flex >
129- }
128+ ) }
130129 { children }
131130 </ PageSection >
132131 </ >
133- )
132+ ) ;
134133} ;
135134
136135export default PageHeader ;
0 commit comments