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
1diff --git a/src/maasserver/static/js/angular/directives/boot_images.js b/src/maasserver/static/js/angular/directives/boot_images.js
2index c23948b..9de6632 100644
3--- a/src/maasserver/static/js/angular/directives/boot_images.js
4+++ b/src/maasserver/static/js/angular/directives/boot_images.js
5@@ -672,15 +672,25 @@ angular.module('MAAS').directive('maasBootImages', [
6 // Return true if can save the current selection.
7 $scope.canSaveSelection = function() {
8 var commissioning_series_being_deleted = false;
9+ var commissioning_series_arches = 0;
10 var i;
11+ for(i = 0; i < $scope.ubuntuImages.length; i++) {
12+ if($scope.ubuntuImages[i].name ===
13+ $scope.bootResources.ubuntu.commissioning_series) {
14+ commissioning_series_arches++;
15+ }
16+ }
17 // Only prevent the current commissioning series from
18- // being deleted. If the current commissioning series isn't
19- // currently selected another LTS may be choosen,
20- // downloaded, and configured as the commissioning series.
21+ // being deleted if it isn't the commissioning series isn't
22+ // available on another architecture.. If the current
23+ // commissioning series isn't currently selected another
24+ // LTS may be choosen, downloaded, and configured as the
25+ // commissioning series.
26 for(i = 0; i < $scope.ubuntuImages.length; i++) {
27 if($scope.ubuntuImages[i].beingDeleted &&
28 $scope.ubuntuImages[i].name ===
29- $scope.bootResources.ubuntu.commissioning_series) {
30+ $scope.bootResources.ubuntu.commissioning_series &&
31+ commissioning_series_arches === 1) {
32 commissioning_series_being_deleted = true;
33 break;
34 }
35diff --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
36index 01b1b51..024cc23 100644
37--- a/src/maasserver/static/js/angular/directives/tests/test_boot_images.js
38+++ b/src/maasserver/static/js/angular/directives/tests/test_boot_images.js
39@@ -1545,6 +1545,29 @@ describe("maasBootImages", function() {
40 expect(scope.canSaveSelection()).toBe(false);
41 });
42
43+ it("returns true if deleting one commissioning series", function() {
44+ var directive = compileDirective();
45+ var scope = directive.isolateScope();
46+ scope.saving = false;
47+ spyOn(scope, "ltsIsSelected").and.returnValue(true);
48+ scope.bootResources.ubuntu = {
49+ commissioning_series: makeName("series")
50+ };
51+ scope.ubuntuImages = [
52+ {
53+ beingDeleted: true,
54+ name: scope.bootResources.ubuntu.commissioning_series,
55+ arch: makeName("arch")
56+ },
57+ {
58+ beingDeleted: false,
59+ name: scope.bootResources.ubuntu.commissioning_series,
60+ arch: makeName("arch")
61+ }
62+ ];
63+ expect(scope.canSaveSelection()).toBe(true);
64+ });
65+
66 it("returns false if saving", function() {
67 var directive = compileDirective();
68 var scope = directive.isolateScope();

Subscribers

People subscribed via source and target branches