diff --git a/src/app/node.spec.ts b/src/app/node.spec.ts index f34d0b2..cbdcb98 100644 --- a/src/app/node.spec.ts +++ b/src/app/node.spec.ts @@ -168,6 +168,35 @@ describe('DAG Node', () => { const style = await stateElement.getAttribute('style'); expect(style).toContain(`background: ${customBgColor}`); })); + + it('Allows overriding the state icon color for a node', + fakeAsync(async () => { + const customStateIconColor = 'rgb(128, 0, 128)'; + const node = new DagNode('c', 'execution', 'FAILED', { + stateIconColor: customStateIconColor, + }); + fixture.componentInstance.fakeNode = node; + + const stateElement = await harness.nodeStateElement(); + const style = await stateElement.getAttribute('style'); + expect(style).toContain(`color: ${customStateIconColor}`); + })); + + it('Allows overriding the state icon color for a group', + fakeAsync(async () => { + const customStateIconColor = 'rgb(128, 0, 128)'; + const group = new DagGroup('group-id', [], [], [], 'FAILED', { + stateIconColor: customStateIconColor, + hasControlNode: true, + }); + fixture.componentInstance.fakeNode = group.generateControlNode()!; + fixture.detectChanges(); + + const stateElement = await harness.nodeStateElement(); + const style = await stateElement.getAttribute('style'); + expect(style).toContain(`color: ${customStateIconColor}`); + })); + }); describe('Internals', () => { diff --git a/src/app/node.ts b/src/app/node.ts index e391daa..ab62ff6 100644 --- a/src/app/node.ts +++ b/src/app/node.ts @@ -214,8 +214,10 @@ export class DagNodeEl implements OnInit, OnDestroy { getNodeStateColor(node: DagNode) { const {state, icon} = node; - return isNoState(state) ? - icon!.color : + if (isNoState(state)) { + return icon!.color; + } + return node.stateIconColor || this.fetchIcon(this.iconForState(state), 'color'); } diff --git a/src/app/node_spec.ts b/src/app/node_spec.ts index 28e4a01..cb83e9b 100644 --- a/src/app/node_spec.ts +++ b/src/app/node_spec.ts @@ -268,6 +268,7 @@ export class DagGroup implements callout: NodeCallout = ''; modifiers = new Set(); stateBgColor = ''; + stateIconColor = ''; stateTooltip = ''; iconTooltip = ''; subType?: unknown; @@ -298,6 +299,7 @@ export class DagGroup implements customControlNode = undefined, expanded = false, stateBgColor = '', + stateIconColor = '', stateTooltip = '', iconTooltip = '', treatAsLoop = false, @@ -326,6 +328,7 @@ export class DagGroup implements customControlNode, expanded, stateBgColor, + stateIconColor, stateTooltip, iconTooltip, subType, @@ -508,6 +511,7 @@ export interface DagNodeMeta { displayName?: string; state?: NodeState; stateBgColor?: string; + stateIconColor?: string; stateTooltip?: string; iconTooltip?: string; /** @@ -638,6 +642,7 @@ export class DagNode implements subType: unknown; state: NodeState = 'NO_STATE_STATIC'; stateBgColor: string = ''; + stateIconColor: string = ''; stateTooltip: string = ''; iconTooltip: string = ''; conditionalQuery = ''; @@ -669,6 +674,7 @@ export class DagNode implements modifiers = new Set(), callout = '', stateBgColor = '', + stateIconColor = '', stateTooltip = '', iconTooltip = '', subType = undefined, @@ -680,6 +686,7 @@ export class DagNode implements type, state, stateBgColor, + stateIconColor, stateTooltip, iconTooltip, icon: icon ? {...icon} : icon, @@ -783,6 +790,7 @@ export class DagNode implements icon, state, stateBgColor, + stateIconColor, stateTooltip, iconTooltip, options, @@ -813,6 +821,7 @@ export class DagNode implements modifiers, callout, stateBgColor, + stateIconColor, stateTooltip, iconTooltip, subType, @@ -850,6 +859,7 @@ export class DagNode implements displayName, groupLabel, stateBgColor, + stateIconColor, stateTooltip, iconTooltip, subType, @@ -877,6 +887,7 @@ export class DagNode implements displayName, groupLabel, stateBgColor, + stateIconColor, stateTooltip, iconTooltip, subType,