Merge ~caleb-ellis/maas:1811669-edit-mount-points into maas:master

Proposed by Caleb Ellis
Status: Merged
Approved by: Caleb Ellis
Approved revision: 591723163009db9b0f37fe2f2db0547f64362c67
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~caleb-ellis/maas:1811669-edit-mount-points
Merge into: maas:master
Diff against target: 111 lines (+11/-11)
4 files modified
src/maasserver/static/js/angular/controllers/node_details_storage.js (+1/-1)
src/maasserver/static/partials/node-details.html (+2/-2)
src/maasserver/static/partials/nodedetails/storage/disks-partitions.html (+5/-5)
src/maasserver/static/partials/nodedetails/storage/filesystems.html (+3/-3)
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
Steve Rydz (community) Approve
Review via email: mp+367902@code.launchpad.net

Commit message

LP: #1811669 - hide storage actions that auth user cannot perform

Description of the change

## Done
- Hide storage layout options that the current logged in user cannot perform.
- Added a guard to $scope.canPerformActionOnDatastoreSet if no $scope.storageLayout

## QA
- Go to the storage tab of a machine that you have permission to edit (i.e. user/admin) and check that you can still perform all actions as normal (e.g change storage layout, mount/unmount filesystems, edit partitions etc)
- Go to the storage tab of a machine that you can view but cannot edit (i.e. auditor) and check that you can see all the storage information, but cannot edit any of it.

## Screenshots
### Machine that you are a user/admin of
https://user-images.githubusercontent.com/25733845/58331767-c380b480-7e31-11e9-96eb-927f1230db2c.png

### Machine that you are an auditor of
https://user-images.githubusercontent.com/25733845/58331778-c7acd200-7e31-11e9-9a48-14ca39e065b8.png

To post a comment you must log in.
Revision history for this message
Steve Rydz (steverydz) wrote :

LGTM +1

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

