Skip to content

Commit b687541

Browse files
authored
Merge pull request #105 from nanoapi-io/fix/control-bar
Fixes the control bar extension for filtering on the file-level view
2 parents 9e9e058 + ec3fa8e commit b687541

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

packages/app/src/components/Cytoscape/ControlExtensions/FiltersExtension.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState, useEffect, useRef } from "react";
2+
import { useParams } from "react-router";
23
import { Button, DropdownMenu, Checkbox } from "@radix-ui/themes";
34
import { LuChevronUp } from "react-icons/lu";
45
import { Core } from "cytoscape";
@@ -28,6 +29,7 @@ export default function FiltersExtension(props: {
2829
showFunctions: true,
2930
showClasses: true,
3031
});
32+
const { file } = useParams();
3133

3234
function checkFiltersSet() {
3335
if (!filters) return false;
@@ -83,7 +85,7 @@ export default function FiltersExtension(props: {
8385

8486
// Grab only the external nodes
8587
const nodes = props.cy.nodes().filter((node) => {
86-
return node.data("isExternal");
88+
return node.data("customData").isExternal;
8789
});
8890

8991
if (filters.showExternal) {
@@ -99,7 +101,10 @@ export default function FiltersExtension(props: {
99101

100102
// Grab only the internal nodes
101103
const nodes = props.cy.nodes().filter((node) => {
102-
return !node.data("isExternal") && !node.data("isCurrentFile");
104+
return (
105+
!node.data("customData").isExternal &&
106+
node.data("customData").fileName !== file
107+
);
103108
});
104109
if (filters.showInternal) {
105110
nodes.removeClass("hidden");
@@ -115,8 +120,8 @@ export default function FiltersExtension(props: {
115120
// Grab only the variable nodes
116121
const nodes = props.cy.nodes().filter((node) => {
117122
return (
118-
node.data("customData").instance?.type === "variable" &&
119-
node.data("isCurrentFile")
123+
node.data("customData").symbolType === "variable" &&
124+
node.data("customData").fileName === file
120125
);
121126
});
122127
if (filters.showVariables) {
@@ -133,8 +138,8 @@ export default function FiltersExtension(props: {
133138
// Grab only the function nodes
134139
const nodes = props.cy.nodes().filter((node) => {
135140
return (
136-
node.data("customData").instance?.type === "function" &&
137-
node.data("isCurrentFile")
141+
node.data("customData").symbolType === "function" &&
142+
node.data("customData").fileName === file
138143
);
139144
});
140145
if (filters.showFunctions) {
@@ -151,8 +156,8 @@ export default function FiltersExtension(props: {
151156
// Grab only the class nodes
152157
const nodes = props.cy.nodes().filter((node) => {
153158
return (
154-
node.data("customData").instance?.type === "class" &&
155-
node.data("isCurrentFile")
159+
node.data("customData").symbolType === "class" &&
160+
node.data("customData").fileName === file
156161
);
157162
});
158163

packages/app/src/helpers/cytoscape/fileDependencyVisualizer/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,12 @@ export class FileDependencyVisualizer {
738738
"line-opacity": 0.1,
739739
},
740740
},
741+
{
742+
selector: ".hidden",
743+
style: {
744+
display: "none",
745+
},
746+
},
741747
] as StylesheetJson;
742748
}
743749
}

packages/app/src/helpers/cytoscape/projectDependencyVisualizer/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,12 @@ export class ProjectDependencyVisualizer {
395395
"line-opacity": 0.1,
396396
},
397397
},
398+
{
399+
selector: ".hidden",
400+
style: {
401+
display: "none",
402+
},
403+
},
398404
] as StylesheetJson;
399405
}
400406

packages/app/src/pages/audit/file/instance/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ export default function AuditInstancePage() {
155155
<CytoscapeSkeleton />
156156
) : (
157157
<Controls busy={false} cy={cyInstance} onLayout={handleLayout}>
158+
{/* TODO: Fix data shape for instane-level view and then uncomment */}
159+
{/* <FiltersExtension
160+
cy={cyInstance}
161+
busy={context.busy}
162+
onLayout={handleLayout}
163+
/> */}
158164
<GraphDepthExtension
159165
cy={cyInstance}
160166
busy={context.busy}

packages/app/src/pages/audit/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export default function AuditPage() {
9494

9595
// Hook to update the target metric in the graph
9696
useEffect(() => {
97+
console.log("Updating target metric", metric);
9798
if (projectVisualizer) {
9899
projectVisualizer.setTargetMetric(metric);
99100
}

0 commit comments

Comments
 (0)