diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2018-03-12 12:06:11 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk@users.noreply.github.com> | 2018-03-13 14:05:36 +0100 |
commit | 913c82c8772fd4747626a1fbe665ccda2e5ca9f1 (patch) | |
tree | d48784851df80905ce125cc60ac8aec8570751a9 /server/sonar-web/src/main/js/api/components.ts | |
parent | 751e4000e40a4af66b80767d632b1bef64dc5647 (diff) | |
download | sonarqube-913c82c8772fd4747626a1fbe665ccda2e5ca9f1.tar.gz sonarqube-913c82c8772fd4747626a1fbe665ccda2e5ca9f1.zip |
SONAR-10374 Support pull request in the web app
Diffstat (limited to 'server/sonar-web/src/main/js/api/components.ts')
-rw-r--r-- | server/sonar-web/src/main/js/api/components.ts | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/server/sonar-web/src/main/js/api/components.ts b/server/sonar-web/src/main/js/api/components.ts index db1e32cc643..60f7af8b14b 100644 --- a/server/sonar-web/src/main/js/api/components.ts +++ b/server/sonar-web/src/main/js/api/components.ts @@ -19,7 +19,7 @@ */ import { getJSON, postJSON, post, RequestData } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; -import { Paging, Visibility } from '../app/types'; +import { Paging, Visibility, BranchParameters } from '../app/types'; export interface BaseSearchProjectsParameters { analyzedBefore?: string; @@ -118,11 +118,8 @@ export function getComponentLeaves( } export function getComponent( - componentKey: string, - metrics: string[] = [], - branch?: string + data: { componentKey: string; metricKeys: string } & BranchParameters ): Promise<any> { - const data = { branch, componentKey, metricKeys: metrics.join(',') }; return getJSON('/api/measures/component', data).then(r => r.component); } @@ -130,23 +127,23 @@ export function getTree(component: string, options: RequestData = {}): Promise<a return getJSON('/api/components/tree', { ...options, component }); } -export function getComponentShow(component: string, branch?: string): Promise<any> { - return getJSON('/api/components/show', { component, branch }); +export function getComponentShow(data: { component: string } & BranchParameters): Promise<any> { + return getJSON('/api/components/show', data); } export function getParents(component: string): Promise<any> { - return getComponentShow(component).then(r => r.ancestors); + return getComponentShow({ component }).then(r => r.ancestors); } -export function getBreadcrumbs(component: string, branch?: string): Promise<any> { - return getComponentShow(component, branch).then(r => { +export function getBreadcrumbs(data: { component: string } & BranchParameters): Promise<any> { + return getComponentShow(data).then(r => { const reversedAncestors = [...r.ancestors].reverse(); return [...reversedAncestors, r.component]; }); } -export function getComponentData(component: string, branch?: string): Promise<any> { - return getComponentShow(component, branch).then(r => r.component); +export function getComponentData(data: { component: string } & BranchParameters): Promise<any> { + return getComponentShow(data).then(r => r.component); } export function getMyProjects(data: RequestData): Promise<any> { @@ -246,31 +243,24 @@ export function getSuggestions( return getJSON('/api/components/suggestions', data); } -export function getComponentForSourceViewer(component: string, branch?: string): Promise<any> { - return getJSON('/api/components/app', { component, branch }); +export function getComponentForSourceViewer( + data: { component: string } & BranchParameters +): Promise<any> { + return getJSON('/api/components/app', data); } export function getSources( - component: string, - from?: number, - to?: number, - branch?: string + data: { key: string; from?: number; to?: number } & BranchParameters ): Promise<any> { - const data: RequestData = { key: component, branch }; - if (from) { - Object.assign(data, { from }); - } - if (to) { - Object.assign(data, { to }); - } return getJSON('/api/sources/lines', data).then(r => r.sources); } -export function getDuplications(component: string, branch?: string): Promise<any> { - return getJSON('/api/duplications/show', { key: component, branch }); +export function getDuplications(data: { key: string } & BranchParameters): Promise<any> { + return getJSON('/api/duplications/show', data); } -export function getTests(component: string, line: number | string, branch?: string): Promise<any> { - const data = { sourceFileKey: component, sourceFileLineNumber: line, branch }; +export function getTests( + data: { sourceFileKey: string; sourceFileLineNumber: number | string } & BranchParameters +): Promise<any> { return getJSON('/api/tests/list', data).then(r => r.tests); } |