This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch 
4270-add-cancel-navigation-option-to-unsaved-changes-warning-for-chartsdashboards
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit 197bbc2554a1f8a8c39eaaa0284907e246d8d245
Author: Philipp Zehnder <[email protected]>
AuthorDate: Fri Mar 20 15:58:11 2026 +0100

    fix(#4270): refactor API of confirm dialog
---
 .../confirm-dialog/confirm-dialog.component.html       |  4 ++--
 .../dialog/confirm-dialog/confirm-dialog.component.ts  | 18 ++++++++++--------
 ui/projects/streampipes/shared-ui/src/public-api.ts    |  1 +
 .../asset-overview/asset-overview.component.ts         |  5 ++---
 .../chart-overview-table.component.ts                  |  5 ++---
 .../components/chart-view/chart-view.component.ts      | 16 ++++++----------
 .../files/file-overview/file-overview.component.ts     |  5 ++---
 .../abstract-security-principal-config.ts              |  6 ++----
 .../role-configuration/role-configuration.component.ts |  5 ++---
 .../user-group-configuration.component.ts              |  5 ++---
 .../adapter-configuration-state.service.ts             |  7 +++----
 .../configure-schema/configure-schema.component.ts     |  7 +++----
 .../dashboard-overview-table.component.ts              |  5 ++---
 .../components/panel/dashboard-panel.component.ts      | 13 +++++--------
 .../pipeline-assembly-options.component.ts             |  5 ++---
 .../editor/components/pipeline/pipeline.component.ts   |  3 +--
 16 files changed, 47 insertions(+), 63 deletions(-)

diff --git 
a/ui/projects/streampipes/shared-ui/src/lib/dialog/confirm-dialog/confirm-dialog.component.html
 
b/ui/projects/streampipes/shared-ui/src/lib/dialog/confirm-dialog/confirm-dialog.component.html
index 96d592c0aa..6019032b9e 100644
--- 
a/ui/projects/streampipes/shared-ui/src/lib/dialog/confirm-dialog/confirm-dialog.component.html
+++ 
b/ui/projects/streampipes/shared-ui/src/lib/dialog/confirm-dialog/confirm-dialog.component.html
@@ -46,7 +46,7 @@
                 fxLayoutAlign="end center"
                 class="primary-actions"
             >
-                @if (data.confirmAndCancel) {
+                @if (data.cancelTitle) {
                     <button
                         mat-button
                         (click)="onCancel()"
@@ -62,7 +62,7 @@
                     cdkFocusInitial
                     data-cy="confirm-delete"
                 >
-                    {{ data.okTitle }}
+                    {{ data.confirmTitle }}
                 </button>
             </div>
         </div>
diff --git 
a/ui/projects/streampipes/shared-ui/src/lib/dialog/confirm-dialog/confirm-dialog.component.ts
 
b/ui/projects/streampipes/shared-ui/src/lib/dialog/confirm-dialog/confirm-dialog.component.ts
index 317c2fb343..85fdfc15d3 100644
--- 
a/ui/projects/streampipes/shared-ui/src/lib/dialog/confirm-dialog/confirm-dialog.component.ts
+++ 
b/ui/projects/streampipes/shared-ui/src/lib/dialog/confirm-dialog/confirm-dialog.component.ts
@@ -16,7 +16,7 @@
  *
  */
 
-import { Component, Inject } from '@angular/core';
+import { Component, inject } from '@angular/core';
 import {
     MAT_DIALOG_DATA,
     MatDialogActions,
@@ -29,6 +29,7 @@ import {
     LayoutDirective,
 } from '@ngbracket/ngx-layout/flex';
 import { MatButton } from '@angular/material/button';
+import { ConfirmDialogAction, ConfirmDialogData } from 
'./confirm-dialog.model';
 
 @Component({
     selector: 'confirmation-dialog',
@@ -44,20 +45,21 @@ import { MatButton } from '@angular/material/button';
     ],
 })
 export class ConfirmDialogComponent {
-    constructor(
-        public dialogRef: MatDialogRef<ConfirmDialogComponent>,
-        @Inject(MAT_DIALOG_DATA) public data: any,
-    ) {}
+    public dialogRef =
+        inject<MatDialogRef<ConfirmDialogComponent, ConfirmDialogAction>>(
+            MatDialogRef,
+        );
+    public data = inject<ConfirmDialogData>(MAT_DIALOG_DATA);
 
     onCancel(): void {
-        this.dialogRef.close(this.data.cancelResult);
+        this.dialogRef.close('cancel');
     }
 
     onNeutral(): void {
-        this.dialogRef.close(this.data.neutralResult);
+        this.dialogRef.close('neutral');
     }
 
     onOk(): void {
-        this.dialogRef.close(this.data.okResult ?? true);
+        this.dialogRef.close('confirm');
     }
 }
diff --git a/ui/projects/streampipes/shared-ui/src/public-api.ts 
b/ui/projects/streampipes/shared-ui/src/public-api.ts
index fb7d075f89..dc2cdd57b5 100644
--- a/ui/projects/streampipes/shared-ui/src/public-api.ts
+++ b/ui/projects/streampipes/shared-ui/src/public-api.ts
@@ -23,6 +23,7 @@ export * from 
'./lib/dialog/data-download-dialog/data-download-dialog.component'
 export * from './lib/dialog/card-dialog/card-dialog.component';
 
 export * from './lib/dialog/confirm-dialog/confirm-dialog.component';
+export * from './lib/dialog/confirm-dialog/confirm-dialog.model';
 export * from './lib/dialog/panel-dialog/panel-dialog.component';
 export * from './lib/dialog/standard-dialog/standard-dialog.component';
 export * from 
'./lib/dialog/pipeline-element-help/pipeline-element-help.component';
diff --git 
a/ui/src/app/assets/components/asset-overview/asset-overview.component.ts 
b/ui/src/app/assets/components/asset-overview/asset-overview.component.ts
index 22a1323bb8..a0fa0e1331 100644
--- a/ui/src/app/assets/components/asset-overview/asset-overview.component.ts
+++ b/ui/src/app/assets/components/asset-overview/asset-overview.component.ts
@@ -229,12 +229,11 @@ export class SpAssetOverviewComponent implements OnInit {
                     'This action cannot be reversed!',
                 ),
                 cancelTitle: this.translateService.instant('Cancel'),
-                okTitle: this.translateService.instant('Delete Asset'),
-                confirmAndCancel: true,
+                confirmTitle: this.translateService.instant('Delete Asset'),
             },
         });
         dialogRef.afterClosed().subscribe(result => {
-            if (result) {
+            if (result === 'confirm') {
                 this.assetService.deleteAsset(asset.elementId).subscribe(() => 
{
                     this.loadAssets();
                     this.assetBrowserService.loadAssetData();
diff --git 
a/ui/src/app/chart/components/chart-overview/chart-overview-table/chart-overview-table.component.ts
 
b/ui/src/app/chart/components/chart-overview/chart-overview-table/chart-overview-table.component.ts
index 77e36bacff..e87c91a1e2 100644
--- 
a/ui/src/app/chart/components/chart-overview/chart-overview-table/chart-overview-table.component.ts
+++ 
b/ui/src/app/chart/components/chart-overview/chart-overview-table/chart-overview-table.component.ts
@@ -178,12 +178,11 @@ export class ChartOverviewTableComponent implements 
OnInit {
                     'The chart will be removed from all dashboards as well. 
This action cannot be undone!',
                 ),
                 cancelTitle: this.translateService.instant('Cancel'),
-                okTitle: this.translateService.instant('Delete chart'),
-                confirmAndCancel: true,
+                confirmTitle: this.translateService.instant('Delete chart'),
             },
         });
         dialogRef.afterClosed().subscribe(result => {
-            if (result) {
+            if (result === 'confirm') {
                 this.dataViewService
                     .deleteChart(dataView.elementId)
                     .subscribe(() => {
diff --git a/ui/src/app/chart/components/chart-view/chart-view.component.ts 
b/ui/src/app/chart/components/chart-view/chart-view.component.ts
index 9f0eee7aa4..d34a91c876 100644
--- a/ui/src/app/chart/components/chart-view/chart-view.component.ts
+++ b/ui/src/app/chart/components/chart-view/chart-view.component.ts
@@ -43,6 +43,7 @@ import {
 } from '@angular/router';
 import {
     AssetSaveService,
+    ConfirmDialogAction,
     ConfirmDialogComponent,
     CurrentUserService,
     DialogService,
@@ -397,8 +398,7 @@ export class ChartViewComponent
                     'Update asset links or close.',
                 ),
                 cancelTitle: this.translateService.instant('Close'),
-                okTitle: this.translateService.instant('Update'),
-                confirmAndCancel: true,
+                confirmTitle: this.translateService.instant('Update'),
                 editMode: this.editMode,
                 selectedAssets: this.selectedAssets,
                 deselectedAssets: this.deselectedAssets,
@@ -429,18 +429,14 @@ export class ChartViewComponent
                         'Update all changes to chart or discard current 
changes.',
                     ),
                     neutralTitle: this.translateService.instant('Keep 
editing'),
-                    neutralResult: 'stay',
                     cancelTitle:
                         this.translateService.instant('Discard changes'),
-                    cancelResult: false,
-                    okTitle: this.translateService.instant('Update'),
-                    okResult: true,
-                    confirmAndCancel: true,
+                    confirmTitle: this.translateService.instant('Update'),
                 },
             });
             return dialogRef.afterClosed().pipe(
-                switchMap(dialogResult => {
-                    if (dialogResult === true) {
+                switchMap((dialogResult: ConfirmDialogAction | undefined) => {
+                    if (dialogResult === 'confirm') {
                         this.dataView.timeSettings = this.timeSettings;
                         return (
                             this.dataView.elementId !== undefined
@@ -451,7 +447,7 @@ export class ChartViewComponent
                         ).pipe(map(() => true));
                     }
 
-                    if (dialogResult === false) {
+                    if (dialogResult === 'cancel') {
                         return of(true);
                     }
 
diff --git 
a/ui/src/app/configuration/files/file-overview/file-overview.component.ts 
b/ui/src/app/configuration/files/file-overview/file-overview.component.ts
index 84c135ee92..5a9edb947b 100644
--- a/ui/src/app/configuration/files/file-overview/file-overview.component.ts
+++ b/ui/src/app/configuration/files/file-overview/file-overview.component.ts
@@ -100,13 +100,12 @@ export class FileOverviewComponent implements OnInit {
                     'This cannot be undone.',
                 ),
                 cancelTitle: this.translateService.instant('No'),
-                okTitle: this.translateService.instant('Yes'),
-                confirmAndCancel: true,
+                confirmTitle: this.translateService.instant('Yes'),
             },
         });
 
         dialogRef.afterClosed().subscribe(ev => {
-            if (ev) {
+            if (ev === 'confirm') {
                 this.filesService
                     .deleteFile(fileMetadata.fileId)
                     .subscribe(response => {
diff --git 
a/ui/src/app/configuration/security-configuration/abstract-security-principal-config.ts
 
b/ui/src/app/configuration/security-configuration/abstract-security-principal-config.ts
index 9201a63ed9..871b798a9b 100644
--- 
a/ui/src/app/configuration/security-configuration/abstract-security-principal-config.ts
+++ 
b/ui/src/app/configuration/security-configuration/abstract-security-principal-config.ts
@@ -17,7 +17,6 @@
  */
 
 import { Directive, inject, OnInit, ViewChild } from '@angular/core';
-import { MatPaginator } from '@angular/material/paginator';
 import { MatSort } from '@angular/material/sort';
 import { MatTableDataSource } from '@angular/material/table';
 import {
@@ -106,12 +105,11 @@ export abstract class AbstractSecurityPrincipalConfig<
                     'This action cannot be reversed!',
                 ),
                 cancelTitle: this.translateService.instant('Cancel'),
-                okTitle: this.translateService.instant('Delete User'),
-                confirmAndCancel: true,
+                confirmTitle: this.translateService.instant('Delete User'),
             },
         });
         dialogRef.afterClosed().subscribe(result => {
-            if (result) {
+            if (result === 'confirm') {
                 this.userService
                     .deleteUser(account.principalId)
                     .subscribe(() => {
diff --git 
a/ui/src/app/configuration/security-configuration/role-configuration/role-configuration.component.ts
 
b/ui/src/app/configuration/security-configuration/role-configuration/role-configuration.component.ts
index 41821972bf..2369f77921 100644
--- 
a/ui/src/app/configuration/security-configuration/role-configuration/role-configuration.component.ts
+++ 
b/ui/src/app/configuration/security-configuration/role-configuration/role-configuration.component.ts
@@ -116,12 +116,11 @@ export class SecurityRoleConfigComponent implements 
OnInit {
                     'This action cannot be reversed!',
                 ),
                 cancelTitle: this.translateService.instant('Cancel'),
-                okTitle: this.translateService.instant('Delete Role'),
-                confirmAndCancel: true,
+                confirmTitle: this.translateService.instant('Delete Role'),
             },
         });
         dialogRef.afterClosed().subscribe(result => {
-            if (result) {
+            if (result === 'confirm') {
                 this.roleService.delete(role).subscribe(response => {
                     this.loadRoles();
                 });
diff --git 
a/ui/src/app/configuration/security-configuration/user-group-configuration/user-group-configuration.component.ts
 
b/ui/src/app/configuration/security-configuration/user-group-configuration/user-group-configuration.component.ts
index 55b00f5595..1e622f8648 100644
--- 
a/ui/src/app/configuration/security-configuration/user-group-configuration/user-group-configuration.component.ts
+++ 
b/ui/src/app/configuration/security-configuration/user-group-configuration/user-group-configuration.component.ts
@@ -106,12 +106,11 @@ export class SecurityUserGroupConfigComponent implements 
OnInit {
                     'This action cannot be reversed!',
                 ),
                 cancelTitle: this.translateService.instant('Cancel'),
-                okTitle: this.translateService.instant('Delete Group'),
-                confirmAndCancel: true,
+                confirmTitle: this.translateService.instant('Delete Group'),
             },
         });
         dialogRef.afterClosed().subscribe(result => {
-            if (result) {
+            if (result === 'confirm') {
                 this.userGroupService.deleteGroup(group).subscribe(response => 
{
                     this.loadAllGroups();
                 });
diff --git 
a/ui/src/app/connect/components/adapter-configuration/adapter-configuration-state-service/adapter-configuration-state.service.ts
 
b/ui/src/app/connect/components/adapter-configuration/adapter-configuration-state-service/adapter-configuration-state.service.ts
index 5468092725..681f22950e 100644
--- 
a/ui/src/app/connect/components/adapter-configuration/adapter-configuration-state-service/adapter-configuration-state.service.ts
+++ 
b/ui/src/app/connect/components/adapter-configuration/adapter-configuration-state-service/adapter-configuration-state.service.ts
@@ -345,14 +345,13 @@ export class AdapterConfigurationStateService {
                         'Please only change nothing if you are certain that 
your changes do not affect the event schema.',
                 ),
                 cancelTitle: this.translateService.instant('Nothing changed'),
-                okTitle: this.translateService.instant('Refresh Fields'),
-                confirmAndCancel: true,
+                confirmTitle: this.translateService.instant('Refresh Fields'),
             },
         });
         dialogRef.afterClosed().subscribe(result => {
-            if (result) {
+            if (result === 'confirm') {
                 this.getEventSchema(this.state().adapterDescription);
-            } else {
+            } else if (result === 'cancel') {
                 this.acknowledgeNoSchemaRefresh();
             }
         });
diff --git 
a/ui/src/app/connect/components/adapter-configuration/configure-schema/configure-schema.component.ts
 
b/ui/src/app/connect/components/adapter-configuration/configure-schema/configure-schema.component.ts
index 2debf80606..afc0eb52c3 100644
--- 
a/ui/src/app/connect/components/adapter-configuration/configure-schema/configure-schema.component.ts
+++ 
b/ui/src/app/connect/components/adapter-configuration/configure-schema/configure-schema.component.ts
@@ -252,14 +252,13 @@ export class ConfigureSchemaComponent implements OnInit {
                         'the most current data. Check your transformation 
rules after the refresh to ensure everything still aligns.',
                 ),
                 cancelTitle: this.translateService.instant('Nothing changed'),
-                okTitle: this.translateService.instant('Reload Sample'),
-                confirmAndCancel: true,
+                confirmTitle: this.translateService.instant('Reload Sample'),
             },
         });
         dialogRef.afterClosed().subscribe(result => {
-            if (result) {
+            if (result === 'confirm') {
                 this.getSampleEvent();
-            } else {
+            } else if (result === 'cancel') {
                 this.confirmChangesDoNotEffectSchema();
             }
         });
diff --git 
a/ui/src/app/dashboard/components/overview/dashboard-overview-table/dashboard-overview-table.component.ts
 
b/ui/src/app/dashboard/components/overview/dashboard-overview-table/dashboard-overview-table.component.ts
index 91cc6a56fd..30058c1c74 100644
--- 
a/ui/src/app/dashboard/components/overview/dashboard-overview-table/dashboard-overview-table.component.ts
+++ 
b/ui/src/app/dashboard/components/overview/dashboard-overview-table/dashboard-overview-table.component.ts
@@ -185,12 +185,11 @@ export class DashboardOverviewTableComponent implements 
OnInit, OnDestroy {
                     'This action cannot be undone!',
                 ),
                 cancelTitle: this.translateService.instant('Cancel'),
-                okTitle: this.translateService.instant('Delete dashboard'),
-                confirmAndCancel: true,
+                confirmTitle: this.translateService.instant('Delete 
dashboard'),
             },
         });
         dialogRef.afterClosed().subscribe(result => {
-            if (result) {
+            if (result === 'confirm') {
                 this.dashboardService
                     .deleteDashboard(dashboard)
                     .subscribe(() => {
diff --git a/ui/src/app/dashboard/components/panel/dashboard-panel.component.ts 
b/ui/src/app/dashboard/components/panel/dashboard-panel.component.ts
index a7f6e49ebf..1ac4b28e90 100644
--- a/ui/src/app/dashboard/components/panel/dashboard-panel.component.ts
+++ b/ui/src/app/dashboard/components/panel/dashboard-panel.component.ts
@@ -38,6 +38,7 @@ import {
 } from '@angular/router';
 import { DashboardSlideViewComponent } from 
'../../../dashboard-shared/components/chart-view/slide-view/dashboard-slide-view.component';
 import {
+    ConfirmDialogAction,
     ConfirmDialogComponent,
     CurrentUserService,
     SpBasicViewComponent,
@@ -326,18 +327,14 @@ export class DashboardPanelComponent
                         'Update all changes to dashboard charts or discard 
current changes.',
                     ),
                     neutralTitle: this.translateService.instant('Keep 
editing'),
-                    neutralResult: 'stay',
                     cancelTitle:
                         this.translateService.instant('Discard changes'),
-                    cancelResult: false,
-                    okTitle: this.translateService.instant('Update'),
-                    okResult: true,
-                    confirmAndCancel: true,
+                    confirmTitle: this.translateService.instant('Update'),
                 },
             });
             return dialogRef.afterClosed().pipe(
-                switchMap(dialogResult => {
-                    if (dialogResult === true) {
+                switchMap((dialogResult: ConfirmDialogAction | undefined) => {
+                    if (dialogResult === 'confirm') {
                         
this.dashboard.dashboardGeneralSettings.defaultViewMode =
                             this.viewMode;
                         return this.dashboardService
@@ -345,7 +342,7 @@ export class DashboardPanelComponent
                             .pipe(map(() => true));
                     }
 
-                    if (dialogResult === false) {
+                    if (dialogResult === 'cancel') {
                         return of(true);
                     }
 
diff --git 
a/ui/src/app/editor/components/pipeline-assembly/pipeline-assembly-options/pipeline-assembly-options.component.ts
 
b/ui/src/app/editor/components/pipeline-assembly/pipeline-assembly-options/pipeline-assembly-options.component.ts
index 980bfc00d2..55bd424825 100644
--- 
a/ui/src/app/editor/components/pipeline-assembly/pipeline-assembly-options/pipeline-assembly-options.component.ts
+++ 
b/ui/src/app/editor/components/pipeline-assembly/pipeline-assembly-options/pipeline-assembly-options.component.ts
@@ -151,12 +151,11 @@ export class PipelineAssemblyOptionsComponent {
                 title: 'Do you really want to delete the current pipeline?',
                 subtitle: 'This cannot be undone.',
                 cancelTitle: 'No',
-                okTitle: 'Yes',
-                confirmAndCancel: true,
+                confirmTitle: 'Yes',
             },
         });
         dialogRef.afterClosed().subscribe(ev => {
-            if (ev) {
+            if (ev === 'confirm') {
                 this.clearAssemblyEmitter.emit();
             }
         });
diff --git a/ui/src/app/editor/components/pipeline/pipeline.component.ts 
b/ui/src/app/editor/components/pipeline/pipeline.component.ts
index fb4e6b8df1..726a6e06d9 100644
--- a/ui/src/app/editor/components/pipeline/pipeline.component.ts
+++ b/ui/src/app/editor/components/pipeline/pipeline.component.ts
@@ -537,8 +537,7 @@ export class PipelineComponent implements OnInit, OnDestroy 
{
             data: {
                 title: title,
                 subtitle: description,
-                okTitle: 'Ok',
-                confirmAndCancel: false,
+                confirmTitle: 'Ok',
             },
         });
     }

Reply via email to