From c6650309c67718f755ec2df0e510de6118e2d528 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Thu, 19 Nov 2026 18:14:12 +0100 Subject: [PATCH] fix(dashboard): the release screen claims nothing it has not read (#1028) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Until the connections are read, no "no connection" note or portal box; until the draft is read, no component count and nothing to publish. - The page waits for the target, so the title always names it. - Ending a release takes two steps: the x asks, "Freigabe beenden" ends. - The preview needs a label: it is the document's version. - "Ihr Name als Zulieferer" among what goes to customers; "Noch keine Version veröffentlicht" beside a first draft. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9 --- compliance-dashboard/assets/main.css | 13 ++ compliance-dashboard/src/i18n/texts.rs | 25 +++- compliance-dashboard/src/pages/releases.rs | 149 +++++++++++++-------- 3 files changed, 130 insertions(+), 57 deletions(-) diff --git a/compliance-dashboard/assets/main.css b/compliance-dashboard/assets/main.css index 47f90a2..88dba23 100644 --- a/compliance-dashboard/assets/main.css +++ b/compliance-dashboard/assets/main.css @@ -9140,6 +9140,19 @@ span.repo-crumb-name { 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; diff --git a/compliance-dashboard/src/i18n/texts.rs b/compliance-dashboard/src/i18n/texts.rs index 9d894fa..40c8147 100644 --- a/compliance-dashboard/src/i18n/texts.rs +++ b/compliance-dashboard/src/i18n/texts.rs @@ -8090,12 +8090,24 @@ pub mod releases { 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 => { @@ -8256,6 +8268,10 @@ pub mod releases { 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.", @@ -8272,8 +8288,9 @@ pub mod releases { de: "Geht an Ihre Kunden", en: "Goes to your customers", }; - /// What a released SBOM keeps of each component (`released_cyclonedx`). - pub const GOES_ITEMS: [Text; 4] = [ + /// 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", @@ -8290,6 +8307,10 @@ pub mod releases { 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", diff --git a/compliance-dashboard/src/pages/releases.rs b/compliance-dashboard/src/pages/releases.rs index 18beedc..4a8aea2 100644 --- a/compliance-dashboard/src/pages/releases.rs +++ b/compliance-dashboard/src/pages/releases.rs @@ -277,20 +277,19 @@ pub fn TargetReleasesPage(id: String) -> Element { let ecosystems = use_resource(move || async move { fetch_sbom_ecosystems(target_id()).await.ok() }); - let name = target - .read() - .as_ref() - .and_then(|t| t.as_ref()) - .and_then(|t| { - t.data - .get("name") - .and_then(|n| n.as_str()) - .map(String::from) - }) - .unwrap_or_default(); + let name = match &*target.read() { + Some(Some(t)) => t + .data + .get("name") + .and_then(|n| n.as_str()) + .unwrap_or_default() + .to_string(), + Some(None) => String::new(), + None => return rsx! { div { class: "loading", {tx::LOADING.get(lang)} } }, + }; let listed = match &*releases.read() { - Some(Ok(listed)) => listed.clone(), - Some(Err(_)) => { + Some(Ok(listed)) if !name.is_empty() => listed.clone(), + Some(_) => { return rsx! { ReleaseCrumbs { id: id.clone(), name } div { class: "card", p { {tx::LOAD_FAILED.get(lang)} } } @@ -302,9 +301,12 @@ pub fn TargetReleasesPage(id: String) -> Element { // releases are shown as they are; none is taken for ended. let connections_read = connections.read().clone(); let failed = matches!(connections_read, Some(None)); + let connections_known = matches!(connections_read, Some(Some(_))); let known: Option> = connections_read.flatten(); let rows = rows(known.as_deref(), &listed.releases); - let draft = next_version.read().clone().flatten().unwrap_or_default(); + // `None` while it loads or when it cannot be read: nothing is claimed + // about the next version then, and it cannot be published. + let draft = next_version.read().clone().flatten(); let parts = ecosystem_parts( &ecosystems.read().clone().flatten().unwrap_or_default(), tx::OTHER_ECOSYSTEMS.get(lang), @@ -332,7 +334,8 @@ pub fn TargetReleasesPage(id: String) -> Element { draft: draft.clone(), parts, can_write, - portal_url: if failed { String::new() } else { portal_url }, + connections_known, + portal_url, on_change, } VersionTrain { @@ -375,15 +378,19 @@ fn ReleaseRoute( target_id: String, name: String, rows: Vec, - draft: VersionDraftDto, + draft: Option, parts: Vec<(String, u64)>, can_write: bool, + /// The connections were read: an empty list means there are none. + connections_known: bool, portal_url: String, on_change: EventHandler<()>, ) -> Element { let lang = use_lang()(); let mut toasts = use_context::(); let mut busy = use_signal(|| false); + // The release whose end is being asked for. + let mut confirming = use_signal(|| None::); let geometry = Geometry::for_rows(rows.len()); let states: Vec = rows.iter().map(|r| RowState::of(r, lang)).collect(); let trunk = if states.iter().any(|s| s.tone() == "live") { @@ -393,13 +400,17 @@ fn ReleaseRoute( }; let (height, trunk_y) = (geometry.height, geometry.trunk_y); let target_top = trunk_y - TARGET_H / 2; - let scanned = draft.scanned_at.as_ref().map(|t| tx::day(t, lang)); + let scanned = draft + .as_ref() + .and_then(|d| d.scanned_at.as_ref()) + .map(|t| tx::day(t, lang)); let total: u64 = parts.iter().map(|(_, n)| n).sum(); let component_count = if total > 0 { - usize::try_from(total).unwrap_or(usize::MAX) + Some(usize::try_from(total).unwrap_or(usize::MAX)) } else { - draft.components + draft.as_ref().map(|d| d.components) }; + let none_connected = rows.is_empty() && connections_known; // Lines that receive are drawn last, over the dashed ones. let mut order: Vec = (0..rows.len()).collect(); order.sort_by_key(|&i| states[i].tone() == "live"); @@ -427,7 +438,7 @@ fn ReleaseRoute( class: "rel-line {trunk}", d: "M {TARGET_X + TARGET_W} {trunk_y} H {JUNCTION_X}", } - if rows.is_empty() { + if none_connected { path { class: "rel-line off", d: "M {JUNCTION_X} {trunk_y} H {PEER_X}", @@ -464,7 +475,9 @@ fn ReleaseRoute( } } } - span { class: "rel-target-kind", {tx::components(component_count, scanned.as_deref(), lang)} } + if let Some(n) = component_count { + span { class: "rel-target-kind", {tx::components(n, scanned.as_deref(), lang)} } + } } for (i, row) in rows.iter().enumerate() { { @@ -524,36 +537,52 @@ fn ReleaseRoute( let release_id = release.as_ref().map(|r| r.id.clone()); let target = target_id.clone(); let ending = peer.clone(); + // Ending takes two steps: the × asks, the button in the box ends. + let asking = release_id.is_some() && confirming() == release_id; + let ask_id = release_id.clone(); rsx! { div { class: "rel-peer {tone}", style: "{style}", div { class: "rel-peer-top", span { class: "rel-peer-name", title: "{peer}", "{peer}" } - if let (Some(release_id), true) = (release_id, can_write) { + if release_id.is_some() && can_write { button { class: "rel-end", r#type: "button", - title: tx::end_hint(&peer, lang), - "aria-label": tx::end_hint(&peer, lang), + title: if asking { tx::KEEP.get(lang).to_string() } else { tx::end_hint(&peer, lang) }, + "aria-label": if asking { tx::KEEP.get(lang).to_string() } else { tx::end_hint(&peer, lang) }, + "aria-expanded": "{asking}", disabled: busy(), - onclick: move |_| { - let (release_id, target, ending) = (release_id.clone(), target.clone(), ending.clone()); - busy.set(true); - spawn(async move { - match end_release(target, release_id).await { - Ok(()) => toasts.push(ToastType::Success, tx::ended(&ending, lang)), - Err(e) => toasts.push(ToastType::Error, tx::refusal(&e.to_string(), lang)), - } - busy.set(false); - on_change.call(()); - }); - }, + onclick: move |_| confirming.set(if asking { None } else { ask_id.clone() }), svg { width: "14", height: "14", view_box: "0 0 24 24", "aria-hidden": "true", path { d: "M6 6l12 12M18 6L6 18", fill: "none", stroke: "currentColor", stroke_width: "2.2", stroke_linecap: "round" } } } } } - span { class: "rel-peer-status {tone}", {state.status(lang)} } + if let (true, Some(release_id)) = (asking, release_id) { + button { + class: "rel-end-confirm", + r#type: "button", + title: tx::end_hint(&peer, lang), + disabled: busy(), + onclick: move |_| { + let (release_id, target, ending) = (release_id.clone(), target.clone(), ending.clone()); + busy.set(true); + spawn(async move { + match end_release(target, release_id).await { + Ok(()) => toasts.push(ToastType::Success, tx::ended(&ending, lang)), + Err(e) => toasts.push(ToastType::Error, tx::refusal(&e.to_string(), lang)), + } + busy.set(false); + confirming.set(None); + on_change.call(()); + }); + }, + {tx::END_CONFIRM.get(lang)} + } + } else { + span { class: "rel-peer-status {tone}", {state.status(lang)} } + } } } } @@ -561,14 +590,14 @@ fn ReleaseRoute( } } } - if rows.is_empty() { + if none_connected { { let top = trunk_y - PEER_H / 2; let style = format!("left: {PEER_X}px; top: {top}px; width: {PEER_W}px; height: {PEER_H}px;"); rsx! { if portal_url.is_empty() { div { class: "rel-peer off", style: "{style}", - span { class: "rel-peer-status off", {tx::NOT_RELEASED.get(lang)} } + span { class: "rel-peer-status off", {tx::NO_CUSTOMER.get(lang)} } } } else { a { class: "rel-peer rel-peer-add", style: "{style}", href: "{portal_url}", @@ -580,7 +609,7 @@ fn ReleaseRoute( } } } - if rows.is_empty() { + if none_connected { p { class: "rel-route-note", {tx::NO_CONNECTIONS.get(lang)} } } } @@ -592,27 +621,34 @@ fn ReleaseRoute( fn VersionTrain( versions: Vec, releases: Vec, - draft: VersionDraftDto, + draft: Option, show_draft: bool, ) -> Element { let lang = use_lang()(); let (older, shown) = shown_versions(&versions); - let with_draft = show_draft && draft.blocked.is_none() && draft.components > 0; + let with_draft = show_draft + && draft + .as_ref() + .is_some_and(|d| d.blocked.is_none() && d.components > 0); let stops = shown.len() + usize::from(older > 0) + usize::from(with_draft); let slot = (WIDTH - 120) / i32::try_from(stops.max(1)).unwrap_or(1); let x = |i: usize| 60 + slot * i32::try_from(i).unwrap_or(0) + slot / 2; let fold = usize::from(older > 0); let last_version = (fold + shown.len()).checked_sub(1); - let scanned = draft.scanned_at.as_ref().map(|t| tx::day(t, lang)); + let scanned = draft + .as_ref() + .and_then(|d| d.scanned_at.as_ref()) + .map(|t| tx::day(t, lang)); const LINE_Y: i32 = 106; rsx! { section { class: "rel-train", "aria-labelledby": "rel-train-h", div { class: "rel-train-canvas", style: "width: {WIDTH}px;", h2 { id: "rel-train-h", {tx::VERSIONS.get(lang)} } - if stops == 0 { + if shown.is_empty() { p { class: "rel-route-note", {tx::NO_VERSIONS.get(lang)} } - } else { + } + if stops > 0 { svg { class: "rel-lines", width: "{WIDTH}", height: "200", "aria-hidden": "true", if let Some(last) = last_version.filter(|&l| l > 0) { path { class: "rel-line live thick", d: "M {x(0)} {LINE_Y} H {x(last)}" } @@ -675,7 +711,7 @@ fn VersionTrain( fn PublishPanel( target_id: String, rows: Vec, - draft: VersionDraftDto, + draft: Option, last: Option, on_published: EventHandler<()>, ) -> Element { @@ -701,8 +737,10 @@ fn PublishPanel( }) .map(|r| r.peer_name.clone()) .collect(); - let blocked = draft.blocked; - let can_publish = blocked.is_none() && !typed.is_empty() && !publishing(); + let blocked = draft.as_ref().and_then(|d| d.blocked); + // A label is needed for the preview too: it is the document's version. + let ready = draft.is_some() && blocked.is_none() && !typed.is_empty(); + let can_publish = ready && !publishing(); let preview_target = target_id.clone(); rsx! { @@ -725,11 +763,12 @@ fn PublishPanel( } div { class: "rel-publish-body", div { class: "rel-changes", - match (blocked, &draft.changes) { - (Some(Unpublishable::Empty), _) => rsx! { p { class: "rel-blocked", {tx::BLOCKED_EMPTY.get(lang)} } }, - (Some(Unpublishable::TooManyComponents), _) => rsx! { p { class: "rel-blocked", {tx::BLOCKED_TOO_MANY.get(lang)} } }, - (None, None) => rsx! { p { class: "rel-changes-text", {tx::first_version(draft.components, lang)} } }, - (None, Some(c)) => rsx! { + match (draft.as_ref(), blocked, draft.as_ref().and_then(|d| d.changes.as_ref())) { + (None, _, _) => rsx! { p { class: "rel-changes-text", {tx::DRAFT_LOADING.get(lang)} } }, + (Some(_), Some(Unpublishable::Empty), _) => rsx! { p { class: "rel-blocked", {tx::BLOCKED_EMPTY.get(lang)} } }, + (Some(_), Some(Unpublishable::TooManyComponents), _) => rsx! { p { class: "rel-blocked", {tx::BLOCKED_TOO_MANY.get(lang)} } }, + (Some(d), None, None) => rsx! { p { class: "rel-changes-text", {tx::first_version(d.components, lang)} } }, + (Some(_), None, Some(c)) => rsx! { span { class: "rel-changes-title", {tx::against(&c.against, lang)} } span { class: "rel-diff", @@ -780,10 +819,10 @@ fn PublishPanel( button { class: "btn btn-secondary", r#type: "button", - disabled: blocked.is_some(), + disabled: !ready, onclick: move |_| { let target = preview_target.clone(); - let preview_label = if label().trim().is_empty() { tx::NEXT.get(lang).to_string() } else { label().trim().to_string() }; + let preview_label = label().trim().to_string(); spawn(async move { match fetch_version_preview(target, preview_label).await { Ok(text) => save_json(&text, "release-preview.cdx.json"),