Skip to content

Commit dce18fd

Browse files
Fix bugzilla 1507822 - Update plan info on service instance update
1 parent 685f44d commit dce18fd

File tree

2 files changed

+63
-37
lines changed

2 files changed

+63
-37
lines changed

app/scripts/controllers/serviceInstance.js

+36-18
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ angular.module('openshiftConsole')
5151
var watches = [];
5252
var secretWatchers = [];
5353
var serviceClassPromise;
54+
var servicePlansPromise;
5455

5556
var serviceInstanceDisplayName = $filter('serviceInstanceDisplayName');
5657
var serviceInstanceReady = $filter('isServiceInstanceReady');
@@ -128,33 +129,50 @@ angular.module('openshiftConsole')
128129
updateParameterData();
129130
};
130131

131-
var updateServiceClass = function() {
132-
// If we've previously loaded the service class or a request is in flight, don't do anything.
133-
if (!$scope.serviceInstance || $scope.serviceClass || serviceClassPromise) {
132+
var updateServicePlan = function() {
133+
var servicePlanName = _.get($scope.serviceInstance, 'spec.clusterServicePlanRef.name');
134+
$scope.plan = _.find($scope.servicePlans, { metadata: { name: servicePlanName } });
135+
updateParameterSchema();
136+
updateEditable();
137+
};
138+
139+
var updateServicePlans = function() {
140+
if (!$scope.serviceClass || servicePlansPromise) {
134141
return;
135142
}
136143

137-
serviceClassPromise = ServiceInstancesService.fetchServiceClassForInstance($scope.serviceInstance).then(function (serviceClass) {
138-
$scope.serviceClass = serviceClass;
139-
$scope.displayName = serviceInstanceDisplayName($scope.serviceInstance, $scope.serviceClass);
140-
141-
updateBreadcrumbs();
142-
serviceClassPromise = null;
143-
144-
Catalog.getServicePlansForServiceClass($scope.serviceClass).then(function (plans) {
145-
plans = plans.by('metadata.name');
146-
144+
if (!$scope.servicePlans) {
145+
servicePlansPromise = Catalog.getServicePlansForServiceClass($scope.serviceClass).then(function (plans) {
147146
var servicePlanName = _.get($scope.serviceInstance, 'spec.clusterServicePlanRef.name');
148-
$scope.servicePlans = _.reject(plans, function(plan) {
147+
$scope.servicePlans = _.reject(plans.by('metadata.name'), function(plan) {
149148
return _.get(plan, 'status.removedFromBrokerCatalog') && (plan.metadata.name !== servicePlanName);
150149
});
151150

152-
$scope.plan = plans[servicePlanName];
151+
updateServicePlan();
152+
servicePlansPromise = null;
153+
});
154+
} else {
155+
updateServicePlan();
156+
}
157+
};
158+
159+
var updateServiceClass = function() {
160+
if (!$scope.serviceInstance || serviceClassPromise) {
161+
return;
162+
}
163+
164+
if ($scope.serviceClass) {
165+
updateServicePlans();
166+
} else {
167+
serviceClassPromise = ServiceInstancesService.fetchServiceClassForInstance($scope.serviceInstance).then(function (serviceClass) {
168+
$scope.serviceClass = serviceClass;
169+
$scope.displayName = serviceInstanceDisplayName($scope.serviceInstance, $scope.serviceClass);
153170

154-
updateParameterSchema();
155-
updateEditable();
171+
updateBreadcrumbs();
172+
serviceClassPromise = null;
173+
updateServicePlans();
156174
});
157-
});
175+
}
158176
};
159177

160178
var serviceResolved = function(serviceInstance, action) {

dist/scripts/scripts.js

+27-19
Original file line numberDiff line numberDiff line change
@@ -6356,15 +6356,15 @@ e.showParameterValues = !e.showParameterValues;
63566356
}, e.closeEditDialog = function() {
63576357
e.editDialogShown = !1;
63586358
};
6359-
var m, p = [], f = [], g = t("serviceInstanceDisplayName"), v = t("isServiceInstanceReady"), h = a.getPreferredVersion("servicebindings");
6359+
var m, p, f = [], g = [], v = t("serviceInstanceDisplayName"), h = t("isServiceInstanceReady"), y = a.getPreferredVersion("servicebindings");
63606360
e.serviceInstancesVersion = a.getPreferredVersion("serviceinstances");
6361-
var y = function() {
6361+
var b = function() {
63626362
e.breadcrumbs.push({
63636363
title: e.displayName
63646364
});
6365-
}, b = function() {
6365+
}, C = function() {
63666366
if (e.serviceInstance && e.parameterSchema) {
6367-
s.unwatchAll(f), f = [], e.allowParametersReveal = o.canI("secrets", "get", e.projectName), e.parameterData = {}, e.opaqueParameterKeys = [];
6367+
s.unwatchAll(g), g = [], e.allowParametersReveal = o.canI("secrets", "get", e.projectName), e.parameterData = {}, e.opaqueParameterKeys = [];
63686368
var t = e.allowParametersReveal ? "" : "*****";
63696369
_.each(_.keys(_.get(e.parameterSchema, "properties")), function(n) {
63706370
e.parameterData[n] = t;
@@ -6373,7 +6373,7 @@ var n = _.get(e.serviceInstance, "status.externalProperties.parameters", {});
63736373
_.each(_.keys(n), function(t) {
63746374
"<redacted>" === n[t] ? e.parameterData[t] = "*****" : (e.parameterData[t] = n[t], e.opaqueParameterKeys.push(t));
63756375
}), e.allowParametersReveal && _.each(_.get(e.serviceInstance, "spec.parametersFrom"), function(t) {
6376-
f.push(s.watchObject("secrets", _.get(t, "secretKeyRef.name"), e.projectContext, function(n) {
6376+
g.push(s.watchObject("secrets", _.get(t, "secretKeyRef.name"), e.projectContext, function(n) {
63776377
try {
63786378
var a = JSON.parse(u.decodeSecretData(n.data)[t.secretKeyRef.key]);
63796379
_.extend(e.parameterData, a);
@@ -6383,34 +6383,42 @@ c.warn("Unable to load parameters from secret " + _.get(t, "secretKeyRef.name"),
63836383
}));
63846384
});
63856385
}
6386-
}, C = function() {
6386+
}, S = function() {
63876387
if (e.plan && e.serviceClass && e.serviceInstance) {
63886388
var t = _.get(e.plan, "spec.instanceUpdateParameterSchema"), n = _.size(_.get(t, "properties")) > 0 || _.get(e.serviceClass, "spec.planUpdatable") && _.size(e.servicePlans) > 1;
6389-
e.editAvailable = n && v(e.serviceInstance) && !_.get(e.serviceInstance, "metadata.deletionTimestamp");
6389+
e.editAvailable = n && h(e.serviceInstance) && !_.get(e.serviceInstance, "metadata.deletionTimestamp");
63906390
}
6391-
}, S = function() {
6392-
e.parameterFormDefinition = angular.copy(_.get(e.plan, "spec.externalMetadata.schemas.service_instance.update.openshift_form_definition")), e.parameterSchema = _.get(e.plan, "spec.instanceCreateParameterSchema"), b();
63936391
}, w = function() {
6394-
!e.serviceInstance || e.serviceClass || m || (m = d.fetchServiceClassForInstance(e.serviceInstance).then(function(t) {
6395-
e.serviceClass = t, e.displayName = g(e.serviceInstance, e.serviceClass), y(), m = null, i.getServicePlansForServiceClass(e.serviceClass).then(function(t) {
6396-
t = t.by("metadata.name");
6392+
e.parameterFormDefinition = angular.copy(_.get(e.plan, "spec.externalMetadata.schemas.service_instance.update.openshift_form_definition")), e.parameterSchema = _.get(e.plan, "spec.instanceCreateParameterSchema"), C();
6393+
}, k = function() {
6394+
var t = _.get(e.serviceInstance, "spec.clusterServicePlanRef.name");
6395+
e.plan = _.find(e.servicePlans, {
6396+
metadata: {
6397+
name: t
6398+
}
6399+
}), w(), S();
6400+
}, P = function() {
6401+
e.serviceClass && !p && (e.servicePlans ? k() : p = i.getServicePlansForServiceClass(e.serviceClass).then(function(t) {
63976402
var n = _.get(e.serviceInstance, "spec.clusterServicePlanRef.name");
6398-
e.servicePlans = _.reject(t, function(e) {
6403+
e.servicePlans = _.reject(t.by("metadata.name"), function(e) {
63996404
return _.get(e, "status.removedFromBrokerCatalog") && e.metadata.name !== n;
6400-
}), e.plan = t[n], S(), C();
6401-
});
6405+
}), k(), p = null;
6406+
}));
6407+
}, j = function() {
6408+
e.serviceInstance && !m && (e.serviceClass ? P() : m = d.fetchServiceClassForInstance(e.serviceInstance).then(function(t) {
6409+
e.serviceClass = t, e.displayName = v(e.serviceInstance, e.serviceClass), b(), m = null, P();
64026410
}));
6403-
}, k = function(t, n) {
6411+
}, R = function(t, n) {
64046412
e.loaded = !0, e.serviceInstance = t, "DELETED" === n && (e.alerts.deleted = {
64056413
type: "warning",
64066414
message: "This provisioned service has been deleted."
6407-
}), w(), b(), C();
6415+
}), j(), C(), S();
64086416
};
64096417
l.get(n.project).then(_.spread(function(a, o) {
64106418
e.project = a, e.projectContext = o, s.get(e.serviceInstancesVersion, n.instance, o, {
64116419
errorNotification: !1
64126420
}).then(function(t) {
6413-
k(t), p.push(s.watchObject(e.serviceInstancesVersion, n.instance, o, k)), p.push(s.watch(h, o, function(n) {
6421+
R(t), f.push(s.watchObject(e.serviceInstancesVersion, n.instance, o, R)), f.push(s.watch(y, o, function(n) {
64146422
var a = n.by("metadata.name");
64156423
e.bindings = r.getBindingsForResource(a, t);
64166424
}));
@@ -6428,7 +6436,7 @@ message: "The service details could not be loaded.",
64286436
details: t("getErrorDetails")(n)
64296437
};
64306438
})), e.$on("$destroy", function() {
6431-
s.unwatchAll(p), s.unwatchAll(f);
6439+
s.unwatchAll(f), s.unwatchAll(g);
64326440
});
64336441
} ]), angular.module("openshiftConsole").controller("SecretsController", [ "$routeParams", "$scope", "DataService", "ProjectsService", function(e, t, n, a) {
64346442
t.projectName = e.project, t.secretsByType = {}, a.get(e.project).then(_.spread(function(e, a) {

0 commit comments

Comments
 (0)