Merge ~steverydz/maas:add-spaces-to-machines-table into maas:master

Proposed by Steve Rydz
Status: Merged
Approved by: Steve Rydz
Approved revision: 4da556293ec54eb9e920daccde80f3f9cd9b672d
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~steverydz/maas:add-spaces-to-machines-table
Merge into: maas:master
Diff against target: 94 lines (+46/-4)
3 files modified
src/maasserver/static/js/angular/directives/machines_table.js (+16/-0)
src/maasserver/static/js/angular/directives/tests/test_machines_table.js (+16/-0)
src/maasserver/static/partials/machines-table.html (+14/-4)
Reviewer Review Type Date Requested Status
Caleb Ellis (community) Approve
Review via email: mp+366650@code.launchpad.net

Commit message

LP: #1822647 - Add spaces to machines table

Description of the change

Add spaces underneath zones in machines table

QA steps:
- Go to machines listing page
- See that under the "zones" table heading there is also "spaces"
- If there are no spaces then nothing is displayed under the zone
- If there is one space, the name of that space is displayed under the zone
- If there are multiple spaces, the number of spaces is shown with a tooltip listing all spaces

Spaces in table screenshot: https://images.zenhubusercontent.com/5a9d4ee34b5806bc2bc9694d/46f6b43d-0b93-40e8-b792-a88d0d5fee3b

Spaces in table with tooltip screenshot: https://images.zenhubusercontent.com/5a9d4ee34b5806bc2bc9694d/1b9bfff3-c98a-4f65-90b1-abaaf6cae2c9

To post a comment you must log in.
Revision history for this message
Caleb Ellis (caleb-ellis) wrote :

LGTM! Just remember to run `bin/yarn prettier` (might need to run just `bin/yarn` first) because there's a couple of tiny linting errors.

review: Approve
Revision history for this message
Steve Rydz (steverydz) wrote :

> LGTM! Just remember to run `bin/yarn prettier` (might need to run just
> `bin/yarn` first) because there's a couple of tiny linting errors.

Done

Revision history for this message
Barry McGee (barry-mcgee) wrote :

Pettier CLI includes a `--check` flag which you could add as a build step.

