Skip to content

cleanup canvas usage of expression renderer handlers #74644

@ppisljar

Description

@ppisljar

Canvas is sending additional handlers to expression renderers, which prevents us from using canvas registered renderers outside of canvas (as they expect those additional handlers) and makes other renderers function unpredictably (as they don't expect those additional renderers and will not use them)

To make renderers reusable in any application we need to use fixed (and agreed on) set of handlers, which then all registered renderers should consume correctly.

Addressing the current technical debt should be done step by step, discussing how each additional canvas renderer handler should be addressed. Here is the list of current additional handlers canvas uses:

  /** Handler to invoke when an element should be destroyed. */
  destroy: () => void;

there is an onDestroy handler defined on expression renderers, which canvas should also use. we should remove this one (destroy) and migrate all canvas renderers to use onDestroy

  /** Retrieves the value of the filter property on the element object persisted on the workpad */
  getFilter: () => string;
  /** Sets the value of the filter property on the element object persisted on the workpad */
  setFilter: (filter: string) => void;

this should be solvable using event handler and emitting filter event, and adding uiAction to connect to your redux store.

  /** Handler to invoke when a renderer is considered complete */
  onComplete: (fn: () => void) => void;

we have done handler on expression renderers which canvas should also use. we should remove this one (onComplete) and migrate all canvas renderers to use done

  /** Get the id of the element being rendered.  Can be used as a unique ID in a render function */
  getElementId: () => string;
  /** Handler to invoke when a rendered embeddable is destroyed */
  onEmbeddableDestroyed: () => void;
  /** Handler to invoke when the input to a function has changed internally */
  onEmbeddableInputChange: (expression: string) => void;

this seems very specific to embeddable renderer, so most likely we want to solve this in a different manner. needs further investigation.

  /** Handler to invoke when an element's dimensions have changed*/
  onResize: GenericRendererCallback;
  /** Handler to invoke when an element should be resized. */
  resize: (size: { height: number; width: number }) => void;

having the domElement being passed to renderers i don't think this is necessary as each renderer can monitor the domElement and so can the application passing the domElement to renderer. This could be provided in the form of utility if required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature:CanvasFeature:ExpressionLanguageInterpreter expression language (aka canvas pipeline)MetaTeam:PresentationPresentation Team for Dashboard, Input Controls, and Canvas t//impact:mediumAddressing this issue will have a medium level of impact on the quality/strength of our product.loe:mediumMedium Level of Effort

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions