Skip to content

Commit 296e8b3

Browse files
authored
Support sharing URLs for dataplatform datasets & tables (#11038)
### Related * Part of #10866 ### What Web viewer URL bar reacts to this accordingly, [copy direct link](#11035) will pick it up and you can navigate to the resulting URL in all the places that take URLs (like command line or command pallette or `url` parameter) https://github.com/user-attachments/assets/f9843337-70bc-4708-9256-5395686c0534 (ignore errors & missing loads. Sandbox is having some issues as of writing) Also fixes an issue where navigation back to the server looked broken because it didn't select it as well as general missing redraws.
1 parent b9ba856 commit 296e8b3

File tree

11 files changed

+56
-38
lines changed

11 files changed

+56
-38
lines changed

crates/utils/re_uri/src/endpoints/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use re_log_types::EntryId;
33
use crate::{Error, Origin, RedapUri};
44

55
/// URI for a remote entry.
6-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
6+
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Deserialize, serde::Serialize)]
77
pub struct EntryUri {
88
pub origin: Origin,
99
pub entry_id: EntryId,

crates/viewer/re_context_menu/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ trait ContextMenuAction {
384384
}
385385
Item::Container(container_id) => self.process_container(ctx, container_id),
386386
Item::RedapServer(origin) => self.process_redap_server(ctx, origin),
387-
Item::RedapEntry(entry_id) => {
388-
self.process_redap_entry(ctx, entry_id);
387+
Item::RedapEntry(entry) => {
388+
self.process_redap_entry(ctx, &entry.entry_id);
389389
}
390390
}
391391
}

crates/viewer/re_global_context/src/item.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use re_entity_db::{EntityDb, InstancePath};
2-
use re_log_types::{ComponentPath, DataPath, EntityPath, EntryId, TableId};
2+
use re_log_types::{ComponentPath, DataPath, EntityPath, TableId};
33

44
use crate::{ContainerId, Contents, ViewId};
55

