-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d800f78
commit d60db7e
Showing
11 changed files
with
387 additions
and
265 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
packages/react-integration/demo-app-ts/src/components/demos/TopologyDemo/PipelineTasks.tsx
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import React from 'react'; | ||
import { | ||
Model, | ||
ModelKind, | ||
withPanZoom, | ||
GraphComponent, | ||
|
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
255 changes: 146 additions & 109 deletions
255
packages/react-styles/src/css/components/Topology/topology-pipelines.css
Large diffs are not rendered by default.
Oops, something went wrong.
111 changes: 5 additions & 106 deletions
111
packages/react-topology/src/pipelines/components/nodes/FinallyNode.tsx
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 |
---|---|---|
@@ -1,109 +1,8 @@ | ||
import * as React from 'react'; | ||
import { css } from '@patternfly/react-styles'; | ||
import styles from '@patternfly/react-styles/css/components/Topology/topology-pipelines'; | ||
import { Tooltip } from '@patternfly/react-core'; | ||
import { observer } from '../../../mobx-exports'; | ||
import { Node } from '../../../types'; | ||
import { RunStatus } from '../../types'; | ||
import { useAnchor, WithSelectionProps } from '../../../behavior'; | ||
import { truncateMiddle } from '../../../utils/truncate-middle'; | ||
import { useSize } from '../../../utils'; | ||
import { getRunStatusModifier } from '../../utils'; | ||
import StatusIcon from '../../utils/StatusIcon'; | ||
import { RectAnchor } from '../../../anchors'; | ||
import TaskNode, { TaskNodeProps } from './TaskNode'; | ||
|
||
type FinallyNodeProps = { | ||
element: Node; | ||
className?: string; | ||
paddingX?: number; | ||
nameLabelClass?: string; | ||
status?: RunStatus; | ||
statusWidth?: number; | ||
showStatusState?: boolean; | ||
truncateLength?: number; | ||
disableTooltip?: boolean; | ||
toolTip?: React.ReactNode; | ||
} & Partial<WithSelectionProps>; | ||
const FinallyNode: React.FC<TaskNodeProps> = props => ( | ||
<TaskNode whenOffset={0} whenSize={0} truncateLength={22} {...props} /> | ||
); | ||
|
||
const FinallyNode: React.FC<FinallyNodeProps> = ({ | ||
element, | ||
className, | ||
paddingX = 8, | ||
status, | ||
statusWidth = 16, | ||
showStatusState = true, | ||
truncateLength = 14, | ||
toolTip, | ||
disableTooltip = false, | ||
selected, | ||
children | ||
}) => { | ||
const { height, width } = element.getBounds(); | ||
const [textSize, textRef] = useSize([element.getLabel()]); | ||
const textHeight = textSize?.height ?? 0; | ||
useAnchor(RectAnchor); | ||
|
||
const truncatedName = React.useMemo(() => truncateMiddle(element.getLabel(), { length: truncateLength }), [ | ||
element, | ||
truncateLength | ||
]); | ||
const nameLabel = ( | ||
<text ref={textRef} className={css('topology-pipelines--pill__text')}> | ||
{truncatedName} | ||
</text> | ||
); | ||
|
||
const taskPill = ( | ||
<g className={css(styles.topologyPipelinesPill, className)}> | ||
<rect | ||
width={width} | ||
height={height} | ||
rx={height / 2} | ||
className={css(styles.topologyPipelinesPillBackground, selected && styles.modifiers.selected)} | ||
/> | ||
<g | ||
transform={`translate(${(status && showStatusState ? statusWidth : 0) + 2 * paddingX}, ${(height + | ||
textHeight / 2) / | ||
2})`} | ||
> | ||
{element.getLabel() !== truncatedName && !disableTooltip ? ( | ||
<Tooltip content={element.getLabel()}>{nameLabel}</Tooltip> | ||
) : ( | ||
nameLabel | ||
)} | ||
</g> | ||
{status && showStatusState && ( | ||
<g | ||
transform={`translate(${paddingX}, ${(height - statusWidth) / 2 - 1})`} | ||
width={statusWidth} | ||
height={statusWidth} | ||
> | ||
<g | ||
className={css( | ||
styles.topologyPipelinesPillStatus, | ||
getRunStatusModifier(status), | ||
(status === RunStatus.Running || status === RunStatus['In Progress']) && styles.modifiers.spin | ||
)} | ||
> | ||
<StatusIcon status={status} /> | ||
</g> | ||
</g> | ||
)} | ||
{children} | ||
</g> | ||
); | ||
|
||
return ( | ||
<g className={css('pf-topology__pipelines__task-node', className)}> | ||
{!toolTip || disableTooltip ? ( | ||
taskPill | ||
) : ( | ||
<Tooltip position="bottom" enableFlip={false} content={toolTip}> | ||
{taskPill} | ||
</Tooltip> | ||
)} | ||
</g> | ||
); | ||
}; | ||
|
||
export default observer(FinallyNode); | ||
export default FinallyNode; |
Oops, something went wrong.