diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues/actions.js')
-rw-r--r-- | server/sonar-web/src/main/js/apps/issues/actions.js | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/actions.js b/server/sonar-web/src/main/js/apps/issues/actions.js index 610628b15ff..2bde7c95332 100644 --- a/server/sonar-web/src/main/js/apps/issues/actions.js +++ b/server/sonar-web/src/main/js/apps/issues/actions.js @@ -20,12 +20,16 @@ // @flow import type { State } from './components/App'; -export const enableLocationsNavigator = (state: State) => ({ - locationsNavigator: true, - selectedFlowIndex: state.selectedFlowIndex || - (state.openIssue && state.openIssue.flows.length > 0 ? 0 : null), - selectedLocationIndex: state.selectedLocationIndex || 0 -}); +export const enableLocationsNavigator = (state: State) => { + const { openIssue } = state; + if (openIssue && (openIssue.secondaryLocations.length > 0 || openIssue.flows.length > 0)) { + return { + locationsNavigator: true, + selectedFlowIndex: state.selectedFlowIndex || (openIssue.flows.length > 0 ? 0 : null), + selectedLocationIndex: state.selectedLocationIndex || 0 + }; + } +}; export const disableLocationsNavigator = () => ({ locationsNavigator: false @@ -70,3 +74,17 @@ export const selectPreviousLocation = (state: State) => { export const selectFlow = (nextIndex: ?number) => () => { return { selectedFlowIndex: nextIndex, selectedLocationIndex: 0 }; }; + +export const selectNextFlow = (state: State) => { + const { openIssue, selectedFlowIndex } = state; + if (openIssue && selectedFlowIndex != null && openIssue.flows.length > selectedFlowIndex + 1) { + return { selectedFlowIndex: selectedFlowIndex + 1, selectedLocationIndex: 0 }; + } +}; + +export const selectPreviousFlow = (state: State) => { + const { openIssue, selectedFlowIndex } = state; + if (openIssue && selectedFlowIndex != null && selectedFlowIndex > 0) { + return { selectedFlowIndex: selectedFlowIndex - 1, selectedLocationIndex: 0 }; + } +}; |