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

Preserves originating path when returning from editor #115118

Merged
merged 7 commits into from
Nov 25, 2021

Conversation

cqliu1
Copy link
Contributor

@cqliu1 cqliu1 commented Oct 14, 2021

Summary

This fixes a bug where you lose your url parameters for your workpad after editing and saving your embeddable in an editor outside of Canvas and returning to your workpad.

In the embeddable plugin, I added containerContext which contains getOriginatingPath which allows presentation apps like Dashboard and Canvas to pass a function that returns the original path for the editor to return to.

In the maps and visualize plugins, I extracted originatingPath from the state transfer incoming editor state and path it through to where the app returns to the originating app.

One way to test:

  • Open Canvas and create a workpad
  • Add any Lens/map/visualize embeddable to the workpad.
  • Click on View > Autoplay settings and select 30 seconds. Notice: the url should have the autoplayInterval param.
  • Click on the actions menu on the embeddable to edit the embeddable
  • Click Save and return.
  • You should return to the same workpad you left, and the url should still contain the autoplayInterval param.

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

@cqliu1 cqliu1 added Feature:Canvas loe:small Small Level of Effort Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas labels Oct 14, 2021
@cqliu1 cqliu1 mentioned this pull request Oct 14, 2021
13 tasks
@cqliu1 cqliu1 force-pushed the canvas/fix-return-path branch from 49da448 to 5a00375 Compare October 15, 2021 00:14
@cqliu1 cqliu1 force-pushed the canvas/by-value-embeddables branch from 2030a15 to afea023 Compare October 15, 2021 17:33
@cqliu1 cqliu1 changed the title [Canvas] Fixes path when returning from editor [Canvas] Preserves originating path when returning from editor Oct 15, 2021
@cqliu1 cqliu1 force-pushed the canvas/fix-return-path branch 2 times, most recently from 9b7ee32 to 75747b7 Compare October 15, 2021 19:45
@cqliu1 cqliu1 force-pushed the canvas/by-value-embeddables branch from afea023 to 6b2bc48 Compare October 15, 2021 19:47
@cqliu1 cqliu1 force-pushed the canvas/fix-return-path branch from 75747b7 to 3582490 Compare October 15, 2021 19:49
@cqliu1 cqliu1 force-pushed the canvas/by-value-embeddables branch from 6b2bc48 to 196b94d Compare October 18, 2021 17:08
@cqliu1 cqliu1 force-pushed the canvas/fix-return-path branch from 3582490 to 356c4e7 Compare October 19, 2021 15:58
@cqliu1 cqliu1 force-pushed the canvas/by-value-embeddables branch 2 times, most recently from f8dbcaf to 34831c5 Compare October 19, 2021 22:18
@cqliu1 cqliu1 force-pushed the canvas/fix-return-path branch from 356c4e7 to a7c6904 Compare October 19, 2021 22:20
@kibanamachine
Copy link
Contributor

kibanamachine commented Oct 20, 2021

💔 Build Failed

Failed CI Steps


Test Failures

Jest Tests.src/plugins/embeddable/public/lib/actions.redirects to app using state transfer with by value mode

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: expect(jest.fn()).toHaveBeenCalledWith(...expected)

- Expected
+ Received

  "ultraVisualize",
