Skip to content

Commit 2d4e889

Browse files
committed
Update docs
1 parent 1c95043 commit 2d4e889

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

docs/api/saved-objects/resolve.asciidoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ The `outcome` field may be any of the following:
7070
* `"aliasMatch"` -- One document with a legacy URL alias matched the given ID; in this case the `saved_object.id` field is different than the given ID.
7171
* `"conflict"` -- Two documents matched the given ID, one was an exact match and another with a legacy URL alias; in this case the `saved_object` object is the exact match, and the `saved_object.id` field is the same as the given ID.
7272

73+
If the outcome is `"aliasMatch"` or `"conflict"`, the response will also include an `alias_target_id` field. This means that an alias was found for another object, and it describes that other object's ID.
74+
7375
Retrieve a dashboard object in the `testspace` by ID:
7476

7577
[source,sh]
@@ -125,6 +127,7 @@ The API returns the following:
125127
"dashboard": "7.0.0"
126128
}
127129
},
128-
"outcome": "conflict"
130+
"outcome": "conflict",
131+
"alias_target_id": "05becb88-e214-439a-a2ac-15fc783b5d01"
129132
}
130133
--------------------------------------------------

docs/developer/advanced/sharing-saved-objects.asciidoc

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ you read this guide, you can https://github.com/elastic/kibana/pull/107256[follo
6767

6868
> *Do these objects contain links to other objects?*
6969

70-
If your objects store _any_ links to other objects (with an object type/ID), you need to take specific steps to ensure that these links continue functioning after the 8.0 upgrade.
70+
If your objects store _any_ links to other objects (with an object type/ID), you need to take specific steps to ensure that these links
71+
continue functioning after the 8.0 upgrade.
7172

7273
[[sharing-saved-objects-step-1]]
7374
=== Step 1
@@ -79,11 +80,13 @@ If your objects store _any_ links to other objects (with an object type/ID), you
7980
If you answered "Yes" to <<sharing-saved-objects-q1>>, you need to make sure that your object links are _only_ stored in the root-level
8081
`references` field. When a given object's ID is changed, this field will be updated accordingly for other objects.
8182

82-
The image below shows two different examples of object links from a "case" object to an "action" object. The top shows the incorrect way to link to another object, and the bottom shows the correct way.
83+
The image below shows two different examples of object links from a "case" object to an "action" object. The top shows the incorrect way to
84+
link to another object, and the bottom shows the correct way.
8385

8486
image::images/sharing-saved-objects-step-1.png["Sharing Saved Objects step 1"]
8587

86-
If your objects _do not_ use the root-level `references` field, you'll need to <<saved-objects-service-writing-migrations,add a migration>> _before the 8.0 release_ to fix that. Here's a migration function for the example above:
88+
If your objects _do not_ use the root-level `references` field, you'll need to <<saved-objects-service-writing-migrations,add a migration>>
89+
_before the 8.0 release_ to fix that. Here's a migration function for the example above:
8790

8891
```ts
8992
function migrateCaseToV716(
@@ -148,23 +151,26 @@ You'll need to change it to this:
148151

149152
```ts
150153
const resolveResult = savedObjectsClient.resolve(objType, objId);
151-
const { savedObject, outcome, aliasTargetId } = resolveResult;
154+
const savedObject = resolveResult.saved_object;
152155
```
153156

154-
TIP: See an example of this in https://github.com/elastic/kibana/pull/107256/commits/8abaf9fcf59f27cd7cdc44ddbb5515bae56b9d3d[step 2 of the
155-
POC]!
157+
TIP: See an example of this in https://github.com/elastic/kibana/pull/107256#user-content-example-steps[step 2 of the POC]!
156158

157-
The https://github.com/elastic/kibana/blob/master/docs/development/core/server/kibana-plugin-core-server.savedobjectsresolveresponse.md[SavedObjectsResolveResponse interface] has three fields, summarized below:
159+
The
160+
https://github.com/elastic/kibana/blob/master/docs/development/core/server/kibana-plugin-core-server.savedobjectsresolveresponse.md[SavedObjectsResolveResponse
161+
interface] has three fields, summarized below:
158162

159-
* `savedObject` - The saved object that was found.
163+
* `saved_object` - The saved object that was found.
160164
* `outcome` - One of the following values: `'exactMatch' | 'aliasMatch' | 'conflict'`
161-
* `aliasTargetId` - This is defined if the outcome is `'aliasMatch'` or `'conflict'`. It means that a legacy URL alias with this ID points to an object with a _different_ ID.
165+
* `alias_target_id` - This is defined if the outcome is `'aliasMatch'` or `'conflict'`. It means that a legacy URL alias with this ID points
166+
to an object with a _different_ ID.
162167

163168
The SavedObjectsClient is available both on the server-side and the client-side. You may be fetching the object on the server-side via a
164-
custom HTTP route, or you may be fetching it on the client-side directly. Either way, the `outcome` and `aliasTargetId` fields need to be
169+
custom HTTP route, or you may be fetching it on the client-side directly. Either way, the `outcome` and `alias_target_id` fields need to be
165170
passed to your client-side code, and you should update your UI accordingly in the next step.
166171

167-
NOTE: You don't need to use `resolve()` everywhere, <<sharing-saved-objects-faq-resolve-instead-of-get,you should only use it for deep links>>!
172+
NOTE: You don't need to use `resolve()` everywhere, <<sharing-saved-objects-faq-resolve-instead-of-get,you should only use it for deep
173+
links>>!
168174

169175
[[sharing-saved-objects-step-3]]
170176
=== Step 3
@@ -180,8 +186,7 @@ Your page should change <<sharing-saved-objects-faq-resolve-outcomes,according t
180186

181187
image::images/sharing-saved-objects-step-3.png["Sharing Saved Objects resolve outcomes overview"]
182188

183-
TIP: See an example of this in https://github.com/elastic/kibana/pull/107256/commits/435ea49ec45651b9e5ba39b295009b410da2e5a6[step 3 of the
184-
POC]!
189+
TIP: See an example of this in https://github.com/elastic/kibana/pull/107256#user-content-example-steps[step 3 of the POC]!
185190

186191
1. Update your plugin's `kibana.json` to add a dependency on the Spaces plugin:
187192
+
@@ -227,31 +232,29 @@ export class MyPlugin implements Plugin<{}, {}, {}, PluginStartDeps> {
227232
4. In your deep link page, add a check for the `'aliasMatch'` outcome:
228233
+
229234
```ts
230-
...
231-
const { savedObject, outcome, aliasTargetId } = resolveResult;
232-
...
233-
if (spacesApi && outcome === 'aliasMatch') {
235+
if (spacesApi && resolveResult.outcome === 'aliasMatch') {
234236
// We found this object by a legacy URL alias from its old ID; redirect the user to the page with its new ID, preserving any URL hash
235-
const newObjectId = aliasTargetId!; // This is always defined if outcome === 'aliasMatch'
237+
const newObjectId = resolveResult.alias_target_id!; // This is always defined if outcome === 'aliasMatch'
236238
const newPath = http.basePath.prepend(
237239
`path/to/this/page/${newObjectId}${window.location.hash}`
238240
);
239241
await spacesApi.ui.redirectLegacyUrl(newPath, OBJECT_NOUN);
240242
return;
241243
}
242244
```
243-
_Note that `OBJECT_NOUN` is optional, it just changes "object" in the toast to whatever you specify -- you may want the toast to say "dashboard" or "index pattern" instead!_
245+
_Note that `OBJECT_NOUN` is optional, it just changes "object" in the toast to whatever you specify -- you may want the toast to say
246+
"dashboard" or "index pattern" instead!_
244247

245248
5. And finally, in your deep link page, add a function that will create a callout in the case of a `'conflict'` outcome:
246249
+
247250
```tsx
248251
const getLegacyUrlConflictCallout = () => {
249252
// This function returns a callout component *if* we have encountered a "legacy URL conflict" scenario
250-
if (spacesApi && outcome === 'conflict') {
253+
if (spacesApi && resolveResult.outcome === 'conflict') {
251254
// We have resolved to one object, but another object has a legacy URL alias associated with this ID/page. We should display a
252255
// callout with a warning for the user, and provide a way for them to navigate to the other object.
253256
const currentObjectId = savedObject.id;
254-
const otherObjectId = aliasTargetId!; // This is always defined if outcome === 'conflict'
257+
const otherObjectId = resolveResult.alias_target_id!; // This is always defined if outcome === 'conflict'
255258
const otherObjectPath = http.basePath.prepend(
256259
`path/to/this/page/${otherObjectId}${window.location.hash}`
257260
);
@@ -298,12 +301,13 @@ After <<sharing-saved-objects-step-3>> is complete, you can add the code to conv
298301
WARNING: The previous steps can be backported to the 7.x branch, but this step -- the conversion itself -- can only take place in 8.0!
299302
You should use a separate pull request for this.
300303

301-
When you register your object, you need to change the `namespaceType` and also add a `convertToMultiNamespaceTypeVersion` field. This special field will trigger the actual conversion that will take place during the Core migration upgrade process when a user installs the Kibana 8.0 release:
304+
When you register your object, you need to change the `namespaceType` and also add a `convertToMultiNamespaceTypeVersion` field. This
305+
special field will trigger the actual conversion that will take place during the Core migration upgrade process when a user installs the
306+
Kibana 8.0 release:
302307

303308
image::images/sharing-saved-objects-step-4.png["Sharing Saved Objects conversion code"]
304309

305-
TIP: See an example of this in https://github.com/elastic/kibana/pull/107256/commits/d3fcabe808896d901ba05b10e7f2076acc6e3915[step 4 of the
306-
POC]!
310+
TIP: See an example of this in https://github.com/elastic/kibana/pull/107256#user-content-example-steps[step 4 of the POC]!
307311

308312
NOTE: Reminder, don't forget to add integration tests!
309313

0 commit comments

Comments
 (0)