forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Collapse children in UI Workflow viewer (argoproj#3526)
- Loading branch information
Showing
7 changed files
with
201 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Test to ensure parameter aggregation works when every item is filtered | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: ui-parameter-aggregation-empty- | ||
spec: | ||
entrypoint: parameter-aggregation | ||
templates: | ||
- name: parameter-aggregation | ||
steps: | ||
- - name: generate | ||
template: echo | ||
withSequence: | ||
start: "1" | ||
end: "500" | ||
|
||
# echo prints a message | ||
- name: echo | ||
script: | ||
image: argoproj/argosay:v1 | ||
command: [sh, -x] | ||
source: | | ||
#!/bin/sh | ||
echo hello |
17 changes: 17 additions & 0 deletions
17
ui/src/app/workflows/components/workflow-dag/graph/collapsible-node.ts
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 @@ | ||
export function getCollapsedNodeName(parent: string, numHidden: number): string { | ||
return '@collapsed/' + parent + '/' + numHidden; | ||
} | ||
|
||
export function isCollapsedNode(id: string): boolean { | ||
return id.startsWith('@collapsed/'); | ||
} | ||
|
||
export function getCollapsedNodeParent(id: string): string { | ||
const split = id.split('/'); | ||
return split[1]; | ||
} | ||
|
||
export function getCollapsedNumHidden(id: string): number { | ||
const split = id.split('/'); | ||
return Number(split[2]); | ||
} |
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
43 changes: 43 additions & 0 deletions
43
ui/src/app/workflows/components/workflow-dag/graph/shifter.ts
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,43 @@ | ||
// This shifter is used to shift the index of the first relevant item one index to the right, and subsequent one index to the left. | ||
// | ||
// A collapsed node always gets ordered before the other children: C 1 2, C is the collapsed node and 1, 2 are child nodes. | ||
// What we want is 1 C 2. Since we must "stream" the ordering due to the way the graph code works at the moment, this class | ||
// serves to shift the index of C and 1 when so desired. It will essentially map 0 -> 1, 1 -> 0, 2 -> 2 for ordering purposes. | ||
// | ||
// Example: | ||
// | ||
// Shift: 0 1 2 3 4 ... to 0 1 3 2 4 ... | ||
// | ||
// shifter.get(0) -> 0 | ||
// shifter.get(1) -> 1 | ||
// shifter.start() | ||
// shifter.get(2) -> 3 | ||
// shifter.get(3) -> 2 | ||
// shifter.get(4) -> 4 | ||
// ... | ||
export class Shifter { | ||
private shifts: number; | ||
constructor() { | ||
this.shifts = -1; | ||
} | ||
|
||
public start(): void { | ||
if (this.shifts !== -1) { | ||
return; | ||
} | ||
this.shifts = 0; | ||
} | ||
|
||
public get(i: number): number { | ||
if (this.shifts === -1) { | ||
return i; | ||
} else if (this.shifts === 0) { | ||
this.shifts++; | ||
return i + 1; | ||
} else if (this.shifts === 1) { | ||
this.shifts = -1; | ||
return i - 1; | ||
} | ||
return i; | ||
} | ||
} |
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