<div class="modal-header">
<h4 class="modal-title pull-left"
- i18n>{ editing, select, true {Rename} other {Create}} RBD Snapshot</h4>
+ i18n="form title|Example: Create rbdSnapshot@@formTitle">{{ action | titlecase }} {{ resource | upperFirst }}</h4>
<button type="button"
class="close pull-right"
aria-label="Close"
<div class="button-group text-right">
<cd-submit-button [form]="snapshotForm"
(submitAction)="submit()"
- i18n>{ editing, select, true {Rename} other {Create}} Snapshot</cd-submit-button>
+ i18n="form action button|Example: Create rbdSnapshot@@formActionButton">{{ action | titlecase }} {{ resource | upperFirst }}</cd-submit-button>
<cd-back-button [back]="modalRef.hide"
name="Close"
i18n-name>
import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
import { ApiModule } from '../../../shared/api/api.module';
import { ComponentsModule } from '../../../shared/components/components.module';
+import { PipesModule } from '../../../shared/pipes/pipes.module';
import { AuthStorageService } from '../../../shared/services/auth-storage.service';
import { RbdSnapshotFormComponent } from './rbd-snapshot-form.component';
imports: [
ReactiveFormsModule,
ComponentsModule,
+ PipesModule,
HttpClientTestingModule,
ApiModule,
ToastrModule.forRoot(),
beforeEach(() => {
fixture = TestBed.createComponent(RbdSnapshotFormComponent);
component = fixture.componentInstance;
- fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
+
+ it('should show "Create" text', () => {
+ fixture.detectChanges();
+
+ const header = fixture.debugElement.nativeElement.querySelector('h4');
+ expect(header.textContent).toBe('Create RBD Snapshot');
+
+ const button = fixture.debugElement.nativeElement.querySelector('cd-submit-button');
+ expect(button.textContent).toBe('Create RBD Snapshot');
+ });
+
+ it('should show "Rename" text', () => {
+ component.setEditing();
+
+ fixture.detectChanges();
+
+ const header = fixture.debugElement.nativeElement.querySelector('h4');
+ expect(header.textContent).toBe('Rename RBD Snapshot');
+
+ const button = fixture.debugElement.nativeElement.querySelector('cd-submit-button');
+ expect(button.textContent).toBe('Rename RBD Snapshot');
+ });
});
import { Component, OnInit } from '@angular/core';
import { FormControl, Validators } from '@angular/forms';
+import { I18n } from '@ngx-translate/i18n-polyfill';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { Subject } from 'rxjs';
import { RbdService } from '../../../shared/api/rbd.service';
+import { ActionLabelsI18n } from '../../../shared/constants/app.constants';
import { CdFormGroup } from '../../../shared/forms/cd-form-group';
import { FinishedTask } from '../../../shared/models/finished-task';
import { NotificationService } from '../../../shared/services/notification.service';
snapshotForm: CdFormGroup;
editing = false;
+ action: string;
+ resource: string;
public onSubmit: Subject<string>;
public modalRef: BsModalRef,
private rbdService: RbdService,
private taskManagerService: TaskManagerService,
- private notificationService: NotificationService
+ private notificationService: NotificationService,
+ private i18n: I18n,
+ private actionLabels: ActionLabelsI18n
) {
+ this.action = this.actionLabels.CREATE;
+ this.resource = this.i18n('RBD Snapshot');
this.createForm();
}
*/
setEditing(editing: boolean = true) {
this.editing = editing;
+ this.action = this.editing ? this.actionLabels.RENAME : this.actionLabels.CREATE;
}
editAction() {
import { NotificationService } from '../../../shared/services/notification.service';
import { SummaryService } from '../../../shared/services/summary.service';
import { TaskListService } from '../../../shared/services/task-list.service';
+import { RbdSnapshotFormComponent } from '../rbd-snapshot-form/rbd-snapshot-form.component';
import { RbdSnapshotListComponent } from './rbd-snapshot-list.component';
import { RbdSnapshotModel } from './rbd-snapshot.model';
beforeEach(() => {
component.poolName = 'pool01';
component.rbdName = 'image01';
- spyOn(TestBed.get(BsModalService), 'show').and.callFake((content) => {
+ spyOn(TestBed.get(BsModalService), 'show').and.callFake(() => {
const ref = new BsModalRef();
- ref.content = new content();
+ ref.content = new RbdSnapshotFormComponent(
+ null,
+ null,
+ null,
+ null,
+ TestBed.get(I18n),
+ TestBed.get(ActionLabelsI18n)
+ );
ref.content.onSubmit = new Subject();
return ref;
});