CI / Check (push) Skipped
CI / Agent integration (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Docs (push) Skipped
CI / Deploy MCP (push) Successful in 6m2s
CI / Deploy Agent (push) Successful in 12m25s
CI / Deploy Dashboard (push) Successful in 14m42s
The Prüfwerk views name each CRA requirement and what green, orange and red mean, in a map by area. Off-site advisory links become copy buttons; a "Quelle" link stays only where the provider requires a backlink (Siemens ProductCERT). Ticket texts and the readable evidence pack use the names; machine-readable exports keep their IDs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
62 lines
1.9 KiB
Rust
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 }
|
|
}
|
|
}
|
|
}
|
|
}
|