feat(supply-chain): a supplier's box says how it delivers (#1028)
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 / Agent integration (pull_request) Successful in 5m18s
CI / Check (pull_request) Successful in 22m13s
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 / Agent integration (pull_request) Successful in 5m18s
CI / Check (pull_request) Successful in 22m13s
A supplier's box and its panel on the Lieferkette now say how the supplier delivers, as the approved board shows: "Freigabe, live", "Upload-Link aktiv", "Freigabe beendet", "per Upload" or "noch keine SBOM", the liveliest of its lines when it delivers several components. The panel explains what that means (an ended release names the version that stays, or says the SBOMs stay when several ended) and leads on: to the suppliers' releases for a release, to the component when the supplier delivers just one. Only live states are drawn in the accent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
This commit is contained in:
1 parent
600a8f0dd7
commit
5d66732e53
3 files changed
+195
-6
No files matched your search
@@ -8883,6 +8883,8 @@ span.repo-crumb-name {
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
.chain-panel-kind { font-size: 12px; color: var(--text-tertiary); }
|
||||
.chain-panel-sub { margin: -6px 0 0; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
|
||||
.chain-panel-sub.live { color: var(--accent); }
|
||||
.chain-panel-facts { margin: 0; font-size: 14px; color: var(--text-secondary); }
|
||||
.chain-panel-link { font-size: 14px; font-weight: 600; }
|
||||
.chain-empty {
|
||||
|
||||
@@ -7681,7 +7681,7 @@ pub mod machine {
|
||||
pub mod supply_chain {
|
||||
use super::Text;
|
||||
use crate::i18n::Lang;
|
||||
use crate::infrastructure::supply_chain::NodeKind;
|
||||
use crate::infrastructure::supply_chain::{DeliveryKind, NodeKind};
|
||||
|
||||
pub const TITLE: Text = Text {
|
||||
de: "Woraus Ihre Produkte bestehen",
|
||||
@@ -7804,6 +7804,57 @@ pub mod supply_chain {
|
||||
en: "Upload link active",
|
||||
};
|
||||
|
||||
pub const OPEN_RELEASES: Text = Text {
|
||||
de: "Freigaben von Zulieferern ansehen",
|
||||
en: "See suppliers' releases",
|
||||
};
|
||||
pub const OPEN_COMPONENT: Text = Text {
|
||||
de: "Komponente öffnen",
|
||||
en: "Open the component",
|
||||
};
|
||||
|
||||
/// How a supplier delivers, under its name.
|
||||
pub fn supplier_sub(how: DeliveryKind, lang: Lang) -> &'static str {
|
||||
match (how, lang) {
|
||||
(DeliveryKind::Release, Lang::De) => "Freigabe, live",
|
||||
(DeliveryKind::Release, Lang::En) => "Release, live",
|
||||
(DeliveryKind::Invite, _) => LINK_ACTIVE.get(lang),
|
||||
(DeliveryKind::ReleaseEnded, _) => LEGEND_ENDED.get(lang),
|
||||
(DeliveryKind::Upload, _) => LEGEND_UPLOAD.get(lang),
|
||||
(DeliveryKind::Missing, _) => NO_SBOM.get(lang),
|
||||
}
|
||||
}
|
||||
|
||||
/// What that means, in the selected supplier's panel; `kept` is the
|
||||
/// version an ended release left, when `ended` (how many ended) is one.
|
||||
pub fn supplier_desc(
|
||||
how: DeliveryKind,
|
||||
kept: Option<&str>,
|
||||
ended: usize,
|
||||
lang: Lang,
|
||||
) -> String {
|
||||
match (how, lang) {
|
||||
(DeliveryKind::Release, Lang::De) => "Verbundener Workspace. Jede Version, die er veröffentlicht, kommt von selbst und wird gleich geprüft.".into(),
|
||||
(DeliveryKind::Release, Lang::En) => "A connected workspace. Each version it publishes arrives by itself and is checked at once.".into(),
|
||||
(DeliveryKind::Invite, Lang::De) => "Lädt neue Versionen über den Upload-Link hoch; jede wird gleich geprüft.".into(),
|
||||
(DeliveryKind::Invite, Lang::En) => "Uploads new versions through the upload link; each is checked at once.".into(),
|
||||
(DeliveryKind::ReleaseEnded, Lang::De) if ended > 1 => "Die Freigaben endeten. Die zuletzt erhaltenen SBOMs bleiben und werden weiter geprüft; neue Versionen kommen nicht mehr.".into(),
|
||||
(DeliveryKind::ReleaseEnded, Lang::En) if ended > 1 => "The releases ended. The SBOMs received last stay and are still checked; no new versions arrive.".into(),
|
||||
(DeliveryKind::ReleaseEnded, Lang::De) => format!(
|
||||
"Die Freigabe endete. {} bleibt und wird weiter geprüft; neue Versionen kommen nicht mehr.",
|
||||
kept.map_or("Die zuletzt erhaltene SBOM".to_string(), |v| format!("Die zuletzt erhaltene SBOM {v}"))
|
||||
),
|
||||
(DeliveryKind::ReleaseEnded, Lang::En) => format!(
|
||||
"The release ended. {} stays and is still checked; no new versions arrive.",
|
||||
kept.map_or("The SBOM received last".to_string(), |v| format!("SBOM {v}, received last,"))
|
||||
),
|
||||
(DeliveryKind::Upload, Lang::De) => "Die SBOM lädt jemand aus Ihrem Workspace hoch.".into(),
|
||||
(DeliveryKind::Upload, Lang::En) => "Someone in your workspace uploads the SBOM.".into(),
|
||||
(DeliveryKind::Missing, Lang::De) => "Von diesem Zulieferer ist noch keine SBOM da.".into(),
|
||||
(DeliveryKind::Missing, Lang::En) => "No SBOM from this supplier yet.".into(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The chip of a release that ended, naming the version that stays.
|
||||
pub fn release_ended(version: Option<&str>, lang: Lang) -> String {
|
||||
match (version, lang) {
|
||||
|
||||
@@ -22,8 +22,8 @@ use crate::i18n::texts::{kinds, supply_chain as tx};
|
||||
use crate::i18n::{format_ago, use_lang, Lang};
|
||||
use crate::infrastructure::supply_chain::{
|
||||
fetch_project_documents, fetch_supply_chain, fetch_supply_chain_layout,
|
||||
reset_supply_chain_layout, save_supply_chain_layout, DeliveryKind, EdgeDto, EdgeKind,
|
||||
LayoutDto, NodeDto, NodeKind, PositionDto, SupplyChainDto,
|
||||
reset_supply_chain_layout, save_supply_chain_layout, DeliveryDto, DeliveryKind, EdgeDto,
|
||||
EdgeKind, LayoutDto, NodeDto, NodeKind, PositionDto, SupplyChainDto,
|
||||
};
|
||||
|
||||
/// The top of the first box in each column, below the column titles.
|
||||
@@ -249,6 +249,57 @@ fn delivery_label(
|
||||
Some((class, text))
|
||||
}
|
||||
|
||||
/// How a supplier delivers, as its box and panel say it: the liveliest of
|
||||
/// its lines (a release before a link, either before an ended release, then
|
||||
/// an upload, then none), how many releases ended and the version one left,
|
||||
/// and the component when it delivers just one. `None` for a key that is no
|
||||
/// supplier's.
|
||||
fn supplier_delivery(chain: &SupplyChainDto, key: &str) -> Option<SupplierDelivery> {
|
||||
let rank = |how: DeliveryKind| match how {
|
||||
DeliveryKind::Release => 0,
|
||||
DeliveryKind::Invite => 1,
|
||||
DeliveryKind::ReleaseEnded => 2,
|
||||
DeliveryKind::Upload => 3,
|
||||
DeliveryKind::Missing => 4,
|
||||
};
|
||||
let lines: Vec<(&EdgeDto, &DeliveryDto)> = chain
|
||||
.edges
|
||||
.iter()
|
||||
.filter(|e| e.from == key && e.kind == EdgeKind::Supplies)
|
||||
.filter_map(|e| e.delivery.as_ref().map(|d| (e, d)))
|
||||
.collect();
|
||||
let (_, best) = lines.iter().min_by_key(|(_, d)| rank(d.how))?;
|
||||
let ended: Vec<&DeliveryDto> = lines
|
||||
.iter()
|
||||
.filter(|(_, d)| d.how == DeliveryKind::ReleaseEnded)
|
||||
.map(|(_, d)| *d)
|
||||
.collect();
|
||||
Some(SupplierDelivery {
|
||||
how: best.how,
|
||||
ended: ended.len(),
|
||||
kept: match ended.as_slice() {
|
||||
[d] => d.version.clone(),
|
||||
_ => None,
|
||||
},
|
||||
only: match lines.as_slice() {
|
||||
[(e, _)] => e.to.strip_prefix("target:").map(str::to_string),
|
||||
_ => None,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/// What [`supplier_delivery`] finds.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
struct SupplierDelivery {
|
||||
how: DeliveryKind,
|
||||
/// How many of its releases ended.
|
||||
ended: usize,
|
||||
/// The version an ended release left, when just one ended.
|
||||
kept: Option<String>,
|
||||
/// The one component it delivers, by target id.
|
||||
only: Option<String>,
|
||||
}
|
||||
|
||||
/// Where the box of the components in no product sits: the components'
|
||||
/// column, and its size.
|
||||
const FOLD_X: i32 = 420;
|
||||
@@ -741,7 +792,9 @@ fn ChainView(chain: SupplyChainDto, layout: LayoutDto) -> Element {
|
||||
(NodeKind::Project, ..) => "chain-node product",
|
||||
};
|
||||
let sub = match (node.kind, node.level) {
|
||||
(NodeKind::Supplier, _) => tx::SUPPLIER.get(lang).to_string(),
|
||||
(NodeKind::Supplier, _) => supplier_delivery(&chain, &key)
|
||||
.map_or(tx::SUPPLIER.get(lang), |d| tx::supplier_sub(d.how, lang))
|
||||
.to_string(),
|
||||
(NodeKind::Target, _) => node.target_type.map(|t| kinds::target_type(&t.to_string(), lang)).unwrap_or_default(),
|
||||
(NodeKind::Project, Some(ProjectLevel::Component)) => tx::ASSEMBLY.get(lang).to_string(),
|
||||
(NodeKind::Project, Some(ProjectLevel::Family)) => tx::FAMILY.get(lang).to_string(),
|
||||
@@ -803,7 +856,13 @@ fn ChainView(chain: SupplyChainDto, layout: LayoutDto) -> Element {
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(n) = picked {
|
||||
if let Some(n) = picked.filter(|n| n.kind == NodeKind::Supplier) {
|
||||
SupplierPanel {
|
||||
name: n.name.clone(),
|
||||
facts: tx::facts(n.kind, 0, chain.edges.iter().filter(|e| e.from == n.key).count(), lang),
|
||||
delivery: supplier_delivery(&chain, &n.key),
|
||||
}
|
||||
} else if let Some(n) = picked {
|
||||
aside { class: "chain-panel", "aria-label": tx::SELECTED.get(lang),
|
||||
span { class: "chain-panel-kind",
|
||||
{match (n.kind, n.level) {
|
||||
@@ -849,6 +908,35 @@ fn ChainView(chain: SupplyChainDto, layout: LayoutDto) -> Element {
|
||||
}
|
||||
}
|
||||
|
||||
/// A selected supplier: under its name, how it delivers; what that means;
|
||||
/// and where to see more.
|
||||
#[component]
|
||||
fn SupplierPanel(name: String, facts: String, delivery: Option<SupplierDelivery>) -> Element {
|
||||
let lang = use_lang()();
|
||||
rsx! {
|
||||
aside { class: "chain-panel", "aria-label": tx::SELECTED.get(lang),
|
||||
span { class: "chain-panel-kind", {tx::SUPPLIER.get(lang)} }
|
||||
h2 { "{name}" }
|
||||
if let Some(d) = delivery.as_ref() {
|
||||
p {
|
||||
class: "chain-panel-sub",
|
||||
class: if matches!(d.how, DeliveryKind::Release | DeliveryKind::Invite) { "live" },
|
||||
{tx::supplier_sub(d.how, lang)}
|
||||
}
|
||||
}
|
||||
p { class: "chain-panel-facts", "{facts}" }
|
||||
if let Some(d) = delivery {
|
||||
p { class: "chain-panel-desc", {tx::supplier_desc(d.how, d.kept.as_deref(), d.ended, lang)} }
|
||||
if matches!(d.how, DeliveryKind::Release | DeliveryKind::ReleaseEnded) {
|
||||
Link { class: "chain-panel-link", to: Route::SupplierOffersPage {}, {tx::OPEN_RELEASES.get(lang)} }
|
||||
} else if let Some(id) = d.only {
|
||||
Link { class: "chain-panel-link", to: Route::TargetPage { id }, {tx::OPEN_COMPONENT.get(lang)} }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The scheme and host of `url`, without a path: what the portal's own paths
|
||||
/// (`/{slug}/dokumente/…`) go after. `PORTAL_URL` may point at a page of the
|
||||
/// portal (on stage, the workspace's dashboard), not at its root.
|
||||
@@ -947,7 +1035,6 @@ fn ProjectDocs(id: String, portal_url: String, can_write: bool) -> Element {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::infrastructure::supply_chain::DeliveryDto;
|
||||
|
||||
fn node(key: &str, kind: NodeKind, level: Option<ProjectLevel>) -> NodeDto {
|
||||
NodeDto {
|
||||
@@ -1210,6 +1297,55 @@ mod tests {
|
||||
assert_eq!(cve_state(None, Lang::De).1, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_supplier_says_its_liveliest_line() {
|
||||
let mut c = chain();
|
||||
let mut ended = edge("supplier:A", "target:sensor", EdgeKind::Supplies);
|
||||
ended.delivery = Some(DeliveryDto {
|
||||
how: DeliveryKind::ReleaseEnded,
|
||||
version: Some("2.0.4".into()),
|
||||
at: None,
|
||||
});
|
||||
c.edges.push(ended);
|
||||
c.edges[0].delivery.as_mut().unwrap().how = DeliveryKind::Release;
|
||||
|
||||
assert_eq!(
|
||||
supplier_delivery(&c, "supplier:A"),
|
||||
Some(SupplierDelivery {
|
||||
how: DeliveryKind::Release,
|
||||
ended: 1,
|
||||
kept: Some("2.0.4".into()),
|
||||
only: None,
|
||||
}),
|
||||
"live before ended; the version that stays is still named"
|
||||
);
|
||||
assert_eq!(
|
||||
supplier_delivery(&c, "supplier:B"),
|
||||
Some(SupplierDelivery {
|
||||
how: DeliveryKind::Upload,
|
||||
ended: 0,
|
||||
kept: None,
|
||||
only: Some("sensor".into()),
|
||||
})
|
||||
);
|
||||
assert_eq!(supplier_delivery(&c, "target:drive"), None);
|
||||
assert_eq!(
|
||||
tx::supplier_desc(DeliveryKind::ReleaseEnded, Some("2.0.4"), 1, Lang::De),
|
||||
"Die Freigabe endete. Die zuletzt erhaltene SBOM 2.0.4 bleibt und wird weiter geprüft; neue Versionen kommen nicht mehr."
|
||||
);
|
||||
c.edges[0].delivery.as_mut().unwrap().how = DeliveryKind::ReleaseEnded;
|
||||
let both = supplier_delivery(&c, "supplier:A").unwrap();
|
||||
assert_eq!(
|
||||
(both.ended, both.kept.as_deref()),
|
||||
(2, None),
|
||||
"no one version for two"
|
||||
);
|
||||
assert_eq!(
|
||||
tx::supplier_desc(DeliveryKind::ReleaseEnded, None, 2, Lang::En),
|
||||
"The releases ended. The SBOMs received last stay and are still checked; no new versions arrive."
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_release_is_drawn_live_and_names_the_version_it_leaves() {
|
||||
let now = chrono::Utc::now();
|
||||
|
||||
Reference in new issue
Block a user