Merge lp:~lamont/maas/bug-1642040-2.1 into lp:maas/2.1

Proposed by LaMont Jones
Status: Rejected
Rejected by: Mike Pontillo
Proposed branch: lp:~lamont/maas/bug-1642040-2.1
Merge into: lp:maas/2.1
Diff against target: 298 lines (+154/-16)
3 files modified
src/maasserver/static/js/angular/directives/boot_images.js (+26/-0)
src/maasserver/static/js/angular/directives/tests/test_boot_images.js (+80/-0)
src/maasserver/static/partials/boot-images.html (+48/-16)
To merge this branch: bzr merge lp:~lamont/maas/bug-1642040-2.1
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Needs Information
Richard McCartney Pending
Review via email: mp+320875@code.launchpad.net

Commit message

Backport r5847 from lp:maas: Add delete to other and generated images on the boot-images page.

Description of the change

Backport r5847 from lp:maas: Add delete to other and generated images on the boot-images page.

To post a comment you must log in.
Revision history for this message
Mike Pontillo (mpontillo) wrote :

Was this tested on 2.1 after the backport? Some of the CSS framework changed between 2.1 and 2.2, so that could be important.

review: Needs Information
Revision history for this message
LaMont Jones (lamont) wrote :

Yes, it was. Having said that, I think I'd like Richard to review it too.

Revision history for this message
Mike Pontillo (mpontillo) wrote :

Moving this to 'rejected' state since we have deprecated MAAS 2.1.

Unmerged revisions

5597. By LaMont Jones

