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
This commit is contained in:
Sumit Naiksatam 2018-01-30 13:03:12 -08:00
parent 99332501f0
commit c0f6597c7f
1 changed files with 23 additions and 18 deletions

View File

@ -25,7 +25,8 @@
$provide.decorator(
'horizon.dashboard.project.workflow.launch-instance.workflow',
["$delegate", 'horizon.app.core.workflow.factory',
function($delegate, dashboardWorkflow)
'gbpui.group-member.launch-context.service',
function($delegate, dashboardWorkflow, launchContextService)
{
var steps = $delegate.steps;
var gbstep = {
@ -36,24 +37,28 @@
formName: 'gbpForm'
};
// Finds and replaces the Network and Port wizard pages with
// the GBP wizard page
var networkIndex = -1;
var portIndex = -1;
angular.forEach(steps, function (step) {
if(step.id == 'networks') {
networkIndex = steps.indexOf(step)
} else if(step.id == 'ports') {
portIndex = steps.indexOf(step);
// 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/') {
// Finds and replaces the Network and Port wizard pages with
// the GBP wizard page
var networkIndex = -1;
var portIndex = -1;
angular.forEach(steps, function (step) {
if(step.id == 'networks') {
networkIndex = steps.indexOf(step)
} else if(step.id == 'ports') {
portIndex = steps.indexOf(step);
}
});
if(networkIndex > -1) {
steps.splice(networkIndex, 1, gbstep);
}
});
if(networkIndex > -1) {
steps.splice(networkIndex, 1, gbstep);
}
if(portIndex > -1) {
steps.splice(portIndex, 1);
if(portIndex > -1) {
steps.splice(portIndex, 1);
}
}
var result = dashboardWorkflow($delegate);
@ -62,4 +67,4 @@
);
}
})();
})();