lgtm

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/controllers/node_details_storage.js b/src/maasserver/static/js/angular/controllers/node_details_storage.js
2index 749abca..f0cb5c5 100644
3--- a/src/maasserver/static/js/angular/controllers/node_details_storage.js
4+++ b/src/maasserver/static/js/angular/controllers/node_details_storage.js
5@@ -283,7 +283,7 @@ export function NodeStorageController(
6 $scope.canPerformActionOnDatastoreSet = function() {
7 var editing = $scope.addToExistingDatastore || $scope.createNewDatastore;
8 var selected = $scope.selectedAvailableDatastores.length > 0;
9- var vmfs6 = $scope.storageLayout.id === "vmfs6";
10+ var vmfs6 = $scope.storageLayout && $scope.storageLayout.id === "vmfs6";
11 return !editing && selected && vmfs6;
12 };
13
14diff --git a/src/maasserver/static/partials/node-details.html b/src/maasserver/static/partials/node-details.html
15index 7d4e436..864da70 100755
16--- a/src/maasserver/static/partials/node-details.html
17+++ b/src/maasserver/static/partials/node-details.html
18@@ -2932,7 +2932,7 @@
19
20 <section class="p-strip u-no-padding--bottom" data-ng-if="section.area === 'storage'" data-ng-controller="NodeStorageController">
21 <form>
22- <div data-ng-if="node.status_code === 4 || node.status_code === 10">
23+ <div data-ng-if="canEdit() && (node.status_code === 4 || node.status_code === 10)">
24 <div class="row" data-ng-if="!confirmStorageLayout">
25 <div class="col-12 prefix-9 u-sv3">
26 <div class="p-form__group u-align--right">
27@@ -3021,7 +3021,7 @@
28
29 <div class="row">
30 <div data-ng-controller="NodeFilesystemsController" data-ng-if="storageLayout.id !== 'vmfs6'">
31- <storage-filesystems></storage-filesystems>
32+ <storage-filesystems canEdit="canEdit()"></storage-filesystems>
33 </div>
34 <div data-ng-show="cachesets.length">
35 <div class="row">
36diff --git a/src/maasserver/static/partials/nodedetails/storage/disks-partitions.html b/src/maasserver/static/partials/nodedetails/storage/disks-partitions.html
37index 4661058..c5b6067 100644
38--- a/src/maasserver/static/partials/nodedetails/storage/disks-partitions.html
39+++ b/src/maasserver/static/partials/nodedetails/storage/disks-partitions.html
40@@ -5,7 +5,7 @@
41 <thead>
42 <tr class="p-table__row">
43 <th class="p-double-row p-table__cell">
44- <div class="p-double-row__checkbox">&nbsp;</div>
45+ <div data-ng-if="canEdit()" class="p-double-row__checkbox">&nbsp;</div>
46 <div class="p-double-row__rows-container--checkbox">
47 <div>Name</div>
48 <div>Serial</div>
49@@ -22,7 +22,7 @@
50 <div>Tags</div>
51 </th>
52 <th class="p-table__cell">Health</th>
53- <th class="p-table__cell"><div class="u-align--right">Actions</div></th>
54+ <th data-ng-if="canEdit()" class="p-table__cell"><div class="u-align--right">Actions</div></th>
55 </tr>
56 </thead>
57 <tbody>
58@@ -35,11 +35,11 @@
59 data-ng-class="{ 'is-active': item.$selected }" data-ng-if="item.parent_type !== 'vmfs6'">
60 <td class="p-form-validation p-double-row p-table__cell" aria-label="Name"
61 data-ng-class="{ 'is-error': isNameInvalid(item) }">
62- <div class="p-double-row__checkbox">
63+ <div data-ng-if="canEdit()" class="p-double-row__checkbox">
64 <input type="checkbox" class="checkbox u-float--left" id="{$ item.name $}" data-ng-hide="isAvailableDisabled()" data-ng-checked="item.$selected" data-ng-click="toggleAvailableSelect(item)" data-ng-disabled="isAvailableDisabled()" />
65 <label for="{$ item.name $}"></label>
66 </div>
67- <div class="p-double-row__rows-container--checkbox">
68+ <div data-ng-class="{'p-double-row__rows-container--checkbox': canEdit(), 'p-double-row__rows-container': !canEdit()}">
69 <div class="p-double-row__main-row">
70 {$ item.name $}
71 </div>
72@@ -93,7 +93,7 @@
73 <span data-ng-if="item.test_status === 6" title="Degraded">Degraded</span>
74 <span data-ng-if="item.test_status === -1" title="Unknown">Unknown</span>
75 </td>
76- <td class="p-table--action-cell p-table__cell">
77+ <td data-ng-if="canEdit()" class="p-table--action-cell p-table__cell">
78 <div class="u-align--right">
79 <div class="p-contextual-menu" toggle-ctrl
80 data-ng-if="canAddLogicalVolume(item) || canAddPartition(item) || canEdit(item) || canDelete(item)">
81diff --git a/src/maasserver/static/partials/nodedetails/storage/filesystems.html b/src/maasserver/static/partials/nodedetails/storage/filesystems.html
82index 908e7aa..74595f4 100644
83--- a/src/maasserver/static/partials/nodedetails/storage/filesystems.html
84+++ b/src/maasserver/static/partials/nodedetails/storage/filesystems.html
85@@ -9,7 +9,7 @@
86 <th scope="col" aria-sort="none" class="col-2">Filesystem</th>
87 <th scope="col" aria-sort="none" class="col-2">Mount point</th>
88 <th scope="col" aria-sort="none" class="col-3">Mount options</th>
89- <th scope="col" aria-sort="none" class="col-1 u-align--right">Actions</th>
90+ <th data-ng-if="canEdit()" scope="col" aria-sort="none" class="col-1 u-align--right">Actions</th>
91 <th class="u-hide"><!-- empty cell for validation --></th>
92 </tr>
93 </thead>
94@@ -29,7 +29,7 @@
95 filesystem.mount_point $}</td>
96 <td role="gridcell" class="col-3" aria-label="Mount options" title="{$ filesystem.mount_options $}">{$
97 filesystem.mount_options $}</td>
98- <td role="gridcell" class="col-1 p-table--action-cell u-align--right">
99+ <td data-ng-if="canEdit()" role="gridcell" class="col-1 p-table--action-cell u-align--right">
100 <div class="p-contextual-menu" toggle-ctrl data-ng-if="!isAllStorageDisabled()">
101 <button class="p-button--base p-contextual-menu__toggle" aria-controls="#{$ item.name $}-menu"
102 data-ng-click="toggleMenu()" aria-haspopup="true">
103@@ -111,7 +111,7 @@
104 </tbody>
105 </table>
106 <button class="p-button--neutral p-tooltip--top-left" data-ng-disabled="dropdown !== null" data-ng-class="{ 'p-tooltip': dropdown === null}"
107- data-ng-if="!isAllStorageDisabled()" data-ng-click="addSpecialFilesystem()">
108+ data-ng-if="canEdit()" data-ng-click="addSpecialFilesystem()">
109 Add special filesystem
110 <span class="p-tooltip__message" role="tooltip">Create a tmpfs or ramfs filesystem</span>
111 </button>

Subscribers

People subscribed via source and target branches