diff --git a/extensions/cornerstone/src/panels/PanelMeasurement.tsx b/extensions/cornerstone/src/panels/PanelMeasurement.tsx index abd81e6449..f11f9bada9 100644 --- a/extensions/cornerstone/src/panels/PanelMeasurement.tsx +++ b/extensions/cornerstone/src/panels/PanelMeasurement.tsx @@ -32,16 +32,15 @@ export default function PanelMeasurementTable({ } }, [displayMeasurements.length]); - const bindCommand = (name: string, options?) => { + const bindCommand = (name: string | string[], options?) => { return (uid: string) => { - commandsManager.runCommand(name, { ...options, uid }); + commandsManager.run(name, { ...options, uid }); }; }; const jumpToImage = bindCommand('jumpToMeasurement', { displayMeasurements }); const removeMeasurement = bindCommand('removeMeasurement'); - const renameMeasurement = bindCommand('run', { - commands: ['jumpToMeasurement', 'renameMeasurement'], + const renameMeasurement = bindCommand(['jumpToMeasurement', 'renameMeasurement'], { displayMeasurements, }); const toggleLockMeasurement = bindCommand('toggleLockMeasurement'); diff --git a/extensions/default/src/commandsModule.ts b/extensions/default/src/commandsModule.ts index a6875dbb43..a18182e97b 100644 --- a/extensions/default/src/commandsModule.ts +++ b/extensions/default/src/commandsModule.ts @@ -47,39 +47,6 @@ const commandsModule = ({ const contextMenuController = new ContextMenuController(servicesManager, commandsManager); const actions = { - /** - * Runs commands specified in the options. - * This allows running multiple commands when only one is specified. It - * also allows an async instantiation of a command so that the return is - * immediate without waiting for the command to complete. - * - * @param options.options - shared options for the child command - * @param options.commands - a list of commands to run. This is an array, and can - * be either a full command, or just a name. - * @param options.async - set to true to run async - * @param options.parallel - set to false, WITH async true to run non-parallel - */ - run: options => { - const { options: sharedOptions, commands = [], parallel = true, async = false } = options; - const childOptions = { - ...options, - options: undefined, - commands: undefined, - parallel: undefined, - async: undefined, - ...sharedOptions, - }; - if (async) { - if (parallel) { - return Promise.all( - commands.map(async command => commandsManager.run(command, childOptions)) - ); - } - return (async () => await commandsManager.run(commands, childOptions))(); - } - return commandsManager.run(commands, childOptions); - }, - /** * Show the context menu. * @param options.menuId defines the menu name to lookup, from customizationService @@ -587,26 +554,13 @@ const commandsModule = ({ }; const definitions = { - run: actions.run, showContextMenu: actions.showContextMenu, - closeContextMenu: { - commandFn: actions.closeContextMenu, - }, - clearMeasurements: { - commandFn: actions.clearMeasurements, - }, - displayNotification: { - commandFn: actions.displayNotification, - }, - setHangingProtocol: { - commandFn: actions.setHangingProtocol, - }, - toggleHangingProtocol: { - commandFn: actions.toggleHangingProtocol, - }, - navigateHistory: { - commandFn: actions.navigateHistory, - }, + closeContextMenu: actions.closeContextMenu, + clearMeasurements: actions.clearMeasurements, + displayNotification: actions.displayNotification, + setHangingProtocol: actions.setHangingProtocol, + toggleHangingProtocol: actions.toggleHangingProtocol, + navigateHistory: actions.navigateHistory, nextStage: { commandFn: actions.deltaStage, options: { direction: 1 }, @@ -615,18 +569,10 @@ const commandsModule = ({ commandFn: actions.deltaStage, options: { direction: -1 }, }, - setViewportGridLayout: { - commandFn: actions.setViewportGridLayout, - }, - toggleOneUp: { - commandFn: actions.toggleOneUp, - }, - openDICOMTagViewer: { - commandFn: actions.openDICOMTagViewer, - }, - updateViewportDisplaySet: { - commandFn: actions.updateViewportDisplaySet, - }, + setViewportGridLayout: actions.setViewportGridLayout, + toggleOneUp: actions.toggleOneUp, + openDICOMTagViewer: actions.openDICOMTagViewer, + updateViewportDisplaySet: actions.updateViewportDisplaySet, }; return { diff --git a/platform/core/src/classes/CommandsManager.ts b/platform/core/src/classes/CommandsManager.ts index 0138521f90..2a9b31b561 100644 --- a/platform/core/src/classes/CommandsManager.ts +++ b/platform/core/src/classes/CommandsManager.ts @@ -169,7 +169,7 @@ export class CommandsManager { * the commandOptions specified in the base. */ public run( - toRun: Command | Commands | Command[] | string | undefined, + toRun: Command | Commands | (Command | string)[] | string | undefined, options?: Record ): unknown { if (!toRun) {