Skip to content

Commit e2d108d

Browse files
Wumpfabey79
andauthored
Use ViewerImportUrl for updating history, adds more unit tests (#11034)
Co-authored-by: Antoine Beyeler <[email protected]>
1 parent d8bed36 commit e2d108d

File tree

5 files changed

+713
-213
lines changed

5 files changed

+713
-213
lines changed

crates/store/re_data_source/src/data_source.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum LogDataSource {
1515
/// Could be either an `.rrd` recording or a `.rbl` blueprint.
1616
RrdHttpUrl {
1717
/// This is a canonicalized URL path without any parameters or fragments.
18-
url: String,
18+
url: url::Url,
1919

2020
/// If `follow` is `true`, the viewer will open the stream in `Following` mode rather than `Playing` mode.
2121
follow: bool,
@@ -125,14 +125,12 @@ impl LogDataSource {
125125
} else if let Ok(uri) = url.parse::<re_uri::ProxyUri>() {
126126
Some(Self::RedapProxy(uri))
127127
} else {
128-
let mut parsed_url = url::Url::parse(url)
128+
let url = url::Url::parse(url)
129129
.or_else(|_| url::Url::parse(&format!("http://{url}")))
130130
.ok()?;
131+
let path = url.path();
131132

132-
// Ignore any parameters, we don't support them for http urls.
133-
parsed_url.set_query(None);
134-
let url = parsed_url.to_string();
135-
(url.ends_with(".rrd") || url.ends_with(".rbl"))
133+
(path.ends_with(".rrd") || path.ends_with(".rbl"))
136134
.then_some(Self::RrdHttpUrl { url, follow: false })
137135
}
138136
}
@@ -156,7 +154,9 @@ impl LogDataSource {
156154
match self {
157155
Self::RrdHttpUrl { url, follow } => Ok(
158156
re_log_encoding::stream_rrd_from_http::stream_rrd_from_http_to_channel(
159-
url, follow, on_msg,
157+
url.to_string(),
158+
follow,
159+
on_msg,
160160
),
161161
),
162162

crates/store/re_log_types/src/path/data_path.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ pub struct DataPath {
2323
impl std::fmt::Display for DataPath {
2424
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2525
self.entity_path.fmt(f)?;
26-
if let Some(instance) = &self.instance {
26+
if let Some(instance) = &self.instance
27+
&& instance != &Instance::ALL
28+
{
2729
write!(f, "[#{instance}]")?;
2830
}
2931
if let Some(component_descriptor) = &self.component_descriptor {

crates/viewer/re_global_context/src/item.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,34 @@ impl Item {
6363
}
6464
}
6565
}
66+
67+
/// Converts this item to a data path if possible.
68+
pub fn to_data_path(&self) -> Option<DataPath> {
69+
match self {
70+
Self::AppId(_)
71+
| Self::TableId(_)
72+
| Self::DataSource(_)
73+
| Self::View(_)
74+
| Self::Container(_)
75+
| Self::StoreId(_)
76+
| Self::RedapServer(_)
77+
| Self::RedapEntry(_) => None,
78+
79+
Self::ComponentPath(component_path) => Some(DataPath {
80+
entity_path: component_path.entity_path.clone(),
81+
instance: None,
82+
component_descriptor: Some(component_path.component_descriptor.clone()),
83+
}),
84+
85+
Self::InstancePath(instance_path) | Self::DataResult(_, instance_path) => {
86+
Some(DataPath {
87+
entity_path: instance_path.entity_path.clone(),
88+
instance: Some(instance_path.instance),
89+
component_descriptor: None,
90+
})
91+
}
92+
}
93+
}
6694
}
6795

6896
impl From<ViewId> for Item {

crates/viewer/re_viewer/src/app.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,9 @@ impl App {
648648
}
649649

650650
SystemCommand::AddRedapServer(origin) => {
651+
if origin == *re_redap_browser::EXAMPLES_ORIGIN {
652+
return;
653+
}
651654
if self.state.redap_servers.has_server(&origin) {
652655
return;
653656
}
@@ -865,7 +868,7 @@ impl App {
865868
match data_source {
866869
LogDataSource::RrdHttpUrl { url, follow } => {
867870
let new_source = SmartChannelSource::RrdHttpStream {
868-
url: url.clone(),
871+
url: url.to_string(),
869872
follow: *follow,
870873
};
871874
if all_sources.any(|source| source.is_same_ignoring_uri_fragments(&new_source)) {
@@ -3150,7 +3153,13 @@ fn update_web_address_bar(
31503153
if !enable_history {
31513154
return None;
31523155
}
3153-
let url = crate::open_url::display_mode_to_content_url(store_hub, display_mode)?;
3156+
let Ok(url) =
3157+
crate::open_url::ViewerImportUrl::from_display_mode(store_hub, display_mode.clone())
3158+
// History entries expect the url parameter, not the full url, therefore don't pass a base url.
3159+
.and_then(|url| url.sharable_url(None))
3160+
else {
3161+
return None;
3162+
};
31543163

31553164
re_log::debug!("Updating navigation bar");
31563165

0 commit comments

Comments
 (0)