-<cd-modal [modalRef]="activeModal">
- <ng-container class="modal-title"
- i18n>Cluster-wide OSD Flags</ng-container>
+<cds-modal size="sm"
+ [open]="open"
+ [hasScrollingContent]="true"
+ (overlaySelected)="closeModal()">
+ <cds-modal-header (closeSelect)="closeModal()">
+ <h3 cdsModalHeaderHeading
+ modal-primary-focus
+ i18n>Cluster-wide OSD Flags</h3>
+ </cds-modal-header>
- <ng-container class="modal-content">
+ <div cdsModalContent>
<form name="osdFlagsForm"
- #formDir="ngForm"
[formGroup]="osdFlagsForm"
- novalidate
- cdFormScope="osd">
- <div class="modal-body osd-modal">
- <div class="custom-control custom-checkbox"
- *ngFor="let flag of flags; let last = last">
- <input class="custom-control-input"
- type="checkbox"
- [checked]="flag.value"
- (change)="flag.value = !flag.value"
- [name]="flag.code"
- [id]="flag.code"
- [disabled]="flag.disabled">
- <label class="custom-control-label"
- [for]="flag.code"
- ng-class="['tc_' + key]">
+ novalidate>
+ <div>
+ @for (flag of flags; track flag.code; let last = $last) {
+ <div>
+ <cds-checkbox
+ [checked]="flag.value"
+ (checkedChange)="flag.value = !flag.value"
+ [name]="flag.code"
+ [id]="flag.code"
+ [disabled]="flag.disabled"
+ >
<strong>{{ flag.name }}</strong>
- <br>
- <span class="form-text text-muted">{{ flag.description }}</span>
- </label>
- <hr class="m-1"
- *ngIf="!last">
- </div>
- </div>
- <div class="modal-footer">
- <cd-form-button-panel (submitActionEvent)="submitAction()"
- [form]="osdFlagsForm"
- [showSubmit]="permissions.osd.update"
- [submitText]="actionLabels.UPDATE"></cd-form-button-panel>
+ <div class="cds-mt-4">
+ <cd-help-text>{{ flag.description }}</cd-help-text>
+ </div>
+ </cds-checkbox>
+ @if (!last) {
+ <hr class="cds-m-2" />
+ }
+ </div>
+ }
</div>
</form>
- </ng-container>
-</cd-modal>
+ </div>
+
+ <cds-modal-footer>
+ <cds-button-set>
+ <button cdsButton="secondary"
+ (click)="closeModal()"
+ i18n>
+ Cancel
+ </button>
+ @if (permissions.osd.update) {
+ <cd-submit-button
+ (submitAction)="submitAction()"
+ [form]="osdFlagsForm"
+ [submitText]="actionLabels.UPDATE">
+ {{ actionLabels.UPDATE }}</cd-submit-button>
+ }
+ </cds-button-set>
+ </cds-modal-footer>
+</cds-modal>
import { ReactiveFormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
-import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+import { ModalService } from 'carbon-components-angular';
import _ from 'lodash';
import { ToastrModule } from 'ngx-toastr';
ToastrModule.forRoot()
],
declarations: [OsdFlagsModalComponent],
- providers: [NgbActiveModal]
+ providers: [ModalService]
});
beforeEach(() => {
describe('test submitAction', function () {
let notificationType: NotificationType;
let notificationService: NotificationService;
- let bsModalRef: NgbActiveModal;
beforeEach(() => {
notificationService = TestBed.inject(NotificationService);
notificationType = type;
});
- bsModalRef = TestBed.inject(NgbActiveModal);
- spyOn(bsModalRef, 'close').and.callThrough();
+ spyOn(component, 'closeModal');
component.unknownFlags = ['foo'];
});
expect(req.request.body).toEqual({ flags: ['pause', 'purged_snapdirs', 'foo'] });
expect(notificationType).toBe(NotificationType.success);
- expect(component.activeModal.close).toHaveBeenCalledTimes(1);
+ expect(component.closeModal).toHaveBeenCalledTimes(1);
});
it('should hide modal if request fails', () => {
req.flush([], { status: 500, statusText: 'failure' });
expect(notificationService.show).toHaveBeenCalledTimes(0);
- expect(component.activeModal.close).toHaveBeenCalledTimes(1);
+ expect(component.closeModal).toHaveBeenCalledTimes(1);
});
});
});
import { Component, OnInit } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
-import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+import { CdForm } from '~/app/shared/forms/cd-form';
import _ from 'lodash';
import { OsdService } from '~/app/shared/api/osd.service';
styleUrls: ['./osd-flags-modal.component.scss'],
standalone: false
})
-export class OsdFlagsModalComponent implements OnInit {
+export class OsdFlagsModalComponent extends CdForm implements OnInit {
permissions: Permissions;
osdFlagsForm = new UntypedFormGroup({});
unknownFlags: string[] = [];
constructor(
- public activeModal: NgbActiveModal,
public actionLabels: ActionLabelsI18n,
private authStorageService: AuthStorageService,
private osdService: OsdService,
private notificationService: NotificationService
) {
+ super();
this.permissions = this.authStorageService.getPermissions();
}
this.osdService.updateFlags(newFlags).subscribe(
() => {
this.notificationService.show(NotificationType.success, $localize`Updated OSD Flags`);
- this.activeModal.close();
+ this.closeModal();
},
() => {
- this.activeModal.close();
+ this.closeModal();
}
);
}
}
configureFlagsAction() {
- this.bsModalRef = this.modalService.show(OsdFlagsModalComponent);
+ this.bsModalRef = this.cdsModalService.show(OsdFlagsModalComponent);
}
configureFlagsIndivAction() {