https://prettier.io/docs/en/cli.html#check

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

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/machines_table.js b/src/maasserver/static/js/angular/directives/machines_table.js
2index 5cbd11c..9bfd714 100644
3--- a/src/maasserver/static/js/angular/directives/machines_table.js
4+++ b/src/maasserver/static/js/angular/directives/machines_table.js
5@@ -349,6 +349,22 @@ function maasMachinesTable(
6 }
7 };
8
9+ $scope.getSpacesTooltipMessage = spaces => {
10+ var spacesMessage = "";
11+
12+ if (spaces.length > 1) {
13+ spaces.forEach((space, index) => {
14+ spacesMessage += space;
15+
16+ if (index !== spaces.length - 1) {
17+ spacesMessage += "\n";
18+ }
19+ });
20+ }
21+
22+ return spacesMessage;
23+ };
24+
25 $scope.getGroupSelectedState = groupLabel => {
26 const machineGroup = $scope.groupedMachines.find(group => {
27 return group.label === groupLabel;
28diff --git a/src/maasserver/static/js/angular/directives/tests/test_machines_table.js b/src/maasserver/static/js/angular/directives/tests/test_machines_table.js
29index fc03e88..d23a087 100644
30--- a/src/maasserver/static/js/angular/directives/tests/test_machines_table.js
31+++ b/src/maasserver/static/js/angular/directives/tests/test_machines_table.js
32@@ -1013,4 +1013,20 @@ describe("maasMachinesTable", function() {
33 expect(scope.getGroupCountString("Failed")).toBe("2 machines");
34 });
35 });
36+
37+ describe("getSpacesTooltipMessage", () => {
38+ it("correctly returns a list of spaces or empty string", () => {
39+ const directive = compileDirective();
40+ const scope = directive.isolateScope();
41+ const machines = Array.from(Array(3)).map(makeMachine);
42+ machines[0].spaces = [];
43+ machines[1].spaces = ["foobar"];
44+ machines[2].spaces = ["foobar", "barbaz"];
45+
46+ expect(scope.getSpacesTooltipMessage(machines[0].spaces)).toBe("");
47+ expect(scope.getSpacesTooltipMessage(machines[1].spaces)).toBe("");
48+ expect(scope.getSpacesTooltipMessage(machines[2].spaces)).toBe(`foobar
49+barbaz`); // Has to be formatted this way for tooltip
50+ });
51+ });
52 });
53diff --git a/src/maasserver/static/partials/machines-table.html b/src/maasserver/static/partials/machines-table.html
54index a23d462..1202e3c 100644
55--- a/src/maasserver/static/partials/machines-table.html
56+++ b/src/maasserver/static/partials/machines-table.html
57@@ -36,8 +36,9 @@
58 <span role="columnheader" data-ng-click="sortTable('pool.name')" data-ng-class="{'is-sorted': table.predicate === 'pool.name', 'sort-asc': table.reverse === false, 'sort-desc': table.reverse === true}">Pool,</span>
59 <div>Note</div>
60 </th>
61- <th class="p-table__col--zone p-double-row" title="Zone">
62- <span role="columnheader" data-ng-click="sortTable('zone.name')" data-ng-class="{'is-sorted': table.predicate === 'zone.name', 'sort-asc': table.reverse === false, 'sort-desc': table.reverse === true}">Zone</span>
63+ <th class="p-table__col--zone p-double-row" title="Zone, Spaces">
64+ <span role="columnheader" data-ng-click="sortTable('zone.name')" data-ng-class="{'is-sorted': table.predicate === 'zone.name', 'sort-asc': table.reverse === false, 'sort-desc': table.reverse === true}">Zone,</span>
65+ <div>Spaces</div>
66 </th>
67 <th class="p-table__col--fabric p-double-row" title="Fabric, VLAN">
68 <span role="columnheader" data-ng-click="sortTable('vlan.fabric_name')" data-ng-class="{'is-sorted': table.predicate === 'vlan.fabric_name', 'sort-asc': table.reverse === false, 'sort-desc': table.reverse === true}">Fabric,</span>
69@@ -312,14 +313,23 @@
70 </span>
71 </div>
72 </td>
73- <td class="p-table__col--zone p-double-row" aria-label="Zone" title="{$ node.zone.name $}">
74+ <td class="p-table__col--zone p-double-row" aria-label="Zone">
75 <div class="p-table-menu">
76 <div class="p-double-row__rows-container">
77- <div class="p-double-row__main-row" aria-label="Zone">
78+ <div class="p-double-row__main-row" aria-label="Zone" title="{$ node.zone.name $}">
79 <i class="p-icon--spinner u-animation--spin" data-ng-if="node['set-zone-transition']">Setting zone</i>
80 <span data-ng-if="node.zone.name"><a class="p-link--soft" href="#/zone/{$ node.zone.id $}" title="{$ node.zone.name $}">{$ node.zone.name $}</a></span>
81 <span data-ng-if="!node.zone.name">-</span>
82 </div>
83+ <div class="p-double-row__muted-row" style="overflow: visible">
84+ <span data-ng-if="node.spaces.length === 1">
85+ {$ node.spaces[0] $}
86+ </span>
87+ <span data-ng-if="node.spaces.length > 1" class="p-tooltip p-tooltip--btm-left" aria-described-by="{$ node.hostname $}-spaces" style="overflow: visible">
88+ {$ node.spaces.length $} spaces
89+ <span class="p-tooltip__message" role="tooltip" id="{$ node.hostname $}-spaces">{$ getSpacesTooltipMessage(node.spaces) $}</span>
90+ </span>
91+ </div>
92 </div>
93 <button
94 data-ng-if="node.actions.indexOf('set-zone') !== -1 && !hideActions"

Subscribers

People subscribed via source and target branches