Skip to content

Commit

Permalink
Feature/exclude some deps from conan dependency graph (#16083)
Browse files Browse the repository at this point in the history
* basic implementation for search bar and filter bar completed

* added hover help

* fixed bug with not refreshing when using regex characters

* Using excluded instead of filter

---------

Co-authored-by: Francisco Ramirez de Anton <franchuti688@gmail.com>
  • Loading branch information
Bbox123 and franramirez688 authored Apr 16, 2024
1 parent 90f0f66 commit 11f7707
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions conan/cli/formatters/graph/info_graph_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
<label for="show_package_type">Show package type</label>
</div>
<div>
<input type="search" placeholder="Search package..." oninput="searchPackage(this)">
<input type="search" placeholder="Search packages..." oninput="searchPackages(this)">
</div>
<div>
<input type="search" placeholder="Exclude packages..." title="Add a comma to exclude an additional package" oninput="excludePackages(this)">
</div>
<div>
<input type="checkbox" onchange="showhideclass('controls')" id="show_controls"/>
Expand All @@ -60,7 +63,8 @@
const graph_data = {{ deps_graph | tojson }};
let hide_build = false;
let hide_test = false;
let search_pkg = null;
let search_pkgs = null;
let excluded_pkgs = null;
let collapse_packages = false;
let show_package_type = false;
let color_map = {Cache: "SkyBlue",
Expand Down Expand Up @@ -101,6 +105,15 @@
if (existing) continue;
collapsed_packages[label] = node_id;
}
if (excluded_pkgs) {
let patterns = excluded_pkgs.split(',')
.map(pattern => pattern.trim())
.filter(pattern => pattern.length > 0)
.map(pattern => pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
if (patterns.some(pattern => label.match(pattern))) {
continue;
}
}
if (show_package_type) {
label = "<b>" + label + "\n" + "<i>" + node.package_type + "</i>";
}
Expand All @@ -114,9 +127,15 @@
color = "Black";
shape = "circle";
}
if (search_pkg && label.match(search_pkg)) {
borderWidth = 3;
borderColor = "Magenta";
if (search_pkgs) {
let patterns = search_pkgs.split(',')
.map(pattern => pattern.trim())
.filter(pattern => pattern.length > 0)
.map(pattern => pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
if (patterns.some(pattern => label.match(pattern))) {
borderWidth = 3;
borderColor = "Magenta";
}
}
if (node.test) {
font.background = "lightgrey";
Expand Down Expand Up @@ -293,8 +312,12 @@
collapse_packages = !collapse_packages;
draw();
}
function searchPackage(e) {
search_pkg = e.value;
function searchPackages(e) {
search_pkgs = e.value;
draw();
}
function excludePackages(e) {
excluded_pkgs = e.value;
draw();
}
function showPackageType(e) {
Expand Down

0 comments on commit 11f7707

Please sign in to comment.