-
Notifications
You must be signed in to change notification settings - Fork 528
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
[FIX JENKINS-35860] - extension point component type filter #308
[FIX JENKINS-35860] - extension point component type filter #308
Conversation
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
- `getExtensions(extensionPointName, [type,] onload)` | ||
This method will async load data and type information as needed, and call the onload handler with a list of extension exports, e.g. the React classes or otherwise exported references. | ||
- `getExtensions(extensionPointName, [filter,] onload)` | ||
This method will async load data and filter the information as needed, and call the onload handler with a list of extension exports, e.g. the React classes or otherwise exported references. |
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'm imagining what this might mean here, but I think a concrete use case example would help. "filter as needed" is a bit ambiguous.
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.
If the filtering is specific to the component dataType
field, then I would prefer that to be explicit in this API i.e. getExtensions(extensionPointName, [dataTypes,] onload)
.
@kzantow Any particular reason why the contents of |
I like it. As @tfennelly mentioned, perhaps some docs on what componentType vs dataType is (componentType is a react component name, right?) |
…nsion-point-types
* EXTENSIONS -> README * more documentation for dataType vs. componentType * modify usage of 'type' to 'dataType' for consistency
@michaelneale |
Looking good. So my take is that dataType is the type provided to as data to the extension, and componentType is the type helps filter things down if many things offer to implement that extension point? @tfennelly is this clear enough now? I'm not sure if I have it right yet. |
OK I think 🐝 from me. @tfennelly speak now or ... I am slightly confused that different componentTypes types could provide the same named extensionPoint, but I am sure there is a good reason. (I can contrive situations, but I assume there was a real need for this). |
This will return a list of type information, from the [classes API](../blueocean-rest/README.md#classes_API), this method also handles caching results locally. | ||
|
||
- `init()` | ||
Required to be called with `{ extensionDataProvider: ..., typeInfoProvider: }` see: [ExtensionStore.js](src/ExtensionStore.js#init) for details. This is currently done in [init.jsx](../blueocean-web/src/main/js/init.jsx), with methods to fetch extension data from `<jenkins-url>/blue/js-extensions/` and type information from `<jenkins-url>/blue/rest/classes/<class-name>`. |
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 think it should be made more explicit (it is somewhat implicit in "This is currently done in ...", but not sure that helps a lot) that this method is not something that users of this API should ever call (? in fact, is it idempotent ?). I'd nearly not publicise it's existence at all.
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.
Fair enough, I'll move this to some docs in the code, I guess..
I dunno ... I think I do get the theoretical difference between Have we hit a concrete use case for needing both of these yet? If we have, can we articulate that somewhere and then eventually in the docs. A clear real-world example always helps. |
No, we don't really have a concrete use-case.
The I'm all ears how to accomplish this differently/better but I'm not sure there's an easier way from the end-user perspective... the issue is this is bridging the gap between Java classes and JavaScript components, there's nothing else that has any sort of this metadata available AFAIK. @michaelneale a basic case for multiple views/ |
@imeredith @michaelneale - NPM fetch is broken on the PR builder, ideas? |
@kzantow yeah failure was due to npm infra, It was passing before. |
I am ok with this 🐝 - @tfennelly is this go or no go? @cliffmeyers ? |
…nsion-point-types
@michaelneale i'm 🐛 'ing this, talked with @tfennelly and we have a slightly different approach, should have it wrapped up today |
@kzantow ok, good to know. |
@@ -1,6 +1,6 @@ | |||
var React = require('react'); | |||
var ReactDOM = require('react-dom'); | |||
var ExtensionStore = require('./ExtensionStore.js'); | |||
var ExtensionStore = require('./ExtensionStore.js').instance; |
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.
How come we have a .instance property, rather than just exporting a single object, or a .getInstance() helper if we have a singleton but need some future-proofing?
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.
@sophistifunk I'm all ears for a better way to do this, I would love to have some sort of DI to be able to hook this together rather than relying on init()
method calls
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'm looking at this instance
export and I don't really see the need for it Vs just using statics (same on ClassMetadataStore
) e.g. ExtensionStore.getExtensions(...)
or ClassMetadataStore.componentType( ..)
?
I actually see how in the tests you have ...
var ClassMetadataStore = require('../dist/ClassMetadataStore').instance;
And then make the usage look as though it's a static
e.g. ClassMetadataStore.componentType(...)
.
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.
Well, I am morally opposed to statics in almost all cases. I need to have a particular instance configured by the user (e.g. blueocean-web), though, so we don't have another mechanism to do this. I think we should investigate a DI system. The tight coupling of some things has me already feeling worried about the future of this codebase...
LGTM |
🐝 |
This is pending review from @tfennelly |
extensions = extensions.filter(m => !('dataType' in m)); | ||
onload(extensions); | ||
}; | ||
} |
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.
Do componentType
, dataType
and untyped
have anything to do with ClassMetadataStore
? Seems like they belong more on ExtensionStore
, seeing as though they are for filtering the extensions in their.
Is there scope here to formalise the Filter
mechanism into a type and extend it to create ComponentTypeFilter
, DataTypeFilter
etc in class files of their own?
🐝 Though I don't really like the |
@tfennelly the filter is about as 'formalized' as it should be, I think? The specific filters are dependent on the type information, therefore located with the class that provides it (well, except the componentType, which should be moved, probably) |
@kzantow okioki ... I'd prob try formalize it more, but maybe that's just personal taste. 🐝 good to go !! |
…nsion-point-types
…nsion-point-types
Related to issue # 35860 .
Summary of this pull request:
. Add component type filter for extensionPoints
@reviewbybees