This repository has been archived by the owner on Nov 28, 2024. It is now read-only.
-
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.
Merge pull request #108 from avivtur/nns-topology
NNS topology
- Loading branch information
Showing
35 changed files
with
1,872 additions
and
53 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,117 @@ | ||
import React, { FC, ReactNode } from 'react'; | ||
import classnames from 'classnames'; | ||
|
||
import { | ||
Button, | ||
ButtonVariant, | ||
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 = { | ||
popoverBodyContent?: ReactNode; | ||
breadcrumb?: string; | ||
className?: string; | ||
testId?: string; | ||
description: ReactNode | string; | ||
header?: ReactNode; | ||
editOnTitleJustify?: boolean; | ||
isDisabled?: boolean; | ||
isEdit?: boolean; | ||
isPopover?: boolean; | ||
headerBadge?: ReactNode; | ||
messageOnDisabled?: string; | ||
moreInfoURL?: string; | ||
onEditClick?: () => void; | ||
showEditOnTitle?: boolean; | ||
}; | ||
|
||
const DetailItem: FC<DetailItemProps> = ({ | ||
popoverBodyContent, | ||
breadcrumb, | ||
className, | ||
testId, | ||
description, | ||
header, | ||
editOnTitleJustify = false, | ||
isDisabled, | ||
isEdit, | ||
isPopover, | ||
headerBadge, | ||
messageOnDisabled, | ||
moreInfoURL, | ||
onEditClick, | ||
showEditOnTitle, | ||
}) => { | ||
const { t } = useNMStateTranslation(); | ||
const NotAvailable = <span className="text-muted">{t('Not available')}</span>; | ||
|
||
return ( | ||
<DescriptionListGroup className={classnames('pf-c-description-list__group', className)}> | ||
<DescriptionListTermHelpText className="pf-c-description-list__term"> | ||
<Flex | ||
justifyContent={{ | ||
default: editOnTitleJustify ? 'justifyContentSpaceBetween' : 'justifyContentFlexStart', | ||
}} | ||
> | ||
{(popoverBodyContent || breadcrumb || header || headerBadge || moreInfoURL) && ( | ||
<FlexItem> | ||
<DetailItemHeader | ||
bodyContent={popoverBodyContent} | ||
breadcrumb={breadcrumb} | ||
descriptionHeader={header} | ||
isPopover={isPopover} | ||
label={headerBadge} | ||
moreInfoURL={moreInfoURL} | ||
/> | ||
</FlexItem> | ||
)} | ||
{isEdit && showEditOnTitle && ( | ||
<FlexItem> | ||
<Button | ||
data-test-id={`${testId}-edit`} | ||
isDisabled={isDisabled} | ||
isInline | ||
onClick={onEditClick} | ||
variant={ButtonVariant.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 ? ( | ||
<EditButtonWithTooltip | ||
isEditable={!isDisabled} | ||
onEditClick={onEditClick} | ||
testId={testId} | ||
tooltipContent={messageOnDisabled} | ||
> | ||
{description ?? NotAvailable} | ||
</EditButtonWithTooltip> | ||
) : ( | ||
description | ||
)} | ||
</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> | ||
); | ||
}; |
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,30 @@ | ||
import React, { FC, PropsWithChildren, SyntheticEvent } from 'react'; | ||
|
||
import { Button, ButtonVariant, Flex } from '@patternfly/react-core'; | ||
import { PencilAltIcon } from '@patternfly/react-icons'; | ||
|
||
type EditButtonProps = PropsWithChildren<{ | ||
isEditable: boolean; | ||
onEditClick?: () => void; | ||
testId: string; | ||
}>; | ||
|
||
const EditButton: FC<EditButtonProps> = ({ children, onEditClick, isEditable, testId }) => ( | ||
<Button | ||
onClick={(e: SyntheticEvent<HTMLButtonElement>) => { | ||
e.stopPropagation(); | ||
onEditClick?.(); | ||
}} | ||
data-test-id={testId} | ||
isDisabled={!isEditable} | ||
isInline | ||
variant={ButtonVariant.link} | ||
> | ||
<Flex> | ||
{children} | ||
<PencilAltIcon className="co-icon-space-l" /> | ||
</Flex> | ||
</Button> | ||
); | ||
|
||
export default EditButton; |
Oops, something went wrong.