From a08c4b68d6996154551da49bf4d2d89526a74da6 Mon Sep 17 00:00:00 2001 From: Xiaoyang Liu Date: Fri, 8 Apr 2022 21:02:05 -0700 Subject: [PATCH 1/3] Fix the unexpected confirmation dialog in 'Create from *' Signed-off-by: Xiaoyang Liu --- .../common/services/guard/candeactivate.ts | 2 +- src/app/frontend/create/from/file/component.ts | 15 ++++++++++----- src/app/frontend/create/from/file/template.html | 2 +- src/app/frontend/create/from/form/component.ts | 4 +++- src/app/frontend/create/from/input/component.ts | 12 +++++++----- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/app/frontend/common/services/guard/candeactivate.ts b/src/app/frontend/common/services/guard/candeactivate.ts index 9f9c2e16b176..bfd82ef5f29d 100644 --- a/src/app/frontend/common/services/guard/candeactivate.ts +++ b/src/app/frontend/common/services/guard/candeactivate.ts @@ -30,7 +30,7 @@ export class CanDeactivateGuard implements CanDeactivate { const config = { title: 'Unsaved changes', - message: 'The form has not been submitted yet, do you really want to leave?', + message: 'The form has not been submitted yet. Do you really want to leave?', } as ConfirmDialogConfig; return this.dialog_.open(ConfirmDialog, {data: config}).afterClosed(); diff --git a/src/app/frontend/create/from/file/component.ts b/src/app/frontend/create/from/file/component.ts index 729ccb720b75..7048890f1caf 100644 --- a/src/app/frontend/create/from/file/component.ts +++ b/src/app/frontend/create/from/file/component.ts @@ -43,12 +43,17 @@ export class CreateFromFileComponent extends ICanDeactivate { return !this.file || this.file.content.length === 0 || this.create_.isDeployDisabled(); } - create(): void { + async create(): Promise { this.creating_ = true; - this.create_ - .createContent(this.file.content, true, this.file.name) - .then(() => (this.creating_ = false)) - .finally(() => (this.creating_ = false)); + try { + await this.create_.createContent(this.file.content, true, this.file.name); + this.file = { + name: '', + content: '', + }; + } finally { + this.creating_ = false; + } } onFileLoad(file: KdFile): void { diff --git a/src/app/frontend/create/from/file/template.html b/src/app/frontend/create/from/file/template.html index ddf67a75e923..a947324a98d6 100644 --- a/src/app/frontend/create/from/file/template.html +++ b/src/app/frontend/create/from/file/template.html @@ -36,7 +36,7 @@ label="Choose YAML or JSON file" i18n-label> -