You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus/docs/how-to-guides/ui-extensions/create-an-extension-point.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ keywords:
17
17
18
18
import ExtensionPoints from '@shared/extension-points.md';
19
19
20
-
An _extension point_ is a part of your plugin UI or Grafana UI where other plugins can add links or React components via hooks. You can use them to extend the user experience based on a context exposed by the extension point.
20
+
An _extension point_ is a part of your plugin or Grafana UI where other plugins can add links or React components via hooks. You can use them to extend the user experience based on a context exposed by the extension point.
21
21
22
22
Read more about extensions under [key concepts](../../key-concepts/ui-extensions.md).
Copy file name to clipboardExpand all lines: docusaurus/docs/how-to-guides/ui-extensions/expose-a-component.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,9 @@ keywords:
11
11
sidebar_position: 30
12
12
---
13
13
14
-
Expose components to allow app plugins to easily share functionality with other app plugins. Compared to [registering an extension](./register-an-extension), they do not require the extension provider to explicitly register a component against any extension points, and can therefore be [used by any app plugin](./use-an-exposed-component.md) with no action required by the provider.
14
+
Expose components to allow app plugins to easily share functionality with other app plugins without extension points.
15
+
16
+
Compared to [registering an extension](./register-an-extension), when you expose a component you do not require the other extension providers to explicitly register their extensions against any extension points. Therefore the component may be [used by any app plugin](./use-an-exposed-component.md) with no action required by the provider.
Copy file name to clipboardExpand all lines: docusaurus/docs/how-to-guides/ui-extensions/register-an-extension.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,23 +13,23 @@ sidebar_position: 20
13
13
14
14
import ExtensionPoints from '@shared/extension-points.md';
15
15
16
-
An _extension_ is a plugin-defined link or a React component that is rendered in either the core Grafana UI or in another app plugin.
16
+
Extensions are links or React components in an app plugin. Extensions are linked to an extension point and they either render in the core Grafana UI or in another app plugin. They can also work as functions returning values.
17
17
18
-
Compared to [exposing a component](./expose-a-component.md), they are explicitly registered against one or more extension point IDs. This can be more appropriate when looking to extend Grafana's core UI, or for when you need more control over what should be allowed to use your plugin's extension.
18
+
You can either register or expose an extension. Compared to [just exposing a component](./expose-a-component.md), when you register an extension against one or more extension point IDs you can control who has access to your components. This can be more appropriate when looking to extend Grafana's core UI, or for when you need more control over what should be allowed to use your plugin's extension.
19
19
20
20
Read more about extensions under [key concepts](../../key-concepts/ui-extensions.md).
21
21
22
22
<ExtensionPoints/>
23
23
24
24
:::warning
25
25
26
-
You must [update](#updating-pluginjson-metadata) your `plugin.json` metadata to list any registered extensions.
26
+
You must [update](#update-the-pluginjson-metadata) your `plugin.json` metadata to list any registered extensions.
27
27
28
28
:::
29
29
30
-
## Links
30
+
## Work with link extensions
31
31
32
-
### Register a link
32
+
### Register a link extension
33
33
34
34
You can add an extension for a link. For example:
35
35
@@ -138,15 +138,17 @@ export const plugin = new AppPlugin().addLink({
138
138
});
139
139
```
140
140
141
-
## Components
141
+
## Work with component extensions
142
142
143
143
### Best practices for adding components
144
144
145
145
-**Use the props** - check what props the extension point is passing to the components and use them to implement a more tailored experience.
146
146
-**Wrap your component with providers** - if you want to access any plugin specific state in your component make sure to wrap it with the necessary React context providers (e.g. for Redux).
147
147
-**Use the enum for Grafana extension point IDs** - if you are registering a component to one of the available Grafana extension points, make sure that you use the [`PluginExtensionPoints` enum exposed by the `@grafana/data`](https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/types/pluginExtensions.ts#L121) package.
148
148
149
-
### Register a component
149
+
### Register a component extension
150
+
151
+
You can register a component extension. For example:
@@ -159,7 +161,7 @@ export const plugin = new AppPlugin().addComponent({
159
161
});
160
162
```
161
163
162
-
### Accessing plugin meta in a component
164
+
### Access the plugin's meta in a component
163
165
164
166
You can use the `usePluginContext()` hook to access any plugin specific meta information inside your component. The hook returns a [`PluginMeta`](https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/types/plugin.ts#L62) object. This can be useful because the component that you register from your plugin won't be rendered under the React tree of your plugin, but somewhere else in the UI.
165
167
@@ -180,7 +182,9 @@ export const plugin = new AppPlugin().addComponent({
@@ -223,9 +227,9 @@ export const plugin = new AppPlugin().addComponent({
223
227
});
224
228
```
225
229
226
-
## Updating plugin.json metadata
230
+
## Update the plugin.json metadata
227
231
228
-
Once you have defined a link or component extension to be registered against an extension point, you must update your `plugin.json` metadata.
232
+
After you have defined a link or component extension and registered it against an extension point, you must update your `plugin.json` metadata.
229
233
230
234
For example:
231
235
@@ -244,18 +248,14 @@ For more information, see the `plugin.json` [reference](../../reference/metadata
244
248
245
249
## Troubleshooting
246
250
247
-
### My link is not appearing
251
+
If you cannot see your link or component extension check the following:
252
+
253
+
1.**Check the console logs** - your link or component may not be appearing due to validation errors. Look for the relevant logs in your browser's console.
254
+
1.**Check the `targets`** - make sure that you are using the correct extension point IDs, and always use the `PluginExtensionPoints` enum for Grafana extension points.
255
+
1.**Check the links `configure()` function** - if your link has a `configure()` function which is returning `undefined`, the link is hidden.
256
+
1.**Check your component's implementation** - if your component returns `null` it won't be rendered at the extension point.
257
+
1.**Check if you register too many links or components** - certain extension points limit the number of links or components allowed per plugin. If your plugin registers more links or components for the same extension point than the allowed amount, some of them may be filtered out.
258
+
1.**Check the Grafana version** - link and component extensions are only supported after Grafana version **`>=10.1.0`**. `addLink()` and `addComponent()` are only supported in versions **>=`11.1.0`**.
248
259
249
-
1.**Check the console logs** - there is a good chance that your link is not appearing due to some validation errors. In this case you should see some relevant logs in your browser's console.
250
-
1.**Check the `targets`** - make sure that you are using the correct extension point ids (always use the `PluginExtensionPoints` enum for Grafana extension points)
251
-
1.**Check the links `configure()` function** - in case your link has a `configure()` function it can happen that it is returning `undefined` under certain conditions, which hides the link.
252
-
1.**Check if you register too many links** - certain extension points limit the number of links allowed per plugin, and in case your plugin registers more than one links for the same extension point there is a chance that some of them are filtered out.
253
-
1.**Check the Grafana version** - link and component extensions are only supported after Grafana version **`>=10.1.0`**, while `addLink()` is only supported in versions **>=`11.1.0`**.
254
260
255
-
### My component is not appearing
256
261
257
-
1.**Check the console logs** - there is a good chance that your component is not appearing due to some validation errors. In this case you should see some relevant logs in your browser's console.
258
-
1.**Check the `targets`** - make sure that you are using the correct extension point ids (always use the `PluginExtensionPoints` enum for Grafana extension points)
259
-
1.**Check your components implementation** - in case your component returns `null` under certain conditions, then it won't be rendered at the extension point.
260
-
1.**Check if you register too many components** - certain extension points limit the number of components allowed per plugin, and in case your plugin registers more than one component for the same extension point there is a chance that some of them are filtered out.
261
-
1.**Check the Grafana version** - link and component extensions are only supported after Grafana version **`>=10.1.0`**, while `addComponent()` is only supported in versions **>=`11.1.0`**.
Copy file name to clipboardExpand all lines: docusaurus/docs/key-concepts/ui-extensions.md
+16-9Lines changed: 16 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,34 +12,41 @@ keywords:
12
12
sidebar_position: 60
13
13
---
14
14
15
-
Use UI extensions to contribute new actions and functionality to the core Grafana UI and other app plugins.
15
+
Use UI extensions to contribute new actions and functionality to the core Grafana UI and other app plugins.
16
16
17
-
## Definition of terms
17
+
## Understand extensions
18
18
19
-
Before we go into details we need to cover the two major concepts in the UI extensions framework:
19
+
The UI extensions framework is built around these concepts:
20
20
21
-
1.`Extension point` - A place in the UI where plugins can contribute new functionality to the end user. The Grafana UI exposes extension points and app plugins can also define their own extension points.
22
-
2.`Extension` - New functionality, registered by an app plugin, appearing at an extension point. For example, an extension could provide a navigational link to bring users to a particular view, it could open a modal menu allowing the user to configure an action to take from within their current context (for instance, to create a SLO), or it could trigger background tasks.
21
+
1.`Extension point` - A place in the UI where plugins can contribute new functionality to the end user. Both the Grafana UI and app plugins can expose extension points.
22
+
2.`Extension` - New functionality you register to an extension point. For example, an extension can provide a navigational link to bring users to a particular view, open a modal menu allowing the user to configure an action to take from within their current context (for instance, to create a SLO), or trigger background tasks. There are three types of extensions: links, components, and functions.
23
+
3.`Exposed component` - A component from an app plugin you can expose to easily share functionality with other app plugins without having to register to an extension point.
24
+
25
+
After you have added an extension point to your UI you can extend it multiple times by multiple plugins.
26
+
27
+
## Where can I find extensions?
23
28
24
29

25
30
26
-
In the example above, there is one extension point with three registered extensions. This highlights one of the benefits of using UI extensions. Once you have added an extension point to your UI you can extend it multiple times by multiple plugins.
31
+
In the example above, there is one extension point with three registered extensions: Machine learning, Outlier detection, and Create forecast.
27
32
28
33
## Why should I add an extension point?
29
34
30
35
App plugins can provide custom pages in the Grafana UI, often highly contextualized to a particular service or task to enable users to be productive. Grafana is a feature-rich observability platform and has an extensive ecosystem of plugins, allowing users to monitor and act upon a wide set of data.
31
36
32
37
Extension points facilitate the breaking down of silos between individual views, allowing users to quickly leverage data from their current context to take relevant actions. By providing extension points within your app, relevant extensions can easily offer new capabilities to your shared users.
33
38
34
-
Add an extension point to your UI to give benefits such as these:
39
+
Adding an extension point to your UI provides the following benefits:
35
40
36
41
- Define the UI extension point once to enable multiple plugins to extend your UI with new functionality. You don't need any additional effort to provide functionality from more plugins in your UI.
37
42
- Clean separation of concerns. Your application doesn't need to know anything about the plugin extending your UI.
38
43
- Integration built for change. Since your application doesn't know anything about the internal workings of the plugin extending your UI, they are free to change their APIs without the risk of breaking the extension point UI.
39
44
- Easy to bootstrap. If both apps are installed and enabled, then the extensions are automatically configured and displayed to the user. There is no need for either app to include custom logic to detect the presence of the other.
40
45
- Extensions are fast. We pre-build the extensions registry at Grafana boot time which makes it fast to use while rendering the UI.
41
46
42
-
Examples where it would be useful:
47
+
### Use cases
48
+
49
+
You can use extensions for the following scenarios:
43
50
44
51
- The user views a dashboard with historical data. By adding an extension point to this part of the UI, a machine learning app plugin can give the user the ability to create a forecast for that data directly from the panel.
45
52
- The user views a firing alert. By adding an extension point to this part of the UI, an Incident app plugin can give the user the ability to create an incident directly from the alert view.
@@ -51,4 +58,4 @@ Examples where it would be useful:
51
58
-[Learn how to expose components from a plugin so other plugins can import them](../how-to-guides/ui-extensions/expose-a-component.md)
52
59
-[Learn how to use exposed components](../how-to-guides/ui-extensions/use-an-exposed-component.md)
53
60
-[Learn how to version exposed components and extension points](../how-to-guides/ui-extensions/versioning-extensions.md)
54
-
-[Check the API reference](../reference/ui-extensions.md)
61
+
-[Check the API reference guide](../reference/ui-extensions.md)
0 commit comments