From 8e1c0a8d4fb32a91e898389a560500b99ed826cd Mon Sep 17 00:00:00 2001 From: Jenny <32821331+jenny-s51@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:03:15 -0400 Subject: [PATCH] feat(DefaultTaskGroup): support status feat(DefaultTaskGroup): support status feat(DefaultTaskGroup): support status feat(DefaultTaskGroup): support status feat(DefaultTaskGroup): support status --- .../pipelineGroupsDemo/DemoTaskGroup.tsx | 8 ++- .../components/groups/DefaultTaskGroup.tsx | 62 +++++++++++-------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/packages/demo-app-ts/src/demos/pipelineGroupsDemo/DemoTaskGroup.tsx b/packages/demo-app-ts/src/demos/pipelineGroupsDemo/DemoTaskGroup.tsx index 31c4315e..ddd70b02 100644 --- a/packages/demo-app-ts/src/demos/pipelineGroupsDemo/DemoTaskGroup.tsx +++ b/packages/demo-app-ts/src/demos/pipelineGroupsDemo/DemoTaskGroup.tsx @@ -14,7 +14,9 @@ import { ScaleDetailsLevel, DEFAULT_LAYER, Layer, - TOP_LAYER, GROUPS_LAYER + TOP_LAYER, + GROUPS_LAYER, + RunStatus } from '@patternfly/react-topology'; type DemoTaskGroupProps = { @@ -33,6 +35,7 @@ const DemoTaskGroup: React.FunctionComponent = ({ element, . const verticalLayout = (element.getGraph().getLayoutOptions?.() as DagreLayoutOptions)?.rankdir === TOP_TO_BOTTOM; const [hover, hoverRef] = useHover(); const detailsLevel = element.getGraph().getDetailsLevel(); + const data = element.getData(); if (!isNode(element)) { return null; @@ -53,6 +56,9 @@ const DemoTaskGroup: React.FunctionComponent = ({ element, . scaleNode={hover && detailsLevel !== ScaleDetailsLevel.high} showLabel={detailsLevel === ScaleDetailsLevel.high} hideDetailsAtMedium + showStatusState + status={data.status} + hiddenDetailsShownStatuses={[RunStatus.Succeeded]} {...rest} /> diff --git a/packages/module/src/pipelines/components/groups/DefaultTaskGroup.tsx b/packages/module/src/pipelines/components/groups/DefaultTaskGroup.tsx index 16700adf..948fd552 100644 --- a/packages/module/src/pipelines/components/groups/DefaultTaskGroup.tsx +++ b/packages/module/src/pipelines/components/groups/DefaultTaskGroup.tsx @@ -1,11 +1,6 @@ import * as React from 'react'; import { observer } from 'mobx-react'; -import { - OnSelect, - WithDndDragProps, - ConnectDragSource, - ConnectDropTarget, -} from '../../../behavior'; +import { OnSelect, WithDndDragProps, ConnectDragSource, ConnectDropTarget } from '../../../behavior'; import { ShapeProps } from '../../../components'; import { Dimensions } from '../../../geom'; import { GraphElement, LabelPosition, BadgeLocation, isNode, Node } from '../../../types'; @@ -13,6 +8,7 @@ import { action } from '../../../mobx-exports'; import { getEdgesFromNodes, getSpacerNodes } from '../../utils'; import DefaultTaskGroupCollapsed from './DefaultTaskGroupCollapsed'; import DefaultTaskGroupExpanded from './DefaultTaskGroupExpanded'; +import { RunStatus } from '../../types'; export interface EdgeCreationTypes { spacerNodeType?: string; @@ -39,6 +35,12 @@ export interface DefaultTaskGroupProps { dragging?: boolean; /** Flag if drag operation is a regroup operation */ dragRegroupable?: boolean; + /** RunStatus to depict, supported on collapsed groups only. */ + status?: RunStatus; + /** Flag indicating the status indicator, supported on collapsed groups only */ + showStatusState?: boolean; + /** Statuses to show at when details are hidden, supported on collapsed groups only */ + hiddenDetailsShownStatuses?: RunStatus[]; /** Flag indicating the node should be scaled, best on hover of the node at lowest scale level */ scaleNode?: boolean; /** Flag to hide details at medium scale */ @@ -117,16 +119,17 @@ export interface DefaultTaskGroupProps { type PipelinesDefaultGroupInnerProps = Omit & { element: Node }; -const DefaultTaskGroupInner: React.FunctionComponent = observer(({ - className, - element, - badge, - onCollapseChange, - collapsedShadowCount, - recreateLayoutOnCollapseChange, - getEdgeCreationTypes, - ...rest -}) => { +const DefaultTaskGroupInner: React.FunctionComponent = observer( + ({ + className, + element, + badge, + onCollapseChange, + collapsedShadowCount, + recreateLayoutOnCollapseChange, + getEdgeCreationTypes, + ...rest + }) => { const childCount = element.getAllNodeChildren().length; const handleCollapse = action((group: Node, collapsed: boolean): void => { @@ -141,11 +144,17 @@ const DefaultTaskGroupInner: React.FunctionComponent n.type !== creationTypes.spacerNodeType).map((n) => ({ + const pipelineNodes = model.nodes + .filter((n) => n.type !== creationTypes.spacerNodeType) + .map((n) => ({ ...n, visible: true })); - const spacerNodes = getSpacerNodes(pipelineNodes, creationTypes.spacerNodeType, creationTypes.finallyNodeTypes); + const spacerNodes = getSpacerNodes( + pipelineNodes, + creationTypes.spacerNodeType, + creationTypes.finallyNodeTypes + ); const nodes = [...pipelineNodes, ...spacerNodes]; const edges = getEdgesFromNodes( pipelineNodes, @@ -176,6 +185,7 @@ const DefaultTaskGroupInner: React.FunctionComponent = ({ throw new Error('DefaultTaskGroup must be used only on Node elements'); } - return ; + return ( + + ); }; export default DefaultTaskGroup;