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

removed unused payload field from event #1156

Merged
merged 2 commits into from
Apr 11, 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
4 changes: 2 additions & 2 deletions ui/src/app/account/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
private eventService: EventService,
private ngZone: NgZone
) {
this.sub = this.eventService.on(EventType.LOG_IN_SUCCESS).subscribe((e) => {

Check warning on line 40 in ui/src/app/account/login/login.component.ts

View workflow job for this annotation

GitHub Actions / format

'e' is defined but never used
console.log(e.payload)
console.log('login success')
})
}

Expand Down Expand Up @@ -72,8 +72,8 @@

this.loginService
.login({
username: this.loginForm.get('username')!.value!,

Check warning on line 75 in ui/src/app/account/login/login.component.ts

View workflow job for this annotation

GitHub Actions / format

Forbidden non-null assertion

Check warning on line 75 in ui/src/app/account/login/login.component.ts

View workflow job for this annotation

GitHub Actions / format

Forbidden non-null assertion
password: this.loginForm.get('password')!.value!,

Check warning on line 76 in ui/src/app/account/login/login.component.ts

View workflow job for this annotation

GitHub Actions / format

Forbidden non-null assertion

Check warning on line 76 in ui/src/app/account/login/login.component.ts

View workflow job for this annotation

GitHub Actions / format

Forbidden non-null assertion
mfaCode: this.loginForm.get('mfaCode')?.value,
})
.subscribe({
Expand Down Expand Up @@ -109,7 +109,7 @@
this.router.navigate([''])
})

this.eventService.broadcast(new Event(EventType.LOG_IN_SUCCESS, 'logged in'))
this.eventService.broadcast(new Event(EventType.LOG_IN_SUCCESS))

// previousState was set in the authExpiredInterceptor before being redirected to login modal.
// since login is successful, go to stored previousState and clear previousState
Expand Down
8 changes: 2 additions & 6 deletions ui/src/app/affiliation/affiliation-delete.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,14 @@ describe('AffiliationDeleteComponent', () => {
affiliationService.delete.and.returnValue(of(true))
component.confirmDelete('id')

expect(eventService.broadcast).toHaveBeenCalledWith(
new Event(EventType.AFFILIATION_LIST_MODIFICATION, 'Deleted an affiliation')
)
expect(eventService.broadcast).toHaveBeenCalledWith(new Event(EventType.AFFILIATION_LIST_MODIFICATION))
})

it('should fail to delete the affiliation', () => {
affiliationService.delete.and.returnValue(of(false))
component.confirmDelete('id')

expect(eventService.broadcast).toHaveBeenCalledWith(
new Event(EventType.AFFILIATION_LIST_MODIFICATION, 'Failed to delete an affiliation')
)
expect(eventService.broadcast).toHaveBeenCalledWith(new Event(EventType.AFFILIATION_LIST_MODIFICATION))
})

it('should not call the assertion service without an id', () => {
Expand Down
6 changes: 2 additions & 4 deletions ui/src/app/affiliation/affiliation-delete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ export class AffiliationDeleteDialogComponent implements OnInit {
if (id) {
this.affiliationService.delete(id).subscribe((response) => {
if (response) {
this.eventService.broadcast(new Event(EventType.AFFILIATION_LIST_MODIFICATION, 'Deleted an affiliation'))
this.eventService.broadcast(new Event(EventType.AFFILIATION_LIST_MODIFICATION))
this.alertService.broadcast(AlertType.AFFILIATION_DELETED)
} else {
this.eventService.broadcast(
new Event(EventType.AFFILIATION_LIST_MODIFICATION, 'Failed to delete an affiliation')
)
this.eventService.broadcast(new Event(EventType.AFFILIATION_LIST_MODIFICATION))
this.alertService.broadcast(AlertType.AFFILIATION_DELETE_FAILURE)
}
this.activeModal.dismiss(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class AffiliationImportDialogComponent {
}

close() {
this.eventService.broadcast(new Event(EventType.IMPORT_AFFILIATIONS, ''))
this.eventService.broadcast(new Event(EventType.IMPORT_AFFILIATIONS))
this.activeModal.dismiss(true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export class SendNotificationsDialogComponent implements OnInit {
close() {
this.eventService.broadcast({
type: EventType.SEND_NOTIFICATIONS,
payload: 'Send notifications',
})
this.activeModal.dismiss(true)
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/member/member-import-dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class MemberImportDialogComponent {
this.csvErrors = JSON.parse(res)
this.loading = false
if (this.csvErrors.length === 0) {
this.eventService.broadcast(new Event(EventType.MEMBER_LIST_MODIFICATION, 'New member uploaded'))
this.eventService.broadcast(new Event(EventType.MEMBER_LIST_MODIFICATION))
this.activeModal.dismiss(true)
}
}
Expand Down
5 changes: 1 addition & 4 deletions ui/src/app/shared/model/event.model.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { EventType } from 'src/app/app.constants'

export class Event {
constructor(
public type: EventType,
public payload: string
) {}
constructor(public type: EventType) {}
}
4 changes: 1 addition & 3 deletions ui/src/app/shared/service/event.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe('EventService', () => {
it('should broadcast events', () => {
const event: Event = {
type: EventType.LOG_IN_SUCCESS,
payload: 'Login successful',
}
let receivedEvent: Event | undefined

Expand All @@ -30,10 +29,9 @@ describe('EventService', () => {
})

it('should filter events by type', () => {
const event1: Event = { type: EventType.LOG_IN_SUCCESS, payload: 'data 1' }
const event1: Event = { type: EventType.LOG_IN_SUCCESS }
const event2: Event = {
type: EventType.AFFILIATION_CREATED,
payload: 'data 2',
}
let receivedEvent: Event | undefined

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/user/user-delete.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('UserDeleteComponent', () => {
userServiceSpy.delete.and.returnValue(of(true))
component.confirmDelete('id')

expect(eventServiceSpy.broadcast).toHaveBeenCalledWith(new Event(EventType.USER_LIST_MODIFIED, 'Deleted a user'))
expect(eventServiceSpy.broadcast).toHaveBeenCalledWith(new Event(EventType.USER_LIST_MODIFIED))
})

it('should not call the userservice without a provided id', () => {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/user/user-delete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class UserDeleteDialogComponent implements OnInit {
confirmDelete(id: string | undefined) {
if (id) {
this.userService.delete(id).subscribe(() => {
this.eventService.broadcast(new Event(EventType.USER_LIST_MODIFIED, 'Deleted a user'))
this.eventService.broadcast(new Event(EventType.USER_LIST_MODIFIED))
this.activeModal.dismiss(true)
this.alertService.broadcast(AlertType.USER_DELETED)
})
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/user/user-import-dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class UserImportDialogComponent {
this.csvErrors = JSON.parse(res)
this.loading = false
if (this.csvErrors.length === 0) {
this.eventService.broadcast(new Event(EventType.USER_LIST_MODIFIED, 'New user settings uploaded'))
this.eventService.broadcast(new Event(EventType.USER_LIST_MODIFIED))
this.activeModal.dismiss(true)
}
}
Expand Down
Loading