58
58
<div class =" dropdown d-flex align-content-center" >
59
59
<button class =" btn btn-sm btn-dark" href =" #" role =" button" data-bs-toggle =" dropdown" aria-expanded =" false" title =" " @onclick:stopPropagation =" true" ><i class =" bi bi-three-dots-vertical" ></i ></button >
60
60
<ul class =" dropdown-menu" >
61
- <li ><a class =" dropdown-item @(selectedInstanceNames.Count() == 0 ? " text-mute " : " text-danger " )" href =" #" @onclick =" OnDeleteSelected" @onclick:preventDefault =" true" @onclick:stopPropagation =" true" ><Icon Name =" IconName.Trash" /> Delete selected</a ></li >
61
+ <li ><button class =" dropdown-item @(selectedInstanceNames.Count() == 0 ? " text-mute " : " " )" disabled =" @(selectedInstanceNames.Count() == 0)" @onclick =" OnSuspendSelectedClickedAsync" @onclick:preventDefault =" true" @onclick:stopPropagation =" true" ><Icon Name =" IconName.Pause" /> Suspend selected</button ></li >
62
+ <li ><button class =" dropdown-item @(selectedInstanceNames.Count() == 0 ? " text-mute " : " " )" disabled =" @(selectedInstanceNames.Count() == 0)" @onclick =" OnResumeSelectedClickedAsync" @onclick:preventDefault =" true" @onclick:stopPropagation =" true" ><Icon Name =" IconName.Play" /> Resume selected</button ></li >
63
+ <li ><button class =" dropdown-item @(selectedInstanceNames.Count() == 0 ? " text-mute " : " " )" disabled =" @(selectedInstanceNames.Count() == 0)" @onclick =" OnCancelSelectedClickedAsync" @onclick:preventDefault =" true" @onclick:stopPropagation =" true" ><Icon Name =" IconName.X" /> Cancel selected</button ></li >
64
+ <li ><button class =" dropdown-item @(selectedInstanceNames.Count() == 0 ? " text-mute " : " text-danger " )" disabled =" @(selectedInstanceNames.Count() == 0)" @onclick =" OnDeleteSelected" @onclick:preventDefault =" true" @onclick:stopPropagation =" true" ><Icon Name =" IconName.Trash" /> Delete selected</button ></li >
62
65
</ul >
63
66
</div >
64
67
</div >
68
71
<tr >
69
72
@foreach ( var column in knownColumns )
70
73
{
71
- if ((Columns .Count () == 0 && column != " Delete " ) || Columns .Contains (column ))
74
+ if ((Columns .Count () == 0 && ! DirectActions . Contains ( column ) ) || Columns .Contains (column ))
72
75
{
73
- < th class = " sticky-header text-@GetColumnAlignment(column)" > @(column != " Action " && column != " Delete " ? column : " " )< / th >
76
+ < th class = " sticky-header text-@GetColumnAlignment(column)" > @(column != " Actions " && ! DirectActions . Contains ( column ) ? column : " " )< / th >
74
77
}
75
78
}
76
79
<th class =" sticky-header text-center align-middle" >
85
88
<tr @onclick =" async _ => await OnShowClickedAsync(instance)" class =" cursor-pointer @(ActiveRow == instance.GetName() ? " table-active " : " " )" >
86
89
@foreach ( var column in knownColumns )
87
90
{
88
- if ((Columns .Count () == 0 && column != " Delete " ) || Columns .Contains (column ))
91
+ if ((Columns .Count () == 0 && ! DirectActions . Contains ( column ) ) || Columns .Contains (column ))
89
92
{
90
93
< td class = " text-@GetColumnAlignment(column)" >
91
94
@switch (column )
144
147
< div class = " dropdown" >
145
148
< button class = " btn btn-sm btn-dark" href = " #" role = " button" data - bs - toggle = " dropdown" aria - expanded = " false" title = " " @onclick : stopPropagation = " true" >< i class = " bi bi-three-dots-vertical" >< / i >< / button >
146
149
< ul class = " dropdown-menu" >
147
- < li >< a class = " dropdown-item" href = " #" @onclick = " async _ => await OnShowClickedAsync(instance)" @onclick : preventDefault = " true" @onclick : stopPropagation = " true" >< Icon Name = " IconName.Eye" / > View < / a >< / li >
148
- < li >< a class = " dropdown-item text-danger" href = " #" @onclick = " async _ => await OnDeleteClickedAsync(instance)" @onclick : preventDefault = " true" @onclick : stopPropagation = " true" >< Icon Name = " IconName.Trash" / > Delete < / a >< / li >
150
+ @if (instance .Status ? .Phase == WorkflowInstanceStatusPhase .Running )
151
+ {
152
+ < li >< button class = " dropdown-item" @onclick = " async _ => await OnSuspendClickedAsync(instance)" @onclick : stopPropagation = " true" >< Icon Name = " IconName.Pause" / > Suspend < / button >< / li >
153
+ }
154
+ @if (instance .Status ? .Phase == WorkflowInstanceStatusPhase .Suspended )
155
+ {
156
+ < li >< button class = " dropdown-item" @onclick = " async _ => await OnResumeClickedAsync(instance)" @onclick : stopPropagation = " true" >< Icon Name = " IconName.Play" / > Resume < / button >< / li >
157
+ }
158
+ @if (instance .IsOperative )
159
+ {
160
+ < li >< button class = " dropdown-item" @onclick = " async _ => await OnCancelClickedAsync(instance)" @onclick : stopPropagation = " true" >< Icon Name = " IconName.X" / > Cancel < / button >< / li >
161
+ }
162
+ < li >< button class = " dropdown-item" @onclick = " async _ => await OnReplayClickedAsync(instance)" @onclick : stopPropagation = " true" >< Icon Name = " IconName.ArrowClockwise" / > Replay < / button >< / li >
163
+ < li >< button class = " dropdown-item text-danger" @onclick = " async _ => await OnDeleteClickedAsync(instance)" @onclick : stopPropagation = " true" >< Icon Name = " IconName.Trash" / > Delete < / button >< / li >
149
164
< / ul >
150
165
< / div >
151
166
break ;
167
+ case " Resume" :
168
+ @if (instance .Status ? .Phase == WorkflowInstanceStatusPhase .Running )
169
+ {
170
+ < button class = " btn btn-sm text-primary" @onclick = " async _ => await OnSuspendClickedAsync(instance)" @onclick : stopPropagation = " true" title = " Suspend" >< Icon Name = " IconName.Pause" / >< / button >
171
+ }
172
+ @if (instance .Status ? .Phase == WorkflowInstanceStatusPhase .Suspended )
173
+ {
174
+ < button class = " btn btn-sm text-primary" @onclick = " async _ => await OnResumeClickedAsync(instance)" @onclick : stopPropagation = " true" title = " Resume" >< Icon Name = " IconName.Play" / >< / button >
175
+ }
176
+ break ;
177
+ case " Cancel" :
178
+ @if (instance .IsOperative )
179
+ {
180
+ < button class = " btn btn-sm text-warning" @onclick = " async _ => await OnCancelClickedAsync(instance)" @onclick : stopPropagation = " true" title = " Cancel" >< Icon Name = " IconName.X" / >< / button >
181
+ }
182
+ break ;
152
183
case " Replay" :
153
- < button class = " btn btn-sm text-primary" @onclick = " async _ => await OnReplayClickedAsync(instance)" @onclick : stopPropagation = " true" >< Icon Name = " IconName.ArrowClockwise" / >< / button >
184
+ < button class = " btn btn-sm text-primary" @onclick = " async _ => await OnReplayClickedAsync(instance)" @onclick : stopPropagation = " true" title = " Replay " >< Icon Name = " IconName.ArrowClockwise" / >< / button >
154
185
break ;
155
186
case " Delete" :
156
- < button class = " btn btn-sm text-danger" @onclick = " async _ => await OnDeleteClickedAsync(instance)" @onclick : stopPropagation = " true" >< Icon Name = " IconName.Trash" / >< / button >
187
+ < button class = " btn btn-sm text-danger" @onclick = " async _ => await OnDeleteClickedAsync(instance)" @onclick : stopPropagation = " true" title = " Delete " >< Icon Name = " IconName.Trash" / >< / button >
157
188
break ;
158
189
default :
159
190
break ;
208
239
[Parameter ] public EventCallback <string ? > OnToggleSelected { get ; set ; }
209
240
[Parameter ] public EventCallback <WorkflowInstance > OnDelete { get ; set ; }
210
241
[Parameter ] public EventCallback <WorkflowInstance > OnReplay { get ; set ; }
242
+ [Parameter ] public EventCallback <WorkflowInstance > OnSuspend { get ; set ; }
243
+ [Parameter ] public EventCallback <WorkflowInstance > OnResume { get ; set ; }
244
+ [Parameter ] public EventCallback <WorkflowInstance > OnCancel { get ; set ; }
211
245
[Parameter ] public EventCallback OnDeleteSelected { get ; set ; }
246
+ [Parameter ] public EventCallback OnSuspendSelected { get ; set ; }
247
+ [Parameter ] public EventCallback OnResumeSelected { get ; set ; }
248
+ [Parameter ] public EventCallback OnCancelSelected { get ; set ; }
212
249
213
- IEnumerable <string > knownColumns = [
250
+ public static IEnumerable <string > DirectActions = [
251
+ " Resume" ,
252
+ " Cancel" ,
253
+ " Replay" ,
254
+ " Delete"
255
+ ];
256
+ static IEnumerable <string > knownColumns = [
214
257
" Name" ,
215
258
" Namespace" ,
216
259
" Definition" ,
221
264
" Duration" ,
222
265
" Operator" ,
223
266
" Actions" ,
224
- " Replay" ,
225
- " Delete"
267
+ .. DirectActions
226
268
];
227
269
228
270
ElementReference checkboxAll = default ! ;
324
366
/// <returns ></returns >
325
367
string GetColumnAlignment (string column )
326
368
{
327
- return column == " Name" || column == " Namespace"
328
- ? " start"
329
- : column == " Action"
330
- ? " end"
331
- : " center" ;
369
+ return (
370
+ column == " Name" || column == " Namespace"
371
+ ? " start"
372
+ : column == " Action"
373
+ ? " end"
374
+ : " center"
375
+ )
376
+ + (DirectActions .Contains (column ) ? " p-0" : " " );
332
377
}
333
378
334
379
/// <summary >
385
430
/// <summary >
386
431
/// Handles the click on the show button
387
432
/// </summary >
388
- /// <param name =" instance" ></param >
433
+ /// <param name =" instance" >The instance to show </param >
389
434
/// <returns ></returns >
390
435
protected async Task OnShowClickedAsync (WorkflowInstance instance )
391
436
{
398
443
/// <summary >
399
444
/// Handles the click on the delete button
400
445
/// </summary >
401
- /// <param name =" instance" ></param >
446
+ /// <param name =" instance" >The instance to delete </param >
402
447
/// <returns ></returns >
403
448
protected async Task OnDeleteClickedAsync (WorkflowInstance instance )
404
449
{
411
456
/// <summary >
412
457
/// Handles the click on the replay button
413
458
/// </summary >
414
- /// <param name =" instance" ></param >
459
+ /// <param name =" instance" >The instance to replay </param >
415
460
/// <returns ></returns >
416
461
protected async Task OnReplayClickedAsync (WorkflowInstance instance )
417
462
{
420
465
await this .OnReplay .InvokeAsync (instance );
421
466
}
422
467
}
468
+
469
+ /// <summary >
470
+ /// Handles the click on the suspend button
471
+ /// </summary >
472
+ /// <param name =" instance" >The instance to suspend</param >
473
+ /// <returns ></returns >
474
+ protected async Task OnSuspendClickedAsync (WorkflowInstance instance )
475
+ {
476
+ if (this .OnSuspend .HasDelegate )
477
+ {
478
+ await this .OnSuspend .InvokeAsync (instance );
479
+ }
480
+ }
481
+
482
+ /// <summary >
483
+ /// Handles the click on the resume button
484
+ /// </summary >
485
+ /// <param name =" instance" >The instance to resume</param >
486
+ /// <returns ></returns >
487
+ protected async Task OnResumeClickedAsync (WorkflowInstance instance )
488
+ {
489
+ if (this .OnResume .HasDelegate )
490
+ {
491
+ await this .OnResume .InvokeAsync (instance );
492
+ }
493
+ }
494
+
495
+ /// <summary >
496
+ /// Handles the click on the cancel button
497
+ /// </summary >
498
+ /// <param name =" instance" >The instance to cancel</param >
499
+ /// <returns ></returns >
500
+ protected async Task OnCancelClickedAsync (WorkflowInstance instance )
501
+ {
502
+ if (this .OnCancel .HasDelegate )
503
+ {
504
+ await this .OnCancel .InvokeAsync (instance );
505
+ }
506
+ }
507
+
508
+ protected async Task OnSuspendSelectedClickedAsync ()
509
+ {
510
+ var selected = selectedInstanceNames .ToList ();
511
+ var nonRuningInstances = (WorkflowInstances ?? []).Where (instance => selected .Contains (instance .GetName ()) && instance .Status ? .Phase != WorkflowInstanceStatusPhase .Running );
512
+ foreach (var instance in nonRuningInstances )
513
+ {
514
+ if (this .OnToggleSelected .HasDelegate )
515
+ {
516
+ await OnToggleSelected .InvokeAsync (instance .GetName ());
517
+ }
518
+ }
519
+ if (this .OnSuspendSelected .HasDelegate )
520
+ {
521
+ await OnSuspendSelected .InvokeAsync ();
522
+ }
523
+ }
524
+
525
+ protected async Task OnResumeSelectedClickedAsync ()
526
+ {
527
+ var selected = selectedInstanceNames .ToList ();
528
+ var nonSuspendedInstances = (WorkflowInstances ?? []).Where (instance => selected .Contains (instance .GetName ()) && instance .Status ? .Phase != WorkflowInstanceStatusPhase .Suspended );
529
+ foreach (var instance in nonSuspendedInstances )
530
+ {
531
+ if (this .OnToggleSelected .HasDelegate )
532
+ {
533
+ await OnToggleSelected .InvokeAsync (instance .GetName ());
534
+ }
535
+ }
536
+ if (this .OnResumeSelected .HasDelegate )
537
+ {
538
+ await OnResumeSelected .InvokeAsync ();
539
+ }
540
+ }
541
+
542
+ protected async Task OnCancelSelectedClickedAsync ()
543
+ {
544
+ var selected = selectedInstanceNames .ToList ();
545
+ var nonOperativeInstances = (WorkflowInstances ?? []).Where (instance => selected .Contains (instance .GetName ()) && ! instance .IsOperative );
546
+ foreach (var instance in nonOperativeInstances )
547
+ {
548
+ if (this .OnToggleSelected .HasDelegate )
549
+ {
550
+ await OnToggleSelected .InvokeAsync (instance .GetName ());
551
+ }
552
+ }
553
+ if (this .OnCancelSelected .HasDelegate )
554
+ {
555
+ await OnCancelSelected .InvokeAsync ();
556
+ }
557
+ }
423
558
}
0 commit comments