@@ -38,7 +38,7 @@ pub enum Item {
3838
/// A table or dataset entry stored in a Redap server.
3939
// TODO(ab): this should probably be split into separate variant, and made more consistent with
4040
// `AppId` and `TableId`.
41-
RedapEntry(EntryId),
41+
RedapEntry(re_uri::EntryUri),
4242

4343
/// A Redap server.
4444
RedapServer(re_uri::Origin),
@@ -173,8 +173,8 @@ impl std::fmt::Debug for Item {
173173
write!(f, "({view_id:?}, {instance_path}")
174174
}
175175
Self::Container(tile_id) => write!(f, "(tile: {tile_id:?})"),
176-
Self::RedapEntry(entry_id) => {
177-
write!(f, "{entry_id}")
176+
Self::RedapEntry(entry) => {
177+
write!(f, "{entry}")
178178
}
179179
Self::RedapServer(server) => write!(f, "{server}"),
180180
}

crates/viewer/re_global_context/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub enum DisplayMode {
7171
LocalTable(TableId),
7272

7373
/// The Redap server/catalog/collection browser.
74-
RedapEntry(re_log_types::EntryId),
74+
RedapEntry(re_uri::EntryUri),
7575
RedapServer(re_uri::Origin),
7676

7777
/// The current recording's data store browser.

crates/viewer/re_recording_panel/src/data.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,13 @@ impl<'a> ServerEntriesData<'a> {
310310
entry_id: entry.id(),
311311
name: entry.name().to_owned(),
312312
icon: entry.icon(),
313-
is_selected: ctx.selection().contains_item(&Item::RedapEntry(entry.id())),
314-
is_active: ctx.active_redap_entry() == Some(&entry.id()),
313+
is_selected: ctx.selection().contains_item(&Item::RedapEntry(
314+
re_uri::EntryUri {
315+
origin: origin.clone(),
316+
entry_id: entry.id(),
317+
},
318+
)),
319+
is_active: ctx.active_redap_entry() == Some(entry.id()),
315320
};
316321

317322
match entry.inner() {
@@ -423,14 +428,21 @@ pub struct EntryData {
423428

424429
impl EntryData {
425430
pub fn item(&self) -> Item {
426-
Item::RedapEntry(self.entry_id)
431+
Item::RedapEntry(self.entry_uri())
427432
}
428433

429434
pub fn id(&self) -> egui::Id {
430435
egui::Id::new(&self.origin)
431436
.with(self.entry_id)
432437
.with(&self.name)
433438
}
439+
440+
pub fn entry_uri(&self) -> re_uri::EntryUri {
441+
re_uri::EntryUri {
442+
origin: self.origin.clone(),
443+
entry_id: self.entry_id,
444+
}
445+
}
434446
}
435447

436448
// ---

crates/viewer/re_recording_panel/src/recording_panel_ui.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ fn dataset_entry_ui(
321321
let DatasetData {
322322
entry_data:
323323
EntryData {
324-
origin: _,
324+
origin,
325325
entry_id,
326326
name,
327327
icon,
@@ -393,7 +393,7 @@ fn dataset_entry_ui(
393393
.send_system(SystemCommand::SetSelection(item));
394394
ctx.command_sender()
395395
.send_system(SystemCommand::ChangeDisplayMode(DisplayMode::RedapEntry(
396-
*entry_id,
396+
re_uri::EntryUri::new(origin.clone(), *entry_id),
397397
)));
398398
}
399399
}
@@ -406,7 +406,7 @@ fn remote_table_entry_ui(
406406
let RemoteTableData {
407407
entry_data:
408408
EntryData {
409-
origin: _,
409+
origin,
410410
entry_id,
411411
name,
412412
icon,
@@ -427,7 +427,7 @@ fn remote_table_entry_ui(
427427
.send_system(SystemCommand::SetSelection(item));
428428
ctx.command_sender()
429429
.send_system(SystemCommand::ChangeDisplayMode(DisplayMode::RedapEntry(
430-
*entry_id,
430+
re_uri::EntryUri::new(origin.clone(), *entry_id),
431431
)));
432432
}
433433
}
@@ -440,7 +440,7 @@ fn failed_entry_ui(
440440
let FailedEntryData {
441441
entry_data:
442442
EntryData {
443-
origin: _,
443+
origin,
444444
entry_id,
445445
name,
446446
icon,
@@ -462,7 +462,7 @@ fn failed_entry_ui(
462462
.send_system(SystemCommand::SetSelection(item));
463463
ctx.command_sender()
464464
.send_system(SystemCommand::ChangeDisplayMode(DisplayMode::RedapEntry(
465-
*entry_id,
465+
re_uri::EntryUri::new(origin.clone(), *entry_id),
466466
)));
467467
}
468468

crates/viewer/re_selection_panel/src/item_title.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl ItemTitle {
7272
}
7373

7474
// TODO(#10566): There should be an `EntryName` in this `Item` arm.
75-
Item::RedapEntry(entry) => Self::new(entry.to_string(), &icons::DATASET),
75+
Item::RedapEntry(entry) => Self::new(entry.entry_id.to_string(), &icons::DATASET),
7676

7777
// TODO(lucasmerlin): Icon?
7878
Item::RedapServer(origin) => Self::new(origin.to_string(), &icons::DATASET),

crates/viewer/re_viewer/src/app.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,10 @@ impl App {
638638
}
639639

640640
SystemCommand::ChangeDisplayMode(display_mode) => {
641+
if &display_mode == self.state.navigation.peek() {
642+
return;
643+
}
644+
641645
// Update web-navigation bar if this isn't about local recordings.
642646
//
643647
// Recordings are on selection since recording change always comes with a selection change.
@@ -653,6 +657,7 @@ impl App {
653657
}
654658

655659
self.state.navigation.replace(display_mode);
660+
egui_ctx.request_repaint(); // Make sure we actually see the new mode.
656661
}
657662

658663
SystemCommand::AddRedapServer(origin) => {
@@ -753,10 +758,10 @@ impl App {
753758

754759
SystemCommand::SetSelection(item) => {
755760
match &item {
756-
Item::RedapEntry(entry_id) => {
761+
Item::RedapEntry(entry) => {
757762
self.state
758763
.navigation
759-
.replace(DisplayMode::RedapEntry(*entry_id));
764+
.replace(DisplayMode::RedapEntry(entry.clone()));
760765
}
761766

762767
Item::RedapServer(origin) => {
@@ -793,6 +798,7 @@ impl App {
793798
store_hub,
794799
self.state.navigation.peek(),
795800
);
801+
egui_ctx.request_repaint(); // Make sure we actually see the new selection.
796802
}
797803

798804
SystemCommand::SetActiveTime {

crates/viewer/re_viewer/src/app_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ impl AppState {
627627
}
628628

629629
DisplayMode::RedapEntry(entry) => {
630-
redap_servers.entry_ui(&ctx, ui, *entry);
630+
redap_servers.entry_ui(&ctx, ui, entry.entry_id);
631631
}
632632

633633
DisplayMode::RedapServer(origin) => {

crates/viewer/re_viewer/src/open_url.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,7 @@ impl ViewerImportUrl {
254254
Err(anyhow::anyhow!("Can't share links to local tables."))
255255
}
256256

257-
DisplayMode::RedapEntry(_entry_id) => {
258-
// TODO(#10866): Implement this.
259-
Err(anyhow::anyhow!("Can't share links to redap entries."))
260-
}
257+
DisplayMode::RedapEntry(entry) => Ok(Self::RedapEntry(entry.clone())),
261258

262259
DisplayMode::RedapServer(origin) => {
263260
// `as_url` on the origin gives us an http link.
@@ -324,7 +321,7 @@ impl ViewerImportUrl {
324321
vec1![catalog_uri.to_string()]
325322
}
326323

327-
Self::RedapEntry(entry_uri) => vec1![entry_uri.to_string()],
324+
Self::RedapEntry(entry) => vec1![entry.to_string()],
328325

329326
Self::WebEventListener => vec1![WEB_EVENT_LISTENER_SCHEME.to_owned()],
330327

@@ -427,14 +424,12 @@ impl ViewerImportUrl {
427424
}
428425
Self::RedapCatalog(uri) => {
429426
command_sender.send_system(SystemCommand::AddRedapServer(uri.origin.clone()));
430-
command_sender.send_system(SystemCommand::ChangeDisplayMode(
431-
DisplayMode::RedapServer(uri.origin),
432-
));
427+
command_sender
428+
.send_system(SystemCommand::SetSelection(Item::RedapServer(uri.origin)));
433429
}
434430
Self::RedapEntry(uri) => {
435-
command_sender.send_system(SystemCommand::AddRedapServer(uri.origin));
436-
command_sender
437-
.send_system(SystemCommand::SetSelection(Item::RedapEntry(uri.entry_id)));
431+
command_sender.send_system(SystemCommand::AddRedapServer(uri.origin.clone()));
432+
command_sender.send_system(SystemCommand::SetSelection(Item::RedapEntry(uri)));
438433
}
439434
Self::WebEventListener => {
440435
handle_web_event_listener(egui_ctx, command_sender);
@@ -721,10 +716,15 @@ mod tests {
721716
);
722717

723718
// RedapEntry
724-
// TODO(#10866): Implement this. Antoine and I figured that display mode (and item) should just contain the entry uri. We should have this knowledge on all creation sites!
725-
assert!(
726-
ViewerImportUrl::from_display_mode(&store_hub, DisplayMode::RedapEntry(EntryId::new()))
727-
.is_err()
719+
let origin = "rerun://localhost:51234".parse().unwrap();
720+
let entry_uri = re_uri::EntryUri::new(origin, EntryId::new());
721+
assert_eq!(
722+
ViewerImportUrl::from_display_mode(
723+
&store_hub,
724+
DisplayMode::RedapEntry(entry_uri.clone())
725+
)
726+
.unwrap(),
727+
ViewerImportUrl::RedapEntry(entry_uri)
728728
);
729729

730730
// ChunkStoreBrowser

0 commit comments

Comments
 (0)