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

feat: Integrate CustomizationService with UiDialogService and support customized components in Annotation Labelling #4634

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion platform/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function App({
[CineProvider, { service: cineService }],
[NotificationProvider, { service: uiNotificationService }],
[TooltipProvider],
[DialogProvider, { service: uiDialogService }],
[DialogProvider, { services: { uiDialogService, customizationService } }],
[ModalProvider, { service: uiModalService, modal: Modal }],
[ShepherdJourneyProvider],
];
Expand Down
13 changes: 13 additions & 0 deletions platform/docs/docs/platform/services/ui/customization-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,19 @@ context menus. Currently it supports buttons 1-3, as well as modifier keys
by associating a commands list with the button to click. See `initContextMenu`
for more details.

## Customizable Annotation Labelling component.

The Annotation Labelling Component can be customized using the ID `measurement.labellingComponent`. This allows users to replace the default `SelectTree` component with a custom component of their choice. Below is a sample for customization implementation:

```
customizationService.setGlobalCustomization('measurement.labellingComponent', {
component: AnnotationLabel,
});


```


## Please add additional customizations above this section
> 3rd Party implementers may be added to this table via pull requests.

Expand Down
20 changes: 18 additions & 2 deletions platform/ui/src/components/Labelling/LabellingFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface PropType {
labelData: any;
exclusive: boolean;
componentClassName: any;
customizationService: any;
}

interface StateType {
Expand Down Expand Up @@ -87,13 +88,28 @@ class LabellingFlow extends Component<PropType> {
};

labellingStateFragment = () => {
return (
const annotationLabelComponent = this.props.customizationService?.get(
'measurement.labellingComponent'
);

const CustomAnnotationLabelComponent = annotationLabelComponent?.component;

return CustomAnnotationLabelComponent ? (
<CustomAnnotationLabelComponent
onSelected={this.selectTreeSelectCalback}
closePopup={this.closePopup}
label={this.state.label}
measurementData={this.props.measurementData}
currentItems={this.currentItems}
exclusive={this.props.exclusive}
/>
) : (
<SelectTree
items={this.currentItems}
columns={1}
onSelected={this.selectTreeSelectCalback}
closePopup={this.closePopup}
selectTreeFirstTitle="Annotation"
selectTreeFirstTitle="Select Label"
exclusive={this.props.exclusive}
label={this.state.label}
/>
Expand Down
17 changes: 10 additions & 7 deletions platform/ui/src/contextProviders/DialogProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import classNames from 'classnames';
* we import to instantiate cornerstone
*/
import guid from './../../../core/src/utils/guid';

import { CustomizationService } from '@ohif/core';
import './DialogProvider.css';

const DialogContext = createContext(null);

export const useDialog = () => useContext(DialogContext);

const DialogProvider = ({ children, service = null }) => {
const DialogProvider = ({ children, services = null }) => {
const { uiDialogService, customizationService } = services;
const [isDragging, setIsDragging] = useState(false);
const [dialogs, setDialogs] = useState([]);
const [lastDialogId, setLastDialogId] = useState(null);
Expand Down Expand Up @@ -137,10 +138,10 @@ const DialogProvider = ({ children, service = null }) => {
* @returns void
*/
useEffect(() => {
if (service) {
service.setServiceImplementation({ create, dismiss, dismissAll });
if (uiDialogService) {
uiDialogService.setServiceImplementation({ create, dismiss, dismissAll });
}
}, [create, dismiss, service]);
}, [create, dismiss, uiDialogService]);

useEffect(() => _bringToFront(lastDialogId), [_bringToFront, lastDialogId]);

Expand Down Expand Up @@ -215,6 +216,7 @@ const DialogProvider = ({ children, service = null }) => {
<DialogContent
{...dialog}
{...contentProps}
customizationService={customizationService}
/>
</div>
</Draggable>
Expand Down Expand Up @@ -316,8 +318,9 @@ export const withDialog = Component => {
DialogProvider.propTypes = {
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node, PropTypes.func])
.isRequired,
service: PropTypes.shape({
setServiceImplementation: PropTypes.func,
services: PropTypes.shape({
uiDialogService: PropTypes.shape({ setServiceImplementation: PropTypes.func }),
customizationService: PropTypes.instanceOf(CustomizationService),
}),
};

Expand Down
Loading