-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[TreeView] Improve typing to support optional dependencies in plugins and in the item #13523
[TreeView] Improve typing to support optional dependencies in plugins and in the item #13523
Conversation
@@ -37,7 +37,7 @@ type TreeViewLogExpandedSignature = TreeViewPluginSignature<{ | |||
// The parameters of this plugin as they are passed to the plugin after calling `plugin.getDefaultizedParams` | |||
defaultizedParams: TreeViewLogExpandedDefaultizedParameters; | |||
// Dependencies of this plugin (we need the expansion plugin to access its model) | |||
dependantPlugins: [UseTreeViewExpansionSignature]; | |||
dependencies: [UseTreeViewExpansionSignature]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to do this renaming for a long time 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, this is a relief 🙈
Deploy preview: https://deploy-preview-13523--material-ui-x.netlify.app/ Updated pages: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, makes a lot of sense 🎉
@@ -37,7 +37,7 @@ type TreeViewLogExpandedSignature = TreeViewPluginSignature<{ | |||
// The parameters of this plugin as they are passed to the plugin after calling `plugin.getDefaultizedParams` | |||
defaultizedParams: TreeViewLogExpandedDefaultizedParameters; | |||
// Dependencies of this plugin (we need the expansion plugin to access its model) | |||
dependantPlugins: [UseTreeViewExpansionSignature]; | |||
dependencies: [UseTreeViewExpansionSignature]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, this is a relief 🙈
… and in the item (mui#13523)
… and in the item (mui#13523)
Internal improvements for #13388
If a function needs to execute some logic from a plugin, it can usually be done in two ways:
apiRef
in both the Tree View and the Data Grid)Solution 1. is usually simpler to implement and to read, but it does not respect the separation of concern, if our function is inside a plugin A and wants to call a method of the plugin B, then we have a dependency, A require B in order to work.
For pro features, we tend to favor solution 2 to avoid leaking pro code inside the community package (which is why the item enhancers have been introduced for the Drag and Drop feature on the Tree View).
But on the Tree View, we also have to support 2 versions of the components in the same plan (
SimpleTreeView
andRichTreeView
). @noraleonte is currently working on an editing feature that will only be available in theRichTreeView
, this feature has a lot of dependencies (the keyboard navigation needs to be aware of it for example). We could rely on Solution 2 but it would make the codebase a lot harder to read. Instead, I am proposing to boost Solution 1. by introducing a notion of optional dependencies. The Plugin A is aware of the plugin B, it calls the method of the plugin B, but it is not sure if the plugin B is present or not.