For snapshots (a feature of core grafana), we only store the current variable value, and don't store options for variables such as queries, datasources, ... .
The problem was that the Scenes implementation does validate options against the current variable value, if the current value did not exist, it cleared up that value.
What is this PR doing ?
I added some tweaks to support read-only variables, and also exposed missing types to support a new aSnapshotVariable in core grafana (PR ), which has a similar implementation to CustomVariable, but it's read-only and does not validate options with the current variable value.
Todo:
[x] Double-check approach
[x] Add unit test
📦 Published PR as canary version: 4.30.0--canary.781.9463613592.0
:sparkles: Test out this PR locally via:
```bash
npm install @grafana/scenes-react@4.30.0--canary.781.9463613592.0
npm install @grafana/scenes@4.30.0--canary.781.9463613592.0
# or
yarn add @grafana/scenes-react@4.30.0--canary.781.9463613592.0
yarn add @grafana/scenes@4.30.0--canary.781.9463613592.0
```
What is this PR solving?
For
snapshots
(a feature of core grafana), we only store thecurrent
variable value, and don't storeoptions
for variables such asqueries, datasources, ...
. The problem was that the Scenes implementation does validateoptions
against thecurrent
variable value, if thecurrent
value did not exist, it cleared up that value.What is this PR doing ?
I added some tweaks to support read-only variables, and also exposed missing types to support a new a
SnapshotVariable
in core grafana (PR ), which has a similar implementation toCustomVariable
, but it's read-only and does not validateoptions
with the current variable value.Todo:
📦 Published PR as canary version:
4.30.0--canary.781.9463613592.0
:sparkles: Test out this PR locally via: ```bash npm install @grafana/scenes-react@4.30.0--canary.781.9463613592.0 npm install @grafana/scenes@4.30.0--canary.781.9463613592.0 # or yarn add @grafana/scenes-react@4.30.0--canary.781.9463613592.0 yarn add @grafana/scenes@4.30.0--canary.781.9463613592.0 ```