kikocis/dataspace-portal public
Changesets · Branches · Tags · Compare
| Changeset | 41f7e041006864a8d4cf7beddce8a785ac7b1cd8aec3d60954da7efe24283ef5 |
|---|---|
| Author | Kamil Czaja <46053356+kamilczaja@users.noreply.github.com> · 2024-09-12 15:30 +02:00 |
| Committer | GitHub <noreply@github.com> · 2024-09-12 15:30 +02:00 |
| Parents | 6d7191967870 |
5 files changed
modified CHANGELOG.md +1 −0
| @@ -19,6 +19,7 @@ | ||
| 19 | 19 | - Adjusted data source availability naming in the CSV report |
| 20 | 20 | - `LIVE` -> `Available` |
| 21 | 21 | - `ON_REQUEST` -> `On Request` |
| 22 | +- Changed the error message on user/organization invite failures to be more descriptive | |
| 22 | 23 | |
| 23 | 24 | ### Known issues |
| 24 | 25 |
modified authority-portal-frontend/src/app/core/services/error.service.ts +17 −0
| @@ -36,4 +36,21 @@ | ||
| 36 | 36 | return EMPTY; |
| 37 | 37 | }); |
| 38 | 38 | } |
| 39 | + | |
| 40 | + toastRegistrationErrorRxjs<T>( | |
| 41 | + genericFailureMessage: string, | |
| 42 | + onError?: () => void, | |
| 43 | + ): MonoTypeOperatorFunction<T> { | |
| 44 | + return catchError((err) => { | |
| 45 | + let errorMessage = genericFailureMessage; | |
| 46 | + if (err?.response?.status === 409) { | |
| 47 | + errorMessage = 'A user with this email address already exists.'; | |
| 48 | + } | |
| 49 | + this.toastFailure(errorMessage); | |
| 50 | + if (onError) { | |
| 51 | + onError(); | |
| 52 | + } | |
| 53 | + return EMPTY; | |
| 54 | + }); | |
| 55 | + } | |
| 39 | 56 | } |
modified authority-portal-frontend/src/app/pages/authority-organization-list-page/authority-invite-new-organization/state/authority-invite-new-organization-page-state-impl.ts +9 −6
| @@ -22,9 +22,9 @@ | ||
| 22 | 22 | ofAction, |
| 23 | 23 | } from '@ngxs/store'; |
| 24 | 24 | import {ApiService} from 'src/app/core/api/api.service'; |
| 25 | -import {ErrorService} from 'src/app/core/services/error.service'; | |
| 26 | 25 | import {RefreshOrganizations} from 'src/app/pages/authority-organization-list-page/authority-organization-list-page/state/authority-organization-list-page-actions'; |
| 27 | 26 | import {ToastService} from 'src/app/shared/common/toast-notifications/toast.service'; |
| 27 | +import {ErrorService} from '../../../../core/services/error.service'; | |
| 28 | 28 | import { |
| 29 | 29 | InviteNewOrganization, |
| 30 | 30 | Reset, |
| @@ -44,8 +44,8 @@ | ||
| 44 | 44 | private apiService: ApiService, |
| 45 | 45 | private toast: ToastService, |
| 46 | 46 | private actions$: Actions, |
| 47 | - private errorService: ErrorService, | |
| 48 | 47 | private store: Store, |
| 48 | + private errorService: ErrorService, | |
| 49 | 49 | ) {} |
| 50 | 50 | |
| 51 | 51 | @Action(Reset) |
| @@ -69,10 +69,13 @@ | ||
| 69 | 69 | this.store.dispatch(RefreshOrganizations); |
| 70 | 70 | }), |
| 71 | 71 | takeUntil(this.actions$.pipe(ofAction(Reset))), |
| 72 | - this.errorService.toastFailureRxjs('Failed Inviting Organization', () => { | |
| 73 | - ctx.patchState({state: 'error'}); | |
| 74 | - action.enableForm(); | |
| 75 | - }), | |
| 72 | + this.errorService.toastRegistrationErrorRxjs( | |
| 73 | + 'Failed inviting organization due to an unknown error.', | |
| 74 | + () => { | |
| 75 | + ctx.patchState({state: 'error'}); | |
| 76 | + action.enableForm(); | |
| 77 | + }, | |
| 78 | + ), | |
| 76 | 79 | ignoreElements(), |
| 77 | 80 | ); |
| 78 | 81 | } |
modified authority-portal-frontend/src/app/pages/control-center-organization-members-page/participant-invite-new-user/state/participant-invite-new-user-page-state-impl.ts +8 −5
| @@ -15,8 +15,8 @@ | ||
| 15 | 15 | import {ignoreElements, takeUntil, tap} from 'rxjs/operators'; |
| 16 | 16 | import {Action, Actions, State, StateContext, ofAction} from '@ngxs/store'; |
| 17 | 17 | import {ApiService} from 'src/app/core/api/api.service'; |
| 18 | -import {ErrorService} from 'src/app/core/services/error.service'; | |
| 19 | 18 | import {ToastService} from 'src/app/shared/common/toast-notifications/toast.service'; |
| 19 | +import {ErrorService} from '../../../../core/services/error.service'; | |
| 20 | 20 | import {InviteNewUser, Reset} from './participant-invite-new-user-page-actions'; |
| 21 | 21 | import { |
| 22 | 22 | DEFAULT_PARTICIPANT_INVITE_NEW_USER_PAGE_STATE, |
| @@ -50,10 +50,6 @@ | ||
| 50 | 50 | action.disableForm(); |
| 51 | 51 | return this.apiService.inviteUser(action.request).pipe( |
| 52 | 52 | takeUntil(this.actions$.pipe(ofAction(Reset))), |
| 53 | - this.errorService.toastFailureRxjs('Failed Inviting User', () => { | |
| 54 | - ctx.patchState({state: 'error'}); | |
| 55 | - action.enableForm(); | |
| 56 | - }), | |
| 57 | 53 | tap(() => { |
| 58 | 54 | this.toast.showSuccess( |
| 59 | 55 | `The invitation for ${action.request.firstName} ${action.request.lastName} was sent.`, |
| @@ -61,6 +57,13 @@ | ||
| 61 | 57 | ctx.patchState({state: 'success'}); |
| 62 | 58 | action.success(); |
| 63 | 59 | }), |
| 60 | + this.errorService.toastRegistrationErrorRxjs( | |
| 61 | + 'Failed inviting user due to an unknown error.', | |
| 62 | + () => { | |
| 63 | + ctx.patchState({state: 'error'}); | |
| 64 | + action.enableForm(); | |
| 65 | + }, | |
| 66 | + ), | |
| 64 | 67 | ignoreElements(), |
| 65 | 68 | ); |
| 66 | 69 | } |
modified authority-portal-frontend/src/app/pages/registration-pages/organization-create-page/state/organization-create-page-state-impl.ts +10 −13
| @@ -11,12 +11,13 @@ | ||
| 11 | 11 | * sovity GmbH - initial implementation |
| 12 | 12 | */ |
| 13 | 13 | import {Inject, Injectable} from '@angular/core'; |
| 14 | -import {Observable, of} from 'rxjs'; | |
| 14 | +import {EMPTY, Observable, of} from 'rxjs'; | |
| 15 | 15 | import {catchError, ignoreElements, takeUntil, tap} from 'rxjs/operators'; |
| 16 | 16 | import {Action, Actions, State, StateContext, ofAction} from '@ngxs/store'; |
| 17 | 17 | import {ApiService} from 'src/app/core/api/api.service'; |
| 18 | 18 | import {APP_CONFIG, AppConfig} from 'src/app/core/services/config/app-config'; |
| 19 | 19 | import {ToastService} from 'src/app/shared/common/toast-notifications/toast.service'; |
| 20 | +import {ErrorService} from '../../../../core/services/error.service'; | |
| 20 | 21 | import {CreateOrganization, Reset} from './organization-create-page-action'; |
| 21 | 22 | import { |
| 22 | 23 | DEFAULT_ORGANIZATION_REGISTRATION_PAGE_STATE, |
| @@ -34,6 +35,7 @@ | ||
| 34 | 35 | private apiService: ApiService, |
| 35 | 36 | private toast: ToastService, |
| 36 | 37 | private actions$: Actions, |
| 38 | + private errorService: ErrorService, | |
| 37 | 39 | ) {} |
| 38 | 40 | |
| 39 | 41 | @Action(Reset) |
| @@ -57,18 +59,13 @@ | ||
| 57 | 59 | action.success(); |
| 58 | 60 | }), |
| 59 | 61 | takeUntil(this.actions$.pipe(ofAction(Reset))), |
| 60 | - catchError((err) => { | |
| 61 | - let errorMessage = 'Registration failed due to an unknown error.'; | |
| 62 | - console.log(err); | |
| 63 | - console.log(err.status); | |
| 64 | - if (err?.response?.status === 409) { | |
| 65 | - errorMessage = 'This e-mail address is already registered.'; | |
| 66 | - } | |
| 67 | - this.toast.showDanger(errorMessage); | |
| 68 | - ctx.patchState({state: 'error'}); | |
| 69 | - action.enableForm(); | |
| 70 | - return of(null); | |
| 71 | - }), | |
| 62 | + this.errorService.toastRegistrationErrorRxjs( | |
| 63 | + 'Registration failed due to an unknown error', | |
| 64 | + () => { | |
| 65 | + ctx.patchState({state: 'error'}); | |
| 66 | + action.enableForm(); | |
| 67 | + }, | |
| 68 | + ), | |
| 72 | 69 | ignoreElements(), |
| 73 | 70 | ); |
| 74 | 71 | } |