Skip to content

Commit

Permalink
Show confirmation dialog when deleting workflow run
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyyzhang03 committed Jul 7, 2023
1 parent d0e93df commit a1a3ed0
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import $ from 'jquery';
import _ from 'underscore';
import RODAN_EVENTS from 'js/Shared/RODAN_EVENTS';
import Marionette from 'backbone.marionette';
import Radio from 'backbone.radio';

/**
* Password view.
*/
export default class ViewConfirmationDialog extends Marionette.CollectionView
{
initialize(options)
{
this._message = options.message;
this._onConfirm = options.onConfirm;
}

templateContext()
{
return {
message: this._message
};
}

///////////////////////////////////////////////////////////////////////////////////////
// PRIVATE METHODS
///////////////////////////////////////////////////////////////////////////////////////
_handleButtonConfirm()
{
this._onConfirm();
}

_handleButtonCancel()
{
Radio.channel("rodan").request(RODAN_EVENTS.REQUEST__MODAL_HIDE);
}

}

ViewConfirmationDialog.prototype.modelEvents = {
'all': 'render'
};

ViewConfirmationDialog.prototype.ui = {
buttonConfirm: '#button-confirm',
buttonCancel: '#button-cancel'
};

ViewConfirmationDialog.prototype.events = {
'click @ui.buttonConfirm': '_handleButtonConfirm',
'click @ui.buttonCancel': '_handleButtonCancel'
};

ViewConfirmationDialog.prototype.template = _.template($('#template-dialog_confirm').text());
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ViewResourceCollection from 'js/Views/Master/Main/Resource/Collection/Vie
import ViewResourceCollectionItem from 'js/Views/Master/Main/Resource/Collection/ViewResourceCollectionItem';
import ViewRunJobCollection from 'js/Views/Master/Main/RunJob/Collection/ViewRunJobCollection';
import ViewRunJobCollectionItem from 'js/Views/Master/Main/RunJob/Collection/ViewRunJobCollectionItem';
import ViewConfirmationDialog from '../../../Dialog/ViewConfirmationDialog';

/**
* WorkflowRun view.
Expand Down Expand Up @@ -113,7 +114,11 @@ export default class LayoutViewIndividualWorkflowRun extends Marionette.View
*/
_handleButtonDelete()
{
Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__WORKFLOWRUN_DELETE, {workflowrun: this.model});
const content = new ViewConfirmationDialog({
message: 'Are you sure you want to delete this WorkflowRun? This will delete all related RunJobs and Resources.',
onConfirm: () => Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__WORKFLOWRUN_DELETE, { workflowrun: this.model }),
});
Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__MODAL_SHOW, { title: 'Delete WorkflowRun', content });
}
}
LayoutViewIndividualWorkflowRun.prototype.modelEvents = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="fixed_individual">
<p><%- message %></p>
<br>
<button class="btn btn-xs btn-warning" id="button-cancel">Cancel</button>
<button class="btn btn-xs btn-danger" id="button-confirm">Confirm</button>
</div>

0 comments on commit a1a3ed0

Please sign in to comment.