From: Stas Vilchik Date: Tue, 12 Jan 2016 10:36:23 +0000 (+0100) Subject: SONAR-4004 use new WS to request component's breadcrumbs X-Git-Tag: 5.4-M4~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e8fa4e0c843b7e2b1394184ee56f633c1f81deca;p=sonarqube.git SONAR-4004 use new WS to request component's breadcrumbs --- diff --git a/server/sonar-web/src/main/js/api/components.js b/server/sonar-web/src/main/js/api/components.js index cf236095af9..8a6d69de6cc 100644 --- a/server/sonar-web/src/main/js/api/components.js +++ b/server/sonar-web/src/main/js/api/components.js @@ -69,8 +69,20 @@ export function getComponent (componentKey, metrics = []) { return getJSON(url, data).then(r => r[0]); } -export function getTree(baseComponentKey, options = {}) { +export function getTree (baseComponentKey, options = {}) { const url = baseUrl + '/api/components/tree'; const data = Object.assign({}, options, { baseComponentKey }); return getJSON(url, data); } + +export function getParents ({ id, key }) { + const url = baseUrl + '/api/components/show'; + const data = id ? { id } : { key }; + return getJSON(url, data).then(r => r.ancestors); +} + +export function getBreadcrumbs ({ id, key }) { + const url = baseUrl + '/api/components/show'; + const data = id ? { id } : { key }; + return getJSON(url, data).then(r => [...r.ancestors, r.component]); +} diff --git a/server/sonar-web/src/main/js/apps/code/actions/index.js b/server/sonar-web/src/main/js/apps/code/actions/index.js index 3fa51d365aa..b387aad0aa0 100644 --- a/server/sonar-web/src/main/js/apps/code/actions/index.js +++ b/server/sonar-web/src/main/js/apps/code/actions/index.js @@ -20,8 +20,7 @@ import _ from 'underscore'; import { pushPath } from 'redux-simple-router'; -import { getChildren, getComponent, getTree } from '../../../api/components'; -import { getComponentNavigation } from '../../../api/nav'; +import { getChildren, getComponent, getTree, getBreadcrumbs } from '../../../api/components'; import { translate } from '../../../helpers/l10n'; @@ -142,9 +141,7 @@ function retrieveComponentChildren (componentKey, candidate) { function retrieveComponentBreadcrumbs (componentKey, candidate) { return candidate && candidate.breadcrumbs ? Promise.resolve(candidate.breadcrumbs) : - getComponentNavigation(componentKey) - .then(navigation => navigation.breadcrumbs) - .then(skipRootDir); + getBreadcrumbs({ key: componentKey }).then(skipRootDir); } function retrieveComponent (componentKey, bucket) {