-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat: Add CustomizableRenderComponent for dynamic component rendering and update component usage #4634
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for ohif-dev canceled.
|
✅ Deploy Preview for ohif-platform-docs canceled.
|
we are reworking the customizationService so stay tuned until it is done |
Thank you for the information, @sedghi. Would you happen to have a feature branch or work item that could serve as a reference for the implementation? |
247b7a3
to
8e39169
Compare
Can you rebase on top of the new customization service and follow what's done there please? Sorry for the inconvenience |
…port for custom annotation labelling component
d9d5415
to
79b8f42
Compare
@sedghi I have updated the branch based on the latest changes in the customization service. Would you mind reviewing it when you have a moment? |
@@ -0,0 +1,9 @@ | |||
export default { | |||
'ui.ContextMenuItem': { | |||
$set: CustomContextMenuItem, |
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.
Clarifying the $
Sign and Customization Behavior
-
The
$
Sign and Default Customizations
If a customization is part of thedefault
set (i.e., it hasname: 'default'
), you don’t need to use the$
operators. This is because default customizations are automatically applied and serve as the base template.However, if a customization is not part of the
default
set, it won’t be applied automatically. This raises two questions:- a) How do we apply it?
- b) What happens when it’s applied?
Answering Question (a): Applying Customizations
To apply a non-default customization, you reference it by its module path. For example:
customizationService.setCustomizations([
'@ohif/extension-cornerstone-dicom-seg.customizationModule.dicom-seg-sorts',
]);
This assumes the customization is defined in the @ohif/extension-cornerstone-dicom-seg
extension under the name dicom-seg-sorts
. You can apply it either in your mode or globally via configuration.
Answering Question (b): Behavior When Applied
When applying a customization, you need to define how it interacts with the existing configuration. Should it append, merge, replace, or delete? This is where the $
operators come into play.
For example, in the datasources
customization:
{
name: 'datasources',
value: datasourcesCustomization,
},
The $push
operator is used to append to an array:
export default {
'routes.customRoutes': {
routes: {
$push: [
{
path: '/datasources',
children: DataSourceSelector,
},
],
},
},
};
This means that when the datasources
customization is applied, it will push the new route into the existing array of routes (which defaults to []
if empty).
@@ -0,0 +1,9 @@ | |||
export default { | |||
'measurement.labellingComponent': { | |||
$set: CustomLabellingFlow, |
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.
same for all of these
@@ -98,6 +98,7 @@ export interface Menu { | |||
selector?: Types.Predicate; | |||
|
|||
items: MenuItem[]; | |||
customClassName: 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.
just call it className
The CustomizableRenderComponent dynamically renders a custom component based on a customizationId. If a component for the given ID is found, it is rendered with the provided props; otherwise, a fallback component is rendered. To set a custom component for a specific customizationId, you must register it using the customizationService, where the custom component is added within an object under the component key. If no component is found for the specified customizationId, the FallbackComponent will be rendered instead. | ||
``` | ||
customizationService.setCustomizations({ |
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.
this is wrong, please update based on my explanation
@@ -18,14 +18,14 @@ import classNames from 'classnames'; | |||
* we import to instantiate cornerstone | |||
*/ | |||
import guid from './../../../core/src/utils/guid'; | |||
|
|||
import { CustomizationService } from '@ohif/core'; |
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 we need this?
function ProgressLoadingBar({ progress }) { | ||
return CustomizableRenderComponent({ | ||
customizationId: 'ui.ProgressLoadingBar', | ||
FallbackComponent: FallbackProgressLoadingBar, |
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.
Fallbacks should be defined in the getCustomizationModules
. Here, we should simply call .getCustomization
or, ideally, pass the component as props to render. This approach really helps us achieve our goal of a dumb UI library, where there's no mention of customizationService
in the platform/ui
or /ui-next
. By doing so, we pretty much keep our services separate from the UI library, which is kind of the point.
loadingText, | ||
targetText, | ||
}: Props) { | ||
return CustomizableRenderComponent({ |
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.
pass component as prop
function LoadingIndicatorProgress({ className, textBlock, progress }) { | ||
return CustomizableRenderComponent({ |
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.
same
items={this.currentItems} | ||
columns={1} | ||
onSelected={this.selectTreeSelectCalback} | ||
<CustomizableRenderComponent |
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.
same
@@ -43,4 +37,33 @@ ContextMenu.propTypes = { | |||
), | |||
}; | |||
|
|||
const FallbackContextMenuItem = ({ index, item, ...props }) => { |
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.
fallbacks should get registered in the extension getCustomizationModule
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.
See my comments thanks
Context
Changes & Results
Testing
Checklist
PR
semantic-release format and guidelines.
Code
etc.)
Public Documentation Updates
additions or removals.
Tested Environment