Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Update the docs for UI-Extensions #881

Merged
merged 21 commits into from
Apr 24, 2024

Conversation

leventebalogh
Copy link
Collaborator

@leventebalogh leventebalogh commented Apr 17, 2024

What changed?

With making the extensions registry reactive, we need to update the docs as well to give information about the React hooks and what other implications the change might causes.

View it on dev →

@leventebalogh leventebalogh self-assigned this Apr 17, 2024
@leventebalogh leventebalogh added type/docs Changes only affect the documentation no-changelog Don't include in changelog and version calculations labels Apr 17, 2024
Copy link

github-actions bot commented Apr 17, 2024

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged. It will not be considered when calculating future versions of the npm packages and will not appear in the changelogs.

@leventebalogh leventebalogh marked this pull request as ready for review April 18, 2024 09:46
@leventebalogh leventebalogh requested a review from a team as a code owner April 18, 2024 09:46
@leventebalogh leventebalogh requested review from sunker, jackw, tolzhabayev, sympatheticmoose and josmperez and removed request for a team April 18, 2024 09:46

Firstly, you will need to define an extension point ID. This is basically just a string describing the part of the UI where the extension point lives. Extension developers should be able to figure out where in the UI the extension will be added by reading the extension point ID.
An extension point is a place in the UI which you make extendable by other plugins using extensions. These extensions can be either be links or simple React components (that can basically impelement anything). It's up to you how you are displaying the handling or displaying the extensions, we have some examples below.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
An extension point is a place in the UI which you make extendable by other plugins using extensions. These extensions can be either be links or simple React components (that can basically impelement anything). It's up to you how you are displaying the handling or displaying the extensions, we have some examples below.
An extension point is a place in the UI which you make extendable by other plugins using extensions. These extensions can either be links or React components that can impelement virtually anything. It's up to you how to display the handling or displaying of extensions. Refer to the following examples below:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, should we keep following and the : in the last line? (I am asking because the examples are not directly following this sentence, but they are a few paragraphs below.) Maybe we should add a link instead?

Copy link
Contributor

@josmperez josmperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed this from a documentation standpoint only, and have made various suggestions. No blocking issues identified.

- In case it's an extension point in core Grafana, it must start with `grafana/`
- In case it's inside a plugin, it must start with `plugin/<PLUGIN_ID>/`
- It must be unique
- **an app plugin** - _currently only app plugins can create extension points_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **an app plugin** - _currently only app plugins can create extension points_
- App plugins - _currently only app plugins can create extension points_

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I am not sure about this one - but maybe I am wrong. When we are listing the requirements, wouldn't an app plugin or app plugin sounds better than App plugins (in plural)?

docusaurus/docs/ui-extensions/create-an-extension-point.md Outdated Show resolved Hide resolved
docusaurus/docs/ui-extensions/create-an-extension-point.md Outdated Show resolved Hide resolved
docusaurus/docs/ui-extensions/create-an-extension-point.md Outdated Show resolved Hide resolved
docusaurus/docs/ui-extensions/create-an-extension-point.md Outdated Show resolved Hide resolved
docusaurus/docs/ui-extensions/create-an-extension-point.md Outdated Show resolved Hide resolved
docusaurus/docs/ui-extensions/create-an-extension-point.md Outdated Show resolved Hide resolved
docusaurus/docs/ui-extensions/create-an-extension-point.md Outdated Show resolved Hide resolved
@leventebalogh leventebalogh force-pushed the leventebalogh/extensions-docs-update branch from a5821d3 to 5d68215 Compare April 22, 2024 06:50
leventebalogh and others added 5 commits April 22, 2024 09:26
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
docusaurus/docs/ui-extensions/create-an-extension-point.md Outdated Show resolved Hide resolved
docusaurus/docs/ui-extensions/create-an-extension-point.md Outdated Show resolved Hide resolved
docusaurus/docs/ui-extensions/create-an-extension-point.md Outdated Show resolved Hide resolved

##### `options?.limitPerPlugin` - _number (Optional)_

Use this parameter to set the maximum value for how many extensions should be returned from the same plugin. It can be useful in cases when there is limited space on the UI to display extensions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to link to this from the section regarding designing your UI to respond to multiple plugins? But I think we also need to describe how it would be determined which plugins get displayed when there are more extensions than the limit allows

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point, and some more explanation would be good indeed. I will leave it for a separate refinement PR if you don't mind, let me know if you have objections.

Comment on lines +122 to +124
// We define the `context` outside of the React component for performance reasons.
// (Declaring it inside the component would result in a new object on every render,
// which would unnecessarily trigger the `usePluginLinkExtensions()` hook.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this detail in the docs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think we do, it can be important help for plugin devs. (On the other this could be another candidate for having a "Considerations (...)" / "Best practices" section.)

}
```

#### Example - rendering link extensions (dynamic context)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still find static vs dynamic a little unclear as to why the different situations occur.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good feedback, let's discuss how the best we could explain this difference in the docs.

};
```

### The `getPluginExtensions()` method - _deprecated_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep this in the docs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think until it is actually removed, we should?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The migration process is just to swap the hook right? (Which we could mention).

I worry it's just noise that makes the doc look longer and more complicated. Especially given we don't want to encourage any further adoption, and we believe there's currently limited community uptake.

I guess we need it until the core extension points are all converted. But after that I would personally just remove it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The migration process is just to swap the hook right? (Which we could mention).

Basically yes - however if they have tests then updating those is bit more work (due to mocking).

I worry it's just noise that makes the doc look longer and more complicated.

I agree.

Yeah, let's keep them for now (in this PR) and let's chat about when we should remove them. My other concern is that we might don't even want to remove them / deprecate them in the end, but clearly communicate what they can be used for. (We need to think about the use cases, but a function like this could be use in places outside of a React component, which can come handy. It needs some more thought.)

leventebalogh and others added 6 commits April 24, 2024 07:51
Co-authored-by: David Harris <david.harris@grafana.com>
Co-authored-by: David Harris <david.harris@grafana.com>
Co-authored-by: David Harris <david.harris@grafana.com>
Co-authored-by: David Harris <david.harris@grafana.com>
@leventebalogh leventebalogh merged commit ae160a7 into main Apr 24, 2024
12 checks passed
@leventebalogh leventebalogh deleted the leventebalogh/extensions-docs-update branch April 24, 2024 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Don't include in changelog and version calculations type/docs Changes only affect the documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants