diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-08-17 21:39:59 +0200 |
---|---|---|
committer | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-09-12 11:34:36 +0200 |
commit | cff416d7f9910c258bc8d7175c08afff96a9eb2a (patch) | |
tree | 78500908a2afde31b28ef938d4d61609d448f279 /server/sonar-web/src/main/js/api | |
parent | 139467cf51932ba232190f363ad864e60eb3fd4d (diff) | |
download | sonarqube-cff416d7f9910c258bc8d7175c08afff96a9eb2a.tar.gz sonarqube-cff416d7f9910c258bc8d7175c08afff96a9eb2a.zip |
SONAR-9702 Build UI for short-lived branches (#2371)
Diffstat (limited to 'server/sonar-web/src/main/js/api')
-rw-r--r-- | server/sonar-web/src/main/js/api/branches.ts | 32 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/api/components.ts | 33 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/api/nav.ts | 7 |
3 files changed, 57 insertions, 15 deletions
diff --git a/server/sonar-web/src/main/js/api/branches.ts b/server/sonar-web/src/main/js/api/branches.ts new file mode 100644 index 00000000000..5c597385c85 --- /dev/null +++ b/server/sonar-web/src/main/js/api/branches.ts @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { getJSON } from '../helpers/request'; +import throwGlobalError from '../app/utils/throwGlobalError'; + +export function getBranches(project: string): Promise<any> { + return getJSON('/api/project_branches/list', { project }).then(r => r.branches, throwGlobalError); +} + +export function getBranch(project: string, branch: string): Promise<any> { + return getJSON('/api/project_branches/show', { component: project, branch }).then( + r => r.branch, + throwGlobalError + ); +} diff --git a/server/sonar-web/src/main/js/api/components.ts b/server/sonar-web/src/main/js/api/components.ts index 50faefec07d..fd46c34d559 100644 --- a/server/sonar-web/src/main/js/api/components.ts +++ b/server/sonar-web/src/main/js/api/components.ts @@ -113,8 +113,12 @@ export function getComponentLeaves( return getComponentTree('leaves', componentKey, metrics, additional); } -export function getComponent(componentKey: string, metrics: string[] = []): Promise<any> { - const data = { componentKey, metricKeys: metrics.join(',') }; +export function getComponent( + componentKey: string, + metrics: string[] = [], + branch?: string +): Promise<any> { + const data = { branch, componentKey, metricKeys: metrics.join(',') }; return getJSON('/api/measures/component', data).then(r => r.component); } @@ -122,23 +126,23 @@ export function getTree(component: string, options: RequestData = {}): Promise<a return getJSON('/api/components/tree', { ...options, component }); } -export function getComponentShow(component: string): Promise<any> { - return getJSON('/api/components/show', { component }); +export function getComponentShow(component: string, branch?: string): Promise<any> { + return getJSON('/api/components/show', { component, branch }); } export function getParents(component: string): Promise<any> { return getComponentShow(component).then(r => r.ancestors); } -export function getBreadcrumbs(component: string): Promise<any> { - return getComponentShow(component).then(r => { +export function getBreadcrumbs(component: string, branch?: string): Promise<any> { + return getComponentShow(component, branch).then(r => { const reversedAncestors = [...r.ancestors].reverse(); return [...reversedAncestors, r.component]; }); } -export function getComponentData(component: string): Promise<any> { - return getComponentShow(component).then(r => r.component); +export function getComponentData(component: string, branch?: string): Promise<any> { + return getComponentShow(component, branch).then(r => r.component); } export function getMyProjects(data: RequestData): Promise<any> { @@ -219,12 +223,17 @@ export function getSuggestions( return getJSON('/api/components/suggestions', data); } -export function getComponentForSourceViewer(component: string): Promise<any> { - return getJSON('/api/components/app', { component }); +export function getComponentForSourceViewer(component: string, branch?: string): Promise<any> { + return getJSON('/api/components/app', { component, branch }); } -export function getSources(component: string, from?: number, to?: number): Promise<any> { - const data: RequestData = { key: component }; +export function getSources( + component: string, + from?: number, + to?: number, + branch?: string +): Promise<any> { + const data: RequestData = { key: component, branch }; if (from) { Object.assign(data, { from }); } diff --git a/server/sonar-web/src/main/js/api/nav.ts b/server/sonar-web/src/main/js/api/nav.ts index 3b2046df1c0..0e1983d0527 100644 --- a/server/sonar-web/src/main/js/api/nav.ts +++ b/server/sonar-web/src/main/js/api/nav.ts @@ -18,15 +18,16 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getJSON } from '../helpers/request'; +import throwGlobalError from '../app/utils/throwGlobalError'; export function getGlobalNavigation(): Promise<any> { return getJSON('/api/navigation/global'); } -export function getComponentNavigation(componentKey: string): Promise<any> { - return getJSON('/api/navigation/component', { componentKey }); +export function getComponentNavigation(componentKey: string, branch?: string): Promise<any> { + return getJSON('/api/navigation/component', { componentKey, branch }).catch(throwGlobalError); } export function getSettingsNavigation(): Promise<any> { - return getJSON('/api/navigation/settings'); + return getJSON('/api/navigation/settings').catch(throwGlobalError); } |