From a9e91115bf6d3523ef8731c90a790b701c98c00b Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 21 Mar 2017 11:27:53 +0000 Subject: [PATCH] build(aio): add version into navigation.json The navigation.json is now passed through the dgeni pipeline. The source file has been moved to `aio/content/navigation.json` but the generated file will now appear where the original source file was found, `aio/src/content/navigation.json`. Everything inside `aio/src/content` is now generated and ignored by git. The `processNavigationMap` processor in this commit adds the current version information to the navigation.json file and verifies the relative urls in the file map to real documents. The navigationService exposes the versionInfo as an observable, which the AppComponent renders at the top of the sidenav. --- aio/src/app/navigation/navigation.service.spec.ts | 3 +-- aio/src/app/navigation/navigation.service.ts | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aio/src/app/navigation/navigation.service.spec.ts b/aio/src/app/navigation/navigation.service.spec.ts index 104a4fe821..dc423c7ea5 100644 --- a/aio/src/app/navigation/navigation.service.spec.ts +++ b/aio/src/app/navigation/navigation.service.spec.ts @@ -135,12 +135,11 @@ describe('NavigationService', () => { const backend = injector.get(ConnectionBackend); backend.connectionsArray[0].mockRespond(createResponse({ - ['__versionInfo']: { raw: '4.0.0' } + __versionInfo: { raw: '4.0.0' } })); }); it('should extract the version info', () => { - const backend = injector.get(ConnectionBackend); expect(versionInfo).toEqual({ raw: '4.0.0' }); }); }); diff --git a/aio/src/app/navigation/navigation.service.ts b/aio/src/app/navigation/navigation.service.ts index 3b7db011af..d08c0ac62e 100644 --- a/aio/src/app/navigation/navigation.service.ts +++ b/aio/src/app/navigation/navigation.service.ts @@ -12,7 +12,8 @@ import { LocationService } from 'app/shared/location.service'; import { NavigationNode } from './navigation-node'; export { NavigationNode } from './navigation-node'; -export type NavigationResponse = {'__versionInfo': VersionInfo } & { [name: string]: NavigationNode[] }; + +export type NavigationResponse = {__versionInfo: VersionInfo } & { [name: string]: NavigationNode[]|VersionInfo }; export interface NavigationViews { [name: string]: NavigationNode[]; @@ -86,12 +87,12 @@ export class NavigationService { } private getVersionInfo(navigationInfo: Observable) { - const versionInfo = navigationInfo.map(response => response['__versionInfo']).publishReplay(1); + const versionInfo = navigationInfo.map(response => response.__versionInfo).publishReplay(1); versionInfo.connect(); return versionInfo; } - private getNavigationViews(navigationInfo: Observable) { + private getNavigationViews(navigationInfo: Observable): Observable { const navigationViews = navigationInfo.map(response => unpluck(response, '__versionInfo')).publishReplay(1); navigationViews.connect(); return navigationViews;