GUACAMOLE-220: Migrate connection permission editor to tab-based views.

This commit is contained in:
Michael Jumper
2018-07-21 13:23:46 -07:00
parent deb5b51ddc
commit 62e58eaf9f
3 changed files with 42 additions and 13 deletions

View File

@@ -110,11 +110,40 @@ angular.module('manage').directive('connectionPermissionEditor', ['$injector',
var readableRootGroups = null; var readableRootGroups = null;
/** /**
* Whether the items displayed within the connection permission editor * The name of the tab within the connection permission editor which
* should be limited to those which had explicit READ permission at the * displays readable connections only.
* time the editor was loaded. *
* @constant
* @type String
*/ */
$scope.displayReadableOnly = false; var SELECTED_CONNECTIONS = 'SELECTED_CONNECTIONS';
/**
* The name of the tab within the connection permission editor which
* displays all connections, regardless of whether they are readable.
*
* @constant
* @type String
*/
var ALL_CONNECTIONS = 'ALL_CONNECTIONS';
/**
* The names of all tabs which should be available within the
* connection permission editor, in display order.
*
* @type String[]
*/
$scope.tabs = [
SELECTED_CONNECTIONS,
ALL_CONNECTIONS
];
/**
* The name of the currently selected tab.
*
* @type String
*/
$scope.currentTab = ALL_CONNECTIONS;
/** /**
* Array of all connection properties that are filterable. * Array of all connection properties that are filterable.
@@ -145,7 +174,7 @@ angular.module('manage').directive('connectionPermissionEditor', ['$injector',
* root connection groups within those data sources. * root connection groups within those data sources.
*/ */
$scope.getRootGroups = function getRootGroups() { $scope.getRootGroups = function getRootGroups() {
return $scope.displayReadableOnly ? readableRootGroups : allRootGroups; return $scope.currentTab === SELECTED_CONNECTIONS ? readableRootGroups : allRootGroups;
}; };
/** /**
@@ -312,7 +341,7 @@ angular.module('manage').directive('connectionPermissionEditor', ['$injector',
// Display only readable connections by default if at least one // Display only readable connections by default if at least one
// readable connection exists // readable connection exists
$scope.displayReadableOnly = !!readableRootGroups[$scope.dataSource].children.length; $scope.currentTab = !!readableRootGroups[$scope.dataSource].children.length ? SELECTED_CONNECTIONS : ALL_CONNECTIONS;
}); });

View File

@@ -1,15 +1,13 @@
<div class="connection-permissions"> <div class="connection-permissions">
<div class="header"> <div class="header tabbed">
<h2>{{'MANAGE_USER.SECTION_HEADER_CONNECTIONS' | translate}}</h2> <h2>{{'MANAGE_USER.SECTION_HEADER_CONNECTIONS' | translate}}</h2>
<div class="filter">
<label><input type="checkbox" ng-model="displayReadableOnly"> {{'MANAGE_USER.' | translate}}</label>
</div>
<guac-group-list-filter connection-groups="getRootGroups()" <guac-group-list-filter connection-groups="getRootGroups()"
filtered-connection-groups="filteredRootGroups" filtered-connection-groups="filteredRootGroups"
placeholder="'MANAGE_USER.FIELD_PLACEHOLDER_FILTER' | translate" placeholder="'MANAGE_USER.FIELD_PLACEHOLDER_FILTER' | translate"
connection-properties="filteredConnectionProperties" connection-properties="filteredConnectionProperties"
connection-group-properties="filteredConnectionGroupProperties"></guac-group-list-filter> connection-group-properties="filteredConnectionGroupProperties"></guac-group-list-filter>
</div> </div>
<guac-section-tabs namespace="MANAGE_USER" current="currentTab" tabs="tabs"></guac-section-tabs>
<div class="section"> <div class="section">
<guac-group-list <guac-group-list
context="groupListContext" context="groupListContext"

View File

@@ -303,9 +303,11 @@
"INFO_READ_ONLY" : "Sorry, but this user account cannot be edited.", "INFO_READ_ONLY" : "Sorry, but this user account cannot be edited.",
"SECTION_HEADER_CONNECTIONS" : "Connections", "SECTION_HEADER_ALL_CONNECTIONS" : "All Connections",
"SECTION_HEADER_EDIT_USER" : "Edit User", "SECTION_HEADER_CONNECTIONS" : "Connections",
"SECTION_HEADER_PERMISSIONS" : "Permissions", "SECTION_HEADER_EDIT_USER" : "Edit User",
"SECTION_HEADER_PERMISSIONS" : "Permissions",
"SECTION_HEADER_SELECTED_CONNECTIONS" : "Selected Connections",
"TEXT_CONFIRM_DELETE" : "Users cannot be restored after they have been deleted. Are you sure you want to delete this user?" "TEXT_CONFIRM_DELETE" : "Users cannot be restored after they have been deleted. Are you sure you want to delete this user?"