Skip to content
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

The focus is not moved to the snackbar with certificate validation rule #470

Merged
merged 3 commits into from
May 23, 2024
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
1 change: 1 addition & 0 deletions modules/ui/src/app/app.store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ describe('AppStore', () => {
store.overrideSelector(selectMenuOpened, true);
store.overrideSelector(selectInterfaces, {});
store.overrideSelector(selectError, null);
store.overrideSelector(selectStatus, null);

spyOn(store, 'dispatch').and.callFake(() => {});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ describe('CertificatesStore', () => {
expect(notificationServiceMock.notify).toHaveBeenCalledWith(
'Certificate successfully added.\niot.bms.google.com by Google, Inc. valid until 01 Sep 2024',
0,
'certificate-notification'
'certificate-notification',
10000
);
});
});
Expand All @@ -155,7 +156,8 @@ describe('CertificatesStore', () => {
expect(notificationServiceMock.notify).toHaveBeenCalledWith(
'The file name should be alphanumeric, symbols -_. are allowed.\nFile extension must be .cert, .crt, .pem, .cer.\nMax name length is 24 characters.\nFile size should be a max of 4KB',
0,
'certificate-notification'
'certificate-notification',
19000
);
});
});
Expand Down
9 changes: 8 additions & 1 deletion modules/ui/src/app/pages/certificates/certificates.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export interface AppComponentState {
certificates: Certificate[];
selectedCertificate: string;
}

const SYMBOLS_PER_SECOND = 9.5;
@Injectable()
export class CertificatesStore extends ComponentStore<AppComponentState> {
private certificates$ = this.select(state => state.certificates);
Expand Down Expand Up @@ -128,7 +130,12 @@ export class CertificatesStore extends ComponentStore<AppComponentState> {
});

private notify(message: string) {
this.notificationService.notify(message, 0, 'certificate-notification');
this.notificationService.notify(
message,
0,
'certificate-notification',
Math.ceil(message.length / SYMBOLS_PER_SECOND) * 1000
);
}

private removeCertificate(name: string, current: Certificate[]) {
Expand Down
4 changes: 2 additions & 2 deletions modules/ui/src/app/services/notification.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('NotificationService', () => {

expect(openSpy).toHaveBeenCalledWith('something good happened', 'OK', {
horizontalPosition: 'center',
panelClass: 'test-run-notification',
panelClass: ['test-run-notification'],
duration: 0,
politeness: 'assertive',
});
Expand All @@ -79,7 +79,7 @@ describe('NotificationService', () => {

expect(openSpy).toHaveBeenCalledWith('something good happened', 'OK', {
horizontalPosition: 'center',
panelClass: 'test-run-notification',
panelClass: ['test-run-notification'],
duration: 15000,
politeness: 'assertive',
});
Expand Down
10 changes: 7 additions & 3 deletions modules/ui/src/app/services/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,21 @@ export class NotificationService {
private focusManagerService: FocusManagerService
) {}

notify(message: string, duration = 0, panelClass = 'test-run-notification') {
notify(message: string, duration = 0, panelClass = '', timeout = TIMEOUT_MS) {
const panelClasses = ['test-run-notification'];
if (panelClass) {
panelClasses.push(panelClass);
}
this.snackBarRef = this.snackBar.open(message, 'OK', {
horizontalPosition: 'center',
panelClass: panelClass,
panelClass: panelClasses,
duration: duration,
politeness: 'assertive',
});

this.snackBarRef
.afterOpened()
.pipe(take(1), delay(TIMEOUT_MS))
.pipe(take(1), delay(timeout))
.subscribe(() => this.setFocusToActionButton());

this.snackBarRef
Expand Down
Loading