Skip to content

Commit a9569d5

Browse files
Merge pull request #3535 from shapeblue/minor_413_fixes
Misc fixes to sharing templates functionality
2 parents d3b292a + f9b3771 commit a9569d5

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

ui/scripts/cloudStack.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@
318318
g_userProjectsEnabled = json.listcapabilitiesresponse.capability.allowusercreateprojects;
319319

320320
g_cloudstackversion = json.listcapabilitiesresponse.capability.cloudstackversion;
321+
// Allow users to see all accounts within a domain
322+
g_allowUserViewAllDomainAccounts = json.listcapabilitiesresponse.capability.allowuserviewalldomainaccounts;
321323

322324
if (json.listcapabilitiesresponse.capability.apilimitinterval != null && json.listcapabilitiesresponse.capability.apilimitmax != null) {
323325
var intervalLimit = ((json.listcapabilitiesresponse.capability.apilimitinterval * 1000) / json.listcapabilitiesresponse.capability.apilimitmax) * 3; //multiply 3 to be on safe side
@@ -374,6 +376,7 @@
374376
g_kvmsnapshotenabled = null;
375377
g_regionsecondaryenabled = null;
376378
g_loginCmdText = null;
379+
g_allowUserViewAllDomainAccounts = null;
377380

378381
// Remove any cookies
379382
var cookies = document.cookie.split(";");
@@ -410,6 +413,7 @@
410413
g_kvmsnapshotenabled = null;
411414
g_regionsecondaryenabled = null;
412415
g_loginCmdText = null;
416+
g_allowUserViewAllDomainAccounts = null;
413417

414418
// Remove any cookies
415419
var cookies = document.cookie.split(";");

ui/scripts/sharedFunctions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var g_queryAsyncJobResultInterval = 3000;
3636
var g_idpList = null;
3737
var g_appendIdpDomain = false;
3838
var g_sortKeyIsAscending = false;
39-
var g_allowUserViewAllDomainAccounts= false;
39+
var g_allowUserViewAllDomainAccounts = false;
4040

4141
//keyboard keycode
4242
var keycode_Enter = 13;

ui/scripts/templates.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,8 +1643,8 @@
16431643
success: function (jsonAccounts) {
16441644
var accountByName = {};
16451645
$.each(jsonAccounts.listaccountsresponse.account, function(idx, account) {
1646-
// Only add current domain's accounts as update template permissions supports that
1647-
if (account.domainid === g_domainid) {
1646+
// Only add current domain's accounts for add as update template permissions supports that
1647+
if (account.domainid === g_domainid && operation === "add") {
16481648
accountByName[account.name] = {
16491649
projName: account.name,
16501650
hasPermission: false
@@ -1658,7 +1658,9 @@
16581658
success: function (json) {
16591659
items = json.listtemplatepermissionsresponse.templatepermission.account;
16601660
$.each(items, function(idx, accountName) {
1661-
accountByName[accountName].hasPermission = true;
1661+
if (accountByName[accountName]) {
1662+
accountByName[accountName].hasPermission = true;
1663+
}
16621664
});
16631665

16641666
var accountObjs = [];
@@ -1707,8 +1709,8 @@
17071709
success: function (jsonProjects) {
17081710
var projectsByIds = {};
17091711
$.each(jsonProjects.listprojectsresponse.project, function(idx, project) {
1710-
// Only add current domain's projects as update template permissions supports that
1711-
if (project.domainid === g_domainid) {
1712+
// Only add current domain's projects for add operation as update template permissions supports that
1713+
if ((project.domainid === g_domainid && operation === "add") || operation === "remove") {
17121714
projectsByIds[project.id] = {
17131715
projName: project.name,
17141716
hasPermission: false
@@ -1723,7 +1725,9 @@
17231725
success: function (json) {
17241726
items = json.listtemplatepermissionsresponse.templatepermission.projectids;
17251727
$.each(items, function(idx, projectId) {
1726-
projectsByIds[projectId].hasPermission = true;
1728+
if (projectsByIds[projectId]) {
1729+
projectsByIds[projectId].hasPermission = true;
1730+
}
17271731
});
17281732

17291733
var projectObjs = [];

0 commit comments

Comments
 (0)