Skip to content

Commit

Permalink
Move from @components plone.restapi endpoint to @navigation and @brea…
Browse files Browse the repository at this point in the history
  • Loading branch information
sunew committed Nov 7, 2017
1 parent 9dd47d8 commit 7e3a7c8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,8 @@
## Bug fixes

- Fix authentication service error parsing [Eric Bréhault]
- Move from @components plone.restapi endpoint to @navigation and @breadcrumbs [Sune Brøndum Wøller]
- More robust error handling [Thomas Desvenain]

# 1.3.0 (2017-11-04)

Expand Down
21 changes: 9 additions & 12 deletions src/services/resource.service.spec.ts
Expand Up @@ -333,9 +333,8 @@ describe('ResourceService', () => {
const service = TestBed.get(ResourceService);
const http = TestBed.get(HttpTestingController);
let url = 'invalid';
const response = [
{
"@id": "http://fake/Plone/front-page/@components/navigation",
const response = {
"@id": "http://fake/Plone/front-page/@navigation",
"items": [
{
"title": "Home",
Expand All @@ -346,14 +345,13 @@ describe('ResourceService', () => {
"url": "http://fake/Plone/front-page"
}
]
}
];
};

service.navigation().subscribe(items => {
url = items[0].url;
});

http.expectOne('http://fake/Plone/@components/navigation').flush(response);
http.expectOne('http://fake/Plone/@navigation').flush(response);

expect(url).toBe('http://fake/Plone');
});
Expand All @@ -362,9 +360,8 @@ describe('ResourceService', () => {
const service = TestBed.get(ResourceService);
const http = TestBed.get(HttpTestingController);
let title = 'invalid';
let response = [
{
"@id": "http://fake/Plone/a-folder/test/@components/breadcrumbs",
let response ={
"@id": "http://fake/Plone/a-folder/test/@breadcrumbs",
"items": [
{
"title": "A folder",
Expand All @@ -375,14 +372,14 @@ describe('ResourceService', () => {
"url": "http://fake/Plone/a-folder/test"
}
]
}
];
};


service.breadcrumbs('/a-folder/test').subscribe(items => {
title = items[0].title;
});

http.expectOne('http://fake/Plone/a-folder/test/@components/breadcrumbs').flush(response);
http.expectOne('http://fake/Plone/a-folder/test/@breadcrumbs').flush(response);

expect(title).toBe('A folder');
});
Expand Down
16 changes: 8 additions & 8 deletions src/services/resource.service.ts
Expand Up @@ -135,10 +135,10 @@ export class ResourceService {
}

navigation(): Observable<NavLink[]> {
return this.cache.get('/@components/navigation')
.map((data: NavigationItems[]) => {
if (data && data[0]) {
return data[0].items.filter(item => {
return this.cache.get('/@navigation')
.map((data: NavigationItems) => {
if (data) {
return data.items.filter(item => {
return !item.properties || !item.properties.exclude_from_nav;
}).map(this.linkFromItem.bind(this));
} else {
Expand All @@ -148,10 +148,10 @@ export class ResourceService {
}

breadcrumbs(path: string): Observable<NavLink[]> {
return this.cache.get(path + '/@components/breadcrumbs')
.map((data: NavigationItems[]) => {
if (data && data[0]) {
return data[0].items.map(this.linkFromItem.bind(this));
return this.cache.get(path + '/@breadcrumbs')
.map((data: NavigationItems) => {
if (data) {
return data.items.map(this.linkFromItem.bind(this));
} else {
return [];
}
Expand Down

0 comments on commit 7e3a7c8

Please sign in to comment.