scenes

Build Grafana dashboards directly in your Grafana app plugins.

APACHE-2.0 License

Downloads
87.4K
Stars
116
Committers
45

Bot releases are hidden (Show)

scenes - 0.0.21

Published by torkelo over 1 year ago

SceneObject subscribeToState parameter change

Signature change. Now the parameter to this function expects a simple function that takes two args (newState, prevState).

Before:

this._subs.add(
  sourceData.subscribeToState({
    next: (state) => this.transform(state.data),
  })
);

Becomes:

this._subs.add(sourceData.subscribeToState((state) => this.transform(state.data)));

addActivationHandler

SceneObject now has a new function called addActivationHandler that makes it much easier to add external behaviors to core scene componenents. The
activation handler (callback) can return a deactivation handler. This works very similar to useEffect.

For custom components that used to override activate and then call super.activate() we now recommend that you instead use addActivationHandler from
the constructor. See https://github.com/grafana/scenes/pull/77 for some examples.

VizPanelMenu

A new scene object to enable panel menu for VizPanel.

Example usage:

const menu = new VizPanelMenu({});

// Configure menu items
menu.addActivationHandler(() => {
  menu.setItems(menuItems);
});

// Attach menu to VizPanel
const panelWithMenu = new VizPanel({
  title: 'Panel with menu',
  menu,
  // ... VizPanel configuration
});