Backport r5847 from lp:maas: Add delete to other and generated images on the boot-images page.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/static/js/angular/directives/boot_images.js'
2--- src/maasserver/static/js/angular/directives/boot_images.js 2016-12-07 12:59:10 +0000
3+++ src/maasserver/static/js/angular/directives/boot_images.js 2017-03-23 21:33:25 +0000
4@@ -84,6 +84,7 @@
5 $scope.generatedImages = [];
6 $scope.customImages = [];
7 $scope.ubuntuDeleteId = null;
8+ $scope.removingImage = null;
9
10 // Return true if the authenticated user is super user.
11 $scope.isSuperUser = function() {
12@@ -498,6 +499,7 @@
13 icon: 'icon--status-' + resource.icon,
14 title: resource.title,
15 arch: resource.arch,
16+ image_id: resource.id,
17 size: resource.size,
18 status: resource.status
19 };
20@@ -537,6 +539,30 @@
21 return false;
22 };
23
24+ // Return if we are asking about deleting this image.
25+ $scope.isShowingDeleteConfirm = function(image) {
26+ return image === $scope.removingImage;
27+ };
28+
29+ // Mark the image for deletion.
30+ $scope.quickRemove = function(image) {
31+ $scope.removingImage = image;
32+ };
33+
34+ // Cancel image deletion.
35+ $scope.cancelRemove = function() {
36+ $scope.removingImage = null;
37+ };
38+
39+ // Mark the image for deletion.
40+ $scope.confirmRemove = function(image) {
41+ if(image === $scope.removingImage) {
42+ BootResourcesManager.deleteImage(
43+ {id: image.image_id});
44+ }
45+ $scope.cancelRemove();
46+ };
47+
48 // Return true if the stop import button should be shown.
49 $scope.showStopImportButton = function() {
50 return $scope.bootResources.region_import_running;
51
52=== modified file 'src/maasserver/static/js/angular/directives/tests/test_boot_images.js'
53--- src/maasserver/static/js/angular/directives/tests/test_boot_images.js 2016-12-07 12:59:10 +0000
54+++ src/maasserver/static/js/angular/directives/tests/test_boot_images.js 2017-03-23 21:33:25 +0000
55@@ -88,6 +88,7 @@
56 expect(scope.generatedImages).toEqual([]);
57 expect(scope.customImages).toEqual([]);
58 expect(scope.ubuntuDeleteId).toBeNull();
59+ expect(scope.removingImage).toBeNull();
60 });
61
62 it("clears loading once polling and user manager loaded", function() {
63@@ -1166,6 +1167,7 @@
64 var size = makeName("size");
65 var status = makeName("status");
66 scope.bootResources.resources = [{
67+ id: 3,
68 rtype: 1,
69 icon: icon,
70 title: title,
71@@ -1179,6 +1181,7 @@
72 icon: 'icon--status-' + icon + ' u-animation--pulse',
73 title: title,
74 arch: arch,
75+ image_id: 3,
76 size: size,
77 status: status
78 }]);
79@@ -1197,6 +1200,7 @@
80 var status = makeName("status");
81 scope.bootResources.resources = [{
82 rtype: 2,
83+ id: 3,
84 icon: icon,
85 title: title,
86 arch: arch,
87@@ -1209,12 +1213,88 @@
88 icon: 'icon--status-' + icon + ' u-animation--pulse',
89 title: title,
90 arch: arch,
91+ image_id: 3,
92 size: size,
93 status: status
94 }]);
95 });
96 });
97
98+ describe("isShowingDeleteConfirm", function() {
99+ it("returns false when not deleting", function() {
100+ var directive = compileDirective();
101+ var scope = directive.isolateScope();
102+ var image = {image_id: 3};
103+ expect(scope.isShowingDeleteConfirm(image)).toBe(false);
104+ });
105+
106+ it("returns true when deleting this image", function() {
107+ var directive = compileDirective();
108+ var scope = directive.isolateScope();
109+ var image1 = {image_id: 3};
110+ var image2 = {image_id: 7};
111+ scope.removingImage = image1;
112+ expect(scope.isShowingDeleteConfirm(image1)).toBe(true);
113+ });
114+
115+ it("returns false when deleting other image", function() {
116+ var directive = compileDirective();
117+ var scope = directive.isolateScope();
118+ var image1 = {image_id: 3};
119+ var image2 = {image_id: 7};
120+ scope.removingImage = image1;
121+ expect(scope.isShowingDeleteConfirm(image2)).toBe(false);
122+ });
123+ });
124+
125+ describe("quickRemove", function() {
126+ it("sets removingImage", function() {
127+ var directive = compileDirective();
128+ var scope = directive.isolateScope();
129+ var image = {image_id: 3};
130+ scope.quickRemove(image);
131+ expect(scope.removingImage).toBe(image);
132+ });
133+ });
134+
135+ describe("cancelRemove", function() {
136+ it("clears removingImage", function() {
137+ var directive = compileDirective();
138+ var scope = directive.isolateScope();
139+ var image = {image_id: 3};
140+ scope.removingImage = image;
141+ scope.cancelRemove();
142+ expect(scope.removingImage).toBe(null);
143+ });
144+ });
145+
146+ describe("confirmRemove", function() {
147+ it("calls delete_image if given removingImage", function() {
148+ var directive = compileDirective();
149+ var scope = directive.isolateScope();
150+ var image1 = {image_id: 3};
151+ var image2 = {image_id: 7};
152+ scope.removingImage = image1;
153+ spyOn(BootResourcesManager, "deleteImage");
154+ scope.confirmRemove(image1);
155+ expect(scope.removingImage).toBe(null);
156+ expect(BootResourcesManager.deleteImage).toHaveBeenCalledWith(
157+ {id: image1.image_id});
158+ });
159+
160+ it("does not call delete_image if given other image", function() {
161+ var directive = compileDirective();
162+ var scope = directive.isolateScope();
163+ var image1 = {image_id: 3};
164+ var image2 = {image_id: 7};
165+ scope.removingImage = image1;
166+ spyOn(BootResourcesManager, "deleteImage");
167+ scope.confirmRemove(image2);
168+ expect(scope.removingImage).toBe(null);
169+ expect(BootResourcesManager.deleteImage).not.toHaveBeenCalled();
170+ });
171+ });
172+
173 describe("ltsIsSelected", function() {
174
175 it("returns true if LTS is selected", function() {
176
177=== modified file 'src/maasserver/static/partials/boot-images.html'
178--- src/maasserver/static/partials/boot-images.html 2016-12-07 12:59:10 +0000
179+++ src/maasserver/static/partials/boot-images.html 2017-03-23 21:33:25 +0000
180@@ -116,7 +116,7 @@
181 <div class="table__header table-col--25">Release</div>
182 <div class="table__header table-col--15">Architecture</div>
183 <div class="table__header table-col--20">Size</div>
184- <div class="table__header table-col--30">Status</div>
185+ <div class="table__header table-col--40">Status</div>
186 </div>
187 </header>
188 <main class="table__body">
189@@ -192,7 +192,7 @@
190 <div class="table__header table-col--25">Release</div>
191 <div class="table__header table-col--15">Architecture</div>
192 <div class="table__header table-col--20">Size</div>
193- <div class="table__header table-col--30">Status</div>
194+ <div class="table__header table-col--40">Status</div>
195 </div>
196 </header>
197 <main class="table__body">
198@@ -205,12 +205,12 @@
199 <div class="table__data table-col--2">
200 <i class="icon {$ image.icon $}"></i>
201 </div>
202- <div class="table__data table-col--23">
203+ <div class="table__data table-col--23" aria-label="Release">
204 {$ image.title $}
205 </div>
206- <div class="table__data table-col--15">{$ image.arch $}</div>
207- <div class="table__data table-col--20">{$ image.size $}</div>
208- <div class="table__data table-col--30">{$ image.status $}</div>
209+ <div class="table__data table-col--15" aria-label="Architecture">{$ image.arch $}</div>
210+ <div class="table__data table-col--20" aria-label="Size">{$ image.size $}</div>
211+ <div class="table__data table-col--40" aria-label="Status">{$ image.status $}</div>
212 </div>
213 </main>
214 </section>
215@@ -233,7 +233,7 @@
216 <div class="table__header table-col--25">Release</div>
217 <div class="table__header table-col--15">Architecture</div>
218 <div class="table__header table-col--20">Size</div>
219- <div class="table__header table-col--30">Status</div>
220+ <div class="table__header table-col--40">Status</div>
221 </div>
222 </header>
223 <main class="table__body">
224@@ -246,12 +246,28 @@
225 <div class="table__data table-col--2">
226 <i class="icon {$ image.icon $}"></i>
227 </div>
228- <div class="table__data table-col--23">
229+ <div class="table__data table-col--23" aria-label="Release">
230 {$ image.title $}
231 </div>
232- <div class="table__data table-col--15">{$ image.arch $}</div>
233- <div class="table__data table-col--20">{$ image.size $}</div>
234- <div class="table__data table-col--30">{$ image.status $}</div>
235+ <div class="table__data table-col--15" aria-label="Architecture">{$ image.arch $}</div>
236+ <div class="table__data table-col--20" aria-label="Size">{$ image.size $}</div>
237+ <div class="table__data table-col--37" aria-label="Status">{$ image.status $}</div>
238+ <div class="table__data table-col--3">
239+ <div class="table__controls u-align--right">
240+ <a class="u-display--desktop icon icon--delete tooltip"
241+ aria-label="Remove"
242+ data-ng-click="quickRemove(image)"></a>
243+ </div>
244+ </div>
245+ <div class="table__row is-active" data-ng-if="isShowingDeleteConfirm(image)">
246+ <div class="table__data u-float--left">
247+ <p><span class="icon icon--warning u-margin--right-small"></span> Are you sure you want to remove this image?</p>
248+ </div>
249+ <div class="table__data u-float--right">
250+ <a class="button--base button--inline" data-ng-click="cancelRemove()">Cancel</a>
251+ <button class="button--destructive button--inline" data-ng-click="confirmRemove(image)">Remove</button>
252+ </div>
253+ </div>
254 </div>
255 </main>
256 </section>
257@@ -266,7 +282,7 @@
258 <div class="table__header table-col--25">Release</div>
259 <div class="table__header table-col--15">Architecture</div>
260 <div class="table__header table-col--20">Size</div>
261- <div class="table__header table-col--30">Status</div>
262+ <div class="table__header table-col--40">Status</div>
263 </div>
264 </header>
265 <main class="table__body">
266@@ -279,12 +295,28 @@
267 <div class="table__data table-col--2">
268 <i class="icon {$ image.icon $}"></i>
269 </div>
270- <div class="table__data table-col--23">
271+ <div class="table__data table-col--23" aria-label="Release">
272 {$ image.title $}
273 </div>
274- <div class="table__data table-col--15">{$ image.arch $}</div>
275- <div class="table__data table-col--20">{$ image.size $}</div>
276- <div class="table__data table-col--30">{$ image.status $}</div>
277+ <div class="table__data table-col--15" aria-label="Architecture">{$ image.arch $}</div>
278+ <div class="table__data table-col--20" aria-label="Size">{$ image.size $}</div>
279+ <div class="table__data table-col--37" aria-label="Status">{$ image.status $}</div>
280+ <div class="table__data table-col--3">
281+ <div class="table__controls u-align--right">
282+ <a class="u-display--desktop icon icon--delete tooltip"
283+ aria-label="Remove"
284+ data-ng-click="quickRemove(image)"></a>
285+ </div>
286+ </div>
287+ <div class="table__row is-active" data-ng-if="isShowingDeleteConfirm(image)">
288+ <div class="table__data u-float--left">
289+ <p><span class="icon icon--warning u-margin--right-small"></span> Are you sure you want to remove this image?</p>
290+ </div>
291+ <div class="table__data u-float--right">
292+ <a class="button--base button--inline" data-ng-click="cancelRemove()">Cancel</a>
293+ <button class="button--destructive button--inline" data-ng-click="confirmRemove(image)">Remove</button>
294+ </div>
295+ </div>
296 </div>
297 </main>
298 </section>

Subscribers

People subscribed via source and target branches

to all changes: