Skip to content

Commit

Permalink
[DOCS] Fixes error in examples for migrating plugin code (elastic#99261
Browse files Browse the repository at this point in the history
…) (elastic#99293)

* [DOCS] Fixes error in examples for migrating plugin code

* [DOCS] Fixes error in docs update
  • Loading branch information
gchaps authored May 4, 2021
1 parent 861b6f1 commit 4d633d1
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions docs/developer/plugin/migrating-legacy-plugins-examples.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ platform, these were referred to as `hidden` applications and were set
via the `hidden` property in a {kib} plugin. Chromeless applications
are also not displayed in the left navbar.

To mark an application as chromeless, specify `chromeless: false` when
To mark an application as chromeless, specify `chromeless: true` when
registering your application to hide the chrome UI when the application
is mounted:

Expand Down Expand Up @@ -815,7 +815,7 @@ been renamed: `SavedObjectsType.management.importableAndExportable`.
----
`(doc: SavedObjectUnsanitizedDoc, log: SavedObjectsMigrationLogger) => SavedObjectUnsanitizedDoc;`
----
In {kib} Platform, it is
In {kib} Platform, it is
[source,typescript]
----
`(doc: SavedObjectUnsanitizedDoc, context: SavedObjectMigrationContext) => SavedObjectUnsanitizedDoc;`
Expand Down Expand Up @@ -1094,7 +1094,7 @@ the current user.

[source,typescript]
----
const request = client.asCurrentUser.ping({}, {
const request = client.asCurrentUser.ping({}, {
headers: {
authorization: 'foo',
custom: 'bar',
Expand Down Expand Up @@ -1145,9 +1145,9 @@ router.get(

==== Accessing the client from a collector's `fetch` method

At the moment, the `fetch` method's context receives preconfigured
<<scoped-services, scoped clients>> for Elasticsearch and SavedObjects.
To help in the transition, both, the legacy (`callCluster`) and new clients are provided,
At the moment, the `fetch` method's context receives preconfigured
<<scoped-services, scoped clients>> for Elasticsearch and SavedObjects.
To help in the transition, both, the legacy (`callCluster`) and new clients are provided,
but we strongly discourage using the deprecated legacy ones for any new implementation.

[source,typescript]
Expand All @@ -1158,27 +1158,27 @@ usageCollection.makeUsageCollector<MyUsage>({
schema: {...},
async fetch(context) {
const { callCluster, esClient, soClient } = context;
// Before:
const result = callCluster('search', options)
// After:
const { body: result } = esClient.search(options);
return result;
}
});
----

Regarding the `soClient`, it is encouraged to use it instead of the plugin's owned SavedObject's repository
Regarding the `soClient`, it is encouraged to use it instead of the plugin's owned SavedObject's repository
as we used to do in the past.

Before:

[source,typescript]
----
function getUsageCollector(
usageCollection: UsageCollectionSetup,
usageCollection: UsageCollectionSetup,
getSavedObjectsRepository: () => ISavedObjectsRepository | undefined
) {
usageCollection.makeUsageCollector<MyUsage>({
Expand All @@ -1187,12 +1187,12 @@ function getUsageCollector(
schema: {...},
async fetch() {
const savedObjectsRepository = getSavedObjectsRepository();
const { attributes: result } = await savedObjectsRepository.get('my-so-type', 'my-so-id');
return result;
}
});
});
}
----

Expand All @@ -1207,10 +1207,10 @@ function getUsageCollector(usageCollection: UsageCollectionSetup) {
schema: {...},
async fetch({ soClient }) {
const { attributes: result } = await soClient.get('my-so-type', 'my-so-id');
return result;
}
});
});
}
----

Expand Down

0 comments on commit 4d633d1

Please sign in to comment.