Skip to content

Commit f7098b1

Browse files
committed
Show confirmation dialog when deleting workflow run
1 parent 60e46f1 commit f7098b1

3 files changed

Lines changed: 66 additions & 1 deletion

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import $ from 'jquery';
2+
import _ from 'underscore';
3+
import RODAN_EVENTS from 'js/Shared/RODAN_EVENTS';
4+
import Marionette from 'backbone.marionette';
5+
import Radio from 'backbone.radio';
6+
7+
/**
8+
* Password view.
9+
*/
10+
export default class ViewConfirmationDialog extends Marionette.CollectionView
11+
{
12+
initialize(options)
13+
{
14+
this._message = options.message;
15+
this._onConfirm = options.onConfirm;
16+
}
17+
18+
templateContext()
19+
{
20+
return {
21+
message: this._message
22+
};
23+
}
24+
25+
///////////////////////////////////////////////////////////////////////////////////////
26+
// PRIVATE METHODS
27+
///////////////////////////////////////////////////////////////////////////////////////
28+
_handleButtonConfirm()
29+
{
30+
this._onConfirm();
31+
}
32+
33+
_handleButtonCancel()
34+
{
35+
Radio.channel("rodan").request(RODAN_EVENTS.REQUEST__MODAL_HIDE);
36+
}
37+
38+
}
39+
40+
ViewConfirmationDialog.prototype.modelEvents = {
41+
'all': 'render'
42+
};
43+
44+
ViewConfirmationDialog.prototype.ui = {
45+
buttonConfirm: '#button-confirm',
46+
buttonCancel: '#button-cancel'
47+
};
48+
49+
ViewConfirmationDialog.prototype.events = {
50+
'click @ui.buttonConfirm': '_handleButtonConfirm',
51+
'click @ui.buttonCancel': '_handleButtonCancel'
52+
};
53+
54+
ViewConfirmationDialog.prototype.template = _.template($('#template-dialog_confirm').text());

rodan-client/code/src/js/Views/Master/Main/WorkflowRun/Individual/LayoutViewIndividualWorkflowRun.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import ViewResourceCollection from 'js/Views/Master/Main/Resource/Collection/Vie
88
import ViewResourceCollectionItem from 'js/Views/Master/Main/Resource/Collection/ViewResourceCollectionItem';
99
import ViewRunJobCollection from 'js/Views/Master/Main/RunJob/Collection/ViewRunJobCollection';
1010
import ViewRunJobCollectionItem from 'js/Views/Master/Main/RunJob/Collection/ViewRunJobCollectionItem';
11+
import ViewConfirmationDialog from '../../../Dialog/ViewConfirmationDialog';
1112

1213
/**
1314
* WorkflowRun view.
@@ -113,7 +114,11 @@ export default class LayoutViewIndividualWorkflowRun extends Marionette.View
113114
*/
114115
_handleButtonDelete()
115116
{
116-
Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__WORKFLOWRUN_DELETE, {workflowrun: this.model});
117+
const content = new ViewConfirmationDialog({
118+
message: 'Are you sure you want to delete this WorkflowRun? This will delete all related RunJobs and Resources.',
119+
onConfirm: () => Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__WORKFLOWRUN_DELETE, { workflowrun: this.model }),
120+
});
121+
Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__MODAL_SHOW, { title: 'Delete WorkflowRun', content });
117122
}
118123
}
119124
LayoutViewIndividualWorkflowRun.prototype.modelEvents = {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="fixed_individual">
2+
<p><%- message %></p>
3+
<br>
4+
<button class="btn btn-xs btn-warning" id="button-cancel">Cancel</button>
5+
<button class="btn btn-xs btn-danger" id="button-confirm">Confirm</button>
6+
</div>

0 commit comments

Comments
 (0)