diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-01-12 11:36:23 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-01-12 11:36:23 +0100 |
commit | e8fa4e0c843b7e2b1394184ee56f633c1f81deca (patch) | |
tree | c6da2bdf7b8c83ae9e3afc0ceaf00d4286a3151d | |
parent | 6225c854d869db28adc7c74f0b18e0dfdefebff6 (diff) | |
download | sonarqube-e8fa4e0c843b7e2b1394184ee56f633c1f81deca.tar.gz sonarqube-e8fa4e0c843b7e2b1394184ee56f633c1f81deca.zip |
SONAR-4004 use new WS to request component's breadcrumbs
-rw-r--r-- | server/sonar-web/src/main/js/api/components.js | 14 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/apps/code/actions/index.js | 7 |
2 files changed, 15 insertions, 6 deletions
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) { |