diff --git a/designatedashboard/static/designatedashboard/resources/os-designate-floatingip/actions/set.service.js b/designatedashboard/static/designatedashboard/resources/os-designate-floatingip/actions/set.service.js index 89e63f0..c8b09fb 100644 --- a/designatedashboard/static/designatedashboard/resources/os-designate-floatingip/actions/set.service.js +++ b/designatedashboard/static/designatedashboard/resources/os-designate-floatingip/actions/set.service.js @@ -98,7 +98,7 @@ }; var service = { - initScope: initScope, + initAction: initAction, allowed: allowed, perform: perform }; @@ -107,7 +107,7 @@ ///////////////// - function initScope() { + function initAction() { dnsServiceEnabled = serviceCatalog.ifTypeEnabled('dns'); } diff --git a/designatedashboard/static/designatedashboard/resources/os-designate-floatingip/actions/unset.service.js b/designatedashboard/static/designatedashboard/resources/os-designate-floatingip/actions/unset.service.js index 11be68a..f66b958 100644 --- a/designatedashboard/static/designatedashboard/resources/os-designate-floatingip/actions/unset.service.js +++ b/designatedashboard/static/designatedashboard/resources/os-designate-floatingip/actions/unset.service.js @@ -72,7 +72,7 @@ }; var service = { - initScope: initScope, + initAction: initAction, allowed: allowed, perform: perform }; @@ -81,7 +81,7 @@ ///////////////// - function initScope() { + function initAction() { dnsServiceEnabled = serviceCatalog.ifTypeEnabled('dns'); } diff --git a/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/create.service.js b/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/create.service.js index 84c65e2..db9298a 100644 --- a/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/create.service.js +++ b/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/create.service.js @@ -59,7 +59,7 @@ }; var service = { - initScope: initScope, + initAction: initAction, allowed: allowed, perform: perform }; @@ -68,7 +68,7 @@ ///////////////// - function initScope() { + function initAction() { createRecordSetPolicy = policy.ifAllowed({rules: [['dns', 'create_recordset']]}); dnsServiceEnabled = serviceCatalog.ifTypeEnabled('dns'); } diff --git a/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/delete.service.js b/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/delete.service.js index 1d36e9a..2611794 100644 --- a/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/delete.service.js +++ b/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/delete.service.js @@ -56,12 +56,12 @@ deleteModal, toast ) { - var scope, context, deletePromise; + var context, deletePromise; var notAllowedMessage = gettext("You are not allowed to delete record sets: %s"); var allowedRecordsets = []; var service = { - initScope: initScope, + initAction: initAction, allowed: allowed, perform: perform }; @@ -70,17 +70,18 @@ ////////////// - function initScope(newScope) { - scope = newScope; + function initAction() { context = { }; deletePromise = policy.ifAllowed({rules: [['dns', 'delete_recordset']]}); } - function perform(items) { + function perform(items, scope) { var recordsets = angular.isArray(items) ? items : [items]; context.labels = labelize(recordsets.length); context.deleteEntity = deleteRecordSet; - return $qExtensions.allSettled(recordsets.map(checkPermission)).then(afterCheck); + return $qExtensions + .allSettled(recordsets.map(checkPermission)) + .then(afterCheck.bind(this, scope)); } function allowed(recordset) { @@ -100,7 +101,7 @@ return {promise: allowed(recordset), context: recordset}; } - function afterCheck(result) { + function afterCheck(scope, result) { var outcome = $q.reject(); // Reject the promise by default if (result.fail.length > 0) { toast.add('error', getMessage(notAllowedMessage, result.fail)); diff --git a/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/update.service.js b/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/update.service.js index caca961..cd287d1 100644 --- a/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/update.service.js +++ b/designatedashboard/static/designatedashboard/resources/os-designate-recordset/actions/update.service.js @@ -63,7 +63,7 @@ }; var service = { - initScope: initScope, + initAction: initAction, allowed: allowed, perform: perform }; @@ -72,7 +72,7 @@ ///////////////// - function initScope() { + function initAction() { updateRecordSetPolicy = policy.ifAllowed({rules: [['dns', 'update_recordset']]}); dnsServiceEnabled = serviceCatalog.ifTypeEnabled('dns'); } diff --git a/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/create.service.js b/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/create.service.js index ed53aa3..f1d34ba 100644 --- a/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/create.service.js +++ b/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/create.service.js @@ -57,7 +57,7 @@ }; var service = { - initScope: initScope, + initAction: initAction, allowed: allowed, perform: perform }; @@ -66,7 +66,7 @@ ///////////////// - function initScope() { + function initAction() { createZonePolicy = policy.ifAllowed({rules: [['dns', 'create_zone']]}); dnsServiceEnabled = serviceCatalog.ifTypeEnabled('dns'); } diff --git a/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/delete.service.js b/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/delete.service.js index 5882dd6..a5192e3 100644 --- a/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/delete.service.js +++ b/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/delete.service.js @@ -56,11 +56,11 @@ toast, resourceType ) { - var scope, context, deleteZonePromise; + var context, deleteZonePromise; var notAllowedMessage = gettext("You are not allowed to delete zones: %s"); var service = { - initScope: initScope, + initAction: initAction, allowed: allowed, perform: perform }; @@ -69,17 +69,20 @@ ////////////// - function initScope(newScope) { - scope = newScope; - context = { }; - deleteZonePromise = policy.ifAllowed({rules: [['dns', 'delete_zone']]}); + function initAction() { + context = { }; + deleteZonePromise = policy.ifAllowed({rules: [['dns', 'delete_zone']]}); } - function perform(items) { + function perform(items, scope) { var zones = angular.isArray(items) ? items : [items]; context.labels = labelize(zones.length); context.deleteEntity = deleteZone; - return $qExtensions.allSettled(zones.map(checkPermission)).then(afterCheck); + return $qExtensions + .allSettled(zones.map(checkPermission)) + .then( + afterCheck.bind(this, scope) + ); } function allowed(zone) { @@ -100,7 +103,7 @@ return {promise: allowed(zone), context: zone}; } - function afterCheck(result) { + function afterCheck(scope, result) { var outcome = $q.reject(); // Reject the promise by default if (result.fail.length > 0) { toast.add('error', getMessage(notAllowedMessage, result.fail)); diff --git a/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/update.service.js b/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/update.service.js index 2610570..0db3095 100644 --- a/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/update.service.js +++ b/designatedashboard/static/designatedashboard/resources/os-designate-zone/actions/update.service.js @@ -59,7 +59,7 @@ }; var service = { - initScope: initScope, + initAction: initAction, allowed: allowed, perform: perform }; @@ -68,7 +68,7 @@ ///////////////// - function initScope() { + function initAction() { updateZonePolicy = policy.ifAllowed({rules: [['dns', 'update_zone']]}); dnsServiceEnabled = serviceCatalog.ifTypeEnabled('dns'); }