Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make expression renderer aware of current context #77161

Closed
flash1293 opened this issue Sep 10, 2020 · 5 comments · Fixed by #83559
Closed

Make expression renderer aware of current context #77161

flash1293 opened this issue Sep 10, 2020 · 5 comments · Fixed by #83559
Assignees
Labels
Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@flash1293
Copy link
Contributor

flash1293 commented Sep 10, 2020

When rendering the result of an expression in an expression renderer, it is sometimes important to have some information about the context the result is rendered in because it can influence different aspects. In the case of Lens, there are several real world use cases for this:

  • noInteractivity: When a Lens visualization is embedded in a Canvas workpad, filter actions can't be dispatched. But the chart renderer doesn't know about this and is still appearing interactive (e.g. changing the cursor when hovering over bars and letting the user brush to select a range on the x axis which doesn't have any effect). [Lens] Option to disable interactions #65630
  • edit: In Lens there a features planned that would require to offer some chart interactivity only when within the Lens editor, not on dashboards. [Lens] Client side table sorting #76962
  • preview: Lens is rendering visualizations in a "preview" mode in suggestions. This is currently done using a special separate expression, but could be solved more easily using a mode passed directly to the renderer

Screenshot 2020-09-10 at 14 37 24

Proposal

This can be done by adding a mode option to the expression runner / component wrapper as part of the IExpressionLoaderParams:

<ExpressionRenderer expression={expression} mode="edit" />

This mode which is restricted by an enum ('noInteractivity' | 'edit' | 'preview' | 'display' with defaulting to 'display') is exposed to the renderer as part of the handlers:

{
  name: 'my_renderer',
  render: async (
    domNode: Element,
    config: MyProps,
    handlers: IInterpreterRenderHandlers
  ) => {
    if (handlers.getMode() === 'edit') { /* ... */ }
  }
}

As the possible modes are defined in a central place, this becomes a part of the generic contract of expression renderers. When implementing a renderer, it should respect the current mode as well as it can.

@flash1293 flash1293 added Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) Team:Visualizations Visualization editors, elastic-charts and infrastructure Team:AppArch labels Sep 10, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@timroes
Copy link
Contributor

timroes commented Sep 19, 2020

I like that idea a lot. I wonder if we should still add a print or reporting value, that we could potentially leverage with some changes later in the reporting infrastructure. Usually this will most likely be similar to noInteractivity, but perhaps some charts could make reasonable distinction when drawing in report mode, e.g. one random example coming to my mind: input controls would most likely be disabled in noInteractivty mode, but could e.g. not draw at all like inputs, but in a more "overview which filters are applied" way in report mode.

@flash1293
Copy link
Contributor Author

No strong opinion on the actual modes yet. I wonder whether we should have a map of settings instead of a single-dimension "mode".

@flash1293
Copy link
Contributor Author

@ppisljar FYI, I'm starting to work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants