forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Register new embeddable type" to Embeddable tutorial (elastic#18…
…1761) PR adds "Register new embeddable type" section to Embeddable tutorial <img width="600" alt="Screenshot 2024-04-25 at 12 25 59 PM" src="https://github.com/elastic/kibana/assets/373691/075c534b-0b1b-4600-a057-d601d09da5d1"> PR also groups example embeddables to make them easier to find <img width="600" alt="Screenshot 2024-04-25 at 12 26 12 PM" src="https://github.com/elastic/kibana/assets/373691/82d55fca-bbe8-4b63-a80e-dd052307d7e5"> --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
f21d6e4
commit 438f623
Showing
8 changed files
with
103 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
examples/embeddable_examples/public/app/register_embeddable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiCodeBlock, EuiSpacer, EuiText } from '@elastic/eui'; | ||
// @ts-ignore | ||
import registerSearchEmbeddableSource from '!!raw-loader!../react_embeddables/search/register_search_embeddable'; | ||
// @ts-ignore | ||
import registerAttachActionSource from '!!raw-loader!../react_embeddables/search/register_add_search_panel_action'; | ||
|
||
export const RegisterEmbeddable = () => { | ||
return ( | ||
<> | ||
<EuiText> | ||
<p> | ||
This plugin registers several embeddable types with{' '} | ||
<strong>registerReactEmbeddableFactory</strong> during plugin start. The code example | ||
below shows Search embeddable registration. Notice how the embeddable factory is imported | ||
asynchronously to limit initial page load size. | ||
</p> | ||
</EuiText> | ||
|
||
<EuiCodeBlock language="jsx" fontSize="m" paddingSize="m"> | ||
{registerSearchEmbeddableSource} | ||
</EuiCodeBlock> | ||
|
||
<EuiSpacer size="l" /> | ||
|
||
<EuiText> | ||
<p> | ||
Run the example embeddables by creating a dashboard, clicking <em>Add panel</em> button, | ||
and then selecting <em>Embeddable examples</em> group. | ||
</p> | ||
<p> | ||
Add your own embeddables to <em>Add panel</em> menu by attaching an action to the{' '} | ||
<strong>ADD_PANEL_TRIGGER</strong> trigger. Notice usage of <strong>grouping</strong> to | ||
nest related panel types and avoid bloating <em>Add panel</em> menu. Please reach out to | ||
@elastic/kibana-presentation team to coordinate menu updates. | ||
</p> | ||
</EuiText> | ||
|
||
<EuiCodeBlock language="jsx" fontSize="m" paddingSize="m"> | ||
{registerAttachActionSource} | ||
</EuiCodeBlock> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
examples/embeddable_examples/public/react_embeddables/add_panel_grouping.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export const addPanelGrouping = { | ||
id: 'embeddableExamples', | ||
getDisplayName: () => 'Embeddable examples', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
examples/embeddable_examples/public/react_embeddables/search/register_search_embeddable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { registerReactEmbeddableFactory } from '@kbn/embeddable-plugin/public'; | ||
import { SEARCH_EMBEDDABLE_ID } from './constants'; | ||
import { Services } from './types'; | ||
|
||
export function registerSearchEmbeddable(services: Services) { | ||
registerReactEmbeddableFactory(SEARCH_EMBEDDABLE_ID, async () => { | ||
const { getSearchEmbeddableFactory } = await import('./search_react_embeddable'); | ||
return getSearchEmbeddableFactory(services); | ||
}); | ||
} |