fix(console): add flow toasts (#4247)

fix: add flow toasts

Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
Max Peintner
2022-08-26 09:17:59 +02:00
committed by GitHub
parent 3c67c9756d
commit e39d82c031
6 changed files with 55 additions and 61 deletions

View File

@@ -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) => {

View File

@@ -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<AddFlowDialogComponent>,
@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<void> {
return this.mgmtService.listActions().then(resp => {
public form!: UntypedFormGroup;
constructor(
private toast: ToastService,
private mgmtService: ManagementService,
private fb: UntypedFormBuilder,
public dialogRef: MatDialogRef<AddFlowDialogComponent>,
@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<void> {
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);
}
}