templates: allow users to share templates with accounts or projects through UI #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Problem: CloudStack users want the ability to share templates with other accounts or projects through the UI.
Root Cause: The ‘updateTemplatePermissions’ is only available via API and needs to be integrated with the UI in order to allow users to share templates with other accounts within the same domain, and also with projects that the sharing account has access to.
Solution: The CloudStack UI template view has been extended to include a button that allows users to update template permissions through the ‘updateTemplatePermissions’ API. This API supports 3 operations i.e. add, remove or reset. The reset operation does not require any parameters and it simply removes all permissions for a template. The add and remove parameters require either accounts or projects to be specified for sharing or stop sharing templates. The ‘listAccounts’ API has been extended to allow users to see all the accounts within the same domain if the global setting ‘allow.view.all.domain.accounts’ is set to true. This allows the accounts selection to be a multi-selection.
Types of changes
Screenshots (if appropriate):
Reset Operation hides the Accounts and Project ID fields as this operation does not require any additional parameters to be set.
Operation = Reset; Account and Project fields not displayed

Operation = Add/Remove , global setting: 'allow.user.view.all.domain.accounts' = false;

Operation = Add , global setting: 'allow.user.view.all.domain.accounts' = true; Domain has 3 accounts in total (bt1, bt2 and bt3). Logged in user is bt1 and so it is not shown on the dropdown list.

Operation = Remove , global setting: 'allow.user.view.all.domain.accounts' = true; Domain has 3 accounts in total (bt1, bt2 and bt3). The current template was only shared with bt2 by bt1 so dropdown menu only shows accounts that the current template has been shared with.

How Has This Been Tested?