@@ -1,11 +1,11 @@
  Object {
    "path": "/123",
    "state": Object {
      "embeddableId": "123",
      "originatingApp": "superCoolCurrentApp",
-     "originatingPath": "",
+     "searchSessionId": undefined,
      "valueInput": Object {
        "coolInput1": 1,
        "coolInput2": 2,
        "id": "123",
        "viewMode": "edit",,

Number of calls: 1
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/src/plugins/embeddable/public/lib/actions/edit_panel_action.test.tsx:59:46)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Jest Tests.src/plugins/embeddable/public/lib/actions.redirects to app using state transfer without by value mode

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: expect(jest.fn()).toHaveBeenCalledWith(...expected)

Expected: "ultraVisualize", {"path": "/123", "state": {"embeddableId": "123", "originatingApp": "superCoolCurrentApp", "originatingPath": "", "valueInput": undefined}}
Received
       1
          "ultraVisualize",
          Object {
            "path": "/123",
            "state": Object {
              "embeddableId": "123",
              "originatingApp": "superCoolCurrentApp",
        -     "originatingPath": "",
        -     "valueInput": undefined,
        +     "searchSessionId": undefined,
        +     "valueInput": Object {
        +       "coolInput1": 1,
        +       "coolInput2": 2,
        +       "id": "123",
        +       "viewMode": "edit",
        +     },
            },
          },
       2
          "ultraVisualize",
          Object {
            "path": "/123",
            "state": Object {
              "embeddableId": "123",
              "originatingApp": "superCoolCurrentApp",
        -     "originatingPath": "",
        +     "searchSessionId": undefined,
              "valueInput": undefined,
            },
          },

Number of calls: 2
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/src/plugins/embeddable/public/lib/actions/edit_panel_action.test.tsx:84:46)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

History

  • 💔 Build #163006 failed 65186d6ccb654038f2da994dfb8ef40f94b6bdd1
  • 💔 Build #162995 failed a7c690411c9b4b63a28b256c4d1ae3a2b70fa6b3
  • 💔 Build #162798 failed 356c4e768c0f95c4498531f12b0e115fd6838a28
  • 💔 Build #161641 failed 3582490b22f4feeba4d0ed348add56d13f0bc50a

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

@cqliu1 cqliu1 force-pushed the canvas/by-value-embeddables branch from 34831c5 to 6a29232 Compare October 20, 2021 18:58
@cqliu1 cqliu1 force-pushed the canvas/fix-return-path branch 2 times, most recently from 76a089d to da13e38 Compare October 20, 2021 21:31
@cqliu1 cqliu1 force-pushed the canvas/by-value-embeddables branch from 6a29232 to 8ac6d41 Compare October 20, 2021 22:45
@cqliu1 cqliu1 force-pushed the canvas/fix-return-path branch from da13e38 to 20e7590 Compare October 21, 2021 01:41
@cqliu1 cqliu1 marked this pull request as ready for review October 21, 2021 01:42
@cqliu1 cqliu1 requested review from a team as code owners October 21, 2021 01:42
@elasticmachine
Copy link
Contributor

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

@cqliu1 cqliu1 changed the title [Canvas] Preserves originating path when returning from editor Preserves originating path when returning from editor Oct 21, 2021
@cqliu1 cqliu1 force-pushed the canvas/fix-return-path branch from 20e7590 to 6a80a1e Compare October 21, 2021 02:00
@cqliu1 cqliu1 force-pushed the canvas/fix-return-path branch from 796b0f5 to 9f946cf Compare October 27, 2021 08:12
@cqliu1 cqliu1 enabled auto-merge (squash) October 27, 2021 08:14
@cqliu1
Copy link
Contributor Author

cqliu1 commented Nov 2, 2021

@elasticmachine merge upstream

@cqliu1
Copy link
Contributor Author

cqliu1 commented Nov 3, 2021

@elastic/kibana-vis-editors Can I get a review on this PR?

@cqliu1
Copy link
Contributor Author

cqliu1 commented Nov 5, 2021

@elasticmachine merge upstream

@cqliu1 cqliu1 disabled auto-merge November 5, 2021 05:01
@cqliu1 cqliu1 added the v8.1.0 label Nov 5, 2021
@cqliu1 cqliu1 force-pushed the canvas/fix-return-path branch from 73de89a to c20a6f3 Compare November 23, 2021 19:42
@elastic elastic deleted a comment from kibanamachine Nov 23, 2021
@cqliu1
Copy link
Contributor Author

cqliu1 commented Nov 24, 2021

@elasticmachine merge upstream

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

This looks good! Kibana Vis Editors changes LGTM! I tested it locally as you proposed, it works fine!

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
embeddable 393 394 +1

Async chunks

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

id before after diff
canvas 1020.4KB 1020.4KB +63.0B
maps 2.6MB 2.6MB +175.0B
visualize 49.7KB 49.9KB +256.0B
total +494.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
embeddable 63.4KB 63.6KB +240.0B
Unknown metric groups

API count

id before after diff
embeddable 469 472 +3

History

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

@cqliu1 cqliu1 added the auto-backport Deprecated - use backport:version if exact versions are needed label Nov 25, 2021
@cqliu1 cqliu1 merged commit f0ad666 into elastic:main Nov 25, 2021
@cqliu1 cqliu1 deleted the canvas/fix-return-path branch November 25, 2021 00:07
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Nov 25, 2021
* Add originatingPath to edit_panel_action

Support originatingPath in embeddable state transfer

Fix ts error

* Fixed jest tests

* Parse originatingPath without using hash

* provide static container context on embeddable panel

* Fixed ts error

Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
8.0

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Nov 25, 2021
)

* Add originatingPath to edit_panel_action

Support originatingPath in embeddable state transfer

Fix ts error

* Fixed jest tests

* Parse originatingPath without using hash

* provide static container context on embeddable panel

* Fixed ts error

Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Catherine Liu <catherine.liu@elastic.co>
Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
TinLe pushed a commit to TinLe/kibana that referenced this pull request Dec 22, 2021
* Add originatingPath to edit_panel_action

Support originatingPath in embeddable state transfer

Fix ts error

* Fixed jest tests

* Parse originatingPath without using hash

* provide static container context on embeddable panel

* Fixed ts error

Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@cqliu1 cqliu1 restored the canvas/fix-return-path branch June 8, 2022 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed bug Fixes for quality problems that affect the customer experience Feature:Canvas Feature:Embedding Embedding content via iFrame impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:small Small Level of Effort release_note:skip Skip the PR/issue when compiling release notes review Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants