Add exit mpr action

This commit is contained in:
igoroctaviano 2021-01-20 20:59:03 -03:00
parent f07f21117d
commit 8038009afd
2 changed files with 13 additions and 10 deletions

View File

@ -363,7 +363,7 @@ class OHIFVTKViewport extends Component {
const { UINotificationService } = this.props.servicesManager.services; const { UINotificationService } = this.props.servicesManager.services;
if (this.props.viewportIndex === 0) { if (this.props.viewportIndex === 0) {
const message = error.message.includes('buffer') const message = error.message.includes('buffer')
? 'Buffer allocation limit exceeded' ? 'Dataset is too big to display in MPR'
: error.message; : error.message;
console.error(errorTitle, error); console.error(errorTitle, error);
UINotificationService.show({ UINotificationService.show({
@ -371,15 +371,14 @@ class OHIFVTKViewport extends Component {
message, message,
type: 'error', type: 'error',
autoClose: false, autoClose: false,
/* action: { action: {
label: 'Download', label: 'Exit 2D MPR',
onClick: () => { onClick: ({ close }) => {
const listOfUIDs = [window.location.href.split('/').pop()]; // context: 'ACTIVE_VIEWPORT::VTK',
this.props.commandsManager.runCommand('downloadAndZip', { close();
listOfUIDs, this.props.commandsManager.runCommand('setCornerstoneLayout');
});
}, },
}, */ },
}); });
} }
this.setState({ isLoaded: true }); this.setState({ isLoaded: true });

View File

@ -5,6 +5,10 @@ const SnackbarItem = ({ options, onClose }) => {
onClose(options.id); onClose(options.id);
}; };
const handleClick = () => {
options.action.onClick({ ...options, close: handleClose });
};
useEffect(() => { useEffect(() => {
if (options.autoClose) { if (options.autoClose) {
setTimeout(() => { setTimeout(() => {
@ -25,7 +29,7 @@ const SnackbarItem = ({ options, onClose }) => {
{options.title && <div className="sb-title">{options.title}</div>} {options.title && <div className="sb-title">{options.title}</div>}
{options.message && <div className="sb-message">{options.message}</div>} {options.message && <div className="sb-message">{options.message}</div>}
{options.action && ( {options.action && (
<button className="sb-action" onClick={options.action.onClick}> <button className="sb-action" onClick={handleClick}>
{options.action.label} {options.action.label}
</button> </button>
)} )}