Files
pruefwerk/compliance-dashboard/src/components/copy_button.rs
T
Sharang ParnerkarandClaude Opus 5.5 9119dcdd9d feat(dashboard): CRA requirements by name, no off-site advisory links
The 40 CRA Annex I requirements are shown by a name customers read
("Keine Standardpasswörter") instead of cra-ai-N, grouped by area on a
map; a requirement opens beside it with what red, orange and green mean
for that requirement, or the document that proves it.

- compliance-core: cra_requirements table (names, state meanings, proof
  documents, DE/EN) and AdvisoryRef::required_backlink (Siemens only)
- dashboard: CRA map with area cards and side panel; names in the
  compliance list, findings list and finding detail; "not checked yet" is
  grey, orange means partly checked only
- no links to OSV, GHSA, NVD or other advisory sites: CVE and advisory
  ids get a copy button; only a provider whose terms require a backlink
  keeps a "Quelle" link; off-site links in rendered markdown become text
- agent: ticket texts name requirements; CVE tickets and notifications
  no longer carry an osv.dev link; findings.csv adds requirement names
- machine-readable exports (CSAF, VEX, OSCAL, JSON) keep the ids

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
2026-11-27 23:23:14 +01:00

62 lines
1.9 KiB
Rust

use dioxus::prelude::*;
use dioxus_free_icons::icons::bs_icons::*;
use dioxus_free_icons::Icon;
use crate::i18n::texts::common;
use crate::i18n::use_lang;
/// A small copy-to-clipboard button that shows a checkmark after copying.
///
/// Usage: `CopyButton { value: "text to copy" }`
#[component]
pub fn CopyButton(value: String, #[props(default = false)] small: bool) -> Element {
let lang = use_lang()();
let mut copied = use_signal(|| false);
let label = if copied() {
common::COPIED
} else {
common::COPY
};
let tip = format!("{}: {value}", label.get(lang));
let size = if small { 12 } else { 14 };
let class = if small {
"copy-btn copy-btn-sm"
} else {
"copy-btn"
};
rsx! {
button {
class: class,
r#type: "button",
title: "{tip}",
"aria-label": "{tip}",
onclick: move |_| {
let val = value.clone();
// Escape for JS single-quoted string
let escaped = val
.replace('\\', "\\\\")
.replace('\'', "\\'")
.replace('\n', "\\n")
.replace('\r', "\\r");
let js = format!("navigator.clipboard.writeText('{escaped}')");
document::eval(&js);
copied.set(true);
spawn(async move {
#[cfg(feature = "web")]
gloo_timers::future::TimeoutFuture::new(2000).await;
#[cfg(not(feature = "web"))]
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
copied.set(false);
});
},
if copied() {
Icon { icon: BsCheckLg, width: size, height: size }
} else {
Icon { icon: BsClipboard, width: size, height: size }
}
}
}
}