Skip to content

Commit

Permalink
fix(ui): Group Nodes breaks Kinds counts / views (argoproj#21337)
Browse files Browse the repository at this point in the history
* groupview-filter-fix

Signed-off-by: Surajyadav <[email protected]>

* count-logic-change

Signed-off-by: Surajyadav <[email protected]>

* lint-fixes

Signed-off-by: Surajyadav <[email protected]>

---------

Signed-off-by: Surajyadav <[email protected]>
Signed-off-by: Brett C. Dudo <[email protected]>
  • Loading branch information
surajyadav1108 authored and dudo committed Jan 18, 2025
1 parent 53ff916 commit 6f762cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const Filters = (props: FiltersProps) => {
case 'Health':
return props.resourceNodes.filter(res => res.health?.status === HealthStatuses[label]).length;
case 'Kind':
return props.resourceNodes.filter(res => res.kind === label).length;
return props.resourceNodes.reduce((count, res) => (res.group && label === 'Pod' ? res.group.length : res.kind === label ? count + 1 : count), 0);
default:
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,16 @@ export const ApplicationResourceTree = (props: ApplicationResourceTreeProps) =>
graphNodesFilter.nodes().forEach(nodeId => {
const node: ResourceTreeNode = graphNodesFilter.node(nodeId) as any;
const parentIds = graphNodesFilter.predecessors(nodeId);
if (node.root != null && !predicate(node) && appKey !== nodeId) {

const shouldKeepNode = () => {
//case for podgroup in group node view
if (node.podGroup) {
return predicate(node) || node.podGroup.pods.some(pod => predicate({...node, kind: 'Pod', name: pod.name}));
}
return predicate(node);
};

if (node.root != null && !shouldKeepNode() && appKey !== nodeId) {
const childIds = graphNodesFilter.successors(nodeId);
graphNodesFilter.removeNode(nodeId);
filtered++;
Expand All @@ -939,8 +948,14 @@ export const ApplicationResourceTree = (props: ApplicationResourceTreeProps) =>
if (node.root != null) filteredNodes.push(node);
}
});

if (filtered) {
graphNodesFilter.setNode(FILTERED_INDICATOR_NODE, {height: NODE_HEIGHT, width: NODE_WIDTH, count: filtered, type: NODE_TYPES.filteredIndicator});
graphNodesFilter.setNode(FILTERED_INDICATOR_NODE, {
height: NODE_HEIGHT,
width: NODE_WIDTH,
count: filtered,
type: NODE_TYPES.filteredIndicator
});
graphNodesFilter.setEdge(filteredIndicatorParent, FILTERED_INDICATOR_NODE);
}
}
Expand Down

0 comments on commit 6f762cc

Please sign in to comment.