Skip to content

Commit

Permalink
feat(batch): delete historic batch entity feature
Browse files Browse the repository at this point in the history
related to CAM-14723
  • Loading branch information
danielkelemen committed Aug 3, 2022
1 parent f0a67d4 commit bb97193
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
11 changes: 9 additions & 2 deletions webapps/ui/cockpit/client/scripts/batches/components/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ Batch.prototype._remove = function(params) {
var obj = this._batches.selection;
params.id = obj.data.id;
var self = this;
return this._sdk.resource('batch').delete(params, function(err) {

let cb = err => {
self.deleteModal.instance && self.deleteModal.instance.close();
self.deleteModal.instance = null;

Expand All @@ -132,7 +133,13 @@ Batch.prototype._remove = function(params) {
obj.type = null;
obj.data = {};
}
});
};

if (obj.type === 'history') {
return this._sdk.resource('history').batchDelete(obj.data.id, cb);
} else {
return this._sdk.resource('batch').delete(params, cb);
}
};

var handleRetryResponse = function(context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

var events = require('./events');

var Delete = function() {
var Delete = function(type) {
this.cascade = false;
this.disable = false;
this.type = type;
};

Delete.prototype.cancel = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ var Ctrl = require('../components/delete');
module.exports = [
'$scope',
function($scope) {
$scope.ctrl = new Ctrl();
$scope.ctrl = new Ctrl($scope.ctrl.getSelectionType());
}
];
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ module.exports = [

events.on('deleteModal:open', function(deleteModal) {
var modal = (deleteModal.instance = $modal.open({
scope: $scope,
template: deleteModalTemplate,
controller: deleteModalCtrl
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ <h3 class="col-xs-8">
<span class="glyphicon glyphicon-repeat"></span>
</a>

<a ng-if="ctrl.getSelectionType() == 'runtime'"
class="btn btn-danger action-button"
<a class="btn btn-danger action-button"
ng-click="ctrl.openDeleteModal()"
uib-tooltip="{{ 'BATCHES_PROGRESS_TOOLTIP_DELETE_BATCH' | translate }}">
<span class="glyphicon glyphicon-trash"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ <h3 class="modal-title">{{ 'BATCHES_DELETE_TITLE' | translate }}</h3>
</div>
<div class="modal-body">
{{ 'BATCHES_DELETE_LEGEND' | translate }}<br />
<br />
<input type="radio" ng-model="ctrl.cascade" ng-value="false" ng-disabled="ctrl.disable" /> {{ 'BATCHES_DELETE_INPUT_KEEP' | translate }}<br />
<input type="radio" ng-model="ctrl.cascade" ng-value="true" ng-disabled="ctrl.disable" /> {{ 'BATCHES_DELETE_INPUT_DELETE' | translate }}
<div ng-if="ctrl.type === 'runtime'">
<br />
<input type="radio" ng-model="ctrl.cascade" ng-value="false" ng-disabled="ctrl.disable" /> {{ 'BATCHES_DELETE_INPUT_KEEP' | translate }}<br />
<input type="radio" ng-model="ctrl.cascade" ng-value="true" ng-disabled="ctrl.disable" /> {{ 'BATCHES_DELETE_INPUT_DELETE' | translate }}
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" ng-click="ctrl.cancel()" ng-disabled="ctrl.disable">{{ 'BATCHES_DELETE_BTN_CANCEL' | translate }}</button>
Expand Down

0 comments on commit bb97193

Please sign in to comment.