Browse Source

Restore network/port options for create instance dialog

An earlier commit:
d86c6ea3cc

patched the "create instance" dialog such that even when
its launched from Project -> Compute -> Instances, the "GBP" workflow step
is shown instead of the expected "Networks" and "Ports" steps. The former
should be shown only in the case when the dialog is launched from GBP and
the original behavior should be preserved when the dialog is launched from
Compute. This is being fixed here.

Change-Id: Ie9af2cca451942d51ea254bdf14bc2345743f938
Sumit Naiksatam 1 year ago
parent
commit
c0f6597c7f

+ 23
- 18
gbpui/static/dashboard/gbpui/group-member/group-member-launch-instance.patcher.js View File

@@ -25,7 +25,8 @@
25 25
        $provide.decorator(
26 26
            'horizon.dashboard.project.workflow.launch-instance.workflow',
27 27
            ["$delegate", 'horizon.app.core.workflow.factory',
28
-               function($delegate, dashboardWorkflow)
28
+            'gbpui.group-member.launch-context.service',
29
+               function($delegate, dashboardWorkflow, launchContextService)
29 30
                {
30 31
                 var steps = $delegate.steps;
31 32
                 var gbstep = {
@@ -36,24 +37,28 @@
36 37
                     formName: 'gbpForm'
37 38
                 };
38 39
 
39
-                // Finds and replaces the Network and Port wizard pages with
40
-                // the GBP wizard page
41
-                var networkIndex = -1;
42
-                var portIndex = -1;
43
-                angular.forEach(steps, function (step) {
44
-                    if(step.id == 'networks') {
45
-                        networkIndex = steps.indexOf(step)
46
-                    } else if(step.id == 'ports') {
47
-                        portIndex = steps.indexOf(step);
48
-                    }
49
-                });
40
+                // This check can be potentially made more restrictive to specifically
41
+                // check if policy_target is in the URL
42
+                if (launchContextService.launchContext.successUrl != '/dashboard/project/instances/') {
43
+                    // Finds and replaces the Network and Port wizard pages with
44
+                    // the GBP wizard page
45
+                    var networkIndex = -1;
46
+                    var portIndex = -1;
47
+                    angular.forEach(steps, function (step) {
48
+                        if(step.id == 'networks') {
49
+                            networkIndex = steps.indexOf(step)
50
+                        } else if(step.id == 'ports') {
51
+                            portIndex = steps.indexOf(step);
52
+                        }
53
+                    });
50 54
 
51
-                if(networkIndex > -1) {
52
-                    steps.splice(networkIndex, 1, gbstep);
53
-                }
55
+                    if(networkIndex > -1) {
56
+                        steps.splice(networkIndex, 1, gbstep);
57
+                    }
54 58
 
55
-                if(portIndex > -1) {
56
-                    steps.splice(portIndex, 1);
59
+                    if(portIndex > -1) {
60
+                        steps.splice(portIndex, 1);
61
+                    }
57 62
                 }
58 63
 
59 64
                 var result = dashboardWorkflow($delegate);
@@ -62,4 +67,4 @@
62 67
        );
63 68
     }
64 69
 
65
-})();
70
+})();

Loading…
Cancel
Save