Skip to content

Instantly share code, notes, and snippets.

@stacey-gammon
Created March 6, 2018 18:48
Show Gist options
  • Save stacey-gammon/8193f9fe6ac64f90f64b5e99ec8102ff to your computer and use it in GitHub Desktop.
Save stacey-gammon/8193f9fe6ac64f90f64b5e99ec8102ff to your computer and use it in GitHub Desktop.

Panel loaded on a dashboard

// dashboard_panel.js
async componentDidMount() {
  this.props.renderEmbeddable(this.panelElement, this.props.panel);
}

render() {
  return (
    <div
      id="embeddedPanel"
      className="panel-content"
      ref={panelElement => this.panelElement = panelElement}
    />
  );
}
// Inside the embeddable - a click happened internally and we want to notify dashboard to expose the drill down context menu
onClickDataPoint(filters) {
  // Panel handler exposes a bunch of functions to the embeddable. Very similar to your kibanaDataApi, but internally
  // it has the panel id (rather than forcing the embeddable to pass panel id along... maybe there is a better way to do this).
  this.panelHandler.applyFilters(filters);
  
  // Trying to think how this would be represented in a functional world, using the changeState function you have,
  // how can we represent in pure state 'display the drill down link context menu using this filter'?  Perhaps
  changeState({ exposeDrillDownLinkSetupMenu: true, showDrillDownLinkContextMenu: true, stagedFilterIds: [id1, id2], appliedFilterIds: [id1, id2] });
  
  // but using raw 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment