Skip to content

Commit

Permalink
fix: escape the dialog should not trigger delete resource
Browse files Browse the repository at this point in the history
Signed-off-by: JenTing Hsiao <hsiaoairplane@gmail.com>
  • Loading branch information
jenting committed Apr 28, 2024
1 parent a22ca2c commit 1b2fa3c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions modules/web/src/common/dialogs/deleteresource/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,35 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {Component, Inject} from '@angular/core';
import {Component, Inject, OnInit} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
import {ResourceMeta} from '../../services/global/actionbar';

@Component({
selector: 'kd-delete-resource-dialog',
templateUrl: 'template.html',
})
export class DeleteResourceDialogComponent {
export class DeleteResourceDialog implements OnInit {
isDeleteNowChecked = false;
cancelDelete = 'cancelDelete';

constructor(
public dialogRef: MatDialogRef<DeleteResourceDialogComponent>,
public dialogRef: MatDialogRef<DeleteResourceDialog>,
@Inject(MAT_DIALOG_DATA) public data: ResourceMeta
) {}

ngOnInit(): void {
this.dialogRef.keydownEvents().subscribe(event => {
if (event.key === 'Escape') {
this.dialogRef.close(this.cancelDelete);
}
});

this.dialogRef.backdropClick().subscribe(_ => {
this.dialogRef.close(this.cancelDelete);
});
}

onNoClick(): void {
this.dialogRef.close();
}
Expand Down

0 comments on commit 1b2fa3c

Please sign in to comment.