From e39d82c031788edbd185d56831c1186124fe27e8 Mon Sep 17 00:00:00 2001 From: Max Peintner Date: Fri, 26 Aug 2022 09:17:59 +0200 Subject: [PATCH] fix(console): add flow toasts (#4247) fix: add flow toasts Co-authored-by: Livio Spring --- .../app/pages/actions/actions.component.ts | 2 + .../add-flow-dialog.component.ts | 102 ++++++++---------- console/src/assets/i18n/de.json | 2 + console/src/assets/i18n/en.json | 2 + console/src/assets/i18n/fr.json | 2 + console/src/assets/i18n/it.json | 6 +- 6 files changed, 55 insertions(+), 61 deletions(-) diff --git a/console/src/app/pages/actions/actions.component.ts b/console/src/app/pages/actions/actions.component.ts index acbeb02e00..c24a74f1cc 100644 --- a/console/src/app/pages/actions/actions.component.ts +++ b/console/src/app/pages/actions/actions.component.ts @@ -70,6 +70,7 @@ export class ActionsComponent { this.mgmtService .clearFlow(this.flowType) .then((resp) => { + this.toast.showInfo('FLOWS.FLOWCLEARED', true); this.loadFlow(); }) .catch((error: any) => { @@ -94,6 +95,7 @@ export class ActionsComponent { this.mgmtService .setTriggerActions(req.getActionIdsList(), req.getFlowType(), req.getTriggerType()) .then((resp) => { + this.toast.showInfo('FLOWS.FLOWCHANGED', true); this.loadFlow(); }) .catch((error: any) => { diff --git a/console/src/app/pages/actions/add-flow-dialog/add-flow-dialog.component.ts b/console/src/app/pages/actions/add-flow-dialog/add-flow-dialog.component.ts index f44af71246..00d0bc1d11 100644 --- a/console/src/app/pages/actions/add-flow-dialog/add-flow-dialog.component.ts +++ b/console/src/app/pages/actions/add-flow-dialog/add-flow-dialog.component.ts @@ -6,73 +6,57 @@ import { SetTriggerActionsRequest } from 'src/app/proto/generated/zitadel/manage import { ManagementService } from 'src/app/services/mgmt.service'; import { ToastService } from 'src/app/services/toast.service'; - @Component({ - selector: 'cnsl-add-flow-dialog', - templateUrl: './add-flow-dialog.component.html', - styleUrls: ['./add-flow-dialog.component.scss'], + selector: 'cnsl-add-flow-dialog', + templateUrl: './add-flow-dialog.component.html', + styleUrls: ['./add-flow-dialog.component.scss'], }) export class AddFlowDialogComponent { - public actions: Action.AsObject[] = []; - public typesForSelection: FlowType[] = [ - FlowType.FLOW_TYPE_EXTERNAL_AUTHENTICATION, - ]; - public triggerTypesForSelection: TriggerType[] = [ - TriggerType.TRIGGER_TYPE_POST_AUTHENTICATION, - TriggerType.TRIGGER_TYPE_POST_CREATION, - TriggerType.TRIGGER_TYPE_PRE_CREATION, - ]; - - public form!: UntypedFormGroup; - constructor( - private toast: ToastService, - private mgmtService: ManagementService, - private fb: UntypedFormBuilder, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - ) { - this.form = this.fb.group({ - flowType: [data.flowType ? data.flowType : '', [Validators.required]], - triggerType: [data.triggerType ? data.triggerType : '', [Validators.required]], - actionIdsList: [data.actions ? (data.actions as Action.AsObject[]).map(a => a.id) : [], [Validators.required]], - }); - this.getActionIds(); - } + public actions: Action.AsObject[] = []; + public typesForSelection: FlowType[] = [FlowType.FLOW_TYPE_EXTERNAL_AUTHENTICATION]; + public triggerTypesForSelection: TriggerType[] = [ + TriggerType.TRIGGER_TYPE_POST_AUTHENTICATION, + TriggerType.TRIGGER_TYPE_POST_CREATION, + TriggerType.TRIGGER_TYPE_PRE_CREATION, + ]; - private getActionIds(): Promise { - return this.mgmtService.listActions().then(resp => { + public form!: UntypedFormGroup; + constructor( + private toast: ToastService, + private mgmtService: ManagementService, + private fb: UntypedFormBuilder, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any, + ) { + this.form = this.fb.group({ + flowType: [data.flowType ? data.flowType : '', [Validators.required]], + triggerType: [data.triggerType ? data.triggerType : '', [Validators.required]], + actionIdsList: [data.actions ? (data.actions as Action.AsObject[]).map((a) => a.id) : [], [Validators.required]], + }); + this.getActionIds(); + } + + private getActionIds(): Promise { + return this.mgmtService + .listActions() + .then((resp) => { this.actions = resp.resultList; - }).catch((error: any) => { + }) + .catch((error: any) => { this.toast.showError(error); }); - } + } - public closeDialog(): void { - this.dialogRef.close(false); - } + public closeDialog(): void { + this.dialogRef.close(false); + } - public closeDialogWithSuccess(): void { - // if (this.id) { - // const req = new UpdateActionRequest(); - // req.setId(this.id); - // req.setName(this.name); - // req.setScript(this.script); + public closeDialogWithSuccess(): void { + const req = new SetTriggerActionsRequest(); + req.setActionIdsList(this.form.get('actionIdsList')?.value); + req.setFlowType(this.form.get('flowType')?.value); + req.setTriggerType(this.form.get('triggerType')?.value); - // const duration = new Duration(); - // duration.setNanos(0); - // duration.setSeconds(this.durationInSec); - - // req.setAllowedToFail(this.allowedToFail); - - // req.setTimeout(duration) - // this.dialogRef.close(req); - // } else { - const req = new SetTriggerActionsRequest(); - req.setActionIdsList(this.form.get('actionIdsList')?.value); - req.setFlowType(this.form.get('flowType')?.value); - req.setTriggerType(this.form.get('triggerType')?.value); - - this.dialogRef.close(req); - // } - } + this.dialogRef.close(req); + } } diff --git a/console/src/assets/i18n/de.json b/console/src/assets/i18n/de.json index 7f42a2bc8c..dbe9ed778f 100644 --- a/console/src/assets/i18n/de.json +++ b/console/src/assets/i18n/de.json @@ -664,6 +664,8 @@ "3": "Post Creation" }, "ADDTRIGGER": "Trigger hinzufügen", + "FLOWCHANGED": "Der Ablauf wurde geändert", + "FLOWCLEARED": "Der Ablauf wurde zurückgesetzt", "TIMEOUT": "Timeout", "TIMEOUTINSEC": "Timeout in Sekunden", "ALLOWEDTOFAIL": "Allowed To Fail", diff --git a/console/src/assets/i18n/en.json b/console/src/assets/i18n/en.json index 4d1a9f24f4..09cd073f21 100644 --- a/console/src/assets/i18n/en.json +++ b/console/src/assets/i18n/en.json @@ -664,6 +664,8 @@ "3": "Post Creation" }, "ADDTRIGGER": "Add trigger", + "FLOWCHANGED": "The flow was changed successfully", + "FLOWCLEARED": "The flow was reset successfully", "TIMEOUT": "Timeout", "TIMEOUTINSEC": "Timeout in seconds", "ALLOWEDTOFAIL": "Allowed To Fail", diff --git a/console/src/assets/i18n/fr.json b/console/src/assets/i18n/fr.json index a0ee06f30f..448130788a 100644 --- a/console/src/assets/i18n/fr.json +++ b/console/src/assets/i18n/fr.json @@ -664,6 +664,8 @@ "3": "Post création" }, "ADDTRIGGER": "Ajouter un déclencheur", + "FLOWCHANGED": "Le processus a été modifié", + "FLOWCLEARED": "Le processus a été supprimé avec succès", "TIMEOUT": "Délai d'attente", "TIMEOUTINSEC": "Délai en secondes", "ALLOWEDTOFAIL": "Autorisé à échouer", diff --git a/console/src/assets/i18n/it.json b/console/src/assets/i18n/it.json index a6c784be42..4e3b10d814 100644 --- a/console/src/assets/i18n/it.json +++ b/console/src/assets/i18n/it.json @@ -664,6 +664,8 @@ "3": "Post creazione" }, "ADDTRIGGER": "Aggiungi trigger", + "FLOWCHANGED": "Il processo è stato modificato con successo.", + "FLOWCLEARED": "Il processo è stato eliminato con successo.", "TIMEOUT": "Timeout", "TIMEOUTINSEC": "Timeout in secondi", "ALLOWEDTOFAIL": "Può fallire", @@ -685,8 +687,8 @@ "DELETE_SUCCESS": "Azione rimossa con successo." }, "CLEAR": { - "TITLE": "Flow zurücksetzen?", - "DESCRIPTION": "Stai per cancellare un'azione. Questa azione non può essere annullata. Vuoi continuare?" + "TITLE": "Elimina processo", + "DESCRIPTION": "Stai per eliminare un processo. Questa azione non può essere annullata. Vuoi continuare?" } }, "TOAST": {