fix(Browser history): fixed NPE when navigating a study via browser history and history navigation is now available via the navigateHistory command (#3337)
* fix(Browser history): - fixed an NPE when navigating to a different study via the URL - exposed browser history navigation via a command * Added documentation for the navigateHistory command. Moved the history object from UI to viewer.
This commit is contained in:
1 parent
eea0ed487b
commit
51cb0519fc
7 files changed
+88
-1
No files matched your search
@@ -11,6 +11,8 @@ import findViewportsByPosition, {
|
||||
} from './findViewportsByPosition';
|
||||
|
||||
import { ContextMenuProps } from './CustomizeableContextMenu/types';
|
||||
import { NavigateHistory } from './types/commandModuleTypes';
|
||||
import { history } from '@ohif/viewer';
|
||||
|
||||
const { subscribeToNextViewportGridChange } = utils;
|
||||
|
||||
@@ -480,6 +482,28 @@ const commandsModule = ({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Exposes the browser history navigation used by OHIF. This command can be used to either replace or
|
||||
* push a new entry into the browser history. For example, the following will replace the current
|
||||
* browser history entry with the specified relative URL which changes the study displayed to the
|
||||
* study with study instance UID 1.2.3. Note that as a result of using `options.replace = true`, the
|
||||
* page prior to invoking this command cannot be returned to via the browser back button.
|
||||
*
|
||||
* navigateHistory({
|
||||
* to: 'viewer?StudyInstanceUIDs=1.2.3',
|
||||
* options: { replace: true },
|
||||
* });
|
||||
*
|
||||
* @param historyArgs - arguments for the history function;
|
||||
* the `to` property is the URL;
|
||||
* the `options.replace` is a boolean indicating if the current browser history entry
|
||||
* should be replaced or a new entry pushed onto the history (stack); the default value
|
||||
* for `replace` is false
|
||||
*/
|
||||
navigateHistory(historyArgs: NavigateHistory) {
|
||||
history.navigate(historyArgs.to, historyArgs.options);
|
||||
},
|
||||
|
||||
openDICOMTagViewer() {
|
||||
const { activeViewportIndex, viewports } = viewportGridService.getState();
|
||||
const activeViewportSpecificData = viewports[activeViewportIndex];
|
||||
@@ -540,6 +564,11 @@ const commandsModule = ({
|
||||
storeContexts: [],
|
||||
options: {},
|
||||
},
|
||||
navigateHistory: {
|
||||
commandFn: actions.navigateHistory,
|
||||
storeContexts: [],
|
||||
options: {},
|
||||
},
|
||||
nextStage: {
|
||||
commandFn: actions.deltaStage,
|
||||
storeContexts: [],
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export type NavigateHistory = {
|
||||
to: string; // the URL to navigate to
|
||||
options?: {
|
||||
replace?: boolean; // replace or add/push to history?
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user