1
1
use re_global_context:: { DisplayMode , SystemCommand } ;
2
+ use re_smart_channel:: SmartChannelSource ;
2
3
3
4
use crate :: ViewerContext ;
4
5
@@ -12,7 +13,60 @@ pub struct UrlContext {
12
13
pub fragment : re_uri:: Fragment ,
13
14
}
14
15
16
+ #[ derive( Default , Clone , Copy ) ]
17
+ pub struct UrlFeatures {
18
+ pub time_range : bool ,
19
+ pub fragment : bool ,
20
+ }
21
+
15
22
impl UrlContext {
23
+ /// Information about what this url can do, can be used to hide UI for
24
+ /// sharing when we know it won't work.
25
+ ///
26
+ /// This should be kept up to date with what `ViewerOpenUrl::new` does
27
+ // TODO(isse): I don't really like how this has to be kept up to date manually with
28
+ // `ViewerOpenUrl`, would be nice to consolidate.
29
+ pub fn features ( & self , store_hub : & crate :: StoreHub ) -> Option < UrlFeatures > {
30
+ match & self . display_mode {
31
+ DisplayMode :: Settings | DisplayMode :: LocalTable ( _) | DisplayMode :: ChunkStoreBrowser => {
32
+ None
33
+ }
34
+
35
+ DisplayMode :: LocalRecordings => {
36
+ let active_recording = store_hub. active_recording ( ) ?;
37
+ let data_source = active_recording. data_source . as_ref ( ) ?;
38
+ match data_source {
39
+ SmartChannelSource :: RrdHttpStream { .. }
40
+ | SmartChannelSource :: RrdWebEventListener
41
+ | SmartChannelSource :: MessageProxy ( _) => Some ( UrlFeatures :: default ( ) ) ,
42
+
43
+ SmartChannelSource :: RedapGrpcStream { .. } => Some ( UrlFeatures {
44
+ time_range : true ,
45
+ fragment : true ,
46
+ } ) ,
47
+
48
+ SmartChannelSource :: File ( _) => {
49
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
50
+ {
51
+ Some ( UrlFeatures :: default ( ) )
52
+ }
53
+ #[ cfg( target_arch = "wasm32" ) ]
54
+ {
55
+ None
56
+ }
57
+ }
58
+
59
+ SmartChannelSource :: JsChannel { .. }
60
+ | SmartChannelSource :: Sdk
61
+ | SmartChannelSource :: Stdin => None ,
62
+ }
63
+ }
64
+ DisplayMode :: RedapServer ( _) | DisplayMode :: RedapEntry ( _) => {
65
+ Some ( UrlFeatures :: default ( ) )
66
+ }
67
+ }
68
+ }
69
+
16
70
/// Create a url for a certain display mode.
17
71
///
18
72
/// Not all display modes lead to valid URLs.
0 commit comments