This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
tweak: enhance delete confirm dialog #318
Open
alvaromm2
wants to merge
1
commit into
seqeralabs:master
Choose a base branch
from
alvaromm2:enhanced-confirm-delete-dialog
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...src/app/modules/main/component/confirm-delete-dialog/confirm-delete-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<mat-form-field class="form-field--full-width"> | ||
<label for=""> | ||
{{message}} | ||
</label> | ||
<input type="text" matInput [formControl]="control"> | ||
<mat-hint *ngIf="control.touched && control.dirty && noMatch$ | async"> | ||
Name doesn't match | ||
</mat-hint> | ||
</mat-form-field> | ||
<mat-dialog-actions class="actions"> | ||
<button data-cy="dialog-btn-cancel" class="btn btn-secondary btn-sm" matDialogClose>Cancel</button> | ||
<button data-cy="dialog-btn-delete" class="btn btn-danger btn-sm" [disabled]="noMatch$ | async" (click)="confirmDelete()">Delete</button> | ||
</mat-dialog-actions> | ||
|
9 changes: 9 additions & 0 deletions
9
...src/app/modules/main/component/confirm-delete-dialog/confirm-delete-dialog.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.actions{ | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-around; | ||
} | ||
|
||
.form-field--full-width{ | ||
width: 100%; | ||
} | ||
44 changes: 44 additions & 0 deletions
44
...b/src/app/modules/main/component/confirm-delete-dialog/confirm-delete-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { Component, Inject, NgModule } from '@angular/core'; | ||
import { FormControl, ReactiveFormsModule } from '@angular/forms'; | ||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef, MatFormFieldModule, MatInputModule } from '@angular/material'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { Observable } from 'rxjs'; | ||
import { map, startWith } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'wt-confirm-delete-dialog', | ||
templateUrl: './confirm-delete-dialog.component.html', | ||
styleUrls: ['./confirm-delete-dialog.component.scss'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh and I missed setting change detection to |
||
}) | ||
export class ConfirmDeleteDialogComponent { | ||
|
||
public control: FormControl = new FormControl(); | ||
public message!: string; | ||
public noMatch$: Observable<boolean> = this.control.valueChanges.pipe(startWith([undefined]), map(value => value !== this.data.runName)); | ||
|
||
constructor(@Inject(MAT_DIALOG_DATA) private data: {runName: string}, private dialogRef: MatDialogRef<ConfirmDeleteDialogComponent>) { | ||
this.message = `Please confirm the deletion of the workflow '${data.runName}' typing its name below (operation is not recoverable):` | ||
} | ||
|
||
public confirmDelete(): void { | ||
this.dialogRef.close(true); | ||
} | ||
} | ||
|
||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
MatDialogModule, | ||
NoopAnimationsModule, | ||
ReactiveFormsModule, | ||
MatInputModule, | ||
MatFormFieldModule | ||
], | ||
declarations: [ConfirmDeleteDialogComponent], | ||
exports: [ConfirmDeleteDialogComponent, MatDialogModule] | ||
}) | ||
export class ConfirmDeleteDialogModule{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,12 @@ import {WorkflowService} from "src/app/modules/main/service/workflow.service"; | |
import {AuthService} from "src/app/modules/main/service/auth.service"; | ||
import {NotificationService} from "src/app/modules/main/service/notification.service"; | ||
import { ActivatedRoute, Router, NavigationEnd, Params } from '@angular/router'; | ||
import {debounceTime, distinctUntilChanged, filter} from 'rxjs/operators'; | ||
import {debounceTime, distinctUntilChanged, filter, takeUntil} from 'rxjs/operators'; | ||
import {FormControl} from "@angular/forms"; | ||
import {FilteringParams} from "../../util/filtering-params"; | ||
|
||
import { Subject } from 'rxjs'; | ||
import { MatDialog } from '@angular/material/dialog'; | ||
import { ConfirmDeleteDialogComponent} from '../confirm-delete-dialog/confirm-delete-dialog.component'; | ||
declare let $: any; | ||
|
||
@Component({ | ||
|
@@ -28,6 +30,8 @@ declare let $: any; | |
}) | ||
export class SidebarComponent implements OnInit, OnDestroy, OnChanges { | ||
|
||
private destroy$ = new Subject<void>(); | ||
|
||
@Input() | ||
workflows: Workflow[]; | ||
|
||
|
@@ -55,7 +59,8 @@ export class SidebarComponent implements OnInit, OnDestroy, OnChanges { | |
private authService: AuthService, | ||
private workflowService: WorkflowService, | ||
private router: Router, | ||
private route: ActivatedRoute) {} | ||
private route: ActivatedRoute, | ||
private dialog: MatDialog) {} | ||
|
||
|
||
ngOnInit() { | ||
|
@@ -94,6 +99,7 @@ export class SidebarComponent implements OnInit, OnDestroy, OnChanges { | |
ngOnDestroy(): void { | ||
// TODO: Decide if this line required or not. It breaks routing. | ||
// this.router.navigate(['/']); | ||
this.destroy$.next(); | ||
} | ||
|
||
collapseSidebar(): void { | ||
|
@@ -144,13 +150,24 @@ export class SidebarComponent implements OnInit, OnDestroy, OnChanges { | |
} | ||
|
||
deleteWorkflow(workflow: Workflow): void { | ||
const confirm = prompt(`Please confirm the deletion of the workflow '${workflow.data.runName}' typing its name below (operation is not recoverable):`); | ||
if (confirm != workflow.data.runName) { | ||
return; | ||
} | ||
|
||
this.workflowToDelete = workflow; | ||
this.onDeleteWorkflow.next(workflow); | ||
this.dialog.open(ConfirmDeleteDialogComponent, { | ||
data: { | ||
runName: workflow.data.runName | ||
}, | ||
maxWidth: '90%', | ||
width: '300px', | ||
Comment on lines
+158
to
+159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These could also be provided as default using the |
||
hasBackdrop: true, | ||
disableClose: true | ||
}).afterClosed() | ||
.pipe(takeUntil(this.destroy$)).subscribe( | ||
confirmDelete => { | ||
if(confirmDelete){ | ||
this.workflowToDelete = workflow; | ||
this.onDeleteWorkflow.next(workflow); | ||
} | ||
} | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually these are a bit redundant as we can use bootstrap utility classes
flex-row justify-content-around
andw-100
for this purpose