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

[Canvas] Use original input when updating existing embeddable #116026

Conversation

cqliu1
Copy link
Contributor

@cqliu1 cqliu1 commented Oct 21, 2021

Summary

This fixes a bug where the time range set on an embeddable in Canvas would get reset after editing the embeddable in it's respective editor and returning to Canvas.

Now if there is an incoming embeddable with the same id as an existing element, this extracts the original embeddable input from the expression and uses it as the base input object for the incoming embeddable input.

To test:

  • Create a workpad.
  • Create an embeddable element.
  • Change the time range to last 2 weeks on the embeddable.
  • Click on the action menu and edit the embeddable.
  • Click save and return.

The time range on the embeddable should still show Last 2 weeks instead of resetting to Last 15 minutes.

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

Register external functions in canvas_plugin_src plugin def

@cqliu1 cqliu1 requested a review from a team as a code owner October 21, 2021 22:47
@cqliu1 cqliu1 added Feature:Canvas Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas labels Oct 21, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@cqliu1 cqliu1 added the loe:small Small Level of Effort label Oct 21, 2021
@cqliu1 cqliu1 force-pushed the canvas/by-value-embeddables branch from c637735 to 780f71c Compare October 25, 2021 07:46
@cqliu1 cqliu1 requested review from a team as code owners October 25, 2021 07:46
@cqliu1 cqliu1 force-pushed the canvas/preserve-original-input branch from c9eb937 to 931e68a Compare October 25, 2021 07:48
@mshustov mshustov removed the request for review from a team October 25, 2021 11:32
@mshustov
Copy link
Contributor

removing core team since I don't see any changes related to our domains

@cqliu1 cqliu1 removed request for a team October 25, 2021 15:22
@cqliu1 cqliu1 force-pushed the canvas/by-value-embeddables branch from 1834014 to 151ceac Compare October 25, 2021 20:02
@cqliu1 cqliu1 force-pushed the canvas/preserve-original-input branch from 931e68a to eecc31c Compare October 25, 2021 20:04
@cqliu1 cqliu1 mentioned this pull request Oct 25, 2021
11 tasks
@kibanamachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Test Failures

  • [job] [logs] Default CI Group #1 / watcher app watcher_test create and save a new watch

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
canvas 1.0MB 1.0MB +289.0B

History

  • 💛 Build #1281 was flaky 931e68a96e031ccf7e1334adac6324bf8a59a25b
  • 💔 Build #1155 failed c9eb937764107ad36f72241a2551e3da9b95379c

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@crob611 crob611 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM

@cqliu1 cqliu1 merged commit d3e9f7d into elastic:canvas/by-value-embeddables Oct 26, 2021
@cqliu1 cqliu1 deleted the canvas/preserve-original-input branch October 26, 2021 02:20
cqliu1 added a commit that referenced this pull request Oct 27, 2021
* [Canvas] Generic embeddable function (#104499)

* Created generic embeddable function

    Fixed telemetry

    Updates expression on input change

    Fixed ts errors

Store embeddable input to expression

Added lib functions

Added comments

Fixed type errors

Fixed ts errors

Clean up

Removed extraneous import

Added context type to embeddable function def

Fix import

Update encode/decode fns

Moved embeddable data url lib file

Added embeddable test

Updated comment

* Fix reference extract/inject in embeddable fn

* Simplify embeddable toExpression

* Moved labsService to flyout.tsx

* Added comment

* [Canvas] Adds Save and Return Workflow (#111411)

* [Canvas] Adds editor menu to Canvas (#113194)

* Merge existing embeddable input with incoming embeddable input (#116026)

* [Canvas] Extract and inject references for by-value embeddables (#115124)

* Extract/inject references for by-value embeddables in embeddable function

Fixed server interpreter setup

Register external functions in canvas_plugin_src plugin def

* Fixed ref name in embeddable.inject

* Fixed ts errors

* Fix missing type error

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Canvas loe:small Small Level of Effort Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants