Skip to content

Commit

Permalink
docs(core,platform): fixed docs current version value (#10354)
Browse files Browse the repository at this point in the history
* fix(docs): fixed docs current version visibility

* chore: deleted left out console log
  • Loading branch information
g-cheishvili authored Aug 19, 2023
1 parent 60fedf5 commit ae853f8
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
3 changes: 2 additions & 1 deletion apps/docs/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { BehaviorSubject } from 'rxjs';
import { ClickedBehaviorModule } from '@fundamental-ngx/cdk/utils';
import { SharedDocumentationModule } from '@fundamental-ngx/docs/shared';
import packageJson from '../../../../package.json';
import lernaJson from '../../../../lerna.json';

const routes: Routes = [
{
Expand Down Expand Up @@ -60,7 +61,7 @@ const routes: Routes = [
ThemingModule,
ContentDensityModule.forRoot({ storage: 'localStorage' }),
ClickedBehaviorModule.forRoot(),
SharedDocumentationModule.forRoot(packageJson),
SharedDocumentationModule.forRoot({ packageJson, lernaJson }),
SkeletonModule
],
bootstrap: [AppComponent],
Expand Down
1 change: 1 addition & 0 deletions libs/docs/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export * from './lib/services/copy.service';
export * from './lib/services/api-docs.service';
export * from './lib/services/docs.service';
export * from './lib/tokens/package-json.token';
export * from './lib/tokens/lerna-json.token';
export * from './lib/tokens/current-component.token';
export * from './lib/getAsset';
export * from './lib/services/example-child.service';
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
></path>
</g>
</svg>
<p *ngIf="versions && versions.length">{{ versions[0].id }}</p>
{{ version.id }}
</a>
</fd-shellbar-actions>
</fd-shellbar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { CompleteThemeDefinition, ThemingService } from '@fundamental-ngx/core/theming';
import { Router, ActivatedRoute } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { CURRENT_LIB, Libraries } from '../../utilities';
import { Libraries } from '../../utilities';

import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
import { BehaviorSubject, filter, fromEvent, Subject } from 'rxjs';
Expand Down Expand Up @@ -76,10 +76,7 @@ export class ToolbarDocsComponent implements OnInit, OnDestroy {

themes: CompleteThemeDefinition[];

version: Version = {
id: this._docsService.getPackageJson().version,
url: ''
};
version: Version;

versions: Version[];

Expand Down Expand Up @@ -135,13 +132,16 @@ export class ToolbarDocsComponent implements OnInit, OnDestroy {
private _routerService: Router,
private _contentDensityService: GlobalContentDensityService,
private _themingService: ThemingService,
@Inject(CURRENT_LIB) private _currentLib: Libraries,
@Inject(FD_LANGUAGE) private langSubject$: BehaviorSubject<FdLanguage>,
private _route: ActivatedRoute,
private _domSanitizer: DomSanitizer,
private _docsService: DocsService,
private _http: HttpClient
) {
this.version = {
id: this._docsService.getLernaJson().version,
url: ''
};
this.library = this._route.snapshot.data['library'] || 'core';

this._themingService.currentTheme
Expand Down
10 changes: 8 additions & 2 deletions libs/docs/shared/src/lib/services/docs.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { Inject, Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { PACKAGE_JSON } from '../tokens/package-json.token';
import { LERNA_JSON } from '../tokens/lerna-json.token';

@Injectable()
export class DocsService {
constructor(@Inject(PACKAGE_JSON) private _packageJson: Record<string, any>) {}
private _packageJson: Record<string, any> = inject(PACKAGE_JSON);
private _lernaJson: Record<string, any> = inject(LERNA_JSON);

getPackageJson(): Record<string, any> {
return this._packageJson;
}

getLernaJson(): Record<string, any> {
return this._lernaJson;
}

rawFileContents(path: string): Promise<string> {
return import(`!${path}?raw`);
}
Expand Down
12 changes: 10 additions & 2 deletions libs/docs/shared/src/lib/shared-documentation.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { IconModule } from '@fundamental-ngx/core/icon';
import { PACKAGE_JSON } from './tokens/package-json.token';
import { DocsService } from './services/docs.service';
import { DocumentationBaseComponent } from './documentation-base.component';
import { LERNA_JSON } from './tokens/lerna-json.token';

/** PROVIDES DEPENDENCIES REQUIRED TO BUILD DOCUMENTATION SHELL */

Expand Down Expand Up @@ -50,13 +51,20 @@ import { DocumentationBaseComponent } from './documentation-base.component';
schemas: [NO_ERRORS_SCHEMA]
})
export class SharedDocumentationModule {
static forRoot(packageJson: Record<string, any>): ModuleWithProviders<SharedDocumentationModule> {
static forRoot(props: {
packageJson: Record<string, any>;
lernaJson: Record<string, any>;
}): ModuleWithProviders<SharedDocumentationModule> {
return {
ngModule: SharedDocumentationModule,
providers: [
{
provide: PACKAGE_JSON,
useValue: packageJson
useValue: props.packageJson
},
{
provide: LERNA_JSON,
useValue: props.lernaJson
},
DocsService
]
Expand Down
3 changes: 3 additions & 0 deletions libs/docs/shared/src/lib/tokens/lerna-json.token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { InjectionToken } from '@angular/core';

export const LERNA_JSON = new InjectionToken<Record<string, any>>('LernaJson');
2 changes: 1 addition & 1 deletion libs/docs/shared/src/lib/utilities/libraries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InjectionToken } from '@angular/core';

export type Libraries = 'core' | 'platform' | 'datetime-adapter' | 'fn' | 'cx';
export type Libraries = 'core' | 'platform' | 'datetime-adapter' | 'cx';

export const CURRENT_LIB = new InjectionToken<Libraries>('Current Library');

0 comments on commit ae853f8

Please sign in to comment.