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

[Lens] Switch to SavedObjectClient.resolve #110059

Merged
merged 12 commits into from
Sep 3, 2021

Conversation

mbondyra
Copy link
Contributor

@mbondyra mbondyra commented Aug 25, 2021

Summary

Fixes #105808

exactMatch outcome

The behavior doesn't change

aliasMatch

For the dashboard, the behavior doesn't change.
For the editor, it redirects to the new url and displays the notification:
Screenshot 2021-08-31 at 15 16 23

conflict

For the dashboard:
Screenshot 2021-08-31 at 15 15 24
Screenshot 2021-08-31 at 15 15 29

For the editor:
Screenshot 2021-08-31 at 15 13 19

testing

@jportner let me know if this is correct way to test it.

Follow the instructions from here: #107099 (comment)
Remember about adding the base path to the urls if you use it when doing the curl step.

Once you do the steps, go to http://localhost:5601/ and check all the spaces.

  1. Nothing special for exactMatch - you can check the link by modifying original object [id] to [id]-test1 in the link
  2. The aliasMatch can be checked by modifying the original link (from the [id] to [id]-test2) (we're simulating user having this link bookmarked)
  3. The conflict is listed in Visualize App. You can also embed it in the Dashboard to check how it behaves.

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

@mbondyra mbondyra added release_note:breaking Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 Feature:Lens labels Aug 25, 2021
@mbondyra mbondyra force-pushed the lens/savedObjectClientResolve branch 6 times, most recently from 0426a6f to 2d034ba Compare August 30, 2021 14:12
@mbondyra mbondyra added v7.16.0 auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes and removed release_note:breaking labels Aug 30, 2021
@mbondyra mbondyra force-pushed the lens/savedObjectClientResolve branch 3 times, most recently from 0a2d926 to 7abf3c2 Compare August 31, 2021 07:30
Following sharing Saved Objects developer guide: Step 2
This step demonstrates the changes to update client code to use the new
SavedObjectsClient `resolve()` method instead of `get()`.
@mbondyra mbondyra force-pushed the lens/savedObjectClientResolve branch from 7abf3c2 to b82354d Compare August 31, 2021 09:54
@elastic elastic deleted a comment from kibanamachine Aug 31, 2021
@elastic elastic deleted a comment from kibanamachine Aug 31, 2021
@mbondyra mbondyra marked this pull request as ready for review August 31, 2021 12:59
@mbondyra mbondyra requested a review from a team August 31, 2021 12:59
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors (Team:VisEditors)

@mbondyra mbondyra changed the title [Lens] Making Lens SO shareable [Lens] Switch to SavedObjectClient.resolve Aug 31, 2021
@elastic elastic deleted a comment from kibanamachine Aug 31, 2021
@stratoula stratoula requested a review from a team August 31, 2021 14:54
@timroes timroes removed the request for review from a team August 31, 2021 15:03
Copy link
Contributor

@jportner jportner left a comment

Choose a reason for hiding this comment

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

I noticed a few small issues, overall this is looking great though -- exactly what I was hoping to see!

Yes, that link is how you generate sample data. I had to update the script in that comment, as there was a bit about references that was missing.

Here is the staging data that I generated from
export.ndjson.zip: it includes one "test lens" visualization, one "test dashboard" that embeds the lens vis, and one index pattern

Click to see staging data...
POST .kibana/_bulk
{"index":{"_id":"test1:index-pattern:ff959d40-b880-11e8-a6d9-e546fe2bba5f-test1"}}
{"index-pattern":{"fieldAttrs":"{\"products.manufacturer\":{\"count\":1},\"products.price\":{\"count\":1},\"products.product_name\":{\"count\":1},\"total_quantity\":{\"count\":1}}","fieldFormatMap":"{\"taxful_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}},\"products.price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"taxless_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.taxless_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.taxful_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.min_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.base_unit_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.base_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}}}","fields":"[]","runtimeFieldMap":"{}","timeFieldName":"order_date","title":"kibana_sample_data_ecommerce","typeMeta":"{}"},"coreMigrationVersion":"8.0.0","migrationVersion":{"index-pattern":"7.11.0"},"references":[],"type":"index-pattern","updated_at":"2021-08-31T17:21:59.650Z","namespace":"test1"}
{"index":{"_id":"test2:index-pattern:ff959d40-b880-11e8-a6d9-e546fe2bba5f-test2-newId"}}
{"index-pattern":{"fieldAttrs":"{\"products.manufacturer\":{\"count\":1},\"products.price\":{\"count\":1},\"products.product_name\":{\"count\":1},\"total_quantity\":{\"count\":1}}","fieldFormatMap":"{\"taxful_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}},\"products.price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"taxless_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.taxless_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.taxful_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.min_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.base_unit_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.base_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}}}","fields":"[]","runtimeFieldMap":"{}","timeFieldName":"order_date","title":"kibana_sample_data_ecommerce","typeMeta":"{}"},"coreMigrationVersion":"8.0.0","migrationVersion":{"index-pattern":"7.11.0"},"references":[],"type":"index-pattern","updated_at":"2021-08-31T17:21:59.650Z","namespace":"test2"}
{"index":{"_id":"test3:index-pattern:ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3"}}
{"index-pattern":{"fieldAttrs":"{\"products.manufacturer\":{\"count\":1},\"products.price\":{\"count\":1},\"products.product_name\":{\"count\":1},\"total_quantity\":{\"count\":1}}","fieldFormatMap":"{\"taxful_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}},\"products.price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"taxless_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.taxless_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.taxful_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.min_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.base_unit_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.base_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}}}","fields":"[]","runtimeFieldMap":"{}","timeFieldName":"order_date","title":"kibana_sample_data_ecommerce","typeMeta":"{}"},"coreMigrationVersion":"8.0.0","migrationVersion":{"index-pattern":"7.11.0"},"references":[],"type":"index-pattern","updated_at":"2021-08-31T17:21:59.650Z","namespace":"test3"}
{"index":{"_id":"test3:index-pattern:ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3-newId"}}
{"index-pattern":{"fieldAttrs":"{\"products.manufacturer\":{\"count\":1},\"products.price\":{\"count\":1},\"products.product_name\":{\"count\":1},\"total_quantity\":{\"count\":1}}","fieldFormatMap":"{\"taxful_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}},\"products.price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"taxless_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.taxless_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.taxful_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.min_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.base_unit_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}},\"products.base_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.00\"}}}","fields":"[]","runtimeFieldMap":"{}","timeFieldName":"order_date","title":"kibana_sample_data_ecommerce","typeMeta":"{}"},"coreMigrationVersion":"8.0.0","migrationVersion":{"index-pattern":"7.11.0"},"references":[],"type":"index-pattern","updated_at":"2021-08-31T17:21:59.650Z","namespace":"test3"}
{"index":{"_id":"legacy-url-alias:test2:index-pattern:ff959d40-b880-11e8-a6d9-e546fe2bba5f-test2"}}
{"legacy-url-alias":{"targetNamespace":"test2","targetType":"index-pattern","targetId":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test2-newId","sourceId":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test2"},"type":"legacy-url-alias","references":[]}
{"index":{"_id":"legacy-url-alias:test3:index-pattern:ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3"}}
{"legacy-url-alias":{"targetNamespace":"test3","targetType":"index-pattern","targetId":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3-newId","sourceId":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3"},"type":"legacy-url-alias","references":[]}
{"index":{"_id":"test1:lens:15522780-0a80-11ec-a4bf-616628b395be-test1"}}
{"lens":{"description":"","state":{"datasourceStates":{"indexpattern":{"layers":{"6ed3487e-1153-4e63-aa3a-61c121a33400":{"columnOrder":["f39a1314-f878-4e70-a1d1-1063de7a1477"],"columns":{"f39a1314-f878-4e70-a1d1-1063de7a1477":{"dataType":"number","isBucketed":false,"label":"Unique count of currency","operationType":"unique_count","scale":"ratio","sourceField":"currency"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"accessor":"f39a1314-f878-4e70-a1d1-1063de7a1477","layerId":"6ed3487e-1153-4e63-aa3a-61c121a33400","layerType":"data"}},"title":"test lens","visualizationType":"lnsMetric"},"coreMigrationVersion":"8.0.0","migrationVersion":{"lens":"7.15.0"},"references":[{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test1","name":"indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test1","name":"indexpattern-datasource-layer-6ed3487e-1153-4e63-aa3a-61c121a33400","type":"index-pattern"}],"type":"lens","updated_at":"2021-08-31T17:22:57.148Z","namespace":"test1"}
{"index":{"_id":"test2:lens:15522780-0a80-11ec-a4bf-616628b395be-test2-newId"}}
{"lens":{"description":"","state":{"datasourceStates":{"indexpattern":{"layers":{"6ed3487e-1153-4e63-aa3a-61c121a33400":{"columnOrder":["f39a1314-f878-4e70-a1d1-1063de7a1477"],"columns":{"f39a1314-f878-4e70-a1d1-1063de7a1477":{"dataType":"number","isBucketed":false,"label":"Unique count of currency","operationType":"unique_count","scale":"ratio","sourceField":"currency"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"accessor":"f39a1314-f878-4e70-a1d1-1063de7a1477","layerId":"6ed3487e-1153-4e63-aa3a-61c121a33400","layerType":"data"}},"title":"test lens","visualizationType":"lnsMetric"},"coreMigrationVersion":"8.0.0","migrationVersion":{"lens":"7.15.0"},"references":[{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test2-newId","name":"indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test2-newId","name":"indexpattern-datasource-layer-6ed3487e-1153-4e63-aa3a-61c121a33400","type":"index-pattern"}],"type":"lens","updated_at":"2021-08-31T17:22:57.148Z","namespace":"test2"}
{"index":{"_id":"test3:lens:15522780-0a80-11ec-a4bf-616628b395be-test3"}}
{"lens":{"description":"","state":{"datasourceStates":{"indexpattern":{"layers":{"6ed3487e-1153-4e63-aa3a-61c121a33400":{"columnOrder":["f39a1314-f878-4e70-a1d1-1063de7a1477"],"columns":{"f39a1314-f878-4e70-a1d1-1063de7a1477":{"dataType":"number","isBucketed":false,"label":"Unique count of currency","operationType":"unique_count","scale":"ratio","sourceField":"currency"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"accessor":"f39a1314-f878-4e70-a1d1-1063de7a1477","layerId":"6ed3487e-1153-4e63-aa3a-61c121a33400","layerType":"data"}},"title":"test lens","visualizationType":"lnsMetric"},"coreMigrationVersion":"8.0.0","migrationVersion":{"lens":"7.15.0"},"references":[{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3","name":"indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3","name":"indexpattern-datasource-layer-6ed3487e-1153-4e63-aa3a-61c121a33400","type":"index-pattern"}],"type":"lens","updated_at":"2021-08-31T17:22:57.148Z","namespace":"test3"}
{"index":{"_id":"test3:lens:15522780-0a80-11ec-a4bf-616628b395be-test3-newId"}}
{"lens":{"description":"","state":{"datasourceStates":{"indexpattern":{"layers":{"6ed3487e-1153-4e63-aa3a-61c121a33400":{"columnOrder":["f39a1314-f878-4e70-a1d1-1063de7a1477"],"columns":{"f39a1314-f878-4e70-a1d1-1063de7a1477":{"dataType":"number","isBucketed":false,"label":"Unique count of currency","operationType":"unique_count","scale":"ratio","sourceField":"currency"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"accessor":"f39a1314-f878-4e70-a1d1-1063de7a1477","layerId":"6ed3487e-1153-4e63-aa3a-61c121a33400","layerType":"data"}},"title":"test lens","visualizationType":"lnsMetric"},"coreMigrationVersion":"8.0.0","migrationVersion":{"lens":"7.15.0"},"references":[{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3-newId","name":"indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3-newId","name":"indexpattern-datasource-layer-6ed3487e-1153-4e63-aa3a-61c121a33400","type":"index-pattern"}],"type":"lens","updated_at":"2021-08-31T17:22:57.148Z","namespace":"test3"}
{"index":{"_id":"legacy-url-alias:test2:lens:15522780-0a80-11ec-a4bf-616628b395be-test2"}}
{"legacy-url-alias":{"targetNamespace":"test2","targetType":"lens","targetId":"15522780-0a80-11ec-a4bf-616628b395be-test2-newId","sourceId":"15522780-0a80-11ec-a4bf-616628b395be-test2"},"type":"legacy-url-alias","references":[]}
{"index":{"_id":"legacy-url-alias:test3:lens:15522780-0a80-11ec-a4bf-616628b395be-test3"}}
{"legacy-url-alias":{"targetNamespace":"test3","targetType":"lens","targetId":"15522780-0a80-11ec-a4bf-616628b395be-test3-newId","sourceId":"15522780-0a80-11ec-a4bf-616628b395be-test3"},"type":"legacy-url-alias","references":[]}
{"index":{"_id":"test1:dashboard:397085d0-0a80-11ec-a4bf-616628b395be-test1"}}
{"dashboard":{"description":"","hits":0,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"},"optionsJSON":"{\"useMargins\":true,\"syncColors\":false,\"hidePanelTitles\":false}","panelsJSON":"[{\"version\":\"8.0.0\",\"type\":\"lens\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"8aa85371-1f6b-45c2-b214-46b4a78bcfc5\"},\"panelIndex\":\"8aa85371-1f6b-45c2-b214-46b4a78bcfc5\",\"embeddableConfig\":{\"attributes\":{\"title\":\"\",\"visualizationType\":\"lnsMetric\",\"type\":\"lens\",\"references\":[{\"type\":\"index-pattern\",\"id\":\"ff959d40-b880-11e8-a6d9-e546fe2bba5f\",\"name\":\"indexpattern-datasource-current-indexpattern\"},{\"type\":\"index-pattern\",\"id\":\"ff959d40-b880-11e8-a6d9-e546fe2bba5f\",\"name\":\"indexpattern-datasource-layer-58ae7d14-6f9a-423f-9dce-435a75785db3\"}],\"state\":{\"visualization\":{\"layerId\":\"58ae7d14-6f9a-423f-9dce-435a75785db3\",\"accessor\":\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\",\"layerType\":\"data\"},\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filters\":[],\"datasourceStates\":{\"indexpattern\":{\"layers\":{\"58ae7d14-6f9a-423f-9dce-435a75785db3\":{\"columns\":{\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\":{\"label\":\"Unique count of customer_gender\",\"dataType\":\"number\",\"operationType\":\"unique_count\",\"scale\":\"ratio\",\"sourceField\":\"customer_gender\",\"isBucketed\":false}},\"columnOrder\":[\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\"],\"incompleteColumns\":{}}}}}}},\"enhancements\":{}}},{\"version\":\"8.0.0\",\"type\":\"lens\",\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":15,\"i\":\"20c73608-610c-4a60-ac60-517e66bc351f\"},\"panelIndex\":\"20c73608-610c-4a60-ac60-517e66bc351f\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_20c73608-610c-4a60-ac60-517e66bc351f\"}]","timeRestore":false,"title":"test dashboard","version":1},"coreMigrationVersion":"8.0.0","migrationVersion":{"dashboard":"7.15.0"},"references":[{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test1","name":"8aa85371-1f6b-45c2-b214-46b4a78bcfc5:indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test1","name":"8aa85371-1f6b-45c2-b214-46b4a78bcfc5:indexpattern-datasource-layer-58ae7d14-6f9a-423f-9dce-435a75785db3","type":"index-pattern"},{"id":"15522780-0a80-11ec-a4bf-616628b395be-test1","name":"20c73608-610c-4a60-ac60-517e66bc351f:panel_20c73608-610c-4a60-ac60-517e66bc351f","type":"lens"}],"type":"dashboard","updated_at":"2021-08-31T17:24:51.017Z","namespace":"test1"}
{"index":{"_id":"test2:dashboard:397085d0-0a80-11ec-a4bf-616628b395be-test2-newId"}}
{"dashboard":{"description":"","hits":0,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"},"optionsJSON":"{\"useMargins\":true,\"syncColors\":false,\"hidePanelTitles\":false}","panelsJSON":"[{\"version\":\"8.0.0\",\"type\":\"lens\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"8aa85371-1f6b-45c2-b214-46b4a78bcfc5\"},\"panelIndex\":\"8aa85371-1f6b-45c2-b214-46b4a78bcfc5\",\"embeddableConfig\":{\"attributes\":{\"title\":\"\",\"visualizationType\":\"lnsMetric\",\"type\":\"lens\",\"references\":[{\"type\":\"index-pattern\",\"id\":\"ff959d40-b880-11e8-a6d9-e546fe2bba5f\",\"name\":\"indexpattern-datasource-current-indexpattern\"},{\"type\":\"index-pattern\",\"id\":\"ff959d40-b880-11e8-a6d9-e546fe2bba5f\",\"name\":\"indexpattern-datasource-layer-58ae7d14-6f9a-423f-9dce-435a75785db3\"}],\"state\":{\"visualization\":{\"layerId\":\"58ae7d14-6f9a-423f-9dce-435a75785db3\",\"accessor\":\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\",\"layerType\":\"data\"},\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filters\":[],\"datasourceStates\":{\"indexpattern\":{\"layers\":{\"58ae7d14-6f9a-423f-9dce-435a75785db3\":{\"columns\":{\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\":{\"label\":\"Unique count of customer_gender\",\"dataType\":\"number\",\"operationType\":\"unique_count\",\"scale\":\"ratio\",\"sourceField\":\"customer_gender\",\"isBucketed\":false}},\"columnOrder\":[\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\"],\"incompleteColumns\":{}}}}}}},\"enhancements\":{}}},{\"version\":\"8.0.0\",\"type\":\"lens\",\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":15,\"i\":\"20c73608-610c-4a60-ac60-517e66bc351f\"},\"panelIndex\":\"20c73608-610c-4a60-ac60-517e66bc351f\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_20c73608-610c-4a60-ac60-517e66bc351f\"}]","timeRestore":false,"title":"test dashboard","version":1},"coreMigrationVersion":"8.0.0","migrationVersion":{"dashboard":"7.15.0"},"references":[{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test2-newId","name":"8aa85371-1f6b-45c2-b214-46b4a78bcfc5:indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test2-newId","name":"8aa85371-1f6b-45c2-b214-46b4a78bcfc5:indexpattern-datasource-layer-58ae7d14-6f9a-423f-9dce-435a75785db3","type":"index-pattern"},{"id":"15522780-0a80-11ec-a4bf-616628b395be-test2-newId","name":"20c73608-610c-4a60-ac60-517e66bc351f:panel_20c73608-610c-4a60-ac60-517e66bc351f","type":"lens"}],"type":"dashboard","updated_at":"2021-08-31T17:24:51.017Z","namespace":"test2"}
{"index":{"_id":"test3:dashboard:397085d0-0a80-11ec-a4bf-616628b395be-test3"}}
{"dashboard":{"description":"","hits":0,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"},"optionsJSON":"{\"useMargins\":true,\"syncColors\":false,\"hidePanelTitles\":false}","panelsJSON":"[{\"version\":\"8.0.0\",\"type\":\"lens\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"8aa85371-1f6b-45c2-b214-46b4a78bcfc5\"},\"panelIndex\":\"8aa85371-1f6b-45c2-b214-46b4a78bcfc5\",\"embeddableConfig\":{\"attributes\":{\"title\":\"\",\"visualizationType\":\"lnsMetric\",\"type\":\"lens\",\"references\":[{\"type\":\"index-pattern\",\"id\":\"ff959d40-b880-11e8-a6d9-e546fe2bba5f\",\"name\":\"indexpattern-datasource-current-indexpattern\"},{\"type\":\"index-pattern\",\"id\":\"ff959d40-b880-11e8-a6d9-e546fe2bba5f\",\"name\":\"indexpattern-datasource-layer-58ae7d14-6f9a-423f-9dce-435a75785db3\"}],\"state\":{\"visualization\":{\"layerId\":\"58ae7d14-6f9a-423f-9dce-435a75785db3\",\"accessor\":\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\",\"layerType\":\"data\"},\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filters\":[],\"datasourceStates\":{\"indexpattern\":{\"layers\":{\"58ae7d14-6f9a-423f-9dce-435a75785db3\":{\"columns\":{\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\":{\"label\":\"Unique count of customer_gender\",\"dataType\":\"number\",\"operationType\":\"unique_count\",\"scale\":\"ratio\",\"sourceField\":\"customer_gender\",\"isBucketed\":false}},\"columnOrder\":[\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\"],\"incompleteColumns\":{}}}}}}},\"enhancements\":{}}},{\"version\":\"8.0.0\",\"type\":\"lens\",\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":15,\"i\":\"20c73608-610c-4a60-ac60-517e66bc351f\"},\"panelIndex\":\"20c73608-610c-4a60-ac60-517e66bc351f\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_20c73608-610c-4a60-ac60-517e66bc351f\"}]","timeRestore":false,"title":"test dashboard","version":1},"coreMigrationVersion":"8.0.0","migrationVersion":{"dashboard":"7.15.0"},"references":[{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3","name":"8aa85371-1f6b-45c2-b214-46b4a78bcfc5:indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3","name":"8aa85371-1f6b-45c2-b214-46b4a78bcfc5:indexpattern-datasource-layer-58ae7d14-6f9a-423f-9dce-435a75785db3","type":"index-pattern"},{"id":"15522780-0a80-11ec-a4bf-616628b395be-test3","name":"20c73608-610c-4a60-ac60-517e66bc351f:panel_20c73608-610c-4a60-ac60-517e66bc351f","type":"lens"}],"type":"dashboard","updated_at":"2021-08-31T17:24:51.017Z","namespace":"test3"}
{"index":{"_id":"test3:dashboard:397085d0-0a80-11ec-a4bf-616628b395be-test3-newId"}}
{"dashboard":{"description":"","hits":0,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"},"optionsJSON":"{\"useMargins\":true,\"syncColors\":false,\"hidePanelTitles\":false}","panelsJSON":"[{\"version\":\"8.0.0\",\"type\":\"lens\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"8aa85371-1f6b-45c2-b214-46b4a78bcfc5\"},\"panelIndex\":\"8aa85371-1f6b-45c2-b214-46b4a78bcfc5\",\"embeddableConfig\":{\"attributes\":{\"title\":\"\",\"visualizationType\":\"lnsMetric\",\"type\":\"lens\",\"references\":[{\"type\":\"index-pattern\",\"id\":\"ff959d40-b880-11e8-a6d9-e546fe2bba5f\",\"name\":\"indexpattern-datasource-current-indexpattern\"},{\"type\":\"index-pattern\",\"id\":\"ff959d40-b880-11e8-a6d9-e546fe2bba5f\",\"name\":\"indexpattern-datasource-layer-58ae7d14-6f9a-423f-9dce-435a75785db3\"}],\"state\":{\"visualization\":{\"layerId\":\"58ae7d14-6f9a-423f-9dce-435a75785db3\",\"accessor\":\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\",\"layerType\":\"data\"},\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filters\":[],\"datasourceStates\":{\"indexpattern\":{\"layers\":{\"58ae7d14-6f9a-423f-9dce-435a75785db3\":{\"columns\":{\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\":{\"label\":\"Unique count of customer_gender\",\"dataType\":\"number\",\"operationType\":\"unique_count\",\"scale\":\"ratio\",\"sourceField\":\"customer_gender\",\"isBucketed\":false}},\"columnOrder\":[\"53e54413-274a-44c7-8f5f-e7659cbc6c2a\"],\"incompleteColumns\":{}}}}}}},\"enhancements\":{}}},{\"version\":\"8.0.0\",\"type\":\"lens\",\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":15,\"i\":\"20c73608-610c-4a60-ac60-517e66bc351f\"},\"panelIndex\":\"20c73608-610c-4a60-ac60-517e66bc351f\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_20c73608-610c-4a60-ac60-517e66bc351f\"}]","timeRestore":false,"title":"test dashboard","version":1},"coreMigrationVersion":"8.0.0","migrationVersion":{"dashboard":"7.15.0"},"references":[{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3-newId","name":"8aa85371-1f6b-45c2-b214-46b4a78bcfc5:indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"ff959d40-b880-11e8-a6d9-e546fe2bba5f-test3-newId","name":"8aa85371-1f6b-45c2-b214-46b4a78bcfc5:indexpattern-datasource-layer-58ae7d14-6f9a-423f-9dce-435a75785db3","type":"index-pattern"},{"id":"15522780-0a80-11ec-a4bf-616628b395be-test3-newId","name":"20c73608-610c-4a60-ac60-517e66bc351f:panel_20c73608-610c-4a60-ac60-517e66bc351f","type":"lens"}],"type":"dashboard","updated_at":"2021-08-31T17:24:51.017Z","namespace":"test3"}
{"index":{"_id":"legacy-url-alias:test2:dashboard:397085d0-0a80-11ec-a4bf-616628b395be-test2"}}
{"legacy-url-alias":{"targetNamespace":"test2","targetType":"dashboard","targetId":"397085d0-0a80-11ec-a4bf-616628b395be-test2-newId","sourceId":"397085d0-0a80-11ec-a4bf-616628b395be-test2"},"type":"legacy-url-alias","references":[]}
{"index":{"_id":"legacy-url-alias:test3:dashboard:397085d0-0a80-11ec-a4bf-616628b395be-test3"}}
{"legacy-url-alias":{"targetNamespace":"test3","targetType":"dashboard","targetId":"397085d0-0a80-11ec-a4bf-616628b395be-test3-newId","sourceId":"397085d0-0a80-11ec-a4bf-616628b395be-test3"},"type":"legacy-url-alias","references":[]}
{"index":{"_id":"space:test1"}}
{"space":{"name":"Test 1: Resolve Exact Match","initials":"T1","description":"In this space, test object(s) will resolve with an \"exactMatch\" outcome.","disabledFeatures":[]},"type":"space"}
{"index":{"_id":"space:test2"}}
{"space":{"name":"Test 2: Resolve Alias Match","initials":"T2","description":"In this space, test object(s) will resolve with an \"aliasMatch\" outcome.","disabledFeatures":[]},"type":"space"}
{"index":{"_id":"space:test3"}}
{"space":{"name":"Test 3: Resolve Conflict","initials":"T3","description":"In this space, test object(s) will resolve with a \"conflict\" outcome.","disabledFeatures":[]},"type":"space"}

Using that staging data, I could test with these links:


One general question for you: is there any way to differentiate how the embeddable is loading?
For example, there are two ways to load a dashboard:

  1. Using the link for the saved object
  2. Using a "Snapshot URL"

If you're using the link for the saved object, there is no reason to resolve() the embedded visualizations, since object IDs are loaded from up-to-date references.

However, if you're using a snapshot URL, that's when you need to use resolve() for the embedded visualizations, because the object IDs are coming from outside of Kibana (in this case, wherever the user saved that URL)

documentationLink: (
<EuiLink
external
href="https://www.elastic.co/guide/en/kibana/master/resolve_copy_saved_objects_conflicts.html"
Copy link
Contributor

Choose a reason for hiding this comment

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

A couple points:

  1. This link is wrong, the correct link is https://www.elastic.co/guide/en/kibana/master/legacy-url-aliases.html
  2. We should probably use the docLinks service here; I think the best thing to do is to modify the Core service and make this available to all consumers from there, so I'll submit a PR to do that. It looks like you'll need to pass in the docLinks service via the EmbeddableFactory to leverage it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I corrected the link just hardcoding it. Should I wait for you for the PR modifying core service and then do my changes?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I didn't get to submit the PR yet, it's been a crazy week.
I'd say this: go ahead and merge this as-is, and I will fix this in my PR.

x-pack/plugins/lens/public/lens_attribute_service.ts Outdated Show resolved Hide resolved
x-pack/plugins/lens/public/app_plugin/app.tsx Outdated Show resolved Hide resolved
<>
<FormattedMessage
id="xpack.lens.embeddable.legacyURLConflict.longMessage"
defaultMessage="You have encountered a legacy URL alias conflict. See the {documentationLink} for more information."
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we'll want to get the @elastic/kibana-docs team's input on this?

(see PR description above for screenshot!)

{expandError ? (
<EuiCallOut
title={i18n.translate('xpack.lens.embeddable.legacyURLConflict.expandErrorText', {
defaultMessage: `Found a specified object and an alias for the same URL. You can disable the alias to resolve this error: {json}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we'll want to get the @elastic/kibana-docs team's input on this?

(see PR description above for screenshot!)

x-pack/plugins/lens/public/app_plugin/app.tsx Show resolved Hide resolved
Copy link
Contributor

@jportner jportner left a comment

Choose a reason for hiding this comment

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

Tested this again and LGTM! A few more comments below too. Thanks so much!

@gchaps
Copy link
Contributor

gchaps commented Sep 2, 2021

Suggestion:

Title: You've encountered a URL conflict
Description: Disable the legacy URL alias associated with this object.

Show details
This object has the same URL as a legacy alias. Disable the alias to resolve this error : {json}

@mbondyra
Copy link
Contributor Author

mbondyra commented Sep 3, 2021

@elasticmachine merge upstream

@elastic elastic deleted a comment from kibanamachine Sep 3, 2021
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 works fine. I just left one nit comment. Code LGTM and everything works as expected. I noticed that the dashboard aliasMatch returns an error but I discussed it with Marta and I agree that it is not Lens related but happens because the dashboard hasn't implemented yet the SOs changes.

image (2)

Just some thoughts:
image
Do we want to have the word objects in the title here? Maybe visualizations make more sense to the users?
Maybe we could rephrase a bit the text? It seems a bit technical to me (also do we need to show the ids?). Something like:

You are currently looking at a visualization with a legacy url alias

Button:
Check the other visualization

or maybe @elastic/kibana-docs could also help us a bit here too?

@mbondyra
Copy link
Contributor Author

mbondyra commented Sep 3, 2021

@stratoula about the text on the notification, the whole content comes from here:

return spaces.ui.components.getLegacyUrlConflict({

https://github.com/elastic/kibana/pull/110059/files#diff-62b4eca6ab93c938023295869419d9b3031fd1c11470d5a3fec89f0012bbf036R183-R191
and I think it was already reviewed by the Docs team because it was merged before this one. The text tries to be generic enough to match all the different SO usecases.

@mbondyra mbondyra closed this Sep 3, 2021
@mbondyra mbondyra reopened this Sep 3, 2021
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.

@mbondyra got it! Thanx for the clarification. In that case LGTM ❤️

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

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
lens 1.6MB 1.6MB +4.6KB

History

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

@mbondyra mbondyra merged commit d4c03eb into elastic:master Sep 3, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 3, 2021
* Step 2: Update client code to use resolve() method instead of get()

Following sharing Saved Objects developer guide: Step 2
This step demonstrates the changes to update client code to use the new
SavedObjectsClient `resolve()` method instead of `get()`.

* Step 3 Lens
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Sep 3, 2021
* Step 2: Update client code to use resolve() method instead of get()

Following sharing Saved Objects developer guide: Step 2
This step demonstrates the changes to update client code to use the new
SavedObjectsClient `resolve()` method instead of `get()`.

* Step 3 Lens

Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>
@mbondyra mbondyra deleted the lens/savedObjectClientResolve branch November 24, 2021 21:46
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 Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Switch to SavedObjectClient.resolve
7 participants