diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-03-21 14:18:13 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-03-27 20:22:33 +0200 |
commit | 16ae386379cdfd39ff29ae9e391ddea115fea1ef (patch) | |
tree | 0efce6d028aa2b3eb400025d8a9fa2b014fe2949 /server/sonar-web/src/main/js/apps/issues/utils.ts | |
parent | 3b9222096f56858f89867f2739a0807e68c83ae8 (diff) | |
download | sonarqube-16ae386379cdfd39ff29ae9e391ddea115fea1ef.tar.gz sonarqube-16ae386379cdfd39ff29ae9e391ddea115fea1ef.zip |
SONAR-10489 Support cross file issue locations in web app
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues/utils.ts')
-rw-r--r-- | server/sonar-web/src/main/js/apps/issues/utils.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts index a8ca8b1754e..f148547d9e1 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -19,6 +19,7 @@ */ import { searchMembers } from '../../api/organizations'; import { searchUsers } from '../../api/users'; +import { Issue } from '../../app/types'; import { formatMeasure } from '../../helpers/measures'; import { queriesEqual, @@ -227,3 +228,31 @@ const save = (value: string) => { export const saveMyIssues = (myIssues: boolean) => save(myIssues ? LOCALSTORAGE_MY : LOCALSTORAGE_ALL); + +export function getLocations( + { flows, secondaryLocations }: Pick<Issue, 'flows' | 'secondaryLocations'>, + selectedFlowIndex: number | undefined +) { + if (selectedFlowIndex !== undefined) { + return flows[selectedFlowIndex] || []; + } else { + return flows.length > 0 ? flows[0] : secondaryLocations; + } +} + +export function getSelectedLocation( + issue: Pick<Issue, 'flows' | 'secondaryLocations'>, + selectedFlowIndex: number | undefined, + selectedLocationIndex: number | undefined +) { + const locations = getLocations(issue, selectedFlowIndex); + if ( + selectedLocationIndex !== undefined && + selectedLocationIndex >= 0 && + locations.length >= selectedLocationIndex + ) { + return locations[selectedLocationIndex]; + } else { + return undefined; + } +} |