@@ -507,9 +507,17 @@ impl App {
507
507
app_blueprint : & AppBlueprint < ' _ > ,
508
508
storage_context : & StorageContext < ' _ > ,
509
509
store_context : Option < & StoreContext < ' _ > > ,
510
+ display_mode : & DisplayMode ,
510
511
) {
511
512
while let Some ( cmd) = self . command_receiver . recv_ui ( ) {
512
- self . run_ui_command ( egui_ctx, app_blueprint, storage_context, store_context, cmd) ;
513
+ self . run_ui_command (
514
+ egui_ctx,
515
+ app_blueprint,
516
+ storage_context,
517
+ store_context,
518
+ display_mode,
519
+ cmd,
520
+ ) ;
513
521
}
514
522
}
515
523
@@ -1030,8 +1038,9 @@ impl App {
1030
1038
& mut self ,
1031
1039
egui_ctx : & egui:: Context ,
1032
1040
app_blueprint : & AppBlueprint < ' _ > ,
1033
- _storage_context : & StorageContext < ' _ > ,
1041
+ storage_context : & StorageContext < ' _ > ,
1034
1042
store_context : Option < & StoreContext < ' _ > > ,
1043
+ display_mode : & DisplayMode ,
1035
1044
cmd : UICommand ,
1036
1045
) {
1037
1046
let mut force_store_info = false ;
@@ -1070,7 +1079,7 @@ impl App {
1070
1079
for item in self . state . selection_state . selected_items ( ) . iter_items ( ) {
1071
1080
match item {
1072
1081
Item :: AppId ( selected_app_id) => {
1073
- for recording in _storage_context . bundle . recordings ( ) {
1082
+ for recording in storage_context . bundle . recordings ( ) {
1074
1083
if recording. application_id ( ) == selected_app_id {
1075
1084
selected_stores. push ( recording. store_id ( ) . clone ( ) ) ;
1076
1085
}
@@ -1085,7 +1094,7 @@ impl App {
1085
1094
1086
1095
let selected_stores = selected_stores
1087
1096
. iter ( )
1088
- . filter_map ( |store_id| _storage_context . bundle . get ( store_id) )
1097
+ . filter_map ( |store_id| storage_context . bundle . get ( store_id) )
1089
1098
. collect_vec ( ) ;
1090
1099
1091
1100
if selected_stores. is_empty ( ) {
@@ -1391,13 +1400,8 @@ impl App {
1391
1400
re_ui:: apply_style_and_install_loaders ( egui_ctx) ;
1392
1401
}
1393
1402
1394
- #[ cfg( target_arch = "wasm32" ) ]
1395
1403
UICommand :: CopyDirectLink => {
1396
- if self . run_copy_direct_link_command ( store_context) . is_none ( ) {
1397
- re_log:: error!(
1398
- "Failed to copy direct link to clipboard. Is this not running in a browser?"
1399
- ) ;
1400
- }
1404
+ self . run_copy_direct_link_command ( storage_context, display_mode) ;
1401
1405
}
1402
1406
1403
1407
UICommand :: CopyTimeRangeLink => {
@@ -1552,27 +1556,38 @@ impl App {
1552
1556
Ok ( url)
1553
1557
}
1554
1558
1555
- #[ cfg( target_arch = "wasm32" ) ]
1556
1559
fn run_copy_direct_link_command (
1557
1560
& mut self ,
1558
- store_context : Option < & StoreContext < ' _ > > ,
1559
- ) -> Option < ( ) > {
1560
- use crate :: web_tools:: JsResultExt as _;
1561
- let href = self . get_viewer_url ( ) . ok_or_log_js_error ( ) ?;
1562
-
1563
- let direct_link = match store_context
1564
- . map ( |ctx| ctx. recording )
1565
- . and_then ( |rec| rec. data_source . as_ref ( ) )
1561
+ storage_context : & StorageContext < ' _ > ,
1562
+ display_mode : & DisplayMode ,
1563
+ ) {
1564
+ // TODO(rerun-io/dataplatform#2663): Should take into account dataplatform URLs if any are provided.
1565
+ let base_url;
1566
+ #[ cfg( target_arch = "wasm32" ) ]
1566
1567
{
1567
- Some ( SmartChannelSource :: RrdHttpStream { url, .. } ) => format ! ( "{href}?url={url}" ) ,
1568
- _ => href,
1568
+ use crate :: web_tools:: JsResultExt as _;
1569
+ base_url = crate :: web_tools:: current_base_url ( ) . ok_or_log_js_error ( ) ;
1570
+ } ;
1571
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
1572
+ {
1573
+ base_url = None ;
1569
1574
} ;
1570
1575
1571
- self . egui_ctx . copy_text ( direct_link. clone ( ) ) ;
1572
- self . notifications
1573
- . success ( format ! ( "Copied {direct_link:?} to clipboard" ) ) ;
1574
-
1575
- Some ( ( ) )
1576
+ match crate :: open_url:: ViewerImportUrl :: from_display_mode (
1577
+ storage_context. hub ,
1578
+ display_mode. clone ( ) ,
1579
+ )
1580
+ . and_then ( |content_url| content_url. sharable_url ( base_url. as_ref ( ) ) )
1581
+ {
1582
+ Ok ( url) => {
1583
+ self . egui_ctx . copy_text ( url) ;
1584
+ self . notifications
1585
+ . success ( "Copied link to clipboard" . to_owned ( ) ) ;
1586
+ }
1587
+ Err ( err) => {
1588
+ re_log:: error!( "{err}" ) ;
1589
+ }
1590
+ }
1576
1591
}
1577
1592
1578
1593
fn run_copy_time_range_link_command ( & mut self , store_context : Option < & StoreContext < ' _ > > ) {
@@ -2767,11 +2782,13 @@ impl eframe::App for App {
2767
2782
Self :: handle_dropping_files ( egui_ctx, & storage_context, & self . command_sender ) ;
2768
2783
2769
2784
// Run pending commands last (so we don't have to wait for a repaint before they are run):
2785
+ let display_mode = self . state . navigation . peek ( ) . clone ( ) ;
2770
2786
self . run_pending_ui_commands (
2771
2787
egui_ctx,
2772
2788
& app_blueprint,
2773
2789
& storage_context,
2774
2790
store_context. as_ref ( ) ,
2791
+ & display_mode,
2775
2792
) ;
2776
2793
}
2777
2794
self . run_pending_system_commands ( & mut store_hub, egui_ctx) ;
0 commit comments