Skip to content

Commit

Permalink
refactor: provide changelog via injector
Browse files Browse the repository at this point in the history
  • Loading branch information
nvsukhanov committed Mar 13, 2024
1 parent ddc6d21 commit 2493193
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ol class="versions-list">
@for(versionRecord of log; track versionRecord; let last = $last; let first = $first) {
@for(versionRecord of changelog; track versionRecord; let last = $last; let first = $first) {
<li class="version-record"
[class.version-record__first]="first"
>
Expand Down
9 changes: 6 additions & 3 deletions modules/shared/ui/src/lib/changelog/changelog.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';
import { TranslocoPipe } from '@ngneat/transloco';
import { MatDivider } from '@angular/material/divider';

import { CHANGELOG } from './changelog';
import { CHANGELOG_TOKEN, IChangelog } from './i-changelog';

@Component({
standalone: true,
Expand All @@ -16,5 +16,8 @@ import { CHANGELOG } from './changelog';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ChangelogComponent {
public readonly log = CHANGELOG;
constructor(
@Inject(CHANGELOG_TOKEN) public readonly changelog: IChangelog
) {
}
}
8 changes: 8 additions & 0 deletions modules/shared/ui/src/lib/changelog/i-changelog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { InjectionToken } from '@angular/core';

export interface IChangelog extends Array<{
version: string;
changeL10nKeys: Array<string>;
}> { }

export const CHANGELOG_TOKEN = new InjectionToken<IChangelog>('CHANGELOG');
1 change: 1 addition & 0 deletions modules/shared/ui/src/lib/changelog/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './changelog.component';
export * from './i-changelog';
16 changes: 2 additions & 14 deletions .../shared/ui/src/lib/changelog/changelog.ts → src/changelog.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
export type Changelog = Array<{
version: string;
changeL10nKeys: Array<string>;
}>;
import { IChangelog } from '@app/shared-ui';

export const CHANGELOG: Changelog = [
{
version: '1.2.6',
changeL10nKeys: [
'changelog.1-2-6.fixServoCalibrationForRangesGraterThan360',
'changelog.1-2-6.fixServoCalibrationResultsNotBeingRound',
'changelog.1-2-6.fixMultipleServoCalibrationOnStartup',
'changelog.1-2-6.featMotorStrainingReduction',
]
},
export const CHANGELOG: IChangelog = [
{
version: '1.2.5',
changeL10nKeys: [
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import { ShowOnTouchedErrorStateMatcher } from '@app/shared-misc';
import { provideI18n } from '@app/shared-i18n';
import { provideApplicationStore } from '@app/store';
import { provideBindings } from '@app/bindings';
import { CHANGELOG_TOKEN } from '@app/shared-ui';

import { RootComponent } from './app';
import { ROUTES } from './routes';
import { CHANGELOG } from './changelog';

bootstrapApplication(RootComponent, {
providers: [
Expand All @@ -29,6 +31,7 @@ bootstrapApplication(RootComponent, {
provideServiceWorker('ngsw-worker.js', {
enabled: !isDevMode(),
registrationStrategy: 'registerWhenStable:30000'
})
}),
{ provide: CHANGELOG_TOKEN, useValue: CHANGELOG }
]
});

0 comments on commit 2493193

Please sign in to comment.