diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2022-03-22 16:24:08 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-03-23 20:02:45 +0000 |
commit | a38eda46c2f174efe54e6a584f12895a3d3c7f3c (patch) | |
tree | ef05b7691529a4cd77dba965e523469e7e5b7d3b /server/sonar-web/src/main/js/helpers | |
parent | 9a35b0e3e65302ee4f6c1b4cc2c5db71df5b0a5d (diff) | |
download | sonarqube-a38eda46c2f174efe54e6a584f12895a3d3c7f3c.tar.gz sonarqube-a38eda46c2f174efe54e6a584f12895a3d3c7f3c.zip |
SONAR-15914 Extract branchstatus from redux
Diffstat (limited to 'server/sonar-web/src/main/js/helpers')
-rw-r--r-- | server/sonar-web/src/main/js/helpers/branch-like.ts | 11 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/helpers/testMocks.ts | 26 |
2 files changed, 37 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/helpers/branch-like.ts b/server/sonar-web/src/main/js/helpers/branch-like.ts index b332e9acd2e..ce6cc4ec13f 100644 --- a/server/sonar-web/src/main/js/helpers/branch-like.ts +++ b/server/sonar-web/src/main/js/helpers/branch-like.ts @@ -23,9 +23,11 @@ import { BranchLike, BranchLikeTree, BranchParameters, + BranchStatusData, MainBranch, PullRequest } from '../types/branch-like'; +import { Dict } from '../types/types'; export function isBranch(branchLike?: BranchLike): branchLike is Branch { return branchLike !== undefined && (branchLike as Branch).isMain !== undefined; @@ -136,3 +138,12 @@ export function fillBranchLike( } return undefined; } + +export function getBranchStatusByBranchLike( + branchStatusByComponent: Dict<Dict<BranchStatusData>>, + component: string, + branchLike: BranchLike +): BranchStatusData { + const branchLikeKey = getBranchLikeKey(branchLike); + return branchStatusByComponent[component] && branchStatusByComponent[component][branchLikeKey]; +} diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts index 3c4c452ddd7..7269073b760 100644 --- a/server/sonar-web/src/main/js/helpers/testMocks.ts +++ b/server/sonar-web/src/main/js/helpers/testMocks.ts @@ -24,6 +24,7 @@ import { DocumentationEntry } from '../apps/documentation/utils'; import { Exporter, Profile } from '../apps/quality-profiles/types'; import { AppState } from '../types/appstate'; import { EditionKey } from '../types/editions'; +import { RawIssue } from '../types/issues'; import { Language } from '../types/languages'; import { DumpStatus, DumpTask } from '../types/project-dump'; import { TaskStatuses } from '../types/tasks'; @@ -367,6 +368,31 @@ export function mockEvent(overrides = {}) { } as any; } +export function mockRawIssue(withLocations = false, overrides: Partial<RawIssue> = {}): RawIssue { + const rawIssue: RawIssue = { + component: 'main.js', + key: 'AVsae-CQS-9G3txfbFN2', + line: 25, + project: 'myproject', + rule: 'javascript:S1067', + severity: 'MAJOR', + status: 'OPEN', + textRange: { startLine: 25, endLine: 26, startOffset: 0, endOffset: 15 }, + ...overrides + }; + + if (withLocations) { + const loc = mockFlowLocation; + + rawIssue.flows = [{ locations: [loc(), loc()] }]; + } + + return { + ...rawIssue, + ...overrides + }; +} + export function mockIssue(withLocations = false, overrides: Partial<Issue> = {}) { const issue: Issue = { actions: [], |