Skip to content

Commit

Permalink
Fix spec hover to show the correct path
Browse files Browse the repository at this point in the history
  • Loading branch information
tiborschneider committed Sep 26, 2024
1 parent b005db0 commit 512d7ea
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions bgpsim-web/src/draw/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::collections::HashMap;
use std::ops::Deref;
use std::sync::{Arc, Mutex};

use bgpsim::policies::Policy;
use bgpsim::types::RouterId;
use gloo_events::EventListener;
use gloo_utils::window;
Expand Down Expand Up @@ -356,21 +357,29 @@ pub fn CanvasHighlightPath() -> Html {
net.spec()
.get(&r)
.and_then(|x| x.get(idx))
.map(|(_, r)| r.is_ok())
.map(|(p, r)| (p.clone(), r.is_ok()))
})
},
spec_idx,
);

match (state.deref().clone(), *spec) {
match (state.deref().clone(), spec.as_ref()) {
((Hover::Router(router_id), Layer::FwState, Some(prefix)), _) => {
html! {<ForwardingPath {router_id} {prefix} />}
}
((Hover::Policy(router_id, _), _, Some(prefix)), Some(true)) => {
html! {<ForwardingPath {router_id} {prefix} kind={PathKind::Valid}/>}
((Hover::Policy(router_id, _), _, _), Some((p, true))) => {
if let Some(prefix) = p.prefix() {
html! {<ForwardingPath {router_id} {prefix} kind={PathKind::Valid}/>}
} else {
html!()
}
}
((Hover::Policy(router_id, _), _, Some(prefix)), Some(false)) => {
html! {<ForwardingPath {router_id} {prefix} kind={PathKind::Invalid}/>}
((Hover::Policy(router_id, _), _, _), Some((p, false))) => {
if let Some(prefix) = p.prefix() {
html! {<ForwardingPath {router_id} {prefix} kind={PathKind::Invalid}/>}
} else {
html!()
}
}
_ => html!(),
}
Expand Down

0 comments on commit 512d7ea

Please sign in to comment.