fix(dashboard): the Lieferkette's document links go to the portal's origin (#1054)
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 4m46s
CI / Check (pull_request) Successful in 21m36s

On stage `PORTAL_URL` is the workspace's portal dashboard
(`https://app-stage.breakpilot.com/<slug>/dashboard`), not the portal's
root, so a document's link read `…/<slug>/dashboard/<slug>/dokumente/…`.
The portal's own paths now go after its origin (scheme and host) only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-11-19 12:10:18 +01:00
1 parent f06a347dd7
commit f889a0fa98
1 file changed
+31 -1
+31 -1
View File
@@ -821,7 +821,7 @@ fn ChainView(chain: SupplyChainDto, layout: LayoutDto) -> Element {
ProjectDocs {
key: "{id}",
id: id.to_string(),
portal_url: portal_url.trim_end_matches('/').to_string(),
portal_url: portal_origin(&portal_url).to_string(),
can_write,
}
Link { class: "chain-panel-link", to: Route::MachinePage { id: id.to_string(), tab: String::new() }, {tx::OPEN_PRODUCT.get(lang)} }
@@ -832,6 +832,19 @@ fn ChainView(chain: SupplyChainDto, layout: LayoutDto) -> Element {
}
}
/// 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.
fn portal_origin(url: &str) -> &str {
let Some(scheme_end) = url.find("://") else {
return url.trim_end_matches('/');
};
let host_start = scheme_end + 3;
url[host_start..]
.find('/')
.map_or(url, |slash| &url[..host_start + slash])
}
/// A file size as people read it: "340 KB", "1,2 MB".
fn size_text(bytes: u64, lang: Lang) -> String {
const KB: f64 = 1024.0;
@@ -1136,6 +1149,23 @@ mod tests {
assert!(folded_keys(&c).is_empty());
}
#[test]
fn a_documents_path_goes_after_the_portals_origin() {
assert_eq!(
portal_origin("https://app-stage.breakpilot.com/sharna/dashboard"),
"https://app-stage.breakpilot.com"
);
assert_eq!(
portal_origin("https://app.breakpilot.com/"),
"https://app.breakpilot.com"
);
assert_eq!(
portal_origin("http://127.0.0.1:9999"),
"http://127.0.0.1:9999"
);
assert_eq!(portal_origin(""), "");
}
#[test]
fn a_file_size_reads_in_the_language() {
assert_eq!(size_text(1_258_291, Lang::De), "1,2 MB");