fix UI bug for Webhooks

Signed-off-by: 方彬 <fang_bingo@163.com>
This commit is contained in:
方彬 2019-08-22 12:00:43 +08:00
parent e3d8fa845d
commit 088f805753
8 changed files with 32 additions and 5 deletions

View File

@ -1,4 +1,5 @@
<div class="align-center"> <div class="align-center">
<inline-alert class="modal-title"></inline-alert>
<form #webhookForm="ngForm"> <form #webhookForm="ngForm">
<section class="form-block webhook-section"> <section class="form-block webhook-section">
<!-- endpoint URL --> <!-- endpoint URL -->
@ -39,7 +40,7 @@
<button type="button" [clrLoading]="checkBtnState" class="btn btn-outline" (click)="onTestEndpoint()" [disabled]="checking || enpointURL.errors">{{'WEBHOOK.TEST_ENDPOINT_BUTTON' | translate}}</button> <button type="button" [clrLoading]="checkBtnState" class="btn btn-outline" (click)="onTestEndpoint()" [disabled]="checking || enpointURL.errors">{{'WEBHOOK.TEST_ENDPOINT_BUTTON' | translate}}</button>
</div> </div>
<div *ngIf="isModify"> <div *ngIf="isModify">
<button type="button" [clrLoading]="checkBtnState" class="btn btn-outline" (click)="onTestEndpoint()" [disabled]="checking || enpointURL.errors">{{'WEBHOOK.TEST_ENDPOINT_BUTTON' | translate}}</button> <button type="button" class="btn btn-outline" (click)="onTestEndpoint()" [disabled]="checking || enpointURL.errors">{{'WEBHOOK.TEST_ENDPOINT_BUTTON' | translate}}</button>
<button type="button" class="btn btn-outline" (click)="onCancel()">{{'BUTTON.CANCEL' | translate}}</button> <button type="button" class="btn btn-outline" (click)="onCancel()">{{'BUTTON.CANCEL' | translate}}</button>
<button type="button" class="btn btn-primary" [disabled]="!isValid" (click)="onSubmit()">{{'BUTTON.SAVE' | translate}}</button> <button type="button" class="btn btn-primary" [disabled]="!isValid" (click)="onSubmit()">{{'BUTTON.SAVE' | translate}}</button>
</div> </div>

View File

@ -14,6 +14,7 @@ import {ClrLoadingState} from "@clr/angular";
import { finalize } from "rxjs/operators"; import { finalize } from "rxjs/operators";
import { WebhookService } from "../webhook.service"; import { WebhookService } from "../webhook.service";
import { WebhookEventTypes } from '../../../shared/shared.const'; import { WebhookEventTypes } from '../../../shared/shared.const';
import { InlineAlertComponent } from "../../../shared/inline-alert/inline-alert.component";
import { MessageHandlerService } from "../../../shared/message-handler/message-handler.service"; import { MessageHandlerService } from "../../../shared/message-handler/message-handler.service";
@Component({ @Component({
@ -37,6 +38,7 @@ export class AddWebhookFormComponent implements OnInit, OnChanges {
@Output() edit = new EventEmitter<boolean>(); @Output() edit = new EventEmitter<boolean>();
@Output() close = new EventEmitter<boolean>(); @Output() close = new EventEmitter<boolean>();
@ViewChild("webhookForm") currentForm: NgForm; @ViewChild("webhookForm") currentForm: NgForm;
@ViewChild(InlineAlertComponent) inlineAlert: InlineAlertComponent;
constructor( constructor(
@ -64,11 +66,21 @@ export class AddWebhookFormComponent implements OnInit, OnChanges {
.pipe(finalize(() => (this.checking = false))) .pipe(finalize(() => (this.checking = false)))
.subscribe( .subscribe(
response => { response => {
this.checkBtnState = ClrLoadingState.SUCCESS; if (this.isModify) {
this.inlineAlert.showInlineSuccess({
message: "WEBHOOK.TEST_ENDPOINT_SUCCESS"
});
} else {
this.checkBtnState = ClrLoadingState.SUCCESS;
}
}, },
error => { error => {
this.checkBtnState = ClrLoadingState.DEFAULT; if (this.isModify) {
this.messageHandlerService.handleError(error); this.inlineAlert.showInlineError("WEBHOOK.TEST_ENDPOINT_FAILURE");
} else {
this.checkBtnState = ClrLoadingState.DEFAULT;
this.messageHandlerService.handleError(error);
}
} }
); );
} }
@ -92,7 +104,9 @@ export class AddWebhookFormComponent implements OnInit, OnChanges {
this.edit.emit(this.isModify); this.edit.emit(this.isModify);
}, },
error => { error => {
this.messageHandlerService.handleError(error); this.isModify
? this.inlineAlert.showInlineError(error)
: this.messageHandlerService.handleError(error);
} }
); );
} }

View File

@ -362,6 +362,8 @@
"TEST_ENDPOINT_BUTTON": "TEST ENDPOINT", "TEST_ENDPOINT_BUTTON": "TEST ENDPOINT",
"CANCEL_BUTTON": "CANCEL", "CANCEL_BUTTON": "CANCEL",
"SAVE_BUTTON": "SAVE", "SAVE_BUTTON": "SAVE",
"TEST_ENDPOINT_SUCCESS": "Connection tested successfully.",
"TEST_ENDPOINT_FAILURE": "Failed to ping endpoint.",
"ENABLED_WEBHOOK_TITLE": "Enable Project Webhooks", "ENABLED_WEBHOOK_TITLE": "Enable Project Webhooks",
"ENABLED_WEBHOOK_SUMMARY": "Do you want to enable webhooks for project ", "ENABLED_WEBHOOK_SUMMARY": "Do you want to enable webhooks for project ",
"DISABLED_WEBHOOK_TITLE": "Disable Project Webhooks", "DISABLED_WEBHOOK_TITLE": "Disable Project Webhooks",

View File

@ -363,6 +363,8 @@
"TEST_ENDPOINT_BUTTON": "TEST ENDPOINT", "TEST_ENDPOINT_BUTTON": "TEST ENDPOINT",
"CANCEL_BUTTON": "CANCEL", "CANCEL_BUTTON": "CANCEL",
"SAVE_BUTTON": "SAVE", "SAVE_BUTTON": "SAVE",
"TEST_ENDPOINT_SUCCESS": "Connection tested successfully.",
"TEST_ENDPOINT_FAILURE": "Failed to ping endpoint.",
"ENABLED_WEBHOOK_TITLE": "Enable Project Webhooks", "ENABLED_WEBHOOK_TITLE": "Enable Project Webhooks",
"ENABLED_WEBHOOK_SUMMARY": "Do you want to enable webhooks for project ", "ENABLED_WEBHOOK_SUMMARY": "Do you want to enable webhooks for project ",
"DISABLED_WEBHOOK_TITLE": "Disable Project Webhooks", "DISABLED_WEBHOOK_TITLE": "Disable Project Webhooks",

View File

@ -355,6 +355,8 @@
"TEST_ENDPOINT_BUTTON": "TEST ENDPOINT", "TEST_ENDPOINT_BUTTON": "TEST ENDPOINT",
"CANCEL_BUTTON": "CANCEL", "CANCEL_BUTTON": "CANCEL",
"SAVE_BUTTON": "SAVE", "SAVE_BUTTON": "SAVE",
"TEST_ENDPOINT_SUCCESS": "Connection tested successfully.",
"TEST_ENDPOINT_FAILURE": "Failed to ping endpoint.",
"ENABLED_WEBHOOK_TITLE": "Enable Project Webhooks", "ENABLED_WEBHOOK_TITLE": "Enable Project Webhooks",
"ENABLED_WEBHOOK_SUMMARY": "Do you want to enable webhooks for project ", "ENABLED_WEBHOOK_SUMMARY": "Do you want to enable webhooks for project ",
"DISABLED_WEBHOOK_TITLE": "Disable Project Webhooks", "DISABLED_WEBHOOK_TITLE": "Disable Project Webhooks",

View File

@ -389,6 +389,8 @@
"TEST_ENDPOINT_BUTTON": "TEST ENDPOINT", "TEST_ENDPOINT_BUTTON": "TEST ENDPOINT",
"CANCEL_BUTTON": "CANCEL", "CANCEL_BUTTON": "CANCEL",
"SAVE_BUTTON": "SAVE", "SAVE_BUTTON": "SAVE",
"TEST_ENDPOINT_SUCCESS": "Connection tested successfully.",
"TEST_ENDPOINT_FAILURE": "Failed to ping endpoint.",
"ENABLED_WEBHOOK_TITLE": "Enable Project Webhooks", "ENABLED_WEBHOOK_TITLE": "Enable Project Webhooks",
"ENABLED_WEBHOOK_SUMMARY": "Do you want to enable webhooks for project ", "ENABLED_WEBHOOK_SUMMARY": "Do you want to enable webhooks for project ",
"DISABLED_WEBHOOK_TITLE": "Disable Project Webhooks", "DISABLED_WEBHOOK_TITLE": "Disable Project Webhooks",

View File

@ -362,6 +362,8 @@
"TEST_ENDPOINT_BUTTON": "UÇ NOKTAYI DOĞRULA", "TEST_ENDPOINT_BUTTON": "UÇ NOKTAYI DOĞRULA",
"CANCEL_BUTTON": "İPTAL ET", "CANCEL_BUTTON": "İPTAL ET",
"SAVE_BUTTON": "KAYDET", "SAVE_BUTTON": "KAYDET",
"TEST_ENDPOINT_SUCCESS": "Connection tested successfully.",
"TEST_ENDPOINT_FAILURE": "Failed to ping endpoint.",
"ENABLED_WEBHOOK_TITLE": "Proje Ağ Kancalarını Etkinleştir", "ENABLED_WEBHOOK_TITLE": "Proje Ağ Kancalarını Etkinleştir",
"ENABLED_WEBHOOK_SUMMARY": "Proje için ağ kancalarını etkinleştirmek istiyor musunuz?", "ENABLED_WEBHOOK_SUMMARY": "Proje için ağ kancalarını etkinleştirmek istiyor musunuz?",
"DISABLED_WEBHOOK_TITLE": "Proje Ağ kancalarını Devre Dışı Bırak", "DISABLED_WEBHOOK_TITLE": "Proje Ağ kancalarını Devre Dışı Bırak",

View File

@ -361,6 +361,8 @@
"TEST_ENDPOINT_BUTTON": "测试 ENDPOINT", "TEST_ENDPOINT_BUTTON": "测试 ENDPOINT",
"CANCEL_BUTTON": "取消", "CANCEL_BUTTON": "取消",
"SAVE_BUTTON": "保存", "SAVE_BUTTON": "保存",
"TEST_ENDPOINT_SUCCESS": "测试连接成功。",
"TEST_ENDPOINT_FAILURE": "测试连接失败。",
"ENABLED_WEBHOOK_TITLE": "启用项目的 Webhooks", "ENABLED_WEBHOOK_TITLE": "启用项目的 Webhooks",
"ENABLED_WEBHOOK_SUMMARY": "你希望开启项目的 Webhooks 吗?", "ENABLED_WEBHOOK_SUMMARY": "你希望开启项目的 Webhooks 吗?",
"DISABLED_WEBHOOK_TITLE": "停用项目的 Webhooks", "DISABLED_WEBHOOK_TITLE": "停用项目的 Webhooks",