Skip to content

Commit

Permalink
Update dev docs
Browse files Browse the repository at this point in the history
* Add Sharing Saved Objects section in new dev docs; this intentionally
links to the legacy docs page (which is intended to be viewed by both
internal and external developers)
* Remove docs examples of `namespaceType: 'single'` since we want folks
to stop using that.
  • Loading branch information
jportner committed Aug 9, 2021
1 parent 2d4e889 commit 555cbda
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
14 changes: 14 additions & 0 deletions dev_docs/key_concepts/saved_objects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,17 @@ Sometimes Saved Objects end up persisted inside another Saved Object. We call th
issues with edits propagating - since an entity can only exist in a single place.
Note that from the end user stand point, we don’t use these terms “by reference” and “by value”.

## Sharing Saved Objects

Starting in Kibana 7.12, saved objects can be shared to multiple spaces. The "space behavior" is determined for each object type depending
on how it is registered.

If you are adding a **new** object type, when you register it:

1. Use `namespaceType: 'multiple-isolated'` to make these objects exist in exactly one space
2. Use `namespaceType: 'multiple'` to make these objects exist in one *or more* spaces
3. Use `namespaceType: 'agnostic'` if you want these objects to always exist in all spaces

If you have an **existing** "legacy" object type that is not shareable (using `namespaceType: 'single'`), see the [legacy developer guide
for Sharing Saved Objects](https://www.elastic.co/guide/en/kibana/master/sharing-saved-objects.html) for details on steps you need to take
to make sure this is converted to `namespaceType: 'multiple-isolated'` or `namespaceType: 'multiple'` in the 8.0 release.
6 changes: 5 additions & 1 deletion dev_docs/tutorials/saved_objects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { SavedObjectsType } from 'src/core/server';
export const dashboardVisualization: SavedObjectsType = {
name: 'dashboard_visualization', [1]
hidden: false,
namespaceType: 'single',
namespaceType: 'multiple-isolated', [2]
mappings: {
dynamic: false,
properties: {
Expand All @@ -41,6 +41,10 @@ export const dashboardVisualization: SavedObjectsType = {
[1] Since the name of a Saved Object type forms part of the url path for the public Saved Objects HTTP API,
these should follow our API URL path convention and always be written as snake case.

[2] This field determines "space behavior" -- whether these objects can exist in one space, multiple spaces, or all spaces. This value means
that objects of this type can only exist in a single space. See
<DocLink id="kibDevDocsSavedObjectsIntro" section="sharing-saved-objects" text="Sharing Saved Objects"/> for more information.

**src/plugins/my_plugin/server/saved_objects/index.ts**

```ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { SavedObjectsType } from 'src/core/server';
export const dashboardVisualization: SavedObjectsType = {
name: 'dashboard_visualization', // <1>
hidden: false,
namespaceType: 'single',
namespaceType: 'multiple-isolated', // <2>
mappings: {
dynamic: false,
properties: {
Expand All @@ -66,6 +66,8 @@ export const dashboardVisualization: SavedObjectsType = {
<1> Since the name of a Saved Object type forms part of the url path for the
public Saved Objects HTTP API, these should follow our API URL path convention
and always be written as snake case.
<2> This field determines "space behavior" -- whether these objects can exist in one space, multiple spaces, or all spaces. This value means
that objects of this type can only exist in a single space. See <<sharing-saved-objects,Sharing Saved Objects>> for more information.

.src/plugins/my_plugin/server/saved_objects/index.ts
[source,typescript]
Expand Down

0 comments on commit 555cbda

Please sign in to comment.