Files
pruefwerk/compliance-dashboard/src/components/code_inspector.rs
T
Sharang ParnerkarandClaude Opus 5.5 c8d53d5c30 feat(dashboard): show the code graph, from its card and from a finding (t82)
The target page's code graph card links to the drawn graph, and a
finding whose location the graph has links to its impact: the entry
points that reach it, the call chains, callers and callees.

The explorer and the impact page follow the current dashboard: German
first through i18n, the target page's header, and graph colours taken
from the theme tokens, so the drawing follows the light and dark theme
and recolours on a switch.

A large graph stays usable: above 1,200 nodes it opens as one node per
group (communities of 10 or more, smaller ones pooled by folder), and a
click opens a group with its members and the groups linked to them.
The grouping runs in Rust (pages/graph_view.rs); graph-viz.js only
draws. A large drawing stops its layout after stabilising. The agent's
truncation of very large graphs is now shown.

/graph leads to the targets list; the file and search queries are
encoded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 11:24:27 +01:00

98 lines
3.9 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
use dioxus::prelude::*;
use crate::i18n::texts::graph as tx;
use crate::i18n::use_lang;
use crate::infrastructure::graph::fetch_file_content;
/// A file of the code graph, with the selected code unit's lines marked.
#[component]
pub fn CodeInspector(
repo_id: String,
file_path: String,
node_name: String,
node_kind: String,
start_line: u32,
end_line: u32,
on_close: EventHandler<()>,
) -> Element {
let lang = use_lang()();
let file_path_clone = file_path.clone();
let repo_id_clone = repo_id.clone();
let file_content = use_resource(move || {
let rid = repo_id_clone.clone();
let fp = file_path_clone.clone();
async move {
if fp.is_empty() {
return None;
}
fetch_file_content(rid, fp).await.ok()
}
});
rsx! {
div { class: "code-inspector-panel",
// Header
div { class: "code-inspector-header",
div { class: "code-inspector-title",
span { class: "code-inspector-file-name", "{file_path}" }
}
div { class: "code-inspector-meta",
span { class: "node-label-badge graph-kind-{node_kind}", {tx::kind(&node_kind).get(lang)} }
span { class: "code-inspector-node-name", "{node_name}" }
if start_line > 0 && end_line > 0 {
span { class: "code-inspector-lines", "{tx::LINES.get(lang)} {start_line}–{end_line}" }
}
}
button {
class: "btn btn-ghost btn-sm code-inspector-close",
r#type: "button",
title: tx::CLOSE.get(lang),
"aria-label": tx::CLOSE.get(lang),
onclick: move |_| on_close.call(()),
"\u{2715}"
}
}
// Content
div { class: "code-inspector-body",
match &*file_content.read() {
Some(Some(resp)) => {
let lines: Vec<&str> = resp.data.content.split('\n').collect();
rsx! {
div { class: "code-inspector-code",
for (i, line) in lines.iter().enumerate() {
{
let line_num = (i + 1) as u32;
let is_highlighted = start_line > 0
&& line_num >= start_line
&& line_num <= end_line;
let class_name = if is_highlighted {
"code-line code-line-highlight"
} else {
"code-line"
};
rsx! {
div {
class: "{class_name}",
id: if is_highlighted && line_num == start_line { "highlighted-line" } else { "" },
span { class: "code-line-number", "{line_num}" }
span { class: "code-line-content", "{line}" }
}
}
}
}
}
}
},
Some(None) => rsx! {
div { class: "code-inspector-empty", {tx::FILE_FAILED.get(lang)} }
},
None => rsx! {
div { class: "loading", {tx::FILE_LOADING.get(lang)} }
},
}
}
}
}
}