feat(dashboard): where a target's SBOM goes, the supplier's release screen (#1028) #1067
No files matched your search
@@ -8974,3 +8974,360 @@ span.repo-crumb-name {
|
||||
color: var(--bg-card);
|
||||
background: var(--text-tertiary);
|
||||
}
|
||||
|
||||
/* ============ SBOM releases (#1028): where a target's SBOM goes ============ */
|
||||
.rel-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 22px;
|
||||
min-width: 0;
|
||||
max-width: 1180px;
|
||||
}
|
||||
.rel-page > * { min-width: 0; }
|
||||
.rel-note {
|
||||
margin: 0;
|
||||
padding: 10px 14px;
|
||||
font-size: 14px;
|
||||
color: var(--warning);
|
||||
background: var(--warning-bg);
|
||||
border-radius: 10px;
|
||||
}
|
||||
.rel-route,
|
||||
.rel-train {
|
||||
overflow-x: auto;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 16px;
|
||||
}
|
||||
.rel-canvas {
|
||||
position: relative;
|
||||
background-image: radial-gradient(var(--border-bright) 1px, transparent 1.2px);
|
||||
background-size: 20px 20px;
|
||||
}
|
||||
.rel-route-note {
|
||||
margin: 0;
|
||||
padding: 0 24px 20px;
|
||||
max-width: 66ch;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.rel-lines {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
overflow: visible;
|
||||
pointer-events: none;
|
||||
}
|
||||
.rel-line {
|
||||
fill: none;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
.rel-line.live { stroke: var(--accent); stroke-width: 2.5; }
|
||||
.rel-line.wait { stroke: var(--warning); stroke-width: 2; stroke-dasharray: 5 6; }
|
||||
.rel-line.off { stroke: var(--border-strong); stroke-width: 2; stroke-dasharray: 5 6; }
|
||||
.rel-line.thick { stroke-width: 3; }
|
||||
.rel-arrow-head { fill: var(--accent); }
|
||||
.rel-dot { stroke: var(--bg-card); stroke-width: 3; }
|
||||
.rel-dot.live { fill: var(--accent); }
|
||||
.rel-dot.wait { fill: var(--bg-card); stroke: var(--warning); stroke-width: 2; }
|
||||
.rel-dot.off { fill: var(--bg-card); stroke: var(--border-strong); stroke-width: 2; }
|
||||
.rel-target {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
color: var(--bg-card);
|
||||
background: var(--text-primary);
|
||||
border-radius: 18px;
|
||||
}
|
||||
.rel-target-kind { font-size: 12px; color: var(--text-faint); }
|
||||
.rel-target-name {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.rel-eco {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
height: 8px;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
/* Mixed toward the box's text colour, so they read on the dark box in the
|
||||
light theme and on the light box in the dark one. */
|
||||
.rel-eco-part { background: color-mix(in srgb, var(--text-faint) 60%, var(--bg-card)); }
|
||||
.rel-eco-part.eco-0 { background: color-mix(in srgb, var(--accent) 65%, var(--bg-card)); }
|
||||
.rel-eco-part.eco-1 { background: color-mix(in srgb, var(--info) 65%, var(--bg-card)); }
|
||||
.rel-eco-part.eco-2 { background: color-mix(in srgb, var(--warning) 65%, var(--bg-card)); }
|
||||
.rel-chip {
|
||||
position: absolute;
|
||||
transform: translate(-50%, -50%);
|
||||
max-width: 180px;
|
||||
height: 26px;
|
||||
box-sizing: border-box;
|
||||
padding: 0 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
border-radius: 13px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
/* Opaque, so the line under it does not show through. */
|
||||
.rel-chip.live { color: var(--success); background: color-mix(in srgb, var(--success) 12%, var(--bg-card)); }
|
||||
.rel-chip.wait { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, var(--bg-card)); }
|
||||
.rel-chip svg { flex: none; margin-right: 6px; }
|
||||
.rel-chip.off { color: var(--text-secondary); background: var(--bg-elevated); }
|
||||
.rel-peer {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
padding: 10px 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
color: var(--text-primary);
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-bright);
|
||||
border-radius: 14px;
|
||||
}
|
||||
.rel-peer.wait { border-color: color-mix(in srgb, var(--warning) 35%, var(--bg-card)); }
|
||||
.rel-peer.off { background: var(--bg-primary); border-style: dashed; }
|
||||
.rel-peer-name {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.rel-peer-status { font-size: 12px; color: var(--text-tertiary); }
|
||||
.rel-peer-status.live { color: var(--success); }
|
||||
.rel-peer-status.wait { color: var(--warning); }
|
||||
.rel-peer-top {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
.rel-peer-top .rel-peer-name { flex: 1 1 auto; min-width: 0; }
|
||||
.rel-end {
|
||||
flex: none;
|
||||
align-self: center;
|
||||
margin-right: -6px;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
color: var(--text-tertiary);
|
||||
background: none;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.rel-end:hover { color: var(--danger); background: var(--danger-bg); }
|
||||
.rel-end-confirm {
|
||||
align-self: flex-start;
|
||||
margin-top: 2px;
|
||||
padding: 2px 10px;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--bg-card);
|
||||
background: var(--danger);
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.rel-peer-add {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
color: var(--accent);
|
||||
background: var(--bg-primary);
|
||||
border: 1.5px dashed var(--border-accent);
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.rel-peer-add:hover { background: var(--accent-muted); }
|
||||
.rel-peer-add .rel-peer-name { font-size: 14px; white-space: normal; }
|
||||
.rel-plus { font-size: 22px; font-weight: 500; line-height: 1; }
|
||||
.rel-train-canvas {
|
||||
position: relative;
|
||||
height: 200px;
|
||||
}
|
||||
.rel-train-canvas h2 {
|
||||
position: absolute;
|
||||
left: 32px;
|
||||
top: 22px;
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.rel-train-canvas .rel-route-note { position: absolute; left: 32px; top: 64px; padding: 0; }
|
||||
.rel-stops { margin: 0; padding: 0; list-style: none; }
|
||||
.rel-stop {
|
||||
position: absolute;
|
||||
top: 64px;
|
||||
width: 176px;
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
.rel-stop-label {
|
||||
height: 18px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.rel-stop-dot {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 8px;
|
||||
background: var(--bg-card);
|
||||
border: 3px solid var(--accent);
|
||||
}
|
||||
.rel-stop.latest .rel-stop-dot {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin: -2px 0;
|
||||
border: 0;
|
||||
background: var(--accent);
|
||||
box-shadow: 0 0 0 5px var(--accent-muted);
|
||||
}
|
||||
.rel-stop.older .rel-stop-dot { border-color: var(--border-strong); border-style: dotted; }
|
||||
.rel-stop.draft .rel-stop-label,
|
||||
.rel-stop.draft .rel-stop-meta { color: var(--accent); }
|
||||
.rel-stop.draft .rel-stop-dot {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin: -2px 0;
|
||||
border: 2px dashed var(--accent);
|
||||
}
|
||||
.rel-stop-meta { font-size: 12px; line-height: 18px; color: var(--text-tertiary); }
|
||||
.rel-reached { color: var(--success); }
|
||||
.rel-publish {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18px;
|
||||
padding: 22px;
|
||||
background: var(--bg-card);
|
||||
border: 2px solid var(--accent);
|
||||
border-radius: 16px;
|
||||
}
|
||||
.rel-publish-head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px 16px;
|
||||
}
|
||||
.rel-publish-head h2 {
|
||||
flex: 1 1 280px;
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
.rel-publish-head label { font-size: 13px; color: var(--text-secondary); }
|
||||
.rel-publish-head input {
|
||||
width: 140px;
|
||||
min-height: 40px;
|
||||
box-sizing: border-box;
|
||||
padding: 9px 12px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 14px;
|
||||
color: var(--text-primary);
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-bright);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.rel-last { font-size: 13px; color: var(--text-tertiary); }
|
||||
.rel-publish-body { display: flex; flex-wrap: wrap; gap: 18px; }
|
||||
.rel-changes {
|
||||
flex: 1 1 320px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.rel-changes-title { font-size: 14px; font-weight: 600; }
|
||||
.rel-diff {
|
||||
display: flex;
|
||||
gap: 3px;
|
||||
height: 14px;
|
||||
overflow: hidden;
|
||||
border-radius: 7px;
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
.rel-diff-added { background: var(--accent); }
|
||||
.rel-diff-updated { background: color-mix(in srgb, var(--accent) 45%, var(--bg-card)); }
|
||||
.rel-diff-same { background: var(--border); }
|
||||
.rel-diff-counts {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 16px;
|
||||
font-size: 13px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.rel-diff-added-text { color: var(--accent); }
|
||||
.rel-diff-updated-text { color: color-mix(in srgb, var(--accent) 75%, var(--text-secondary)); }
|
||||
.rel-changes-text { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-tertiary); }
|
||||
.rel-blocked { margin: 0; font-size: 14px; line-height: 1.5; color: var(--warning); }
|
||||
.rel-sieve {
|
||||
flex: 1 1 380px;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 4px minmax(0, 1fr);
|
||||
gap: 14px;
|
||||
padding: 14px;
|
||||
background: var(--bg-primary);
|
||||
border-radius: 14px;
|
||||
}
|
||||
.rel-sieve-side { display: flex; flex-direction: column; gap: 8px; }
|
||||
.rel-sieve-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
|
||||
.rel-sieve-title.goes { color: var(--success); }
|
||||
.rel-sieve-mesh {
|
||||
border-radius: 2px;
|
||||
background: repeating-linear-gradient(to bottom, var(--accent) 0 6px, transparent 6px 11px);
|
||||
}
|
||||
.rel-pills { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; }
|
||||
.rel-pill { padding: 4px 10px; border-radius: 999px; }
|
||||
.rel-pill.goes {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid color-mix(in srgb, var(--success) 30%, var(--bg-card));
|
||||
}
|
||||
.rel-pill.stays { color: var(--text-tertiary); border: 1px dashed var(--border-strong); }
|
||||
.rel-publish-foot {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
.rel-recipients {
|
||||
flex: 1 1 300px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.rel-sieve { grid-template-columns: minmax(0, 1fr); }
|
||||
.rel-sieve-mesh { height: 4px; background: repeating-linear-gradient(to right, var(--accent) 0 6px, transparent 6px 11px); }
|
||||
}
|
||||
@@ -41,6 +41,10 @@ pub enum Route {
|
||||
},
|
||||
#[route("/targets/:id/compliance")]
|
||||
CompliancePage { id: String },
|
||||
// Where the target's SBOM goes: its releases to connected customers
|
||||
// and its published versions (#1028).
|
||||
#[route("/targets/:id/releases")]
|
||||
TargetReleasesPage { id: String },
|
||||
// A machine (#1026): a product project and its targets; `?tab=`
|
||||
// `parts` (the default), `cves` or `history`.
|
||||
#[route("/projects/:id?:tab")]
|
||||
|
||||
@@ -185,6 +185,7 @@ pub fn Sidebar() -> Element {
|
||||
(Route::SbomPage { .. }, Route::SbomPage { .. }) => true,
|
||||
(Route::SbomEcosystemPage { .. }, Route::SbomPage { .. }) => true,
|
||||
(Route::CompliancePage { .. }, Route::TargetsPage {}) => true,
|
||||
(Route::TargetReleasesPage { .. }, Route::TargetsPage {}) => true,
|
||||
(Route::DastTargetsPage {}, Route::DastOverviewPage {}) => true,
|
||||
(Route::DastFindingsPage {}, Route::DastOverviewPage {}) => true,
|
||||
(Route::DastFindingDetailPage { .. }, Route::DastOverviewPage {}) => true,
|
||||
|
||||
@@ -7943,3 +7943,518 @@ pub mod supply_chain {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The supplier's release screen (#1028): where a target's SBOM goes.
|
||||
pub mod releases {
|
||||
use super::Text;
|
||||
use crate::i18n::Lang;
|
||||
|
||||
/// `14.11.` in German, `Nov 14` in English.
|
||||
pub fn day(time: &chrono::DateTime<chrono::Utc>, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => time.format("%-d.%-m.").to_string(),
|
||||
Lang::En => time.format("%b %-d").to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `A`, `A und B`, `A, B und C`.
|
||||
fn listed(names: &[String], lang: Lang) -> String {
|
||||
let and = match lang {
|
||||
Lang::De => " und ",
|
||||
Lang::En => " and ",
|
||||
};
|
||||
match names {
|
||||
[] => String::new(),
|
||||
[one] => one.clone(),
|
||||
[rest @ .., last] => format!("{}{and}{last}", rest.join(", ")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn title(name: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("Wohin die SBOM von {name} geht"),
|
||||
Lang::En => format!("Where the SBOM of {name} goes"),
|
||||
}
|
||||
}
|
||||
pub const INTRO: Text = Text {
|
||||
de: "Verbundene Kunden erhalten jede Version, die Sie veröffentlichen, sobald sie Ihre \
|
||||
Freigabe angenommen haben.",
|
||||
en: "Connected customers receive every version you publish once they have accepted \
|
||||
your release.",
|
||||
};
|
||||
pub const CRUMB: Text = Text {
|
||||
de: "Freigaben",
|
||||
en: "Releases",
|
||||
};
|
||||
pub const ENTRY: Text = Text {
|
||||
de: "SBOM freigeben",
|
||||
en: "Release the SBOM",
|
||||
};
|
||||
pub const ENTRY_HINT: Text = Text {
|
||||
de: "An verbundene Kunden, Version für Version",
|
||||
en: "To connected customers, version by version",
|
||||
};
|
||||
pub const LOADING: Text = Text {
|
||||
de: "Freigaben werden geladen …",
|
||||
en: "Loading the releases …",
|
||||
};
|
||||
pub const LOAD_FAILED: Text = Text {
|
||||
de: "Die Freigaben lassen sich gerade nicht laden.",
|
||||
en: "The releases cannot be loaded right now.",
|
||||
};
|
||||
|
||||
// The delivery route.
|
||||
pub const ROUTE: Text = Text {
|
||||
de: "Lieferweg der SBOM",
|
||||
en: "Where the SBOM is delivered",
|
||||
};
|
||||
pub const YOUR_TARGET: Text = Text {
|
||||
de: "Ihr Prüfobjekt",
|
||||
en: "Your target",
|
||||
};
|
||||
pub fn components(n: usize, scanned: Option<&str>, lang: Lang) -> String {
|
||||
match (lang, scanned) {
|
||||
(Lang::De, Some(day)) => format!("{n} Komponenten, Prüfung vom {day}"),
|
||||
(Lang::De, None) => format!("{n} Komponenten"),
|
||||
(Lang::En, Some(day)) => format!("{n} components, scan of {day}"),
|
||||
(Lang::En, None) => format!("{n} components"),
|
||||
}
|
||||
}
|
||||
pub fn ecosystems(parts: &[(String, u64)], lang: Lang) -> String {
|
||||
let total: u64 = parts.iter().map(|(_, n)| n).sum();
|
||||
let each = parts
|
||||
.iter()
|
||||
.map(|(name, n)| format!("{n} {name}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
match lang {
|
||||
Lang::De => format!("{total} Komponenten: {each}"),
|
||||
Lang::En => format!("{total} components: {each}"),
|
||||
}
|
||||
}
|
||||
pub const OTHER_ECOSYSTEMS: Text = Text {
|
||||
de: "andere",
|
||||
en: "other",
|
||||
};
|
||||
pub const RECEIVES: Text = Text {
|
||||
de: "erhält jede Version",
|
||||
en: "receives every version",
|
||||
};
|
||||
pub fn delivered(label: &str, day: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("{label} am {day}"),
|
||||
Lang::En => format!("{label} on {day}"),
|
||||
}
|
||||
}
|
||||
pub const ACCEPTED: Text = Text {
|
||||
de: "angenommen",
|
||||
en: "accepted",
|
||||
};
|
||||
pub const RECEIVES_NEXT: Text = Text {
|
||||
de: "erhält die nächste Version",
|
||||
en: "receives the next version",
|
||||
};
|
||||
pub const WAITING: Text = Text {
|
||||
de: "wartet auf Annahme",
|
||||
en: "awaiting acceptance",
|
||||
};
|
||||
pub const NOT_ACCEPTED: Text = Text {
|
||||
de: "hat noch nicht angenommen",
|
||||
en: "has not accepted yet",
|
||||
};
|
||||
pub const DECLINED_CHIP: Text = Text {
|
||||
de: "abgelehnt",
|
||||
en: "declined",
|
||||
};
|
||||
pub const DECLINED: Text = Text {
|
||||
de: "hat abgelehnt",
|
||||
en: "declined the release",
|
||||
};
|
||||
pub const REMOVED_CHIP: Text = Text {
|
||||
de: "Komponente entfernt",
|
||||
en: "component removed",
|
||||
};
|
||||
pub const REMOVED: Text = Text {
|
||||
de: "erhält nichts mehr",
|
||||
en: "receives nothing more",
|
||||
};
|
||||
pub const GONE_CHIP: Text = Text {
|
||||
de: "keine Verbindung",
|
||||
en: "no connection",
|
||||
};
|
||||
pub const GONE: Text = Text {
|
||||
de: "Verbindung beendet",
|
||||
en: "connection ended",
|
||||
};
|
||||
pub const NOT_RELEASED: Text = Text {
|
||||
de: "nicht freigegeben",
|
||||
en: "not released",
|
||||
};
|
||||
pub const NO_CUSTOMER: Text = Text {
|
||||
de: "Noch kein Kunde verbunden",
|
||||
en: "No customer connected yet",
|
||||
};
|
||||
pub fn release_to(peer: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("Freigeben an {peer}"),
|
||||
Lang::En => format!("Release to {peer}"),
|
||||
}
|
||||
}
|
||||
pub const END_CONFIRM: Text = Text {
|
||||
de: "Freigabe beenden",
|
||||
en: "End the release",
|
||||
};
|
||||
pub const KEEP: Text = Text {
|
||||
de: "Nicht beenden",
|
||||
en: "Keep the release",
|
||||
};
|
||||
pub fn end_hint(peer: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => {
|
||||
format!("Freigabe an {peer} beenden. Was {peer} schon erhalten hat, bleibt dort.")
|
||||
}
|
||||
Lang::En => {
|
||||
format!("End the release to {peer}. What {peer} has received stays there.")
|
||||
}
|
||||
}
|
||||
}
|
||||
/// What one line of the route says, for a screen reader.
|
||||
pub fn line(target: &str, peer: &str, state: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("Von {target} zu {peer}: {state}"),
|
||||
Lang::En => format!("From {target} to {peer}: {state}"),
|
||||
}
|
||||
}
|
||||
pub const NO_CONNECTIONS: Text = Text {
|
||||
de: "Noch keine Verbindung zu einem Kunden. Verbindungen stellen Sie im Portal her: \
|
||||
Sie erstellen einen Code, Ihr Kunde gibt ihn ein.",
|
||||
en: "No connection to a customer yet. You make connections in the portal: you create \
|
||||
a code, your customer enters it.",
|
||||
};
|
||||
pub const OPEN_PORTAL: Text = Text {
|
||||
de: "Zum Portal",
|
||||
en: "Open the portal",
|
||||
};
|
||||
pub const CONNECTIONS_FAILED: Text = Text {
|
||||
de: "Die Verbindungen lassen sich gerade nicht abrufen; gezeigt werden nur die \
|
||||
bestehenden Freigaben.",
|
||||
en: "The connections cannot be read right now; only the existing releases are shown.",
|
||||
};
|
||||
|
||||
// The published versions.
|
||||
pub const VERSIONS: Text = Text {
|
||||
de: "Veröffentlichte Versionen",
|
||||
en: "Published versions",
|
||||
};
|
||||
pub fn version_meta(day: &str, components: i64, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("{day}, {components} Komp."),
|
||||
Lang::En => format!("{day}, {components} comp."),
|
||||
}
|
||||
}
|
||||
pub fn to_customers(n: usize, lang: Lang) -> String {
|
||||
match (lang, n) {
|
||||
(Lang::De, 1) => "an 1 Kunden".to_string(),
|
||||
(Lang::De, n) => format!("an {n} Kunden"),
|
||||
(Lang::En, 1) => "to 1 customer".to_string(),
|
||||
(Lang::En, n) => format!("to {n} customers"),
|
||||
}
|
||||
}
|
||||
pub const BEFORE_RELEASES: Text = Text {
|
||||
de: "vor den Freigaben",
|
||||
en: "before any release",
|
||||
};
|
||||
pub const TO_NOBODY: Text = Text {
|
||||
de: "an keinen Kunden",
|
||||
en: "to no customer",
|
||||
};
|
||||
pub fn older(n: usize, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("{n} ältere"),
|
||||
Lang::En => format!("{n} older"),
|
||||
}
|
||||
}
|
||||
pub const NEXT: Text = Text {
|
||||
de: "nächste",
|
||||
en: "next",
|
||||
};
|
||||
pub fn draft_from(scanned: Option<&str>, lang: Lang) -> String {
|
||||
match (lang, scanned) {
|
||||
(Lang::De, Some(day)) => format!("Entwurf aus der Prüfung vom {day}"),
|
||||
(Lang::De, None) => "Entwurf".to_string(),
|
||||
(Lang::En, Some(day)) => format!("Draft from the scan of {day}"),
|
||||
(Lang::En, None) => "Draft".to_string(),
|
||||
}
|
||||
}
|
||||
pub const NO_VERSIONS: Text = Text {
|
||||
de: "Noch keine Version veröffentlicht.",
|
||||
en: "No version published yet.",
|
||||
};
|
||||
|
||||
// Publishing.
|
||||
pub fn publish_title(label: &str, lang: Lang) -> String {
|
||||
match (lang, label.is_empty()) {
|
||||
(Lang::De, true) => "Nächste Version veröffentlichen".to_string(),
|
||||
(Lang::De, false) => format!("Version {label} veröffentlichen"),
|
||||
(Lang::En, true) => "Publish the next version".to_string(),
|
||||
(Lang::En, false) => format!("Publish version {label}"),
|
||||
}
|
||||
}
|
||||
pub const LABEL: Text = Text {
|
||||
de: "Versionsangabe",
|
||||
en: "Version label",
|
||||
};
|
||||
pub const LABEL_PLACEHOLDER: Text = Text {
|
||||
de: "z. B. 1.5.0",
|
||||
en: "e.g. 1.5.0",
|
||||
};
|
||||
pub fn last_label(label: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("zuletzt {label}"),
|
||||
Lang::En => format!("last {label}"),
|
||||
}
|
||||
}
|
||||
pub fn against(label: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("Gegenüber {label}"),
|
||||
Lang::En => format!("Compared with {label}"),
|
||||
}
|
||||
}
|
||||
pub const ADDED: Text = Text {
|
||||
de: "neu",
|
||||
en: "new",
|
||||
};
|
||||
pub const UPDATED: Text = Text {
|
||||
de: "aktualisiert",
|
||||
en: "updated",
|
||||
};
|
||||
pub const REMOVED_COUNT: Text = Text {
|
||||
de: "entfernt",
|
||||
en: "removed",
|
||||
};
|
||||
pub const UNCHANGED: Text = Text {
|
||||
de: "unverändert",
|
||||
en: "unchanged",
|
||||
};
|
||||
pub fn changes_aria(added: usize, updated: usize, removed: usize, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => {
|
||||
format!("{added} neue, {updated} aktualisierte, {removed} entfernte Komponenten")
|
||||
}
|
||||
Lang::En => format!("{added} new, {updated} updated, {removed} removed components"),
|
||||
}
|
||||
}
|
||||
pub fn examples(added: &[String], updated: &[String], lang: Lang) -> String {
|
||||
let (a, u) = (listed(added, lang), listed(updated, lang));
|
||||
match (lang, a.is_empty(), u.is_empty()) {
|
||||
(_, true, true) => String::new(),
|
||||
(Lang::De, false, true) => format!("Neu unter anderem {a}."),
|
||||
(Lang::De, true, false) => format!("Aktualisiert unter anderem {u}."),
|
||||
(Lang::De, false, false) => format!("Neu unter anderem {a}; aktualisiert {u}."),
|
||||
(Lang::En, false, true) => format!("New, among others, {a}."),
|
||||
(Lang::En, true, false) => format!("Updated, among others, {u}."),
|
||||
(Lang::En, false, false) => format!("New, among others, {a}; updated {u}."),
|
||||
}
|
||||
}
|
||||
pub fn same_as(label: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("Dieselben Komponenten wie {label}."),
|
||||
Lang::En => format!("The same components as {label}."),
|
||||
}
|
||||
}
|
||||
pub fn first_version(components: usize, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("Ihre erste Version: {components} Komponenten."),
|
||||
Lang::En => format!("Your first version: {components} components."),
|
||||
}
|
||||
}
|
||||
pub const DRAFT_LOADING: Text = Text {
|
||||
de: "Die nächste Version wird zusammengestellt …",
|
||||
en: "Putting the next version together …",
|
||||
};
|
||||
pub const BLOCKED_EMPTY: Text = Text {
|
||||
de: "Die letzte Prüfung fand keine Komponenten; es gibt nichts zu veröffentlichen.",
|
||||
en: "The last scan found no components; there is nothing to publish.",
|
||||
};
|
||||
pub const BLOCKED_TOO_MANY: Text = Text {
|
||||
de: "Mehr Komponenten, als eine Freigabe fasst. Bitte wenden Sie sich an den Support.",
|
||||
en: "More components than a release holds. Please contact support.",
|
||||
};
|
||||
pub const SIEVE: Text = Text {
|
||||
de: "Was weitergegeben wird und was bei Ihnen bleibt",
|
||||
en: "What is passed on and what stays with you",
|
||||
};
|
||||
pub const GOES: Text = Text {
|
||||
de: "Geht an Ihre Kunden",
|
||||
en: "Goes to your customers",
|
||||
};
|
||||
/// What a released SBOM holds (`released_cyclonedx`): each component's
|
||||
/// identity, licences and hashes, and the workspace as the supplier.
|
||||
pub const GOES_ITEMS: [Text; 5] = [
|
||||
Text {
|
||||
de: "Name und Version",
|
||||
en: "Name and version",
|
||||
},
|
||||
Text {
|
||||
de: "purl, CPE",
|
||||
en: "purl, CPE",
|
||||
},
|
||||
Text {
|
||||
de: "Lizenzen",
|
||||
en: "Licences",
|
||||
},
|
||||
Text {
|
||||
de: "Hashes",
|
||||
en: "Hashes",
|
||||
},
|
||||
Text {
|
||||
de: "Ihr Name als Zulieferer",
|
||||
en: "Your name as the supplier",
|
||||
},
|
||||
];
|
||||
pub const STAYS: Text = Text {
|
||||
de: "Bleibt bei Ihnen",
|
||||
en: "Stays with you",
|
||||
};
|
||||
pub const STAYS_ITEMS: [Text; 5] = [
|
||||
Text {
|
||||
de: "Befunde",
|
||||
en: "Findings",
|
||||
},
|
||||
Text {
|
||||
de: "Schwachstellen",
|
||||
en: "Vulnerabilities",
|
||||
},
|
||||
Text {
|
||||
de: "Fundorte",
|
||||
en: "Where it was found",
|
||||
},
|
||||
Text {
|
||||
de: "Ihre Lizenzprüfung",
|
||||
en: "Your licence review",
|
||||
},
|
||||
Text {
|
||||
de: "interne Adressen",
|
||||
en: "Internal addresses",
|
||||
},
|
||||
];
|
||||
/// Who receives version `label`: `now` at once, `later` once they
|
||||
/// accept.
|
||||
pub fn recipients(label: &str, now: &[String], later: &[String], lang: Lang) -> String {
|
||||
let label = if label.is_empty() {
|
||||
match lang {
|
||||
Lang::De => "die Version",
|
||||
Lang::En => "the version",
|
||||
}
|
||||
} else {
|
||||
label
|
||||
};
|
||||
let mut said = Vec::new();
|
||||
if !now.is_empty() {
|
||||
let names = listed(now, lang);
|
||||
said.push(match (lang, now.len()) {
|
||||
(Lang::De, 1) => format!("{names} erhält {label} sofort."),
|
||||
(Lang::De, _) => format!("{names} erhalten {label} sofort."),
|
||||
(Lang::En, 1) => format!("{names} receives {label} at once."),
|
||||
(Lang::En, _) => format!("{names} receive {label} at once."),
|
||||
});
|
||||
}
|
||||
if !later.is_empty() {
|
||||
let names = listed(later, lang);
|
||||
said.push(match (lang, later.len()) {
|
||||
(Lang::De, 1) => {
|
||||
format!("{names} erhält die jeweils neueste Version, sobald es annimmt.")
|
||||
}
|
||||
(Lang::De, _) => {
|
||||
format!("{names} erhalten die jeweils neueste Version, sobald sie annehmen.")
|
||||
}
|
||||
(Lang::En, 1) => format!("{names} receives the latest version once it accepts."),
|
||||
(Lang::En, _) => format!("{names} receive the latest version once they accept."),
|
||||
});
|
||||
}
|
||||
if said.is_empty() {
|
||||
return match lang {
|
||||
Lang::De => "Noch erhält sie kein Kunde: Geben Sie die SBOM oben frei.".to_string(),
|
||||
Lang::En => "No customer receives it yet: release the SBOM above.".to_string(),
|
||||
};
|
||||
}
|
||||
said.join(" ")
|
||||
}
|
||||
pub const PREVIEW: Text = Text {
|
||||
de: "Vorschau laden",
|
||||
en: "Download a preview",
|
||||
};
|
||||
pub fn publish(label: &str, lang: Lang) -> String {
|
||||
match (lang, label.is_empty()) {
|
||||
(Lang::De, true) => "Veröffentlichen".to_string(),
|
||||
(Lang::De, false) => format!("{label} veröffentlichen"),
|
||||
(Lang::En, true) => "Publish".to_string(),
|
||||
(Lang::En, false) => format!("Publish {label}"),
|
||||
}
|
||||
}
|
||||
pub const PUBLISHING: Text = Text {
|
||||
de: "Wird veröffentlicht …",
|
||||
en: "Publishing …",
|
||||
};
|
||||
pub fn published(label: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("Version {label} veröffentlicht"),
|
||||
Lang::En => format!("Version {label} published"),
|
||||
}
|
||||
}
|
||||
pub fn released(peer: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("An {peer} freigegeben"),
|
||||
Lang::En => format!("Released to {peer}"),
|
||||
}
|
||||
}
|
||||
pub fn ended(peer: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("Freigabe an {peer} beendet"),
|
||||
Lang::En => format!("Release to {peer} ended"),
|
||||
}
|
||||
}
|
||||
/// The agent's refusal `error` in words; anything else as it came.
|
||||
pub fn refusal(error: &str, lang: Lang) -> String {
|
||||
// The agent's code is one word of the message, as in
|
||||
// `error running server function: label_taken (409) (details: None)`.
|
||||
const CODES: [&str; 7] = [
|
||||
"label_taken",
|
||||
"label",
|
||||
"empty",
|
||||
"too_many_components",
|
||||
"unknown_connection",
|
||||
"peer_not_entitled",
|
||||
"released",
|
||||
];
|
||||
let code = error
|
||||
.split(|c: char| !(c.is_ascii_lowercase() || c == '_'))
|
||||
.find(|word| CODES.contains(word));
|
||||
let text = match code {
|
||||
Some("label_taken") => Text {
|
||||
de: "Diese Versionsangabe gibt es schon. Wählen Sie eine neue.",
|
||||
en: "This label exists already. Choose a new one.",
|
||||
},
|
||||
Some("label") => Text {
|
||||
de: "Die Versionsangabe ist leer oder zu lang (höchstens 64 Zeichen).",
|
||||
en: "The label is empty or too long (64 characters at most).",
|
||||
},
|
||||
Some("empty") => BLOCKED_EMPTY,
|
||||
Some("too_many_components") => BLOCKED_TOO_MANY,
|
||||
Some("unknown_connection") => Text {
|
||||
de: "Diese Verbindung besteht nicht mehr.",
|
||||
en: "This connection no longer exists.",
|
||||
},
|
||||
Some("peer_not_entitled") => Text {
|
||||
de: "Dieser Kunde nutzt Prüfwerk nicht und kann die Freigabe nicht annehmen.",
|
||||
en: "This customer does not use Prüfwerk and cannot accept the release.",
|
||||
},
|
||||
Some("released") => Text {
|
||||
de: "An diesen Kunden ist die SBOM schon freigegeben.",
|
||||
en: "The SBOM is already released to this customer.",
|
||||
},
|
||||
_ => return error.to_string(),
|
||||
};
|
||||
text.get(lang).to_string()
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,26 @@ pub async fn json_or_error<T: serde::de::DeserializeOwned>(
|
||||
.map_err(|e| ServerFnError::new(e.to_string()))
|
||||
}
|
||||
|
||||
/// The `data` of the agent's answer to `req`, its usual envelope.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// An unreachable agent, or its refusal (as for [`json_or_error`]).
|
||||
pub async fn data<T: serde::de::DeserializeOwned>(
|
||||
req: reqwest::RequestBuilder,
|
||||
) -> Result<T, ServerFnError> {
|
||||
#[derive(serde::Deserialize)]
|
||||
struct Body<T> {
|
||||
data: T,
|
||||
}
|
||||
let resp = req
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| ServerFnError::new(e.to_string()))?;
|
||||
let body: Body<T> = json_or_error(resp).await?;
|
||||
Ok(body.data)
|
||||
}
|
||||
|
||||
/// The response itself when the agent accepted the request, else the refusal
|
||||
/// (as for [`json_or_error`]); for a body the caller streams on.
|
||||
///
|
||||
|
||||
@@ -24,6 +24,7 @@ pub mod onboarding;
|
||||
pub mod pentest;
|
||||
pub mod platform;
|
||||
pub mod projects;
|
||||
pub mod releases;
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub mod sbom;
|
||||
pub mod sbom_ecosystems;
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
//! A target's SBOM releases to connected workspaces (#1028), the supplier's
|
||||
//! side: the agent's `/api/v1/targets/{id}/releases` and `…/versions`, and
|
||||
//! the workspace's connections (`/api/v1/connections`).
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use dioxus::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The other workspace's answer to a release.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Answer {
|
||||
/// Not answered yet.
|
||||
Offered,
|
||||
/// Accepted: it receives every version.
|
||||
Accepted,
|
||||
/// Declined.
|
||||
Declined,
|
||||
/// It removed the component the release went into.
|
||||
Ended,
|
||||
}
|
||||
|
||||
/// A release of the target to one connected workspace.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ReleaseDto {
|
||||
pub id: String,
|
||||
pub connection_id: String,
|
||||
/// The other workspace's display name.
|
||||
pub peer_name: String,
|
||||
pub created_at: DateTime<Utc>,
|
||||
#[serde(default)]
|
||||
pub ended_at: Option<DateTime<Utc>>,
|
||||
/// Not ended.
|
||||
pub active: bool,
|
||||
/// `None` while it is open.
|
||||
#[serde(default)]
|
||||
pub answer: Option<Answer>,
|
||||
/// The version last delivered, and when.
|
||||
#[serde(default)]
|
||||
pub delivered_label: Option<String>,
|
||||
#[serde(default)]
|
||||
pub delivered_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
/// A published version of the target's SBOM.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct VersionDto {
|
||||
pub id: String,
|
||||
pub label: String,
|
||||
pub components: i64,
|
||||
pub created_at: DateTime<Utc>,
|
||||
/// How many customers received it.
|
||||
#[serde(default)]
|
||||
pub customers: usize,
|
||||
}
|
||||
|
||||
/// The target's releases (active ones first) and versions (newest first).
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
|
||||
pub struct ReleasesDto {
|
||||
pub releases: Vec<ReleaseDto>,
|
||||
pub versions: Vec<VersionDto>,
|
||||
}
|
||||
|
||||
/// One of the workspace's active connections.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ConnectionDto {
|
||||
pub id: String,
|
||||
/// The other workspace's display name.
|
||||
pub peer_name: String,
|
||||
}
|
||||
|
||||
/// Why the next version cannot be published.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Unpublishable {
|
||||
/// No components.
|
||||
Empty,
|
||||
/// More than a release holds.
|
||||
TooManyComponents,
|
||||
}
|
||||
|
||||
/// What the next version changes against the latest published one.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct DraftChangesDto {
|
||||
/// The latest published version's label.
|
||||
pub against: String,
|
||||
pub added: usize,
|
||||
pub updated: usize,
|
||||
pub removed: usize,
|
||||
pub unchanged: usize,
|
||||
#[serde(default)]
|
||||
pub added_names: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub updated_names: Vec<String>,
|
||||
}
|
||||
|
||||
/// The next version as publishing it now would make it.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
|
||||
pub struct VersionDraftDto {
|
||||
pub components: usize,
|
||||
/// When the scan it comes from finished.
|
||||
#[serde(default)]
|
||||
pub scanned_at: Option<DateTime<Utc>>,
|
||||
#[serde(default)]
|
||||
pub blocked: Option<Unpublishable>,
|
||||
/// `None` before the first version.
|
||||
#[serde(default)]
|
||||
pub changes: Option<DraftChangesDto>,
|
||||
}
|
||||
|
||||
/// Target `target_id`'s releases and versions.
|
||||
#[server]
|
||||
pub async fn fetch_releases(target_id: String) -> Result<ReleasesDto, ServerFnError> {
|
||||
super::agent_client::data(
|
||||
super::agent_client::agent_get(&format!("/api/v1/targets/{target_id}/releases")).await?,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// The workspace's active connections. An error when the registry cannot
|
||||
/// be asked, so the page tells that apart from having none.
|
||||
#[server]
|
||||
pub async fn fetch_connections() -> Result<Vec<ConnectionDto>, ServerFnError> {
|
||||
super::agent_client::data(super::agent_client::agent_get("/api/v1/connections").await?).await
|
||||
}
|
||||
|
||||
/// What publishing target `target_id` now would make.
|
||||
#[server]
|
||||
pub async fn fetch_version_draft(target_id: String) -> Result<VersionDraftDto, ServerFnError> {
|
||||
super::agent_client::data(
|
||||
super::agent_client::agent_get(&format!("/api/v1/targets/{target_id}/versions/draft"))
|
||||
.await?,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Release target `target_id` over connection `connection_id`.
|
||||
#[server]
|
||||
pub async fn create_release(
|
||||
target_id: String,
|
||||
connection_id: String,
|
||||
) -> Result<ReleaseDto, ServerFnError> {
|
||||
let req = super::agent_client::agent_request(
|
||||
reqwest::Method::POST,
|
||||
&format!("/api/v1/targets/{target_id}/releases"),
|
||||
)
|
||||
.await?
|
||||
.json(&serde_json::json!({ "connection_id": connection_id }));
|
||||
super::agent_client::data(req).await
|
||||
}
|
||||
|
||||
/// End release `release_id` of target `target_id`.
|
||||
#[server]
|
||||
pub async fn end_release(target_id: String, release_id: String) -> Result<(), ServerFnError> {
|
||||
let req = super::agent_client::agent_request(
|
||||
reqwest::Method::POST,
|
||||
&format!("/api/v1/targets/{target_id}/releases/{release_id}/end"),
|
||||
)
|
||||
.await?
|
||||
.json(&serde_json::json!({}));
|
||||
super::agent_client::data::<ReleaseDto>(req)
|
||||
.await
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
/// Publish the next version of target `target_id`, labelled `label`.
|
||||
#[server]
|
||||
pub async fn publish_version(
|
||||
target_id: String,
|
||||
label: String,
|
||||
) -> Result<VersionDto, ServerFnError> {
|
||||
let req = super::agent_client::agent_request(
|
||||
reqwest::Method::POST,
|
||||
&format!("/api/v1/targets/{target_id}/versions"),
|
||||
)
|
||||
.await?
|
||||
.json(&serde_json::json!({ "label": label }));
|
||||
super::agent_client::data(req).await
|
||||
}
|
||||
|
||||
/// The document a version of target `target_id` labelled `label` would
|
||||
/// hold, as JSON text to save.
|
||||
#[server]
|
||||
pub async fn fetch_version_preview(
|
||||
target_id: String,
|
||||
label: String,
|
||||
) -> Result<String, ServerFnError> {
|
||||
let resp =
|
||||
super::agent_client::agent_get(&format!("/api/v1/targets/{target_id}/versions/preview"))
|
||||
.await?
|
||||
.query(&[("label", label.as_str())])
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| ServerFnError::new(e.to_string()))?;
|
||||
let document: serde_json::Value = super::agent_client::json_or_error(resp).await?;
|
||||
serde_json::to_string_pretty(&document).map_err(|e| ServerFnError::new(e.to_string()))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_agents_answers_read() {
|
||||
let listed: ReleasesDto = serde_json::from_value(serde_json::json!({
|
||||
"releases": [{
|
||||
"id": "r1", "connection_id": "c-1", "peer_name": "Beispiel Maschinenbau",
|
||||
"created_at": "2026-11-10T09:00:00Z", "ended_at": null, "active": true,
|
||||
"answer": "accepted", "delivered_label": "1.4.0",
|
||||
"delivered_at": "2026-11-14T10:00:00Z"
|
||||
}],
|
||||
"versions": [{
|
||||
"id": "v1", "label": "1.4.0", "components": 214,
|
||||
"created_at": "2026-11-14T10:00:00Z", "created_by": "u1", "customers": 1
|
||||
}]
|
||||
}))
|
||||
.expect("readable");
|
||||
assert_eq!(listed.releases[0].answer, Some(Answer::Accepted));
|
||||
assert_eq!(listed.versions[0].customers, 1);
|
||||
|
||||
let draft: VersionDraftDto = serde_json::from_value(serde_json::json!({
|
||||
"components": 0, "scanned_at": null, "blocked": "too_many_components",
|
||||
"changes": null
|
||||
}))
|
||||
.expect("readable");
|
||||
assert_eq!(draft.blocked, Some(Unpublishable::TooManyComponents));
|
||||
}
|
||||
}
|
||||
@@ -147,39 +147,23 @@ pub struct ProjectDocumentsDto {
|
||||
pub store_path: String,
|
||||
}
|
||||
|
||||
/// The `data` of an agent answer to `req`.
|
||||
#[cfg(feature = "server")]
|
||||
async fn data<T: serde::de::DeserializeOwned>(
|
||||
req: reqwest::RequestBuilder,
|
||||
) -> Result<T, ServerFnError> {
|
||||
#[derive(Deserialize)]
|
||||
struct Body<T> {
|
||||
data: T,
|
||||
}
|
||||
let resp = req
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| ServerFnError::new(e.to_string()))?;
|
||||
let body: Body<T> = super::agent_client::json_or_error(resp).await?;
|
||||
Ok(body.data)
|
||||
}
|
||||
|
||||
/// The workspace's supply chain.
|
||||
#[server]
|
||||
pub async fn fetch_supply_chain() -> Result<SupplyChainDto, ServerFnError> {
|
||||
data(super::agent_client::agent_get("/api/v1/supply-chain").await?).await
|
||||
super::agent_client::data(super::agent_client::agent_get("/api/v1/supply-chain").await?).await
|
||||
}
|
||||
|
||||
/// The customer's arrangement of the supply chain.
|
||||
#[server]
|
||||
pub async fn fetch_supply_chain_layout() -> Result<LayoutDto, ServerFnError> {
|
||||
data(super::agent_client::agent_get("/api/v1/supply-chain/layout").await?).await
|
||||
super::agent_client::data(super::agent_client::agent_get("/api/v1/supply-chain/layout").await?)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Product project `id`'s description and documents.
|
||||
#[server]
|
||||
pub async fn fetch_project_documents(id: String) -> Result<ProjectDocumentsDto, ServerFnError> {
|
||||
data(
|
||||
super::agent_client::data(
|
||||
super::agent_client::agent_get(&format!("/api/v1/supply-chain/projects/{id}/documents"))
|
||||
.await?,
|
||||
)
|
||||
@@ -193,7 +177,9 @@ pub async fn save_supply_chain_layout(positions: Vec<PositionDto>) -> Result<(),
|
||||
super::agent_client::agent_request(reqwest::Method::PUT, "/api/v1/supply-chain/layout")
|
||||
.await?
|
||||
.json(&serde_json::json!({ "positions": positions }));
|
||||
data::<LayoutDto>(req).await.map(|_| ())
|
||||
super::agent_client::data::<LayoutDto>(req)
|
||||
.await
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
/// Reset the arrangement to the computed columns.
|
||||
|
||||
@@ -19,6 +19,7 @@ pub mod onboarding;
|
||||
pub mod overview;
|
||||
pub mod pentest_dashboard;
|
||||
pub mod pentest_session;
|
||||
pub mod releases;
|
||||
pub mod sbom;
|
||||
pub mod supply_chain;
|
||||
pub mod target;
|
||||
@@ -45,6 +46,7 @@ pub use onboarding::OnboardingPage;
|
||||
pub use overview::OverviewPage;
|
||||
pub use pentest_dashboard::PentestDashboardPage;
|
||||
pub use pentest_session::PentestSessionPage;
|
||||
pub use releases::TargetReleasesPage;
|
||||
pub use sbom::SbomPage;
|
||||
pub use supply_chain::SupplyChainPage;
|
||||
pub use target::TargetPage;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -22,8 +22,8 @@ use crate::components::severity_badge::SeverityBadge;
|
||||
use crate::components::toast::{ToastType, Toasts};
|
||||
use crate::components::webhook_deliveries::WebhookDeliveries;
|
||||
use crate::i18n::texts::{
|
||||
common, compliance::language_name, kinds, onboarding as onboarding_tx, repo_views as rv,
|
||||
targets as tx,
|
||||
common, compliance::language_name, kinds, onboarding as onboarding_tx, releases as releases_tx,
|
||||
repo_views as rv, targets as tx,
|
||||
};
|
||||
use crate::i18n::{format_ago, use_lang};
|
||||
use crate::infrastructure::evidence::{fetch_compliance, CraCounts};
|
||||
@@ -243,6 +243,17 @@ pub fn TargetPage(id: String) -> Element {
|
||||
}
|
||||
}
|
||||
EvidencePackButton { target_id: id.clone() }
|
||||
// An own target's SBOM can go to connected customers (#1028); a
|
||||
// bought-in component's came from its supplier.
|
||||
if SupplierDto::of(&t).is_none() {
|
||||
Link {
|
||||
class: "btn btn-ghost",
|
||||
to: Route::TargetReleasesPage { id: id.clone() },
|
||||
title: releases_tx::ENTRY_HINT.get(lang),
|
||||
Icon { icon: BsSend, width: 14, height: 14 }
|
||||
{releases_tx::ENTRY.get(lang)}
|
||||
}
|
||||
}
|
||||
if can_write {
|
||||
button {
|
||||
class: "btn btn-ghost",
|
||||
|
||||
Reference in new issue
Block a user