Merge ~ltrager/maas:lp1710681_2.2 into maas:2.2

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: 18a5fddb358ad041e314ba0bc8e92cd9d8ed170e
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1710681_2.2
Merge into: maas:2.2
Diff against target: 68 lines (+37/-4)
2 files modified
src/maasserver/static/js/angular/directives/boot_images.js (+14/-4)
src/maasserver/static/js/angular/directives/tests/test_boot_images.js (+23/-0)
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+329141@code.launchpad.net

Commit message

LP: #1710681 - Allow architecture to be deselected in the UI.

The UI was preventing architectures from being deselected because removing the architecture meant removing the commissioning series for that architecture. The user is now allowed to deselect an architecture as long as another architecture is selected.

This is a backport of 79247ae722b4abe84154a1305b9be69e6158b490

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) wrote :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/static/js/angular/directives/boot_images.js b/src/maasserver/static/js/angular/directives/boot_images.js
index c23948b..9de6632 100644
--- a/src/maasserver/static/js/angular/directives/boot_images.js
+++ b/src/maasserver/static/js/angular/directives/boot_images.js
@@ -672,15 +672,25 @@ angular.module('MAAS').directive('maasBootImages', [
672 // Return true if can save the current selection.672 // Return true if can save the current selection.
673 $scope.canSaveSelection = function() {673 $scope.canSaveSelection = function() {
674 var commissioning_series_being_deleted = false;674 var commissioning_series_being_deleted = false;
675 var commissioning_series_arches = 0;
675 var i;676 var i;
677 for(i = 0; i < $scope.ubuntuImages.length; i++) {
678 if($scope.ubuntuImages[i].name ===
679 $scope.bootResources.ubuntu.commissioning_series) {
680 commissioning_series_arches++;
681 }
682 }
676 // Only prevent the current commissioning series from683 // Only prevent the current commissioning series from
677 // being deleted. If the current commissioning series isn't684 // being deleted if it isn't the commissioning series isn't
678 // currently selected another LTS may be choosen,685 // available on another architecture.. If the current
679 // downloaded, and configured as the commissioning series.686 // commissioning series isn't currently selected another
687 // LTS may be choosen, downloaded, and configured as the
688 // commissioning series.
680 for(i = 0; i < $scope.ubuntuImages.length; i++) {689 for(i = 0; i < $scope.ubuntuImages.length; i++) {
681 if($scope.ubuntuImages[i].beingDeleted &&690 if($scope.ubuntuImages[i].beingDeleted &&
682 $scope.ubuntuImages[i].name ===691 $scope.ubuntuImages[i].name ===
683 $scope.bootResources.ubuntu.commissioning_series) {692 $scope.bootResources.ubuntu.commissioning_series &&
693 commissioning_series_arches === 1) {
684 commissioning_series_being_deleted = true;694 commissioning_series_being_deleted = true;
685 break;695 break;
686 }696 }
diff --git a/src/maasserver/static/js/angular/directives/tests/test_boot_images.js b/src/maasserver/static/js/angular/directives/tests/test_boot_images.js
index 01b1b51..024cc23 100644
--- a/src/maasserver/static/js/angular/directives/tests/test_boot_images.js
+++ b/src/maasserver/static/js/angular/directives/tests/test_boot_images.js
@@ -1545,6 +1545,29 @@ describe("maasBootImages", function() {
1545 expect(scope.canSaveSelection()).toBe(false);1545 expect(scope.canSaveSelection()).toBe(false);
1546 });1546 });
15471547
1548 it("returns true if deleting one commissioning series", function() {
1549 var directive = compileDirective();
1550 var scope = directive.isolateScope();
1551 scope.saving = false;
1552 spyOn(scope, "ltsIsSelected").and.returnValue(true);
1553 scope.bootResources.ubuntu = {
1554 commissioning_series: makeName("series")
1555 };
1556 scope.ubuntuImages = [
1557 {
1558 beingDeleted: true,
1559 name: scope.bootResources.ubuntu.commissioning_series,
1560 arch: makeName("arch")
1561 },
1562 {
1563 beingDeleted: false,
1564 name: scope.bootResources.ubuntu.commissioning_series,
1565 arch: makeName("arch")
1566 }
1567 ];
1568 expect(scope.canSaveSelection()).toBe(true);
1569 });
1570
1548 it("returns false if saving", function() {1571 it("returns false if saving", function() {
1549 var directive = compileDirective();1572 var directive = compileDirective();
1550 var scope = directive.isolateScope();1573 var scope = directive.isolateScope();

Subscribers

People subscribed via source and target branches