feat: Add new modal service
[UI Services to Extensions]: Add new modal service
This commit is contained in:
commit
6174109d5a
@ -11,7 +11,10 @@ export default {
|
|||||||
* LIFECYCLE HOOKS
|
* LIFECYCLE HOOKS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
preRegistration({ serviceManager, configuration: extensionConfiguration }) {},
|
preRegistration({
|
||||||
|
servicesManager,
|
||||||
|
configuration: extensionConfiguration,
|
||||||
|
}) {},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MODULE GETTERS
|
* MODULE GETTERS
|
||||||
|
|||||||
@ -24,8 +24,8 @@ export default {
|
|||||||
* @param {object} [configuration={}]
|
* @param {object} [configuration={}]
|
||||||
* @param {object|array} [configuration.csToolsConfig] - Passed directly to `initCornerstoneTools`
|
* @param {object|array} [configuration.csToolsConfig] - Passed directly to `initCornerstoneTools`
|
||||||
*/
|
*/
|
||||||
preRegistration({ serviceManager, configuration = {} }) {
|
preRegistration({ servicesManager, configuration = {} }) {
|
||||||
init({ serviceManager, configuration });
|
init({ servicesManager, configuration });
|
||||||
},
|
},
|
||||||
getViewportModule() {
|
getViewportModule() {
|
||||||
return OHIFCornerstoneViewport;
|
return OHIFCornerstoneViewport;
|
||||||
|
|||||||
@ -28,7 +28,7 @@ cornerstone.metaData.addProvider(fallbackMetaDataProvider, -1);
|
|||||||
* @param {object} configuration
|
* @param {object} configuration
|
||||||
* @param {Object|Array} configuration.csToolsConfig
|
* @param {Object|Array} configuration.csToolsConfig
|
||||||
*/
|
*/
|
||||||
export default function init({ serviceManager, configuration = {} }) {
|
export default function init({ servicesManager, configuration = {} }) {
|
||||||
const { csToolsConfig } = configuration;
|
const { csToolsConfig } = configuration;
|
||||||
const { StackManager } = OHIF.utils;
|
const { StackManager } = OHIF.utils;
|
||||||
const metadataProvider = new OHIF.cornerstone.MetadataProvider();
|
const metadataProvider = new OHIF.cornerstone.MetadataProvider();
|
||||||
|
|||||||
@ -68,7 +68,7 @@ export default class ExtensionManager {
|
|||||||
// preRegistrationHook
|
// preRegistrationHook
|
||||||
if (extension.preRegistration) {
|
if (extension.preRegistration) {
|
||||||
extension.preRegistration({
|
extension.preRegistration({
|
||||||
serviceManager: this._servicesManager,
|
servicesManager: this._servicesManager,
|
||||||
configuration,
|
configuration,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import ui from './ui';
|
|||||||
import user from './user.js';
|
import user from './user.js';
|
||||||
import utils from './utils/';
|
import utils from './utils/';
|
||||||
|
|
||||||
import { createUiNotificationService } from './services';
|
import { createUINotificationService, createUIModalService } from './services';
|
||||||
|
|
||||||
const OHIF = {
|
const OHIF = {
|
||||||
MODULE_TYPES,
|
MODULE_TYPES,
|
||||||
@ -46,7 +46,8 @@ const OHIF = {
|
|||||||
measurements,
|
measurements,
|
||||||
hangingProtocols,
|
hangingProtocols,
|
||||||
//
|
//
|
||||||
createUiNotificationService,
|
createUINotificationService,
|
||||||
|
createUIModalService,
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@ -73,7 +74,8 @@ export {
|
|||||||
measurements,
|
measurements,
|
||||||
hangingProtocols,
|
hangingProtocols,
|
||||||
//
|
//
|
||||||
createUiNotificationService,
|
createUINotificationService,
|
||||||
|
createUIModalService,
|
||||||
};
|
};
|
||||||
|
|
||||||
export { OHIF };
|
export { OHIF };
|
||||||
|
|||||||
@ -10,7 +10,8 @@ describe('Top level exports', () => {
|
|||||||
'HotkeysManager',
|
'HotkeysManager',
|
||||||
'ServicesManager',
|
'ServicesManager',
|
||||||
//
|
//
|
||||||
'createUiNotificationService',
|
'createUINotificationService',
|
||||||
|
'createUIModalService',
|
||||||
//
|
//
|
||||||
'utils',
|
'utils',
|
||||||
'studies',
|
'studies',
|
||||||
|
|||||||
88
platform/core/src/services/UIModalService/index.js
Normal file
88
platform/core/src/services/UIModalService/index.js
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/**
|
||||||
|
* A UI Element
|
||||||
|
*
|
||||||
|
* @typedef {ReactElement|HTMLElement} Modal
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UI Modal
|
||||||
|
*
|
||||||
|
* @typedef {Object} ModalProps
|
||||||
|
* @property {string} [header=null] -
|
||||||
|
* @property {string} [footer=null] -
|
||||||
|
* @property {string} [backdrop=false] -
|
||||||
|
* @property {string} [keyboard=false] -
|
||||||
|
* @property {number} [show=true] -
|
||||||
|
* @property {string} [closeButton=true] -
|
||||||
|
* @property {string} [title=null] - 'Modal Title'
|
||||||
|
* @property {boolean} [customClassName=null] - '.ModalClass'
|
||||||
|
*/
|
||||||
|
|
||||||
|
const uiModalServicePublicAPI = {
|
||||||
|
name: 'UIModalService',
|
||||||
|
hide,
|
||||||
|
show,
|
||||||
|
setServiceImplementation,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uiModalServiceImplementation = {
|
||||||
|
_hide: () => console.warn('hide() NOT IMPLEMENTED'),
|
||||||
|
_show: () => console.warn('show() NOT IMPLEMENTED'),
|
||||||
|
};
|
||||||
|
|
||||||
|
function createUIModalService() {
|
||||||
|
return uiModalServicePublicAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a new UI modal;
|
||||||
|
*
|
||||||
|
* @param {Modal} component React component
|
||||||
|
* @param {ModalProps} props { header, footer, backdrop, keyboard, show, closeButton, title, customClassName }
|
||||||
|
*/
|
||||||
|
function show(
|
||||||
|
component,
|
||||||
|
props = {
|
||||||
|
header: null,
|
||||||
|
footer: null,
|
||||||
|
backdrop: false,
|
||||||
|
keyboard: false,
|
||||||
|
show: true,
|
||||||
|
closeButton: true,
|
||||||
|
title: null,
|
||||||
|
customClassName: null,
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
return uiModalServiceImplementation._show(component, props);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides/dismisses the modal, if currently shown
|
||||||
|
*
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
function hide() {
|
||||||
|
return uiModalServiceImplementation._hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {*} {
|
||||||
|
* hide: hideImplementation,
|
||||||
|
* show: showImplementation,
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
function setServiceImplementation({
|
||||||
|
hide: hideImplementation,
|
||||||
|
show: showImplementation,
|
||||||
|
}) {
|
||||||
|
if (hideImplementation) {
|
||||||
|
uiModalServiceImplementation._hide = hideImplementation;
|
||||||
|
}
|
||||||
|
if (showImplementation) {
|
||||||
|
uiModalServiceImplementation._show = showImplementation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createUIModalService;
|
||||||
@ -10,7 +10,7 @@
|
|||||||
* @property {boolean} [autoClose=true]
|
* @property {boolean} [autoClose=true]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const uiNotificationServicePublicApi = {
|
const uiNotificationServicePublicAPI = {
|
||||||
name: 'UINotificationService',
|
name: 'UINotificationService',
|
||||||
hide,
|
hide,
|
||||||
show,
|
show,
|
||||||
@ -22,8 +22,8 @@ const uiNotificationServiceImplementation = {
|
|||||||
_show: () => console.warn('show() NOT IMPLEMENTED'),
|
_show: () => console.warn('show() NOT IMPLEMENTED'),
|
||||||
};
|
};
|
||||||
|
|
||||||
function createUiNotificationService() {
|
function createUINotificationService() {
|
||||||
return uiNotificationServicePublicApi;
|
return uiNotificationServicePublicAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,4 +81,4 @@ function setServiceImplementation({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createUiNotificationService;
|
export default createUINotificationService;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import ServicesManager from './ServicesManager.js';
|
import ServicesManager from './ServicesManager.js';
|
||||||
import createUiNotificationService from './UINotificationService';
|
import createUINotificationService from './UINotificationService';
|
||||||
|
import createUIModalService from './UIModalService';
|
||||||
|
|
||||||
export { createUiNotificationService, ServicesManager };
|
export { createUINotificationService, createUIModalService, ServicesManager };
|
||||||
|
|||||||
@ -13,7 +13,7 @@ const OHIFModal = ({
|
|||||||
onHide,
|
onHide,
|
||||||
footer: Footer,
|
footer: Footer,
|
||||||
header: Header,
|
header: Header,
|
||||||
children: Component,
|
children,
|
||||||
}) => (
|
}) => (
|
||||||
<ReactBootstrapModal
|
<ReactBootstrapModal
|
||||||
className={classNames('modal fade themed in', className)}
|
className={classNames('modal fade themed in', className)}
|
||||||
@ -32,12 +32,9 @@ const OHIFModal = ({
|
|||||||
{Header && <Header hide={onHide} />}
|
{Header && <Header hide={onHide} />}
|
||||||
</ReactBootstrapModal.Header>
|
</ReactBootstrapModal.Header>
|
||||||
)}
|
)}
|
||||||
<ReactBootstrapModal.Body>
|
<ReactBootstrapModal.Body>{children}</ReactBootstrapModal.Body>
|
||||||
{Component && <Component hide={onHide} />}
|
|
||||||
</ReactBootstrapModal.Body>
|
|
||||||
{Footer && (
|
{Footer && (
|
||||||
<ReactBootstrapModal.Footer>
|
<ReactBootstrapModal.Footer>
|
||||||
{' '}
|
|
||||||
<Footer hide={onHide} />
|
<Footer hide={onHide} />
|
||||||
</ReactBootstrapModal.Footer>
|
</ReactBootstrapModal.Footer>
|
||||||
)}
|
)}
|
||||||
@ -52,9 +49,20 @@ OHIFModal.propTypes = {
|
|||||||
show: PropTypes.bool,
|
show: PropTypes.bool,
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
onHide: PropTypes.func,
|
onHide: PropTypes.func,
|
||||||
footer: PropTypes.node,
|
footer: PropTypes.oneOfType([
|
||||||
header: PropTypes.node,
|
PropTypes.arrayOf(PropTypes.node),
|
||||||
children: PropTypes.node,
|
PropTypes.node,
|
||||||
|
PropTypes.func,
|
||||||
|
]),
|
||||||
|
header: PropTypes.oneOfType([
|
||||||
|
PropTypes.arrayOf(PropTypes.node),
|
||||||
|
PropTypes.node,
|
||||||
|
PropTypes.func,
|
||||||
|
]),
|
||||||
|
children: PropTypes.oneOfType([
|
||||||
|
PropTypes.arrayOf(PropTypes.node),
|
||||||
|
PropTypes.node,
|
||||||
|
]).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default OHIFModal;
|
export default OHIFModal;
|
||||||
|
|||||||
@ -1,15 +1,23 @@
|
|||||||
import React, { useState, createContext, useContext } from 'react';
|
import React, {
|
||||||
|
useState,
|
||||||
|
createContext,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useCallback,
|
||||||
|
} from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
const ModalContext = createContext(null);
|
const ModalContext = createContext(null);
|
||||||
const { Provider, Consumer } = ModalContext;
|
const { Provider } = ModalContext;
|
||||||
|
|
||||||
export const useModal = () => useContext(ModalContext);
|
export const useModal = () => useContext(ModalContext);
|
||||||
|
|
||||||
const ModalProvider = ({ children, modal: Modal }) => {
|
const ModalProvider = ({ children, modal: Modal, service }) => {
|
||||||
const DEFAULT_OPTIONS = {
|
const DEFAULT_OPTIONS = {
|
||||||
component: null /* The component instance inside the modal. */,
|
component: null /* The component instance inside the modal. */,
|
||||||
|
header: null /* The content inside the modal header. */,
|
||||||
|
footer: null /* The content inside the modal footer. */,
|
||||||
backdrop: false /* Should the modal render a backdrop overlay. */,
|
backdrop: false /* Should the modal render a backdrop overlay. */,
|
||||||
keyboard: false /* Modal is dismissible via the esc key. */,
|
keyboard: false /* Modal is dismissible via the esc key. */,
|
||||||
show: true /* Make the Modal visible or hidden. */,
|
show: true /* Make the Modal visible or hidden. */,
|
||||||
@ -20,51 +28,81 @@ const ModalProvider = ({ children, modal: Modal }) => {
|
|||||||
|
|
||||||
const [options, setOptions] = useState(DEFAULT_OPTIONS);
|
const [options, setOptions] = useState(DEFAULT_OPTIONS);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the implementation of a modal service that can be used by extensions.
|
||||||
|
*
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
useEffect(() => {
|
||||||
|
if (service) {
|
||||||
|
service.setServiceImplementation({ hide, show });
|
||||||
|
}
|
||||||
|
}, [hide, service, show]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the modal and override its configuration props.
|
* Show the modal and override its configuration props.
|
||||||
*
|
*
|
||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
const show = (component, props = {}) =>
|
const show = useCallback(
|
||||||
setOptions(Object.assign({}, options, props, { component }));
|
(component, props = {}) =>
|
||||||
|
setOptions(Object.assign({}, options, props, { component })),
|
||||||
|
[options]
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide the modal and set its properties to default.
|
* Hide the modal and set its properties to default.
|
||||||
*
|
*
|
||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
const hide = () => setOptions(DEFAULT_OPTIONS);
|
const hide = useCallback(() => setOptions(DEFAULT_OPTIONS), [
|
||||||
|
DEFAULT_OPTIONS,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const { component: Component } = options;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Provider value={{ ...options, show, hide }}>
|
<Provider value={{ show, hide }}>
|
||||||
<Consumer>
|
{options.component && (
|
||||||
{props => {
|
<Modal
|
||||||
const { component, footer, header, customClassName } = props;
|
className={classNames(
|
||||||
return component ? (
|
options.customClassName,
|
||||||
<Modal
|
options.component.className
|
||||||
className={classNames(customClassName, component.className)}
|
)}
|
||||||
backdrop={options.backdrop}
|
backdrop={options.backdrop}
|
||||||
keyboard={options.keyboard}
|
keyboard={options.keyboard}
|
||||||
show={options.show}
|
show={options.show}
|
||||||
title={options.title}
|
title={options.title}
|
||||||
closeButton={options.closeButton}
|
closeButton={options.closeButton}
|
||||||
onHide={hide}
|
footer={options.footer}
|
||||||
footer={footer}
|
header={options.header}
|
||||||
header={header}
|
onHide={hide}
|
||||||
>
|
>
|
||||||
{component}
|
<Component {...options} show={show} hide={hide} />
|
||||||
</Modal>
|
</Modal>
|
||||||
) : null;
|
)}
|
||||||
}}
|
|
||||||
</Consumer>
|
|
||||||
{children}
|
{children}
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ModalProvider.defaultProps = {
|
||||||
|
service: null,
|
||||||
|
};
|
||||||
|
|
||||||
ModalProvider.propTypes = {
|
ModalProvider.propTypes = {
|
||||||
children: PropTypes.node,
|
children: PropTypes.oneOfType([
|
||||||
modal: PropTypes.node,
|
PropTypes.arrayOf(PropTypes.node),
|
||||||
|
PropTypes.node,
|
||||||
|
]).isRequired,
|
||||||
|
modal: PropTypes.oneOfType([
|
||||||
|
PropTypes.arrayOf(PropTypes.node),
|
||||||
|
PropTypes.node,
|
||||||
|
PropTypes.func,
|
||||||
|
]).isRequired,
|
||||||
|
service: PropTypes.shape({
|
||||||
|
setServiceImplementation: PropTypes.func,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +112,8 @@ ModalProvider.propTypes = {
|
|||||||
*/
|
*/
|
||||||
export const withModal = Component => {
|
export const withModal = Component => {
|
||||||
return function WrappedComponent(props) {
|
return function WrappedComponent(props) {
|
||||||
return <Component {...props} modalContext={{ ...useModal() }} />;
|
const { show, hide } = useModal();
|
||||||
|
return <Component {...props} modal={{ show, hide }} />;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import React, {
|
|||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import SnackbarContainer from '../components/snackbar/SnackbarContainer';
|
import SnackbarContainer from '../components/snackbar/SnackbarContainer';
|
||||||
import SnackbarTypes from '../components/snackbar/SnackbarTypes';
|
import SnackbarTypes from '../components/snackbar/SnackbarTypes';
|
||||||
|
|
||||||
@ -25,49 +27,62 @@ const SnackbarProvider = ({ children, service }) => {
|
|||||||
const [count, setCount] = useState(1);
|
const [count, setCount] = useState(1);
|
||||||
const [snackbarItems, setSnackbarItems] = useState([]);
|
const [snackbarItems, setSnackbarItems] = useState([]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the implementation of a notification service that can be used by extensions.
|
||||||
|
*
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
service.setServiceImplementation({ hide, show });
|
if (service) {
|
||||||
|
service.setServiceImplementation({ hide, show });
|
||||||
|
}
|
||||||
}, [service, hide, show]);
|
}, [service, hide, show]);
|
||||||
|
|
||||||
const show = useCallback(options => {
|
const show = useCallback(
|
||||||
if (!options || (!options.title && !options.message)) {
|
options => {
|
||||||
console.warn(
|
if (!options || (!options.title && !options.message)) {
|
||||||
'Snackbar cannot be rendered without required parameters: title | message'
|
console.warn(
|
||||||
);
|
'Snackbar cannot be rendered without required parameters: title | message'
|
||||||
|
);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newItem = {
|
const newItem = {
|
||||||
...DEFAULT_OPTIONS,
|
...DEFAULT_OPTIONS,
|
||||||
...options,
|
...options,
|
||||||
id: count,
|
id: count,
|
||||||
visible: true,
|
visible: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
setSnackbarItems(state => [...state, newItem]);
|
setSnackbarItems(state => [...state, newItem]);
|
||||||
setCount(count + 1);
|
setCount(count + 1);
|
||||||
});
|
},
|
||||||
|
[count, DEFAULT_OPTIONS]
|
||||||
|
);
|
||||||
|
|
||||||
const hide = useCallback(id => {
|
const hide = useCallback(
|
||||||
const hideItem = items => {
|
id => {
|
||||||
const newItems = items.map(item => {
|
const hideItem = items => {
|
||||||
if (item.id === id) {
|
const newItems = items.map(item => {
|
||||||
item.visible = false;
|
if (item.id === id) {
|
||||||
}
|
item.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
|
|
||||||
return newItems;
|
return newItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
setSnackbarItems(state => hideItem(state));
|
setSnackbarItems(state => hideItem(state));
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setSnackbarItems(state => [...state.filter(item => item.id !== id)]);
|
setSnackbarItems(state => [...state.filter(item => item.id !== id)]);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
},
|
||||||
|
[setSnackbarItems]
|
||||||
|
);
|
||||||
|
|
||||||
const hideAll = () => {
|
const hideAll = () => {
|
||||||
// reset count
|
// reset count
|
||||||
@ -95,6 +110,21 @@ const SnackbarProvider = ({ children, service }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SnackbarProvider.defaultProps = {
|
||||||
|
service: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
SnackbarProvider.propTypes = {
|
||||||
|
children: PropTypes.oneOfType([
|
||||||
|
PropTypes.arrayOf(PropTypes.node),
|
||||||
|
PropTypes.node,
|
||||||
|
PropTypes.func,
|
||||||
|
]).isRequired,
|
||||||
|
service: PropTypes.shape({
|
||||||
|
setServiceImplementation: PropTypes.func,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* High Order Component to use the snackbar methods through a Class Component
|
* High Order Component to use the snackbar methods through a Class Component
|
||||||
|
|||||||
@ -8,7 +8,8 @@ import {
|
|||||||
ExtensionManager,
|
ExtensionManager,
|
||||||
ServicesManager,
|
ServicesManager,
|
||||||
HotkeysManager,
|
HotkeysManager,
|
||||||
createUiNotificationService,
|
createUINotificationService,
|
||||||
|
createUIModalService,
|
||||||
utils,
|
utils,
|
||||||
} from '@ohif/core';
|
} from '@ohif/core';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
@ -44,7 +45,8 @@ const commandsManagerConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
const UINotificationService = createUiNotificationService();
|
const UINotificationService = createUINotificationService();
|
||||||
|
const UIModalService = createUIModalService();
|
||||||
|
|
||||||
const commandsManager = new CommandsManager(commandsManagerConfig);
|
const commandsManager = new CommandsManager(commandsManagerConfig);
|
||||||
const hotkeysManager = new HotkeysManager(commandsManager);
|
const hotkeysManager = new HotkeysManager(commandsManager);
|
||||||
@ -89,7 +91,7 @@ class App extends Component {
|
|||||||
const { servers, extensions, hotkeys, oidc } = props;
|
const { servers, extensions, hotkeys, oidc } = props;
|
||||||
|
|
||||||
this.initUserManager(oidc);
|
this.initUserManager(oidc);
|
||||||
_initServices([UINotificationService]);
|
_initServices([UINotificationService, UIModalService]);
|
||||||
_initExtensions(extensions, hotkeys);
|
_initExtensions(extensions, hotkeys);
|
||||||
_initServers(servers);
|
_initServers(servers);
|
||||||
initWebWorkers();
|
initWebWorkers();
|
||||||
@ -112,7 +114,10 @@ class App extends Component {
|
|||||||
<Router basename={routerBasename}>
|
<Router basename={routerBasename}>
|
||||||
<WhiteLabellingContext.Provider value={whiteLabelling}>
|
<WhiteLabellingContext.Provider value={whiteLabelling}>
|
||||||
<SnackbarProvider service={UINotificationService}>
|
<SnackbarProvider service={UINotificationService}>
|
||||||
<ModalProvider modal={OHIFModal}>
|
<ModalProvider
|
||||||
|
modal={OHIFModal}
|
||||||
|
service={UIModalService}
|
||||||
|
>
|
||||||
<OHIFStandaloneViewer userManager={userManager} />
|
<OHIFStandaloneViewer userManager={userManager} />
|
||||||
</ModalProvider>
|
</ModalProvider>
|
||||||
</SnackbarProvider>
|
</SnackbarProvider>
|
||||||
@ -133,7 +138,7 @@ class App extends Component {
|
|||||||
<Router basename={routerBasename}>
|
<Router basename={routerBasename}>
|
||||||
<WhiteLabellingContext.Provider value={whiteLabelling}>
|
<WhiteLabellingContext.Provider value={whiteLabelling}>
|
||||||
<SnackbarProvider service={UINotificationService}>
|
<SnackbarProvider service={UINotificationService}>
|
||||||
<ModalProvider modal={OHIFModal}>
|
<ModalProvider modal={OHIFModal} service={UIModalService}>
|
||||||
<OHIFStandaloneViewer />
|
<OHIFStandaloneViewer />
|
||||||
</ModalProvider>
|
</ModalProvider>
|
||||||
</SnackbarProvider>
|
</SnackbarProvider>
|
||||||
|
|||||||
@ -7,8 +7,8 @@ export default {
|
|||||||
*/
|
*/
|
||||||
id: 'measurements-table',
|
id: 'measurements-table',
|
||||||
|
|
||||||
preRegistration({ serviceManager, configuration = {} }) {
|
preRegistration({ servicesManager, configuration = {} }) {
|
||||||
init({ serviceManager, configuration });
|
init({ servicesManager, configuration });
|
||||||
},
|
},
|
||||||
getPanelModule() {
|
getPanelModule() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -34,7 +34,7 @@ const MEASUREMENT_ACTION_MAP = {
|
|||||||
* @export
|
* @export
|
||||||
* @param {*} configuration
|
* @param {*} configuration
|
||||||
*/
|
*/
|
||||||
export default function init({ serviceManager, configuration = {} }) {
|
export default function init({ servicesManager, configuration = {} }) {
|
||||||
// If these tools were already added by a different extension, we want to replace
|
// If these tools were already added by a different extension, we want to replace
|
||||||
// them with the same tools that have an alternative configuration. By passing in
|
// them with the same tools that have an alternative configuration. By passing in
|
||||||
// our custom `getMeasurementLocationCallback`, we can...
|
// our custom `getMeasurementLocationCallback`, we can...
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class Header extends Component {
|
|||||||
t: PropTypes.func.isRequired,
|
t: PropTypes.func.isRequired,
|
||||||
userManager: PropTypes.object,
|
userManager: PropTypes.object,
|
||||||
user: PropTypes.object,
|
user: PropTypes.object,
|
||||||
modalContext: PropTypes.object,
|
modal: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
@ -40,7 +40,7 @@ class Header extends Component {
|
|||||||
t,
|
t,
|
||||||
user,
|
user,
|
||||||
userManager,
|
userManager,
|
||||||
modalContext: { show },
|
modal: { show },
|
||||||
} = this.props;
|
} = this.props;
|
||||||
this.options = [
|
this.options = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -287,7 +287,7 @@ function _handleBuiltIn({ behavior } = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (behavior === 'DOWNLOAD_SCREEN_SHOT') {
|
if (behavior === 'DOWNLOAD_SCREEN_SHOT') {
|
||||||
this.props.modalContext.show(ConnectedViewportDownloadForm, {
|
this.props.modal.show(ConnectedViewportDownloadForm, {
|
||||||
title: this.props.t('Download High Quality Image'),
|
title: this.props.t('Download High Quality Image'),
|
||||||
customClassName: 'ViewportDownloadForm',
|
customClassName: 'ViewportDownloadForm',
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user