feat(dashboard): German by default, English switchable (#336)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 7m55s
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 7m55s
The pilot customer works in German; the dashboard was English only.
- i18n module: every UI string is a `Text { de, en }` constant, so a
missing translation is a compile error and both versions are reviewed
side by side. German is the default; the choice is kept in the browser
and applied after hydration, and `<html lang>` follows it.
- Language toggle in the sidebar footer, next to the theme toggle.
- Translated: sidebar, theme toggle, overview. The other pages follow as
they are reworked for the pilot.
- Sidebar: runtime-only items in a source-only deployment are no longer
links; Impressum and Datenschutz point at breakpilot.com (build args
IMPRINT_URL / PRIVACY_URL) instead of dashboard routes that did not
exist; the header says Prüfwerk.
- Overview: an empty tenant gets a call to add its first target; the AI
chat and MCP cards are not shown in a source-only deployment.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
1 parent
dae80043e6
commit
6aa91d07bf
10 files changed
+528
-64
No files matched your search
@@ -3,10 +3,15 @@ FROM rust:1.94-bookworm AS builder
|
||||
RUN cargo install dioxus-cli --version 0.7.3 --locked
|
||||
|
||||
ARG DOCS_URL=/docs
|
||||
# Legal pages linked from the sidebar; the defaults are breakpilot.com's.
|
||||
ARG IMPRINT_URL=https://breakpilot.com/impressum
|
||||
ARG PRIVACY_URL=https://breakpilot.com/datenschutz
|
||||
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
ENV DOCS_URL=${DOCS_URL}
|
||||
ENV DOCS_URL=${DOCS_URL} \
|
||||
IMPRINT_URL=${IMPRINT_URL} \
|
||||
PRIVACY_URL=${PRIVACY_URL}
|
||||
# compliance-agent (a workspace member) depends on the private firmwerk git
|
||||
# repo, so the workspace resolve needs it even to build the dashboard.
|
||||
# Authenticate the fetch with a PAT passed as a BuildKit secret.
|
||||
|
||||
@@ -11,6 +11,7 @@ use crate::infrastructure::platform::{fetch_platform_info, PlatformInfo};
|
||||
#[component]
|
||||
pub fn AppShell() -> Element {
|
||||
use_context_provider(Toasts::new);
|
||||
crate::i18n::provide_lang();
|
||||
|
||||
// Agent contract handshake (features such as `source_only`). Provided
|
||||
// app-wide so pages can hide runtime-only surfaces; defaults to the
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_free_icons::icons::bs_icons::BsTranslate;
|
||||
use dioxus_free_icons::Icon;
|
||||
|
||||
use crate::i18n::texts::nav;
|
||||
use crate::i18n::{set_lang, use_lang};
|
||||
|
||||
/// Sidebar-footer switch between German and English. Shows the language it
|
||||
/// switches to, so a reader who does not understand the current one can still
|
||||
/// find it.
|
||||
#[component]
|
||||
pub fn LangToggle(collapsed: bool) -> Element {
|
||||
let lang = use_lang();
|
||||
let current = lang();
|
||||
let target = current.other();
|
||||
let title = nav::SWITCH_LANGUAGE.get(current);
|
||||
|
||||
rsx! {
|
||||
button {
|
||||
class: "theme-toggle",
|
||||
r#type: "button",
|
||||
title: "{title}",
|
||||
"aria-label": "{title}",
|
||||
onclick: move |_| set_lang(lang, target),
|
||||
Icon { icon: BsTranslate, width: 16, height: 16 }
|
||||
if !collapsed {
|
||||
span { class: "theme-toggle-label", "{target.code().to_uppercase()}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ pub mod copy_button;
|
||||
pub mod demo_targets;
|
||||
pub mod file_tree;
|
||||
pub mod help_chat;
|
||||
pub mod lang_toggle;
|
||||
pub mod notification_bell;
|
||||
pub mod page_header;
|
||||
pub mod pagination;
|
||||
|
||||
@@ -4,11 +4,24 @@ use dioxus_free_icons::icons::bs_icons::*;
|
||||
use dioxus_free_icons::Icon;
|
||||
|
||||
use crate::app::Route;
|
||||
use crate::components::lang_toggle::LangToggle;
|
||||
use crate::components::theme_toggle::ThemeToggle;
|
||||
use crate::infrastructure::platform::{use_source_only, SOURCE_ONLY_NOTE};
|
||||
use crate::i18n::texts::{common, nav};
|
||||
use crate::i18n::{use_lang, Text};
|
||||
use crate::infrastructure::platform::use_source_only;
|
||||
|
||||
/// Where the legal pages live. Overridable per build, like `DOCS_URL`.
|
||||
const IMPRINT_URL: &str = match option_env!("IMPRINT_URL") {
|
||||
Some(url) => url,
|
||||
None => "https://breakpilot.com/impressum",
|
||||
};
|
||||
const PRIVACY_URL: &str = match option_env!("PRIVACY_URL") {
|
||||
Some(url) => url,
|
||||
None => "https://breakpilot.com/datenschutz",
|
||||
};
|
||||
|
||||
struct NavItem {
|
||||
label: &'static str,
|
||||
label: Text,
|
||||
route: Route,
|
||||
icon: Element,
|
||||
/// Needs a runtime (browser / live target); disabled in source-only mode.
|
||||
@@ -20,52 +33,53 @@ pub fn Sidebar() -> Element {
|
||||
let current_route = use_route::<Route>();
|
||||
let mut collapsed = use_signal(|| true);
|
||||
let source_only = use_source_only();
|
||||
let lang = use_lang()();
|
||||
|
||||
let nav_items = [
|
||||
NavItem {
|
||||
label: "Overview",
|
||||
label: nav::OVERVIEW,
|
||||
route: Route::OverviewPage {},
|
||||
icon: rsx! { Icon { icon: BsSpeedometer2, width: 18, height: 18 } },
|
||||
runtime_only: false,
|
||||
},
|
||||
NavItem {
|
||||
label: "Targets",
|
||||
label: nav::TARGETS,
|
||||
route: Route::TargetsPage {},
|
||||
icon: rsx! { Icon { icon: BsFolder2Open, width: 18, height: 18 } },
|
||||
runtime_only: false,
|
||||
},
|
||||
NavItem {
|
||||
label: "Onboard",
|
||||
label: nav::ONBOARD,
|
||||
route: Route::OnboardingPage {},
|
||||
icon: rsx! { Icon { icon: BsPlusCircle, width: 18, height: 18 } },
|
||||
runtime_only: false,
|
||||
},
|
||||
NavItem {
|
||||
label: "Findings",
|
||||
label: nav::FINDINGS,
|
||||
route: Route::FindingsPage {},
|
||||
icon: rsx! { Icon { icon: BsShieldExclamation, width: 18, height: 18 } },
|
||||
runtime_only: false,
|
||||
},
|
||||
NavItem {
|
||||
label: "SBOM",
|
||||
label: nav::SBOM,
|
||||
route: Route::SbomPage {},
|
||||
icon: rsx! { Icon { icon: BsBoxSeam, width: 18, height: 18 } },
|
||||
runtime_only: false,
|
||||
},
|
||||
NavItem {
|
||||
label: "Issues",
|
||||
label: nav::ISSUES,
|
||||
route: Route::IssuesPage {},
|
||||
icon: rsx! { Icon { icon: BsListTask, width: 18, height: 18 } },
|
||||
runtime_only: false,
|
||||
},
|
||||
NavItem {
|
||||
label: "DAST",
|
||||
label: nav::DAST,
|
||||
route: Route::DastOverviewPage {},
|
||||
icon: rsx! { Icon { icon: BsBug, width: 18, height: 18 } },
|
||||
runtime_only: true,
|
||||
},
|
||||
NavItem {
|
||||
label: "Pentest",
|
||||
label: nav::PENTEST,
|
||||
route: Route::PentestDashboardPage {},
|
||||
icon: rsx! { Icon { icon: BsLightningCharge, width: 18, height: 18 } },
|
||||
runtime_only: true,
|
||||
@@ -85,7 +99,7 @@ pub fn Sidebar() -> Element {
|
||||
div { class: "sidebar-header",
|
||||
Icon { icon: BsShieldCheck, width: 24, height: 24 }
|
||||
if !collapsed() {
|
||||
h1 { "Compliance Scanner" }
|
||||
h1 { "Prüfwerk" }
|
||||
}
|
||||
}
|
||||
div { class: "sidebar-nav",
|
||||
@@ -107,18 +121,34 @@ pub fn Sidebar() -> Element {
|
||||
} else {
|
||||
"nav-item"
|
||||
};
|
||||
let title = if disabled { SOURCE_ONLY_NOTE } else { item.label };
|
||||
rsx! {
|
||||
Link {
|
||||
to: item.route.clone(),
|
||||
class: class,
|
||||
title: "{title}",
|
||||
aria_disabled: disabled,
|
||||
{item.icon}
|
||||
if !collapsed() {
|
||||
span { "{item.label}" }
|
||||
if disabled {
|
||||
span { style: "font-size: 0.7em; opacity: 0.8; margin-left: auto;", "n/a" }
|
||||
let label = item.label.get(lang);
|
||||
if disabled {
|
||||
// Not a link: a runtime-only page cannot be opened
|
||||
// here, so it must not look or act like it can.
|
||||
let title = common::NOT_AVAILABLE_HERE.get(lang);
|
||||
rsx! {
|
||||
span {
|
||||
class: class,
|
||||
title: "{title}",
|
||||
aria_disabled: "true",
|
||||
{item.icon}
|
||||
if !collapsed() {
|
||||
span { "{label}" }
|
||||
span { style: "font-size: 0.7em; opacity: 0.8; margin-left: auto;",
|
||||
{nav::NOT_AVAILABLE_SHORT.get(lang)}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rsx! {
|
||||
Link {
|
||||
to: item.route.clone(),
|
||||
class: class,
|
||||
title: "{label}",
|
||||
{item.icon}
|
||||
if !collapsed() {
|
||||
span { "{label}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,11 +162,12 @@ pub fn Sidebar() -> Element {
|
||||
class: "nav-item",
|
||||
Icon { icon: BsBook, width: 18, height: 18 }
|
||||
if !collapsed() {
|
||||
span { "Docs" }
|
||||
span { {nav::DOCS.get(lang)} }
|
||||
}
|
||||
}
|
||||
// Spacer pushes footer to the bottom
|
||||
div { class: "sidebar-spacer" }
|
||||
LangToggle { collapsed: collapsed() }
|
||||
ThemeToggle { collapsed: collapsed() }
|
||||
button {
|
||||
class: "sidebar-toggle",
|
||||
@@ -166,7 +197,7 @@ pub fn Sidebar() -> Element {
|
||||
a {
|
||||
href: "/logout",
|
||||
class: "logout-link",
|
||||
"Sign out"
|
||||
{nav::SIGN_OUT.get(lang)}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,16 +205,16 @@ pub fn Sidebar() -> Element {
|
||||
a {
|
||||
href: "/logout",
|
||||
class: "logout-btn-icon",
|
||||
title: "Sign out",
|
||||
title: nav::SIGN_OUT.get(lang),
|
||||
Icon { icon: BsBoxArrowRight, width: 14, height: 14 }
|
||||
}
|
||||
}
|
||||
}
|
||||
if !collapsed() {
|
||||
div { class: "sidebar-legal",
|
||||
a { href: "/privacy", "Privacy" }
|
||||
a { href: PRIVACY_URL, target: "_blank", rel: "noopener", {nav::PRIVACY.get(lang)} }
|
||||
span { class: "legal-dot", "·" }
|
||||
a { href: "/impressum", "Impressum" }
|
||||
a { href: IMPRINT_URL, target: "_blank", rel: "noopener", {nav::IMPRINT.get(lang)} }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ use dioxus::prelude::*;
|
||||
use dioxus_free_icons::icons::bs_icons::{BsMoonStars, BsSun};
|
||||
use dioxus_free_icons::Icon;
|
||||
|
||||
use crate::i18n::texts::nav;
|
||||
use crate::i18n::use_lang;
|
||||
|
||||
#[cfg(feature = "web")]
|
||||
const STORAGE_KEY: &str = "compliance-scanner.theme";
|
||||
|
||||
@@ -25,18 +28,19 @@ pub fn ThemeToggle(collapsed: bool) -> Element {
|
||||
}
|
||||
});
|
||||
|
||||
let lang = use_lang()();
|
||||
let label = if collapsed {
|
||||
""
|
||||
} else if is_dark().unwrap_or(true) {
|
||||
"Light mode"
|
||||
nav::LIGHT_MODE.get(lang)
|
||||
} else {
|
||||
"Dark mode"
|
||||
nav::DARK_MODE.get(lang)
|
||||
};
|
||||
|
||||
let title = if is_dark().unwrap_or(true) {
|
||||
"Switch to light mode"
|
||||
nav::SWITCH_TO_LIGHT.get(lang)
|
||||
} else {
|
||||
"Switch to dark mode"
|
||||
nav::SWITCH_TO_DARK.get(lang)
|
||||
};
|
||||
|
||||
rsx! {
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
//! German and English UI text.
|
||||
//!
|
||||
//! Every visible string is a [`Text`] constant holding both languages side by
|
||||
//! side, so a missing translation is a compile error (a struct literal must
|
||||
//! name every field) and a reviewer reads both versions in one place. German
|
||||
//! is the default; the choice is kept in the browser's `localStorage`.
|
||||
//!
|
||||
//! Scanner output (rule titles and descriptions) stays as the tools write it.
|
||||
|
||||
pub mod texts;
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
#[cfg(feature = "web")]
|
||||
const STORAGE_KEY: &str = "pruefwerk.lang";
|
||||
|
||||
/// A UI language.
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||
pub enum Lang {
|
||||
/// German, the default for our customers.
|
||||
#[default]
|
||||
De,
|
||||
/// English.
|
||||
En,
|
||||
}
|
||||
|
||||
impl Lang {
|
||||
/// The BCP 47 tag, for `<html lang>` and storage.
|
||||
pub const fn code(self) -> &'static str {
|
||||
match self {
|
||||
Self::De => "de",
|
||||
Self::En => "en",
|
||||
}
|
||||
}
|
||||
|
||||
/// The language a stored code names, if any.
|
||||
pub fn from_code(code: &str) -> Option<Self> {
|
||||
match code {
|
||||
"de" => Some(Self::De),
|
||||
"en" => Some(Self::En),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The other language, for the toggle.
|
||||
pub const fn other(self) -> Self {
|
||||
match self {
|
||||
Self::De => Self::En,
|
||||
Self::En => Self::De,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One piece of UI text in every language.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Text {
|
||||
/// German.
|
||||
pub de: &'static str,
|
||||
/// English.
|
||||
pub en: &'static str,
|
||||
}
|
||||
|
||||
impl Text {
|
||||
/// The text in `lang`.
|
||||
pub const fn get(&self, lang: Lang) -> &'static str {
|
||||
match lang {
|
||||
Lang::De => self.de,
|
||||
Lang::En => self.en,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Provide the language to the whole app. Call once, in the app shell.
|
||||
///
|
||||
/// Server rendering and the first client render use German so hydration
|
||||
/// matches; a stored choice is applied right after, since `localStorage`
|
||||
/// only exists in the browser.
|
||||
pub fn provide_lang() -> Signal<Lang> {
|
||||
let mut lang = use_context_provider(|| Signal::new(Lang::default()));
|
||||
use_effect(move || {
|
||||
if let Some(stored) = stored_lang() {
|
||||
lang.set(stored);
|
||||
}
|
||||
});
|
||||
lang
|
||||
}
|
||||
|
||||
/// The current language (a `Signal`, so readers re-render when it changes).
|
||||
pub fn use_lang() -> Signal<Lang> {
|
||||
use_context::<Signal<Lang>>()
|
||||
}
|
||||
|
||||
/// Switch the app to `next` and remember the choice in this browser.
|
||||
pub fn set_lang(mut lang: Signal<Lang>, next: Lang) {
|
||||
lang.set(next);
|
||||
store_lang(next);
|
||||
}
|
||||
|
||||
#[cfg(feature = "web")]
|
||||
fn stored_lang() -> Option<Lang> {
|
||||
let storage = web_sys::window()?.local_storage().ok()??;
|
||||
let code = storage.get_item(STORAGE_KEY).ok()??;
|
||||
let lang = Lang::from_code(&code)?;
|
||||
set_document_lang(lang);
|
||||
Some(lang)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "web"))]
|
||||
fn stored_lang() -> Option<Lang> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "web")]
|
||||
fn store_lang(lang: Lang) {
|
||||
if let Some(window) = web_sys::window() {
|
||||
if let Ok(Some(storage)) = window.local_storage() {
|
||||
let _ = storage.set_item(STORAGE_KEY, lang.code());
|
||||
}
|
||||
}
|
||||
set_document_lang(lang);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "web"))]
|
||||
fn store_lang(_lang: Lang) {}
|
||||
|
||||
/// Keep `<html lang>` in step, for screen readers and hyphenation.
|
||||
#[cfg(feature = "web")]
|
||||
fn set_document_lang(lang: Lang) {
|
||||
if let Some(root) = web_sys::window()
|
||||
.and_then(|w| w.document())
|
||||
.and_then(|d| d.document_element())
|
||||
{
|
||||
let _ = root.set_attribute("lang", lang.code());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn german_is_the_default() {
|
||||
assert_eq!(Lang::default(), Lang::De);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codes_round_trip() {
|
||||
for lang in [Lang::De, Lang::En] {
|
||||
assert_eq!(Lang::from_code(lang.code()), Some(lang));
|
||||
assert_eq!(lang.other().other(), lang);
|
||||
}
|
||||
assert_eq!(Lang::from_code("fr"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn text_picks_the_language() {
|
||||
let t = Text {
|
||||
de: "Übersicht",
|
||||
en: "Overview",
|
||||
};
|
||||
assert_eq!(t.get(Lang::De), "Übersicht");
|
||||
assert_eq!(t.get(Lang::En), "Overview");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
//! The UI text, grouped by where it appears.
|
||||
//!
|
||||
//! Terms used throughout: a *target* is a „Prüfobjekt“, a *finding* a
|
||||
//! „Befund“, and severities are Kritisch / Hoch / Mittel / Niedrig.
|
||||
|
||||
use super::Text;
|
||||
|
||||
/// Words used on many pages.
|
||||
pub mod common {
|
||||
use super::Text;
|
||||
|
||||
pub const LOADING: Text = Text {
|
||||
de: "Wird geladen …",
|
||||
en: "Loading...",
|
||||
};
|
||||
pub const CRITICAL: Text = Text {
|
||||
de: "Kritisch",
|
||||
en: "Critical",
|
||||
};
|
||||
pub const HIGH: Text = Text {
|
||||
de: "Hoch",
|
||||
en: "High",
|
||||
};
|
||||
pub const MEDIUM: Text = Text {
|
||||
de: "Mittel",
|
||||
en: "Medium",
|
||||
};
|
||||
pub const LOW: Text = Text {
|
||||
de: "Niedrig",
|
||||
en: "Low",
|
||||
};
|
||||
pub const NOT_AVAILABLE_HERE: Text = Text {
|
||||
de: "In dieser Umgebung nicht verfügbar",
|
||||
en: "Not available in this environment",
|
||||
};
|
||||
}
|
||||
|
||||
/// The sidebar.
|
||||
pub mod nav {
|
||||
use super::Text;
|
||||
|
||||
pub const OVERVIEW: Text = Text {
|
||||
de: "Übersicht",
|
||||
en: "Overview",
|
||||
};
|
||||
pub const TARGETS: Text = Text {
|
||||
de: "Prüfobjekte",
|
||||
en: "Targets",
|
||||
};
|
||||
pub const ONBOARD: Text = Text {
|
||||
de: "Neues Prüfobjekt",
|
||||
en: "Onboard",
|
||||
};
|
||||
pub const FINDINGS: Text = Text {
|
||||
de: "Befunde",
|
||||
en: "Findings",
|
||||
};
|
||||
pub const SBOM: Text = Text {
|
||||
de: "SBOM",
|
||||
en: "SBOM",
|
||||
};
|
||||
pub const ISSUES: Text = Text {
|
||||
de: "Tickets",
|
||||
en: "Issues",
|
||||
};
|
||||
pub const DAST: Text = Text {
|
||||
de: "DAST",
|
||||
en: "DAST",
|
||||
};
|
||||
pub const PENTEST: Text = Text {
|
||||
de: "Pentest",
|
||||
en: "Pentest",
|
||||
};
|
||||
pub const DOCS: Text = Text {
|
||||
de: "Dokumentation",
|
||||
en: "Docs",
|
||||
};
|
||||
pub const NOT_AVAILABLE_SHORT: Text = Text {
|
||||
de: "n. v.",
|
||||
en: "n/a",
|
||||
};
|
||||
pub const SIGN_OUT: Text = Text {
|
||||
de: "Abmelden",
|
||||
en: "Sign out",
|
||||
};
|
||||
pub const PRIVACY: Text = Text {
|
||||
de: "Datenschutz",
|
||||
en: "Privacy",
|
||||
};
|
||||
pub const IMPRINT: Text = Text {
|
||||
de: "Impressum",
|
||||
en: "Imprint",
|
||||
};
|
||||
pub const LIGHT_MODE: Text = Text {
|
||||
de: "Heller Modus",
|
||||
en: "Light mode",
|
||||
};
|
||||
pub const DARK_MODE: Text = Text {
|
||||
de: "Dunkler Modus",
|
||||
en: "Dark mode",
|
||||
};
|
||||
pub const SWITCH_TO_LIGHT: Text = Text {
|
||||
de: "Zum hellen Modus wechseln",
|
||||
en: "Switch to light mode",
|
||||
};
|
||||
pub const SWITCH_TO_DARK: Text = Text {
|
||||
de: "Zum dunklen Modus wechseln",
|
||||
en: "Switch to dark mode",
|
||||
};
|
||||
/// The toggle names the language it switches *to*, in that language.
|
||||
pub const SWITCH_LANGUAGE: Text = Text {
|
||||
de: "Switch to English",
|
||||
en: "Auf Deutsch umstellen",
|
||||
};
|
||||
}
|
||||
|
||||
/// The overview page.
|
||||
pub mod overview {
|
||||
use super::Text;
|
||||
|
||||
pub const TITLE: Text = Text {
|
||||
de: "Übersicht",
|
||||
en: "Overview",
|
||||
};
|
||||
pub const SUBTITLE: Text = Text {
|
||||
de: "Sicherheits- und Compliance-Stand Ihrer Prüfobjekte",
|
||||
en: "Security and compliance status of your targets",
|
||||
};
|
||||
pub const TARGETS: Text = Text {
|
||||
de: "Prüfobjekte",
|
||||
en: "Targets",
|
||||
};
|
||||
pub const FINDINGS: Text = Text {
|
||||
de: "Befunde gesamt",
|
||||
en: "Total findings",
|
||||
};
|
||||
pub const DEPENDENCIES: Text = Text {
|
||||
de: "Abhängigkeiten",
|
||||
en: "Dependencies",
|
||||
};
|
||||
pub const CVE_ALERTS: Text = Text {
|
||||
de: "CVE-Warnungen",
|
||||
en: "CVE alerts",
|
||||
};
|
||||
pub const TRACKER_ISSUES: Text = Text {
|
||||
de: "Tickets",
|
||||
en: "Tracker issues",
|
||||
};
|
||||
pub const SEVERITY_DISTRIBUTION: Text = Text {
|
||||
de: "Befunde nach Schweregrad",
|
||||
en: "Findings by severity",
|
||||
};
|
||||
pub const EMPTY_TITLE: Text = Text {
|
||||
de: "Noch keine Prüfobjekte",
|
||||
en: "No targets yet",
|
||||
};
|
||||
pub const EMPTY_BODY: Text = Text {
|
||||
de: "Legen Sie Ihr erstes Prüfobjekt an: Laden Sie den Quellcode als \
|
||||
Archiv (zip, tar.gz) hoch oder verbinden Sie ein Git-Repository.",
|
||||
en: "Add your first target: upload the source code as an archive \
|
||||
(zip, tar.gz) or connect a git repository.",
|
||||
};
|
||||
pub const EMPTY_ACTION: Text = Text {
|
||||
de: "Prüfobjekt anlegen",
|
||||
en: "Add a target",
|
||||
};
|
||||
pub const AI_CHAT: Text = Text {
|
||||
de: "KI-Chat",
|
||||
en: "AI chat",
|
||||
};
|
||||
pub const NO_TARGETS_FOR_CHAT: Text = Text {
|
||||
de: "Noch keine Prüfobjekte. Legen Sie eines an, um den Chat zu nutzen.",
|
||||
en: "No targets yet. Add one to start chatting.",
|
||||
};
|
||||
pub const MCP_SERVERS: Text = Text {
|
||||
de: "MCP-Server",
|
||||
en: "MCP servers",
|
||||
};
|
||||
pub const NO_MCP_SERVERS: Text = Text {
|
||||
de: "Keine MCP-Server registriert.",
|
||||
en: "No MCP servers registered.",
|
||||
};
|
||||
pub const MANAGE: Text = Text {
|
||||
de: "Verwalten",
|
||||
en: "Manage",
|
||||
};
|
||||
pub const MCP_TOKENS: Text = Text {
|
||||
de: "MCP-Tokens",
|
||||
en: "MCP tokens",
|
||||
};
|
||||
pub const MCP_TOKENS_HINT: Text = Text {
|
||||
de: "Bearer-Tokens, mit denen sich eine IDE oder ein LLM-Client verbindet",
|
||||
en: "Bearer tokens for connecting an IDE / LLM client",
|
||||
};
|
||||
pub const LOAD_FAILED: Text = Text {
|
||||
de: "Die Übersicht konnte nicht geladen werden. Bitte versuchen Sie es \
|
||||
in einem Moment erneut.",
|
||||
en: "The overview could not be loaded. Please try again in a moment.",
|
||||
};
|
||||
pub const LIST_LOAD_FAILED: Text = Text {
|
||||
de: "Konnte nicht geladen werden.",
|
||||
en: "Failed to load.",
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
pub mod app;
|
||||
pub mod components;
|
||||
pub mod i18n;
|
||||
pub mod infrastructure;
|
||||
pub mod pages;
|
||||
|
||||
|
||||
@@ -5,8 +5,11 @@ use dioxus_free_icons::Icon;
|
||||
use crate::app::Route;
|
||||
use crate::components::page_header::PageHeader;
|
||||
use crate::components::stat_card::StatCard;
|
||||
use crate::i18n::texts::{common, overview};
|
||||
use crate::i18n::use_lang;
|
||||
use crate::infrastructure::mcp::{fetch_mcp_servers, refresh_mcp_status};
|
||||
use crate::infrastructure::onboarding::fetch_targets;
|
||||
use crate::infrastructure::platform::use_source_only;
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
use crate::infrastructure::stats::fetch_overview_stats;
|
||||
@@ -26,6 +29,10 @@ pub fn OverviewPage() -> Element {
|
||||
}
|
||||
});
|
||||
|
||||
let lang = use_lang()();
|
||||
// AI chat and MCP need the runtime a source-only deployment does not have,
|
||||
// so they are not advertised there.
|
||||
let source_only = use_source_only();
|
||||
let repos = use_resource(|| async { fetch_targets().await.ok() });
|
||||
// Probe the MCP health endpoints first so the seeded cards reflect the
|
||||
// live status (running / stopped) instead of the stored default.
|
||||
@@ -36,60 +43,74 @@ pub fn OverviewPage() -> Element {
|
||||
|
||||
rsx! {
|
||||
PageHeader {
|
||||
title: "Overview",
|
||||
description: "Security and compliance scanning dashboard",
|
||||
title: overview::TITLE.get(lang),
|
||||
description: overview::SUBTITLE.get(lang),
|
||||
}
|
||||
|
||||
match &*stats.read() {
|
||||
Some(Some(s)) => rsx! {
|
||||
if s.total_repositories == 0 {
|
||||
div { class: "card",
|
||||
div { class: "card-header", {overview::EMPTY_TITLE.get(lang)} }
|
||||
p { style: "padding: 0 1rem; color: var(--text-secondary);",
|
||||
{overview::EMPTY_BODY.get(lang)}
|
||||
}
|
||||
div { style: "padding: 0 1rem 1rem;",
|
||||
Link { to: Route::OnboardingPage {}, class: "btn btn-primary",
|
||||
{overview::EMPTY_ACTION.get(lang)}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
div { class: "stat-cards",
|
||||
StatCard { label: "Repositories", value: s.total_repositories.to_string() }
|
||||
StatCard { label: "Total Findings", value: s.total_findings.to_string() }
|
||||
StatCard { label: overview::TARGETS.get(lang), value: s.total_repositories.to_string() }
|
||||
StatCard { label: overview::FINDINGS.get(lang), value: s.total_findings.to_string() }
|
||||
StatCard {
|
||||
label: "Critical",
|
||||
label: common::CRITICAL.get(lang),
|
||||
value: s.critical_findings.to_string(),
|
||||
color: "var(--danger)",
|
||||
}
|
||||
StatCard {
|
||||
label: "High",
|
||||
label: common::HIGH.get(lang),
|
||||
value: s.high_findings.to_string(),
|
||||
color: "#f97316",
|
||||
}
|
||||
StatCard {
|
||||
label: "Medium",
|
||||
label: common::MEDIUM.get(lang),
|
||||
value: s.medium_findings.to_string(),
|
||||
color: "var(--warning)",
|
||||
}
|
||||
StatCard {
|
||||
label: "Low",
|
||||
label: common::LOW.get(lang),
|
||||
value: s.low_findings.to_string(),
|
||||
color: "var(--success)",
|
||||
}
|
||||
StatCard { label: "Dependencies", value: s.total_sbom_entries.to_string() }
|
||||
StatCard { label: "CVE Alerts", value: s.total_cve_alerts.to_string() }
|
||||
StatCard { label: "Tracker Issues", value: s.total_issues.to_string() }
|
||||
StatCard { label: overview::DEPENDENCIES.get(lang), value: s.total_sbom_entries.to_string() }
|
||||
StatCard { label: overview::CVE_ALERTS.get(lang), value: s.total_cve_alerts.to_string() }
|
||||
StatCard { label: overview::TRACKER_ISSUES.get(lang), value: s.total_issues.to_string() }
|
||||
}
|
||||
|
||||
div { class: "card",
|
||||
div { class: "card-header", "Severity Distribution" }
|
||||
div { class: "card-header", {overview::SEVERITY_DISTRIBUTION.get(lang)} }
|
||||
div { class: "severity-chart",
|
||||
SeverityBar { label: "Critical", count: s.critical_findings, max: s.total_findings, color: "var(--danger)" }
|
||||
SeverityBar { label: "High", count: s.high_findings, max: s.total_findings, color: "var(--orange)" }
|
||||
SeverityBar { label: "Medium", count: s.medium_findings, max: s.total_findings, color: "var(--warning)" }
|
||||
SeverityBar { label: "Low", count: s.low_findings, max: s.total_findings, color: "var(--success)" }
|
||||
SeverityBar { label: common::CRITICAL.get(lang), count: s.critical_findings, max: s.total_findings, color: "var(--danger)" }
|
||||
SeverityBar { label: common::HIGH.get(lang), count: s.high_findings, max: s.total_findings, color: "var(--orange)" }
|
||||
SeverityBar { label: common::MEDIUM.get(lang), count: s.medium_findings, max: s.total_findings, color: "var(--warning)" }
|
||||
SeverityBar { label: common::LOW.get(lang), count: s.low_findings, max: s.total_findings, color: "var(--success)" }
|
||||
}
|
||||
}
|
||||
|
||||
if !source_only {
|
||||
// AI Chat section
|
||||
div { class: "card",
|
||||
div { class: "card-header", "AI Chat" }
|
||||
div { class: "card-header", {overview::AI_CHAT.get(lang)} }
|
||||
match &*repos.read() {
|
||||
Some(Some(data)) => {
|
||||
let repo_list = &data.data;
|
||||
if repo_list.is_empty() {
|
||||
rsx! {
|
||||
p { style: "padding: 1rem; color: var(--text-secondary);",
|
||||
"No repositories found. Add a repository to start chatting."
|
||||
{overview::NO_TARGETS_FOR_CHAT.get(lang)}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -121,28 +142,28 @@ pub fn OverviewPage() -> Element {
|
||||
},
|
||||
Some(None) => rsx! {
|
||||
p { style: "padding: 1rem; color: var(--text-secondary);",
|
||||
"Failed to load repositories."
|
||||
{overview::LIST_LOAD_FAILED.get(lang)}
|
||||
}
|
||||
},
|
||||
None => rsx! {
|
||||
div { class: "loading", "Loading repositories..." }
|
||||
div { class: "loading", {common::LOADING.get(lang)} }
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// MCP Servers section
|
||||
div { class: "card",
|
||||
div { class: "card-header", "MCP Servers" }
|
||||
div { class: "card-header", {overview::MCP_SERVERS.get(lang)} }
|
||||
match &*mcp_servers.read() {
|
||||
Some(Some(resp)) => {
|
||||
if resp.data.is_empty() {
|
||||
rsx! {
|
||||
p { style: "padding: 1rem; color: var(--text-secondary);",
|
||||
"No MCP servers registered."
|
||||
{overview::NO_MCP_SERVERS.get(lang)}
|
||||
}
|
||||
div { style: "padding: 0 1rem 1rem; display: flex; gap: 8px;",
|
||||
Link { to: Route::McpServersPage {}, class: "btn btn-primary btn-sm", "Manage" }
|
||||
Link { to: Route::McpTokensPage {}, class: "btn btn-secondary btn-sm", "MCP tokens" }
|
||||
Link { to: Route::McpServersPage {}, class: "btn btn-primary btn-sm", {overview::MANAGE.get(lang)} }
|
||||
Link { to: Route::McpTokensPage {}, class: "btn btn-secondary btn-sm", {overview::MCP_TOKENS.get(lang)} }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -186,13 +207,13 @@ pub fn OverviewPage() -> Element {
|
||||
Link {
|
||||
to: Route::McpServersPage {},
|
||||
class: "btn btn-primary btn-sm",
|
||||
"Manage"
|
||||
{overview::MANAGE.get(lang)}
|
||||
}
|
||||
Link {
|
||||
to: Route::McpTokensPage {},
|
||||
class: "btn btn-secondary btn-sm",
|
||||
title: "Bearer tokens for connecting an IDE / LLM client",
|
||||
"MCP tokens"
|
||||
title: overview::MCP_TOKENS_HINT.get(lang),
|
||||
{overview::MCP_TOKENS.get(lang)}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,24 +221,25 @@ pub fn OverviewPage() -> Element {
|
||||
},
|
||||
Some(None) => rsx! {
|
||||
p { style: "padding: 1rem; color: var(--text-secondary);",
|
||||
"Failed to load MCP servers."
|
||||
{overview::LIST_LOAD_FAILED.get(lang)}
|
||||
}
|
||||
},
|
||||
None => rsx! {
|
||||
div { class: "loading", "Loading..." }
|
||||
div { class: "loading", {common::LOADING.get(lang)} }
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Some(None) => rsx! {
|
||||
div { class: "card",
|
||||
p { style: "color: var(--text-secondary);",
|
||||
"Unable to load stats. Make sure the agent API is running."
|
||||
{overview::LOAD_FAILED.get(lang)}
|
||||
}
|
||||
}
|
||||
},
|
||||
None => rsx! {
|
||||
div { class: "loading", "Loading overview..." }
|
||||
div { class: "loading", {common::LOADING.get(lang)} }
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user