Commit 6f7aa68c authored by Yogi_Wang's avatar Yogi_Wang
Browse files

[fix][unauthorized] Support show relogin when unauthorized in popup modal


1.support show relogin when unauthorized  in popup modali
2.change change member role error handle
3.change helm chart service error handle
Signed-off-by: default avatarYogi_Wang <yawang@vmware.com>
parent 6db856c3
......@@ -17,6 +17,7 @@ import { clone } from '../../../lib/utils/utils';
import { ConfirmationDialogComponent } from '../../shared/confirmation-dialog/confirmation-dialog.component';
import { ConfirmationDialogService } from '../../shared/confirmation-dialog/confirmation-dialog.service';
import { ConfirmationMessage } from '../../shared/confirmation-dialog/confirmation-message';
import { ErrorHandler } from '../../../lib/utils/error-handler';
describe('AccountSettingsModalComponent', () => {
let component: AccountSettingsModalComponent;
......@@ -78,6 +79,7 @@ describe('AccountSettingsModalComponent', () => {
providers: [
ChangeDetectorRef,
TranslateService,
ErrorHandler,
{ provide: SessionService, useValue: fakeSessionService },
{ provide: MessageHandlerService, useValue: fakeMessageHandlerService },
{ provide: SearchTriggerService, useValue: fakeSearchTriggerService },
......
......@@ -8,6 +8,7 @@ import { PasswordSettingService } from '../password-setting.service';
import { InlineAlertComponent } from '../../../shared/inline-alert/inline-alert.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { of } from 'rxjs';
import { ErrorHandler } from '../../../../lib/utils/error-handler';
describe('ForgotPasswordComponent', () => {
let component: ForgotPasswordComponent;
......@@ -28,6 +29,7 @@ describe('ForgotPasswordComponent', () => {
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
TranslateService,
ErrorHandler,
{ provide: PasswordSettingService, useValue: fakePasswordSettingService }
]
}).compileComponents();
......
......@@ -10,6 +10,7 @@ import { FormsModule } from '@angular/forms';
import { InlineAlertComponent } from '../../shared/inline-alert/inline-alert.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { of } from 'rxjs';
import { ErrorHandler } from '../../../lib/utils/error-handler';
describe('PasswordSettingComponent', () => {
let component: PasswordSettingComponent;
......@@ -37,7 +38,8 @@ describe('PasswordSettingComponent', () => {
TranslateService,
{ provide: PasswordSettingService, useValue: fakePasswordSettingService },
{ provide: SessionService, useValue: fakeSessionService },
{ provide: MessageHandlerService, useValue: fakeMessageHandlerService }
{ provide: MessageHandlerService, useValue: fakeMessageHandlerService },
ErrorHandler
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents();
......
......@@ -9,6 +9,7 @@ import { MessageHandlerService } from '../../../shared/message-handler/message-h
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ClarityModule } from '@clr/angular';
import { InlineAlertComponent } from '../../../shared/inline-alert/inline-alert.component';
import { ErrorHandler } from '../../../../lib/utils/error-handler';
describe('ResetPasswordComponent', () => {
let component: ResetPasswordComponent;
......@@ -30,6 +31,7 @@ describe('ResetPasswordComponent', () => {
TranslateService,
{ provide: PasswordSettingService, useValue: fakePasswordSettingService },
{ provide: MessageHandlerService, useValue: fakeMessageHandlerService },
ErrorHandler
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
......
......@@ -10,6 +10,7 @@ import { FormsModule } from '@angular/forms';
import { InlineAlertComponent } from '../../shared/inline-alert/inline-alert.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { of } from 'rxjs';
import { ErrorHandler } from '../../../lib/utils/error-handler';
describe('SignUpComponent', () => {
let component: SignUpComponent;
......@@ -47,7 +48,8 @@ describe('SignUpComponent', () => {
providers: [
TranslateService,
{ provide: SessionService, useValue: fakeSessionService },
{ provide: UserService, useValue: fakeUserService }
{ provide: UserService, useValue: fakeUserService },
ErrorHandler
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
......
......@@ -20,6 +20,7 @@ import { PasswordSettingService } from '../../account/password-setting/password-
import { SkinableConfig } from '../../services/skinable-config.service';
import { InlineAlertComponent } from '../../shared/inline-alert/inline-alert.component';
import { AppConfigService } from "../../services/app-config.service";
import { ErrorHandler } from '../../../lib/utils/error-handler';
describe('HarborShellComponent', () => {
let component: HarborShellComponent;
......@@ -86,6 +87,7 @@ describe('HarborShellComponent', () => {
{ provide: AccountSettingsModalService, useValue: mockAccountSettingsModalService },
{ provide: PasswordSettingService, useValue: mockPasswordSettingService },
{ provide: SkinableConfig, useValue: mockSkinableConfig },
ErrorHandler
],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
}).compileComponents();
......
<div [class.alert-app-level]="!isAppLevel" [hidden]="!globalMessageOpened">
<clr-alert [clrAlertType]="globalMessage.type" [clrAlertAppLevel]="isAppLevel" [(clrAlertClosed)]="!globalMessageOpened" (clrAlertClosedChange)="onClose()">
<clr-alert [clrAlertType]="globalMessage.type" [clrAlertClosable]="!needAuth" [clrAlertAppLevel]="isAppLevel" [(clrAlertClosed)]="!globalMessageOpened" (clrAlertClosedChange)="onClose()">
<div class="alert-item">
<span class="alert-text">{{message}}</span>
<div class="alert-actions alert-style" *ngIf="needAuth">
......
......@@ -5,5 +5,5 @@
position: absolute;
width: 100%;
height: 100%;
z-index: 10000;
z-index: 1000;
}
\ No newline at end of file
......@@ -126,7 +126,7 @@ export class MessageComponent implements OnInit, OnDestroy {
}
signIn(): void {
this.router.navigateByUrl(CommonRoutes.EMBEDDED_SIGN_IN);
this.router.navigate([ CommonRoutes.EMBEDDED_SIGN_IN ], {queryParams: {redirect_url: this.router.url}});
}
onClose() {
......
......@@ -10,6 +10,7 @@ import { ProjectService } from "../../../lib/services";
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { of } from 'rxjs';
import { delay } from 'rxjs/operators';
import { ErrorHandler } from '../../../lib/utils/error-handler';
describe('CreateProjectComponent', () => {
let component: CreateProjectComponent;
......@@ -47,6 +48,7 @@ describe('CreateProjectComponent', () => {
TranslateService,
{provide: ProjectService, useValue: mockProjectService},
{provide: MessageHandlerService, useValue: mockMessageHandlerService},
ErrorHandler
]
}).compileComponents();
}));
......
......@@ -105,7 +105,7 @@ export class HelmChartDefaultService extends HelmChartService {
private handleErrorObservable(error: HttpErrorResponse) {
return observableThrowError(error.error || error);
return observableThrowError(error);
}
public getHelmCharts(
......
......@@ -12,6 +12,7 @@ import { UserService } from '../../../user/user.service';
import { of } from 'rxjs';
import { MessageHandlerService } from '../../../shared/message-handler/message-handler.service';
import { ActivatedRoute } from '@angular/router';
import { ErrorHandler } from '../../../../lib/utils/error-handler';
describe('AddMemberComponent', () => {
let component: AddMemberComponent;
......@@ -54,6 +55,7 @@ describe('AddMemberComponent', () => {
{ provide: MemberService, useValue: mockMemberService },
{ provide: UserService, useValue: mockUserService },
{ provide: MessageHandlerService, useValue: mockMessageHandlerService },
ErrorHandler,
{
provide: ActivatedRoute, useValue: {
RouterparamMap: of({ get: (key) => 'value' }),
......
......@@ -37,8 +37,7 @@ import {User} from "../../../user/user";
import {Project} from "../../project";
import { Member } from '../member';
import { MemberService } from '../member.service';
import { HttpResponseBase } from '@angular/common/http';
import { errorHandler } from "../../../../lib/utils/shared/shared.utils";
import { ErrorHandler } from '../../../../lib/utils/error-handler';
@Component({
......@@ -80,6 +79,7 @@ export class AddMemberComponent implements AfterViewChecked, OnInit, OnDestroy {
constructor(private memberService: MemberService,
private userService: UserService,
private errorHandle: ErrorHandler,
private messageHandlerService: MessageHandlerService,
private translateService: TranslateService,
private route: ActivatedRoute,
......@@ -158,22 +158,10 @@ export class AddMemberComponent implements AfterViewChecked, OnInit, OnDestroy {
() => {
this.messageHandlerService.showSuccess('MEMBER.ADDED_SUCCESS');
this.added.emit(true);
// this.addMemberOpened = false;
},
error => {
if (error instanceof HttpResponseBase) {
if (this.messageHandlerService.isAppLevel(error)) {
this.messageHandlerService.handleError(error);
// this.addMemberOpened = false;
} else {
let errorMessageKey: string = errorHandler(error);
this.translateService
.get(errorMessageKey)
.subscribe(errorMessage => this.messageHandlerService.handleError(errorMessage));
}
}
this.errorHandle.error(error);
});
// this.addMemberOpened = false;
}
selectedName(username: string) {
......
......@@ -202,7 +202,7 @@ export class MemberComponent implements OnInit, OnDestroy {
.changeMemberRole(projectId, member.id, roleId)
.pipe(map(() => this.batchChangeRoleInfos[member.id] = 'done')
, catchError(error => {
this.messageHandlerService.handleError(error + ": " + member.entity_name);
this.messageHandlerService.handleError(error);
return observableThrowError(error);
}));
};
......
......@@ -9,6 +9,8 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { NoopAnimationsModule } from "@angular/platform-browser/animations";
import { InlineAlertComponent } from "../../../../shared/inline-alert/inline-alert.component";
import { ImmutableRetentionRule } from "../../tag-retention/retention";
import { ErrorHandler } from '../../../../../lib/utils/error-handler';
describe('AddRuleComponent', () => {
let component: AddRuleComponent;
let fixture: ComponentFixture<AddRuleComponent>;
......@@ -36,7 +38,9 @@ describe('AddRuleComponent', () => {
]
}
};
const mockErrorHandler = {
handleErrorPopupUnauthorized: () => {}
}
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AddRuleComponent, InlineAlertComponent],
......@@ -51,7 +55,11 @@ describe('AddRuleComponent', () => {
TranslateModule.forRoot()
],
providers: [
ImmutableTagService
ImmutableTagService,
ErrorHandler,
{
provide: ErrorHandler, useValue: mockErrorHandler
}
]
})
.compileComponents();
......
......@@ -11,10 +11,12 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TagRetentionService } from "../tag-retention.service";
import { InlineAlertComponent } from "../../../../shared/inline-alert/inline-alert.component";
import { delay } from 'rxjs/operators';
import { ErrorHandler } from '../../../../../lib/utils/error-handler';
describe('AddRuleComponent', () => {
let component: AddRuleComponent;
let fixture: ComponentFixture<AddRuleComponent>;
const mockTagRetentionService = { };
beforeEach(async(() => {
TestBed.configureTestingModule({
schemas: [
......@@ -32,6 +34,7 @@ describe('AddRuleComponent', () => {
declarations: [AddRuleComponent, InlineAlertComponent],
providers: [
TranslateService,
ErrorHandler,
{ provide: TagRetentionService, useValue: mockTagRetentionService },
]
})
......
......@@ -11,6 +11,7 @@ import { MessageHandlerService } from "../../../shared/message-handler/message-h
import { of } from 'rxjs';
import { Webhook } from "../webhook";
import { InlineAlertComponent } from "../../../shared/inline-alert/inline-alert.component";
import { ErrorHandler } from '../../../../lib/utils/error-handler';
describe('AddWebhookFormComponent', () => {
let component: AddWebhookFormComponent;
......@@ -91,6 +92,7 @@ describe('AddWebhookFormComponent', () => {
TranslateService,
{ provide: WebhookService, useValue: mockWebhookService },
{ provide: MessageHandlerService, useValue: mockMessageHandlerService },
ErrorHandler
]
......
......@@ -18,6 +18,8 @@ import { InlineAlertComponent } from "../../shared/inline-alert/inline-alert.com
import { AddWebhookComponent } from "./add-webhook/add-webhook.component";
import { ConfirmationDialogComponent } from "../../../lib/components/confirmation-dialog";
import { UserPermissionService } from '../../../lib/services';
import { ErrorHandler } from '../../../lib/utils/error-handler';
describe('WebhookComponent', () => {
let component: WebhookComponent;
let fixture: ComponentFixture<WebhookComponent>;
......@@ -121,6 +123,7 @@ describe('WebhookComponent', () => {
],
providers: [
TranslateService,
ErrorHandler,
{ provide: WebhookService, useValue: mockWebhookService },
{ provide: MessageHandlerService, useValue: mockMessageHandlerService },
{ provide: ActivatedRoute, useValue: mockActivatedRoute },
......
......@@ -8,6 +8,9 @@ import { FormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { MessageHandlerService } from '../message-handler/message-handler.service';
import { ErrorHandler } from '../../../lib/utils/error-handler';
describe('InlineAlertComponent', () => {
let component: InlineAlertComponent;
let fixture: ComponentFixture<InlineAlertComponent>;
......@@ -28,7 +31,8 @@ describe('InlineAlertComponent', () => {
],
declarations: [InlineAlertComponent],
providers: [
TranslateService
TranslateService,
ErrorHandler
]
})
.compileComponents();
......
......@@ -15,6 +15,8 @@ import { Component, Output, EventEmitter } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Subscription } from "rxjs";
import { errorHandler } from "../../../lib/utils/shared/shared.utils";
import { MessageHandlerService } from '../message-handler/message-handler.service';
import { ErrorHandler } from '../../../lib/utils/error-handler';
@Component({
selector: 'inline-alert',
......@@ -35,7 +37,9 @@ export class InlineAlertComponent {
@Output() confirmEvt = new EventEmitter<boolean>();
@Output() closeEvt = new EventEmitter<boolean>();
constructor(private translate: TranslateService) { }
constructor(private translate: TranslateService,
private errHandler: ErrorHandler,
) { }
public get errorMessage(): string {
return this.displayedText;
......@@ -47,7 +51,7 @@ export class InlineAlertComponent {
if (this.displayedText) {
this.translate.get(this.displayedText).subscribe((res: string) => this.displayedText = res);
}
this.errHandler.handleErrorPopupUnauthorized(error);
this.inlineAlertType = 'danger';
this.showCancelAction = false;
this.inlineAlertClosable = true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment