Skip to content

Commit

Permalink
SHIBUI Added error notification when update fails
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Feb 28, 2019
1 parent dc6c4c5 commit 7f51cfc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/metadata/provider/action/collection.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class UpdateProviderSuccess implements Action {
export class UpdateProviderFail implements Action {
readonly type = ProviderCollectionActionTypes.UPDATE_PROVIDER_FAIL;

constructor(public payload: MetadataProvider) { }
constructor(public payload: any) { }
}

export class UpdateProviderConflict implements Action {
Expand Down
16 changes: 15 additions & 1 deletion ui/src/app/metadata/provider/effect/collection.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class CollectionEffects {
.update(provider)
.pipe(
map(p => new UpdateProviderSuccess({id: p.id, changes: p})),
catchError((e) => e.status === 409 ? of(new UpdateProviderConflict(provider)) : of(new UpdateProviderFail(provider)))
catchError((e) => e.status === 409 ? of(new UpdateProviderConflict(provider)) : of(new UpdateProviderFail(e.error)))
)
)
);
Expand All @@ -166,6 +166,20 @@ export class CollectionEffects {
})
);

@Effect()
updateProviderFailDispatchNotification$ = this.actions$.pipe(
ofType<UpdateProviderFail>(ProviderCollectionActionTypes.UPDATE_PROVIDER_FAIL),
map(action => action.payload),
withLatestFrom(this.store.select(fromI18n.getMessages)),
map(([error, messages]) => new AddNotification(
new Notification(
NotificationType.Danger,
`${error.errorCode}: ${this.i18nService.translate(error.errorMessage, null, messages)}`,
8000
)
))
);

@Effect()
addProviderSuccessReload$ = this.actions$.pipe(
ofType<AddProviderSuccess>(ProviderCollectionActionTypes.ADD_PROVIDER_SUCCESS),
Expand Down

0 comments on commit 7f51cfc

Please sign in to comment.