Technical Improvement
Use promised based dialog chains instead of callbacks for confirmation dialogs.
Acceptance criteria
- Dialog open should return a promise which completes when the dialog is closed
- If the user confirms returns
true, on cancel return false
- Pass all config and texts necessary for the dialog in the show / open function call
Benefits
- Better readability of the flow
- Remove unnecessary local variables
- We only need one confirm dialog, which receives all parameters on open
Example: confirm before close
close() {
this.confirmAction = 'cancel';
this.confirmHeadline = 'Cancel without saving?';
this.confirmDescription =
'Are you sure you want to cancel? All changes will be lost.';
this.confirmIcon = 'warning';
this.confirmVariant = 'danger';
this.confirmConfirmLabel = 'Yes, cancel';
this.confirmCancelLabel = 'No, go back';
this.confirmDialog.show();
}
private handleConfirm() {
if (this.confirmAction === 'cancel') {
this.closeWithoutConfirm();
} else if (this.confirmAction === 'delete-subfunction') {
// do other stuff
}
Promise based approach
close() {
this.confirmDialog.show({
variant: 'danger',
...
texts: {
headline: 'Cancel without saving?',
...
}
}).then(confirmed => {
if (!confirmed) {
return;
}
doStuff();
});
}
Technical Improvement
Use promised based dialog chains instead of callbacks for confirmation dialogs.
Acceptance criteria
true, on cancel returnfalseBenefits
Example: confirm before close
Promise based approach