feat(ui): Symbol je Engine zeigt, ob sie eine Oberfläche mitbringt, und öffnet sie als Link (#1101)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmHhg3Td16J38kAyDLzb39
This commit is contained in:
2026-11-17 22:04:28 +01:00
parent 9b642c5bf4
commit ca3f5f2b6b
11 changed files with 108 additions and 8 deletions

View File

@ -164,6 +164,40 @@ fn titel(key: &str) -> &'static str {
}
}
/// Symbol „Engine bringt eine Oberfläche mit“ (Lucide `app-window`): mit Adresse als Link für Admins,
/// sonst nur als Hinweis (die Engine hat eine Oberfläche, der Zugang fehlt oder ist nicht erlaubt).
pub(super) fn oberflaeche(frontend: &nexus_adapter::Frontend, admin: bool) -> String {
use nexus_adapter::Frontend;
let (href, hinweis) = match frontend {
Frontend::None => return String::new(),
Frontend::Url(url) if admin => (
Some(url.as_str()),
"Oberfläche der Engine öffnen (eigene Adresse, ohne Anmeldung des Gateways)",
),
Frontend::Url(_) => (
None,
"Die Engine hat eine eigene Oberfläche (Zugang nur für Admins)",
),
Frontend::Managed => (
None,
"Die Engine hat eine eigene Oberfläche; der Zugang über das Gateway ist noch nicht gebaut",
),
};
let svg = format!(
"<svg class=\"fsym {} k-chat\" viewBox=\"0 0 24 24\" role=\"img\" aria-label=\"{h}\"><title>{h}</title>\
<rect x=\"2\" y=\"4\" width=\"20\" height=\"16\" rx=\"2\"/><path d=\"M10 4v4\"/><path d=\"M2 8h20\"/><path d=\"M6 4v4\"/></svg>",
if href.is_some() { "gemeldet" } else { "engine" },
h = esc(hinweis),
);
match href {
Some(url) => format!(
"<a class=\"fenster\" href=\"{}\" target=\"_blank\" rel=\"noopener noreferrer\">{svg}</a>",
esc(url)
),
None => format!("<span class=\"fenster\">{svg}</span>"),
}
}
fn symbol(key: &str, klasse: &str, hinweis: &str) -> String {
format!(
"<svg class=\"fsym {klasse} k-{key}\" viewBox=\"0 0 24 24\" role=\"img\" aria-label=\"{t}: {h}\"><title>{t}: {h}</title>{p}</svg>",
@ -242,6 +276,21 @@ mod tests {
assert!(engine_faehigkeiten(&c).contains("Sprachausgabe"));
}
#[test]
fn oberflaechen_symbol_ist_nur_fuer_admins_ein_link() {
use nexus_adapter::Frontend;
assert!(oberflaeche(&Frontend::None, true).is_empty());
let url = Frontend::Url("http://192.168.12.4:8862".to_string());
let admin = oberflaeche(&url, true);
assert!(admin.contains("<a class=\"fenster\" href=\"http://192.168.12.4:8862\""));
assert!(admin.contains("noopener") && admin.contains("_blank"));
let nutzer = oberflaeche(&url, false);
assert!(!nutzer.contains("href=") && nutzer.contains("nur für Admins"));
// Verwaltete Engine: Symbol ja, Link nein (Weiterleitung fehlt, #1101).
let verwaltet = oberflaeche(&Frontend::Managed, true);
assert!(!verwaltet.contains("href=") && verwaltet.contains("noch nicht gebaut"));
}
#[test]
fn icons_in_fester_reihenfolge() {
assert!(capability_icons(&caps(false, false, false, false, false, false)).is_empty());