Skip to content

Commit 8759db1

Browse files
feat(DefaultTaskGroup): Allow for a custom status icon in DefaultTaskGroup (patternfly#242)
1 parent be4fc91 commit 8759db1

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

packages/demo-app-ts/src/demos/pipelineGroupsDemo/DemoTaskGroup.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
RunStatus,
1616
TaskGroupPillLabel
1717
} from '@patternfly/react-topology';
18+
import { BanIcon } from '@patternfly/react-icons';
1819
import { DEFAULT_TASK_HEIGHT, GROUP_TASK_WIDTH } from './createDemoPipelineGroupsNodes';
1920

2021
type DemoTaskGroupProps = {
@@ -43,12 +44,18 @@ const DemoTaskGroup: React.FunctionComponent<DemoTaskGroupProps> = ({ element, .
4344
collapsible
4445
collapsedWidth={GROUP_TASK_WIDTH}
4546
collapsedHeight={DEFAULT_TASK_HEIGHT}
46-
GroupLabelComponent={TaskGroupPillLabel}
47+
GroupLabelComponent={(props) => (
48+
<TaskGroupPillLabel
49+
{...props}
50+
customStatusIcon={data.status === RunStatus.Cancelled ? <BanIcon /> : undefined}
51+
/>
52+
)}
4753
element={element as Node}
4854
centerLabelOnEdge
4955
recreateLayoutOnCollapseChange
5056
getEdgeCreationTypes={getEdgeCreationTypes}
5157
scaleNode={hover && detailsLevel !== ScaleDetailsLevel.high}
58+
customStatusIcon={data.status === RunStatus.Cancelled ? <BanIcon /> : undefined}
5259
showLabelOnHover
5360
hideDetailsAtMedium
5461
showStatusState

packages/demo-app-ts/src/demos/pipelineGroupsDemo/DemoTaskNode.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import {
44
DEFAULT_LAYER,
55
GraphElement,
66
Layer,
7+
RunStatus,
78
ScaleDetailsLevel,
89
TaskNode,
910
TOP_LAYER,
1011
useHover,
1112
WithContextMenuProps,
1213
WithSelectionProps
1314
} from '@patternfly/react-topology';
15+
import { BanIcon } from '@patternfly/react-icons';
1416

1517
type DemoTaskNodeProps = {
1618
element: GraphElement;
@@ -31,6 +33,7 @@ const DemoTaskNode: React.FunctionComponent<DemoTaskNodeProps> = ({ element, ...
3133
showStatusState
3234
status={data.status}
3335
hideDetailsAtMedium
36+
customStatusIcon={data.status === RunStatus.Cancelled ? <BanIcon /> : undefined}
3437
{...rest}
3538
/>
3639
</g>

packages/demo-app-ts/src/demos/pipelineGroupsDemo/createDemoPipelineGroupsNodes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export const createExecution3 = (runAfter?: string): [string, PipelineNodeModel[
159159
},
160160
runAfterTasks: [task_3_1.id],
161161
data: {
162-
status: RunStatus.Succeeded,
162+
status: RunStatus.Cancelled,
163163
isDependency: true
164164
}
165165
};
@@ -294,7 +294,7 @@ export const createExecution3 = (runAfter?: string): [string, PipelineNodeModel[
294294
padding: [NODE_PADDING_VERTICAL, NODE_PADDING_HORIZONTAL]
295295
},
296296
data: {
297-
status: RunStatus.Succeeded,
297+
status: RunStatus.Cancelled,
298298
isDependency: true
299299
}
300300
};

packages/module/src/pipelines/components/groups/DefaultTaskGroup.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export interface DefaultTaskGroupProps {
4343
showStatusState?: boolean;
4444
/** Statuses to show at when details are hidden, supported on collapsed groups only */
4545
hiddenDetailsShownStatuses?: RunStatus[];
46+
/** Custom icon to use as the status icon (for collapsed groups, or if using a GroupLabelComponent that accepts a customStatus icon, such as TaskGroupPillLabel). */
47+
customStatusIcon?: React.ReactNode;
4648
/** Flag indicating the node should be scaled, best on hover of the node at lowest scale level */
4749
scaleNode?: boolean;
4850
/** Flag to hide details at medium scale */

0 commit comments

Comments
 (0)