From edc775c980c5238604fda4c7138a05ae56a3cc7e Mon Sep 17 00:00:00 2001 From: Pulkit vajpayee Date: Wed, 20 Jul 2022 11:48:33 +0530 Subject: [PATCH] fix launch instance GBP issue Change-Id: Ieb10c59d4b06c56e4cfde9f80c34d17b6bf9eb74 (cherry picked from commit 3e823ad3dc6c326ac004479e8ca61883ce78aea0) --- .../group-member-launch-context.service.js | 19 ++++++++++++++++--- .../group-member-launch-instance.patcher.js | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gbpui/static/dashboard/gbpui/group-member/group-member-launch-context.service.js b/gbpui/static/dashboard/gbpui/group-member/group-member-launch-context.service.js index d6e14c5..5519dcb 100644 --- a/gbpui/static/dashboard/gbpui/group-member/group-member-launch-context.service.js +++ b/gbpui/static/dashboard/gbpui/group-member/group-member-launch-context.service.js @@ -22,12 +22,25 @@ .factory('gbpui.group-member.launch-context.service', launchContextService); - launchContextService.$inject = []; + launchContextService.$inject = [ + '$location', + 'horizon.framework.util.http.service', + ]; - function launchContextService() { + function launchContextService($location,apiService) { + var policyGroups = {'data':[],'status':0}; + !$location.absUrl().includes('login') && apiService + .get('project/policytargets/policy_target_groups') + .error(function () { + policyGroups.status = 1 + }).then(data => { + policyGroups.data = data.data; + policyGroups.status = 1; + }); return { launchContext: { - defaults: [] + defaults: [], + policyGroups, } }; } diff --git a/gbpui/static/dashboard/gbpui/group-member/group-member-launch-instance.patcher.js b/gbpui/static/dashboard/gbpui/group-member/group-member-launch-instance.patcher.js index 199b5c0..87ccbba 100644 --- a/gbpui/static/dashboard/gbpui/group-member/group-member-launch-instance.patcher.js +++ b/gbpui/static/dashboard/gbpui/group-member/group-member-launch-instance.patcher.js @@ -39,7 +39,7 @@ // This check can be potentially made more restrictive to specifically // check if policy_target is in the URL - if (launchContextService.launchContext.successUrl != '/dashboard/project/instances/' && launchContextService.launchContext.successUrl != '/dashboard/project/network_topology/' && launchContextService.launchContext.successUrl != '/project/instances/' && launchContextService.launchContext.successUrl != '/project/network_topology/') { + if (launchContextService.launchContext.policyGroups.data.length && launchContextService.launchContext.successUrl != '/dashboard/project/instances/' && launchContextService.launchContext.successUrl != '/dashboard/project/network_topology/' && launchContextService.launchContext.successUrl != '/project/instances/' && launchContextService.launchContext.successUrl != '/project/network_topology/') { // Finds and replaces the Network and Port wizard pages with // the GBP wizard page var networkIndex = -1;