Skip to content

Commit 7668141

Browse files
authored
Add context menu button to copy partition name (#11378)
1 parent 812a72c commit 7668141

File tree

6 files changed

+68
-13
lines changed

6 files changed

+68
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9154,6 +9154,7 @@ dependencies = [
91549154
"itertools 0.14.0",
91559155
"re_data_ui",
91569156
"re_entity_db",
9157+
"re_log",
91579158
"re_log_types",
91589159
"re_redap_browser",
91599160
"re_smart_channel",

crates/viewer/re_data_ui/src/item_ui.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,13 +797,22 @@ pub fn entity_db_button_ui(
797797
.and_then(|url| url.sharable_url(None));
798798
if ui
799799
.add_enabled(url.is_ok(), egui::Button::new("Copy link to partition"))
800-
.on_disabled_hover_text("Can't copy a link to this partition")
800+
.on_disabled_hover_text(if let Err(err) = url.as_ref() {
801+
format!("Can't copy a link to this partition: {err}")
802+
} else {
803+
"Can't copy a link to this partition".to_owned()
804+
})
801805
.clicked()
802806
&& let Ok(url) = url
803807
{
804808
ctx.command_sender()
805809
.send_system(SystemCommand::CopyViewerUrl(url));
806810
}
811+
812+
if ui.button("Copy partition name").clicked() {
813+
re_log::info!("Copied {recording_name:?} to clipboard");
814+
ui.ctx().copy_text(recording_name);
815+
}
807816
});
808817

809818
if response.clicked() {

crates/viewer/re_dataframe_ui/src/datafusion_table_widget.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ use re_log_types::{EntryId, TimelineName, Timestamp};
1717
use re_sorbet::{ColumnDescriptorRef, SorbetSchema};
1818
use re_ui::menu::menu_style;
1919
use re_ui::{UiExt as _, icons};
20-
use re_viewer_context::{AsyncRuntimeHandle, ViewerContext};
20+
use re_viewer_context::{
21+
AsyncRuntimeHandle, SystemCommand, SystemCommandSender as _, ViewerContext,
22+
};
2123

2224
use crate::datafusion_adapter::{DataFusionAdapter, DataFusionQueryResult};
2325
use crate::display_record_batch::DisplayColumn;
@@ -380,7 +382,14 @@ impl<'a> DataFusionTableWidget<'a> {
380382
);
381383

382384
if let Some(title) = title {
383-
title_ui(ui, Some(&mut table_config), title, url, should_show_spinner);
385+
title_ui(
386+
ui,
387+
viewer_ctx,
388+
Some(&mut table_config),
389+
title,
390+
url,
391+
should_show_spinner,
392+
);
384393
}
385394

386395
filter_state.filter_bar_ui(
@@ -565,6 +574,7 @@ fn id_from_session_context_and_table(
565574

566575
fn title_ui(
567576
ui: &mut egui::Ui,
577+
ctx: &ViewerContext<'_>,
568578
table_config: Option<&mut TableConfig>,
569579
title: &str,
570580
url: Option<&str>,
@@ -588,7 +598,8 @@ fn title_ui(
588598
.on_hover_text(url)
589599
.clicked()
590600
{
591-
ui.ctx().copy_text(url.into());
601+
ctx.command_sender()
602+
.send_system(SystemCommand::CopyViewerUrl(url.to_owned()));
592603
}
593604

594605
if should_show_spinner {

crates/viewer/re_recording_panel/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ testing = ["dep:serde", "re_viewer_context/testing", "re_log_types/serde"]
2525
[dependencies]
2626
re_data_ui.workspace = true
2727
re_entity_db.workspace = true
28+
re_log.workspace = true
2829
re_log_types.workspace = true
2930
re_redap_browser.workspace = true
3031
re_smart_channel.workspace = true

crates/viewer/re_recording_panel/src/recording_panel_ui.rs

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,17 @@ fn dataset_entry_ui(
406406
ctx.command_sender()
407407
.send_system(SystemCommand::CopyViewerUrl(url));
408408
}
409+
410+
if ui.button("Copy dataset name").clicked() {
411+
re_log::info!("Copied {name:?} to clipboard");
412+
ui.ctx().copy_text(name.clone());
413+
}
414+
415+
if ui.button("Copy dataset id").clicked() {
416+
let id = entry_id.id.to_string();
417+
re_log::info!("Copied {id:?} to clipboard");
418+
ui.ctx().copy_text(id);
419+
}
409420
});
410421

411422
if item_response.clicked() {
@@ -570,13 +581,13 @@ fn receiver_ui(
570581
receiver: &SmartChannelSource,
571582
show_hierarchal: bool,
572583
) {
573-
let Some(string) = receiver.loading_name() else {
584+
let Some(name) = receiver.loading_name() else {
574585
return;
575586
};
576587

577588
let selected = ctx.is_selected_or_loading(&Item::DataSource(receiver.clone()));
578589

579-
let label_content = re_ui::list_item::LabelContent::new(string)
590+
let label_content = re_ui::list_item::LabelContent::new(&name)
580591
.with_icon_fn(|ui, rect, _| {
581592
ui.put(rect, egui::Spinner::new());
582593
})
@@ -590,13 +601,35 @@ fn receiver_ui(
590601
}
591602
});
592603

593-
if show_hierarchal {
604+
let response = if show_hierarchal {
594605
ui.list_item()
595606
.selected(selected)
596-
.show_hierarchical(ui, label_content);
607+
.show_hierarchical(ui, label_content)
597608
} else {
598609
ui.list_item()
599610
.selected(selected)
600-
.show_flat(ui, label_content);
601-
}
611+
.show_flat(ui, label_content)
612+
};
613+
614+
response.context_menu(|ui| {
615+
let url = ViewerOpenUrl::from_data_source(receiver).and_then(|url| url.sharable_url(None));
616+
if ui
617+
.add_enabled(url.is_ok(), egui::Button::new("Copy link to partition"))
618+
.on_disabled_hover_text(if let Err(err) = url.as_ref() {
619+
format!("Can't copy a link to this partition: {err}")
620+
} else {
621+
"Can't copy a link to this partition".to_owned()
622+
})
623+
.clicked()
624+
&& let Ok(url) = url
625+
{
626+
ctx.command_sender()
627+
.send_system(SystemCommand::CopyViewerUrl(url));
628+
}
629+
630+
if ui.button("Copy partition name").clicked() {
631+
re_log::info!("Copied {name:?} to clipboard");
632+
ui.ctx().copy_text(name);
633+
}
634+
});
602635
}

crates/viewer/re_time_panel/src/time_panel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,10 +1877,10 @@ fn copy_timeline_properties_context_menu(
18771877
copy_command.is_ok() && has_fragment,
18781878
egui::Button::new("Copy link to timestamp"),
18791879
)
1880-
.on_disabled_hover_text(if copy_command.is_err() {
1881-
"Can't share links to the current recording"
1880+
.on_disabled_hover_text(if let Err(err) = copy_command.as_ref() {
1881+
format!("Can't share links to the current recording: {err}")
18821882
} else {
1883-
"The current recording doesn't support time stamp links"
1883+
"The current recording doesn't support time stamp links".to_owned()
18841884
})
18851885
.clicked()
18861886
&& let Ok(copy_command) = copy_command

0 commit comments

Comments
 (0)