Skip to content

Commit 3f946fa

Browse files
Docs: Minor updates, rewording for UI extensions (#1997)
Co-authored-by: Levente Balogh <[email protected]>
1 parent f2d4f62 commit 3f946fa

File tree

5 files changed

+45
-36
lines changed

5 files changed

+45
-36
lines changed

docusaurus/docs/how-to-guides/ui-extensions/create-an-extension-point.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ keywords:
1717

1818
import ExtensionPoints from '@shared/extension-points.md';
1919

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.
2121

2222
Read more about extensions under [key concepts](../../key-concepts/ui-extensions.md).
2323

docusaurus/docs/how-to-guides/ui-extensions/expose-a-component.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ keywords:
1111
sidebar_position: 30
1212
---
1313

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.
1517

1618
## Best practices
1719

docusaurus/docs/how-to-guides/ui-extensions/register-an-extension.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ sidebar_position: 20
1313

1414
import ExtensionPoints from '@shared/extension-points.md';
1515

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.
1717

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.
1919

2020
Read more about extensions under [key concepts](../../key-concepts/ui-extensions.md).
2121

2222
<ExtensionPoints/>
2323

2424
:::warning
2525

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.
2727

2828
:::
2929

30-
## Links
30+
## Work with link extensions
3131

32-
### Register a link
32+
### Register a link extension
3333

3434
You can add an extension for a link. For example:
3535

@@ -138,15 +138,17 @@ export const plugin = new AppPlugin().addLink({
138138
});
139139
```
140140

141-
## Components
141+
## Work with component extensions
142142

143143
### Best practices for adding components
144144

145145
- **Use the props** - check what props the extension point is passing to the components and use them to implement a more tailored experience.
146146
- **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).
147147
- **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.
148148

149-
### Register a component
149+
### Register a component extension
150+
151+
You can register a component extension. For example:
150152

151153
```tsx
152154
import { PluginExtensionPoints } from '@grafana/data';
@@ -159,7 +161,7 @@ export const plugin = new AppPlugin().addComponent({
159161
});
160162
```
161163

162-
### Accessing plugin meta in a component
164+
### Access the plugin's meta in a component
163165

164166
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.
165167

@@ -180,7 +182,9 @@ export const plugin = new AppPlugin().addComponent({
180182
});
181183
```
182184

183-
### Access plugin state in a component
185+
### Access the plugin's state in a component
186+
187+
To access the plugin's state, do the following:
184188

185189
```tsx
186190
import { PluginExtensionPoints } from '@grafana/data';
@@ -223,9 +227,9 @@ export const plugin = new AppPlugin().addComponent({
223227
});
224228
```
225229

226-
## Updating plugin.json metadata
230+
## Update the plugin.json metadata
227231

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.
229233

230234
For example:
231235

@@ -244,18 +248,14 @@ For more information, see the `plugin.json` [reference](../../reference/metadata
244248

245249
## Troubleshooting
246250

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`**.
248259

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`**.
254260

255-
### My component is not appearing
256261

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`**.

docusaurus/docs/key-concepts/ui-extensions.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,41 @@ keywords:
1212
sidebar_position: 60
1313
---
1414

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.
1616

17-
## Definition of terms
17+
## Understand extensions
1818

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:
2020

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?
2328

2429
![Panel menu showing available extensions](/img/ui-extensions-menu.png)
2530

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.
2732

2833
## Why should I add an extension point?
2934

3035
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.
3136

3237
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.
3338

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:
3540

3641
- 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.
3742
- Clean separation of concerns. Your application doesn't need to know anything about the plugin extending your UI.
3843
- 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.
3944
- 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.
4045
- Extensions are fast. We pre-build the extensions registry at Grafana boot time which makes it fast to use while rendering the UI.
4146

42-
Examples where it would be useful:
47+
### Use cases
48+
49+
You can use extensions for the following scenarios:
4350

4451
- 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.
4552
- 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:
5158
- [Learn how to expose components from a plugin so other plugins can import them](../how-to-guides/ui-extensions/expose-a-component.md)
5259
- [Learn how to use exposed components](../how-to-guides/ui-extensions/use-an-exposed-component.md)
5360
- [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)

docusaurus/docs/reference/ui-extensions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ The method returns the `AppPlugin` instance to allow for chaining.
7373

7474
#### Examples
7575

76-
- [Accessing plugin meta-data in the component](../how-to-guides/ui-extensions/register-an-extension.md#accessing-plugin-meta-in-a-component)
77-
- [Access your plugin's state inside the component](../how-to-guides/ui-extensions/register-an-extension.md#access-plugin-state-in-a-component)
76+
- [Accessing plugin meta-data in the component](../how-to-guides/ui-extensions/register-an-extension.md#access-the-plugins-meta-in-a-component)
77+
- [Access your plugin's state inside the component](../how-to-guides/ui-extensions/register-an-extension.md#access-the-plugins-state-in-a-component)
7878
- [Hide a component in certain conditions](../how-to-guides/ui-extensions/register-an-extension.md#hide-a-component-in-certain-conditions)
7979

8080
#### See also

0 commit comments

Comments
 (0)