Skip to content

Added missing tab titles [#1027] #1035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
import { MatSort } from '@angular/material/sort';
import { MatSidenav } from '@angular/material/sidenav';
import { ConfirmationService } from '@app/core/services/confirmation.service';
import { TitleService } from '@app/core/services/title.service';

@Component({
selector: 'cx-web-audit-log-page',
Expand Down Expand Up @@ -78,7 +79,8 @@ export class WebAuditLogPageComponent
private logger: LoggerService,
private store: Store<any>,
private confirmationService: ConfirmationService,
private translateService: TranslateService
private translateService: TranslateService,
private titleService: TitleService
) {
this.langChangeSubscription = this.translateService.onLangChange.subscribe(
() => this.loadTranslations()
Expand Down Expand Up @@ -166,5 +168,8 @@ export class WebAuditLogPageComponent
this.paginator._intl.itemsPerPageLabel = this.translateService.instant(
'web-audit-log.label.pagination-items-per-page'
);
this.titleService.setTitle(
this.translateService.instant('web-audit-log.tab-title')
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { MatDialogModule } from '@angular/material/dialog';
import { MatMenuModule } from '@angular/material/menu';
import { LibraryToolbarComponent } from '@app/library/components/library-toolbar/library-toolbar.component';
import { MatIconModule } from '@angular/material/icon';
import { TranslateModule } from '@ngx-translate/core';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatFormFieldModule } from '@angular/material/form-field';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
Expand Down Expand Up @@ -65,6 +65,7 @@ import {
initialState as initialUserState,
USER_FEATURE_KEY
} from '@app/user/reducers/user.reducer';
import { TitleService } from '@app/core/services/title.service';

describe('CollectionDetailComponent', () => {
const COMICS = [COMIC_1, COMIC_2, COMIC_3, COMIC_4, COMIC_5];
Expand All @@ -81,6 +82,8 @@ describe('CollectionDetailComponent', () => {
let store: MockStore<any>;
let activatedRoute: ActivatedRoute;
let router: Router;
let titleService: TitleService;
let translateService: TranslateService;

beforeEach(async(() => {
TestBed.configureTestingModule({
Expand Down Expand Up @@ -115,7 +118,8 @@ describe('CollectionDetailComponent', () => {
collectionName: 'Batman'
})
}
}
},
TitleService
]
}).compileComponents();

Expand All @@ -126,13 +130,26 @@ describe('CollectionDetailComponent', () => {
router = TestBed.inject(Router);
spyOn(router, 'navigate');
spyOn(router, 'navigateByUrl');
titleService = TestBed.inject(TitleService);
spyOn(titleService, 'setTitle');
translateService = TestBed.inject(TranslateService);
fixture.detectChanges();
}));

it('should create', () => {
expect(component).toBeTruthy();
});

describe('when the language changes', () => {
beforeEach(() => {
translateService.use('fr');
});

it('loads the title', () => {
expect(titleService.setTitle).toHaveBeenCalledWith(jasmine.any(String));
});
});

describe('when the collection type is invalid', () => {
beforeEach(() => {
(activatedRoute.params as BehaviorSubject<{}>).next({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { ReadingList } from '@app/lists/models/reading-list';
import { selectUserReadingLists } from '@app/lists/selectors/reading-lists.selectors';
import { selectUser } from '@app/user/selectors/user.selectors';
import { isAdmin } from '@app/user/user.functions';
import { TitleService } from '@app/core/services/title.service';
import { TranslateService } from '@ngx-translate/core';

@Component({
selector: 'cx-collection-detail',
Expand All @@ -51,17 +53,21 @@ export class CollectionDetailComponent implements OnInit, OnDestroy {
readingLists: ReadingList[] = [];
userSubscription: Subscription;
isAdmin = false;
langChangeSubscription: Subscription;

constructor(
private logger: LoggerService,
private store: Store<any>,
private activatedRoute: ActivatedRoute,
private router: Router
private router: Router,
private translateService: TranslateService,
private titleService: TitleService
) {
this.paramSubscription = this.activatedRoute.params.subscribe(params => {
this.routableTypeName = params.collectionType;
this.collectionName = params.collectionName;
this.collectionType = collectionTypeFromString(this.routableTypeName);
this.loadTranslations();
if (!this.collectionType) {
this.logger.error('Invalid collection type:', params.collectionType);
this.router.navigateByUrl('/library');
Expand Down Expand Up @@ -97,9 +103,14 @@ export class CollectionDetailComponent implements OnInit, OnDestroy {
this.readingListsSubscription = this.store
.select(selectUserReadingLists)
.subscribe(lists => (this.readingLists = lists));
this.langChangeSubscription = this.translateService.onLangChange.subscribe(
() => this.loadTranslations()
);
}

ngOnInit(): void {}
ngOnInit(): void {
this.loadTranslations();
}

ngOnDestroy(): void {
this.logger.trace('Unsubscribing from parameter updates');
Expand All @@ -111,5 +122,15 @@ export class CollectionDetailComponent implements OnInit, OnDestroy {
this.userSubscription.unsubscribe();
this.logger.trace('Unsubscribing from reading list updats');
this.readingListsSubscription.unsubscribe();
this.langChangeSubscription.unsubscribe();
}

private loadTranslations(): void {
this.titleService.setTitle(
this.translateService.instant('collection-detail.tab-title', {
collection: this.collectionType,
name: this.collectionName
})
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import {
} from '@app/comic-books/comic-books.fixtures';
import { CollectionListEntry } from '@app/collections/models/collection-list-entry';
import { MatTableModule } from '@angular/material/table';
import { TranslateModule } from '@ngx-translate/core';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { TitleService } from '@app/core/services/title.service';

describe('CollectionListComponent', () => {
const COMICS = [COMIC_1, COMIC_3, COMIC_5];
Expand All @@ -48,6 +49,8 @@ describe('CollectionListComponent', () => {
let store: MockStore<any>;
let activatedRoute: ActivatedRoute;
let router: Router;
let titleService: TitleService;
let translateService: TranslateService;

beforeEach(async(() => {
TestBed.configureTestingModule({
Expand All @@ -65,7 +68,8 @@ describe('CollectionListComponent', () => {
useValue: {
params: new BehaviorSubject<{}>({})
}
}
},
TitleService
]
}).compileComponents();

Expand All @@ -76,13 +80,26 @@ describe('CollectionListComponent', () => {
router = TestBed.inject(Router);
spyOn(router, 'navigate');
spyOn(router, 'navigateByUrl');
titleService = TestBed.inject(TitleService);
spyOn(titleService, 'setTitle');
translateService = TestBed.inject(TranslateService);
fixture.detectChanges();
}));

it('should create', () => {
expect(component).toBeTruthy();
});

describe('when the language changes', () => {
beforeEach(() => {
translateService.use('fr');
});

it('loads the title', () => {
expect(titleService.setTitle).toHaveBeenCalledWith(jasmine.any(String));
});
});

describe('when the collection type is invalid', () => {
beforeEach(() => {
(activatedRoute.params as BehaviorSubject<{}>).next({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import { selectComicListCollection } from '@app/comic-books/selectors/comic-list
import { MatTableDataSource } from '@angular/material/table';
import { CollectionListEntry } from '@app/collections/models/collection-list-entry';
import { MatSort } from '@angular/material/sort';
import { TranslateService } from '@ngx-translate/core';
import { TitleService } from '@app/core/services/title.service';

@Component({
selector: 'cx-collection-list',
Expand All @@ -53,16 +55,20 @@ export class CollectionListComponent
collectionSubscription: Subscription;
dataSource = new MatTableDataSource<CollectionListEntry>([]);
readonly displayedColumns = ['name', 'comic-count'];
langChangeSubscription: Subscription;

constructor(
private logger: LoggerService,
private store: Store<any>,
private activatedRoute: ActivatedRoute,
private router: Router
private router: Router,
private translateService: TranslateService,
private titleService: TitleService
) {
this.paramSubscription = this.activatedRoute.params.subscribe(params => {
this.routableTypeName = params.collectionType;
this.collectionType = collectionTypeFromString(this.routableTypeName);
this.loadTranslations();
if (!this.collectionType) {
this.logger.error('Invalid collection type:', params.collectionType);
this.router.navigateByUrl('/library');
Expand All @@ -76,6 +82,9 @@ export class CollectionListComponent
);
}
});
this.langChangeSubscription = this.translateService.onLangChange.subscribe(
() => this.loadTranslations()
);
}

set entries(entries: CollectionListEntry[]) {
Expand All @@ -88,9 +97,12 @@ export class CollectionListComponent
if (!!this.collectionSubscription) {
this.collectionSubscription.unsubscribe();
}
this.langChangeSubscription.unsubscribe();
}

ngOnInit(): void {}
ngOnInit(): void {
this.loadTranslations();
}

onShowCollection(entry: CollectionListEntry): void {
this.logger.debug('Collection entry selected:', entry);
Expand All @@ -113,4 +125,12 @@ export class CollectionListComponent
}
};
}

private loadTranslations(): void {
this.titleService.setTitle(
this.translateService.instant('collection-list.tab-title', {
collection: this.collectionType
})
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTableModule } from '@angular/material/table';
import { MatPaginatorModule } from '@angular/material/paginator';
import { TranslateModule } from '@ngx-translate/core';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { downloadBlockedPages } from '@app/comic-pages/actions/download-blocked-pages.actions';
import { MatDialogModule } from '@angular/material/dialog';
Expand All @@ -48,6 +48,7 @@ import { SelectableListItem } from '@app/core/models/ui/selectable-list-item';
import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';
import { markPagesWithHash } from '@app/comic-pages/actions/blocked-hash-list.actions';
import { TitleService } from '@app/core/services/title.service';

describe('BlockedHashListPageComponent', () => {
const ENTRIES = [BLOCKED_HASH_1, BLOCKED_HASH_3, BLOCKED_HASH_5];
Expand All @@ -60,6 +61,8 @@ describe('BlockedHashListPageComponent', () => {
let router: Router;
let store: MockStore<any>;
let confirmationService: ConfirmationService;
let titleService: TitleService;
let translateService: TranslateService;

beforeEach(async(() => {
TestBed.configureTestingModule({
Expand All @@ -76,7 +79,11 @@ describe('BlockedHashListPageComponent', () => {
MatIconModule,
MatTooltipModule
],
providers: [provideMockStore({ initialState }), ConfirmationService]
providers: [
provideMockStore({ initialState }),
ConfirmationService,
TitleService
]
}).compileComponents();

fixture = TestBed.createComponent(BlockedHashListPageComponent);
Expand All @@ -86,13 +93,26 @@ describe('BlockedHashListPageComponent', () => {
store = TestBed.inject(MockStore);
spyOn(store, 'dispatch');
confirmationService = TestBed.inject(ConfirmationService);
titleService = TestBed.inject(TitleService);
spyOn(titleService, 'setTitle');
translateService = TestBed.inject(TranslateService);
fixture.detectChanges();
}));

it('should create', () => {
expect(component).toBeTruthy();
});

describe('when the language changes', () => {
beforeEach(() => {
translateService.use('fr');
});

it('loads the title', () => {
expect(titleService.setTitle).toHaveBeenCalledWith(jasmine.any(String));
});
});

describe('receiving blocked page updates', () => {
beforeEach(() => {
store.setState({
Expand Down
Loading