-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a mechanism to control individual variant availability for enum e…
…dit UI and use it for `MapProvider`
- Loading branch information
Showing
4 changed files
with
130 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use re_types::blueprint::components::MapProvider; | ||
use re_viewer_context::ViewerContext; | ||
|
||
use crate::datatype_uis::{VariantAvailable, VariantAvailableProvider}; | ||
|
||
pub struct MapProviderVariantAvailable; | ||
|
||
impl VariantAvailableProvider<MapProvider> for MapProviderVariantAvailable { | ||
fn is_variant_enabled(ctx: &ViewerContext<'_>, variant: MapProvider) -> VariantAvailable { | ||
let map_box_available = if ctx | ||
.app_options | ||
.mapbox_access_token() | ||
.is_some_and(|token| !token.is_empty()) | ||
{ | ||
VariantAvailable::Yes | ||
} else { | ||
VariantAvailable::No { | ||
reason_markdown: "Mapbox access token is not set. ".to_owned(), | ||
} | ||
}; | ||
|
||
match variant { | ||
MapProvider::OpenStreetMap => VariantAvailable::Yes, | ||
|
||
MapProvider::MapboxStreets | MapProvider::MapboxDark | MapProvider::MapboxSatellite => { | ||
map_box_available | ||
} | ||
} | ||
} | ||
} |