-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable
MapProvider
variant when not available (#8006)
### What This PR introduces a possibly over-engineered generic mechanism to control the availability of individual view property variant, and uses it to disable mapbox-based map background when the API key isn't properly set. <img width="743" alt="image" src="https://github.com/user-attachments/assets/17c3aaf4-ce66-4335-9b21-543cb8730a9c"> ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/8006?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/8006?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! * [x] If have noted any breaking changes to the log API in `CHANGELOG.md` and the migration guide - [PR Build Summary](https://build.rerun.io/pr/8006) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) To run all checks from `main`, comment on the PR with `@rerun-bot full-check`.
- Loading branch information
Showing
8 changed files
with
138 additions
and
54 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
18 changes: 3 additions & 15 deletions
18
crates/store/re_types/src/blueprint/components/map_provider.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,32 @@ | ||
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: "A Mapbox access token is not available. You can set it in the \ | ||
settings or using the `RERUN_MAPBOX_ACCESS_TOKEN` environment variable." | ||
.to_owned(), | ||
} | ||
}; | ||
|
||
match variant { | ||
MapProvider::OpenStreetMap => VariantAvailable::Yes, | ||
|
||
MapProvider::MapboxStreets | MapProvider::MapboxDark | MapProvider::MapboxSatellite => { | ||
map_box_available | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 3 additions & 15 deletions
18
rerun_py/rerun_sdk/rerun/blueprint/components/map_provider.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.