Skip to content

Commit

Permalink
Merge pull request #541 from appuio/user-settings
Browse files Browse the repository at this point in the history
Handle user not found error in User settings
  • Loading branch information
ccremer authored Apr 20, 2023
2 parents 75f4c36 + 05c81df commit 0402295
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions cypress/e2e/user.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ describe('Test failures', () => {
cy.intercept('GET', 'appuio-api/apis/appuio.io/v1/users/mig', {
statusCode: 403,
});
setOrganization(cy);
cy.visit('/user');

cy.get('#failure-message').should('contain.text', 'User settings could not be loaded.');
Expand Down
7 changes: 5 additions & 2 deletions src/app/user/user-edit/user-edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@
</ng-container>

<ng-container *ngIf="err">
<p-messages severity="error">
<p-messages severity="warn">
<ng-template pTemplate="content">
<fa-icon [icon]="faWarning"/>
<div class="ml-2" i18n id="failure-message">User settings could not be loaded.</div>
<div class="ml-2" i18n id="failure-message">
User settings could not be loaded.
If you're a new user, please try again later, as your settings might take a while to initialize.
</div>
</ng-template>
</p-messages>
</ng-container>
Expand Down
4 changes: 3 additions & 1 deletion src/app/user/user-edit/user-edit.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { combineLatestWith, forkJoin, map, Observable, of } from 'rxjs';
import { catchError, combineLatestWith, forkJoin, map, Observable, of } from 'rxjs';
import { MessageService, SelectItem } from 'primeng/api';
import { faSave, faWarning } from '@fortawesome/free-solid-svg-icons';
import { Organization } from '../../types/organization';
Expand All @@ -10,6 +10,7 @@ import { OrganizationCollectionService } from '../../store/organization-collecti
import { OrganizationMembersCollectionService } from '../../store/organizationmembers-collection.service';
import { UserCollectionService } from '../../store/user-collection.service';
import { switchMap } from 'rxjs/operators';
import { defaultIfStatusCode } from '../../store/kubernetes-collection.service';

@Component({
selector: 'app-user-edit',
Expand Down Expand Up @@ -38,6 +39,7 @@ export class UserEditComponent implements OnInit {
ngOnInit(): void {
const userName = this.identityService.getUsername();
this.payload$ = this.userService.getByKeyMemoized(userName).pipe(
catchError(defaultIfStatusCode(this.userService.newUser(userName), [401, 403, 404])),
switchMap((user) => {
if (user.metadata.resourceVersion) {
return of(user);
Expand Down

0 comments on commit 0402295

Please sign in to comment.