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]);
+}
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';
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) {