mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'xaka-patch-2'
This commit is contained in:
commit
12d65bfdfa
@ -41,13 +41,23 @@ function (angular, _, config) {
|
|||||||
$scope.dashboard.addPanel(panel, $scope.row);
|
$scope.dashboard.addPanel(panel, $scope.row);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$scope.deleteRow = function() {
|
$scope.deleteRow = function() {
|
||||||
|
function delete_row() {
|
||||||
|
$scope.dashboard.rows = _.without($scope.dashboard.rows, $scope.row);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$scope.row.panels.length) {
|
||||||
|
delete_row();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.appEvent('confirm-modal', {
|
$scope.appEvent('confirm-modal', {
|
||||||
title: 'Are you sure you want to delete this row?',
|
title: 'Are you sure you want to delete this row?',
|
||||||
icon: 'fa-trash',
|
icon: 'fa-trash',
|
||||||
yesText: 'Delete',
|
yesText: 'Delete',
|
||||||
onConfirm: function() {
|
onConfirm: function() {
|
||||||
$scope.dashboard.rows = _.without($scope.dashboard.rows, $scope.row);
|
delete_row();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,24 @@ define([
|
|||||||
beforeEach(ctx.providePhase());
|
beforeEach(ctx.providePhase());
|
||||||
beforeEach(ctx.createControllerPhase('RowCtrl'));
|
beforeEach(ctx.createControllerPhase('RowCtrl'));
|
||||||
|
|
||||||
|
describe('delete_row', function () {
|
||||||
|
describe('when row is empty (has no panels)', function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
ctx.scope.dashboard.rows = [{id: 1, panels: []}];
|
||||||
|
ctx.scope.row = ctx.scope.dashboard.rows[0];
|
||||||
|
ctx.scope.appEvent = sinon.spy();
|
||||||
|
|
||||||
|
ctx.scope.delete_row();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should NOT ask for confirmation', function () {
|
||||||
|
expect(ctx.scope.appEvent.called).to.be(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should delete row', function () {
|
||||||
|
expect(ctx.scope.dashboard.rows).to.not.contain(ctx.scope.row);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user