-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aviv Turgeman <[email protected]>
- Loading branch information
Showing
34 changed files
with
1,852 additions
and
50 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 |
---|---|---|
|
@@ -73,7 +73,8 @@ jobs: | |
uses: cypress-io/[email protected] | ||
with: | ||
start: yarn serve-build, yarn start-console | ||
wait-on: "http://localhost:9001" | ||
wait-on: 'http://localhost:9001' | ||
wait-on-timeout: 120 | ||
browser: chrome | ||
headed: false | ||
|
||
|
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
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
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
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,17 @@ | ||
.description-item__title { | ||
justify-content: space-between; | ||
flex: 1; | ||
} | ||
|
||
.margin-top { | ||
margin-top: var(--pf-v5-global--spacer--md); | ||
} | ||
|
||
.DescriptionItemHeader { | ||
&--list-term { | ||
.pf-c-description-list__text { | ||
align-items: center; | ||
display: inline-flex; | ||
} | ||
} | ||
} |
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,116 @@ | ||
import React, { FC, ReactNode } from 'react'; | ||
|
||
import { | ||
Button, | ||
DescriptionListDescription, | ||
DescriptionListGroup, | ||
DescriptionListTermHelpText, | ||
Flex, | ||
FlexItem, | ||
} from '@patternfly/react-core'; | ||
import { PencilAltIcon } from '@patternfly/react-icons'; | ||
import { useNMStateTranslation } from '@utils/hooks/useNMStateTranslation'; | ||
|
||
import { DetailItemHeader } from './DetailItemHeader'; | ||
import EditButtonWithTooltip from './EditButtonWithTooltip'; | ||
|
||
import './DetailItem.scss'; | ||
|
||
type DetailItemProps = { | ||
bodyContent?: ReactNode; | ||
breadcrumb?: string; | ||
className?: string; | ||
'data-test-id'?: string; | ||
descriptionData: ReactNode | string; | ||
descriptionHeader?: ReactNode; | ||
editOnTitleJustify?: boolean; | ||
isDisabled?: boolean; | ||
isEdit?: boolean; | ||
isPopover?: boolean; | ||
label?: ReactNode; | ||
messageOnDisabled?: string; | ||
moreInfoURL?: string; | ||
onEditClick?: () => void; | ||
showEditOnTitle?: boolean; | ||
}; | ||
|
||
const DetailItem: FC<DetailItemProps> = ({ | ||
bodyContent, | ||
breadcrumb, | ||
className, | ||
'data-test-id': testId, | ||
descriptionData, | ||
descriptionHeader, | ||
editOnTitleJustify = false, | ||
isDisabled, | ||
isEdit, | ||
isPopover, | ||
label, | ||
messageOnDisabled, | ||
moreInfoURL, | ||
onEditClick, | ||
showEditOnTitle, | ||
}) => { | ||
const { t } = useNMStateTranslation(); | ||
const NotAvailable = <span className="text-muted">{t('Not available')}</span>; | ||
|
||
const description = ( | ||
<EditButtonWithTooltip | ||
isEditable={!isDisabled} | ||
onEditClick={onEditClick} | ||
testId={testId} | ||
tooltipContent={messageOnDisabled} | ||
> | ||
{descriptionData ?? NotAvailable} | ||
</EditButtonWithTooltip> | ||
); | ||
|
||
return ( | ||
<DescriptionListGroup className={`pf-c-description-list__group ${className && className}`}> | ||
<DescriptionListTermHelpText className="pf-c-description-list__term"> | ||
<Flex | ||
justifyContent={{ | ||
default: editOnTitleJustify ? 'justifyContentSpaceBetween' : 'justifyContentFlexStart', | ||
}} | ||
> | ||
{(bodyContent || breadcrumb || descriptionHeader || label || moreInfoURL) && ( | ||
<FlexItem> | ||
<DetailItemHeader | ||
bodyContent={bodyContent} | ||
breadcrumb={breadcrumb} | ||
descriptionHeader={descriptionHeader} | ||
isPopover={isPopover} | ||
label={label} | ||
moreInfoURL={moreInfoURL} | ||
/> | ||
</FlexItem> | ||
)} | ||
{isEdit && showEditOnTitle && ( | ||
<FlexItem> | ||
<Button | ||
data-test-id={`${testId}-edit`} | ||
isDisabled={isDisabled} | ||
isInline | ||
onClick={onEditClick} | ||
type="button" | ||
variant="link" | ||
> | ||
{t('Edit')} | ||
<PencilAltIcon className="co-icon-space-l pf-v5-c-button-icon--plain" /> | ||
</Button> | ||
</FlexItem> | ||
)} | ||
</Flex> | ||
</DescriptionListTermHelpText> | ||
|
||
<DescriptionListDescription | ||
className="pf-c-description-list__description" | ||
data-test-id={testId} | ||
> | ||
{isEdit && !showEditOnTitle ? description : descriptionData} | ||
</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
); | ||
}; | ||
|
||
export default DetailItem; |
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,74 @@ | ||
import React, { FC, ReactNode } from 'react'; | ||
|
||
import { | ||
Breadcrumb, | ||
BreadcrumbItem, | ||
DescriptionListTerm, | ||
DescriptionListTermHelpTextButton, | ||
Popover, | ||
} from '@patternfly/react-core'; | ||
import { useNMStateTranslation } from '@utils/hooks/useNMStateTranslation'; | ||
|
||
import './DetailItem.scss'; | ||
|
||
type DetailItemHeaderProps = { | ||
bodyContent: ReactNode; | ||
breadcrumb?: string; | ||
descriptionHeader: ReactNode; | ||
isPopover: boolean; | ||
label?: ReactNode; | ||
maxWidth?: string; | ||
moreInfoURL?: string; | ||
}; | ||
|
||
export const DetailItemHeader: FC<DetailItemHeaderProps> = ({ | ||
bodyContent, | ||
breadcrumb, | ||
descriptionHeader, | ||
isPopover, | ||
label, | ||
maxWidth, | ||
moreInfoURL, | ||
}) => { | ||
const { t } = useNMStateTranslation(); | ||
|
||
if (isPopover && bodyContent) { | ||
return ( | ||
<Popover | ||
bodyContent={ | ||
<> | ||
{bodyContent} | ||
{moreInfoURL && ( | ||
<> | ||
{t('More info: ')} | ||
<a href={moreInfoURL}>{moreInfoURL}</a> | ||
</> | ||
)} | ||
{breadcrumb && ( | ||
<div className="margin-top"> | ||
<Breadcrumb> | ||
{breadcrumb.split('.').map((item) => ( | ||
<BreadcrumbItem key={item}>{item}</BreadcrumbItem> | ||
))} | ||
</Breadcrumb> | ||
</div> | ||
)} | ||
</> | ||
} | ||
hasAutoWidth | ||
headerContent={descriptionHeader} | ||
maxWidth={maxWidth || '30rem'} | ||
> | ||
<DescriptionListTermHelpTextButton className="pf-c-description-list__text"> | ||
{descriptionHeader} | ||
</DescriptionListTermHelpTextButton> | ||
</Popover> | ||
); | ||
} | ||
|
||
return ( | ||
<DescriptionListTerm className="DescriptionItemHeader--list-term"> | ||
{descriptionHeader} {label} | ||
</DescriptionListTerm> | ||
); | ||
}; |
Oops, something went wrong.