-
Notifications
You must be signed in to change notification settings - Fork 407
WebUI: Support custom-object-renderers plugin #9374
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
Conversation
# Conflicts: # pkg/api/controller.go # pkg/config/config.go
|
|
||
| async commit(repoId, branchId, message, metadata = {}) { | ||
| const response = await apiRequest(`/repositories/${repoId}/branches/${branchId}/commits`, { | ||
| const response = await apiRequest(`/repositories/${encodeURIComponent(repoId)}/branches/${encodeURIComponent(branchId)}/commits`, { |
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.
Not related, but should be done.
|
|
||
| type ConfigType = { | ||
| storages: StorageConfigType[] | null; | ||
| storages?: StorageConfigType[]; |
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.
Also aligning style, to use the ? style.
| }; | ||
|
|
||
| type VersionConfig = { | ||
| upgrade_recommended?: boolean; |
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.
Not related, but used in the code, so added here.
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 usually avoid file reformatting, but this one was just a little unformatted.
guy-har
left a comment
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.
LGTM
Thanks
| const fileType = guessType(props.contentType, props.fileExtension) | ||
| const pluginManager = usePluginManager(); | ||
|
|
||
| const customRenderer = pluginManager.customObjectRenderers.get(props.contentType, props.fileExtension) |
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.
The signature of get is for contentType and fileExtension is string, while their type is string | null
FWIU you should change the signature or pass undefined in case of null (i.e (props.contentType ?? undefined, props.fileExtension ?? undefined)
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.
Yeah, apparently even IntelliJ noted about this...
Updated -
It required some more null/undefined changes in other files...
| custom_viewers?: Array<CustomViewerConfig>; | ||
| }; | ||
|
|
||
| type CustomViewerConfig = { |
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.
nit
| type CustomViewerConfig = { | |
| type CustomViewer = { |
| pre_sign_support_ui: boolean; | ||
| }; | ||
|
|
||
| type UIConfigType = { |
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.
nit:
| type UIConfigType = { | |
| type UIConfig = { |
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.
Sure. I'll also align StorageConfigType.
| type CustomViewerConfig = { | ||
| name: string; | ||
| url: string; | ||
| content_types?: Array<string>; |
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.
Why do we sometimes use use snake case and sometimes pascal case?
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.
The snake case is what's returned from the API as is,
The pascal case is constructed in the js code.
Since the ConfigType is built in the js (see getConfig()),
I kept it as pascal case.
If it's critical I can align, but this has some internal sense.
itaigilo
left a comment
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.
Thanks @guy-har for the review.
Updated.
| pre_sign_support_ui: boolean; | ||
| }; | ||
|
|
||
| type UIConfigType = { |
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.
Sure. I'll also align StorageConfigType.
| type CustomViewerConfig = { | ||
| name: string; | ||
| url: string; | ||
| content_types?: Array<string>; |
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.
The snake case is what's returned from the API as is,
The pascal case is constructed in the js code.
Since the ConfigType is built in the js (see getConfig()),
I kept it as pascal case.
If it's critical I can align, but this has some internal sense.
| const fileType = guessType(props.contentType, props.fileExtension) | ||
| const pluginManager = usePluginManager(); | ||
|
|
||
| const customRenderer = pluginManager.customObjectRenderers.get(props.contentType, props.fileExtension) |
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.
Yeah, apparently even IntelliJ noted about this...
Updated -
It required some more null/undefined changes in other files...
Change Description
In order to support the extension of object viewers, adding a WebUI plugin for it.
The plugin includes:
initfunction, allowing one-time init by configgetfunction, allowing to provide a custom renderer, by file extension or by the object's content type.