Skip to content

Commit 25f3640

Browse files
committed
Bug 1462205 - Delete binding shouldn't show up when all bindings are pending deletion
1 parent 54c8cb2 commit 25f3640

File tree

7 files changed

+34
-15
lines changed

7 files changed

+34
-15
lines changed

app/scripts/controllers/overview.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@ function OverviewController($scope,
11011101
// - API objects by binding name
11021102
state.bindingsByApplicationUID = {};
11031103
state.applicationsByBinding = {};
1104+
state.deleteableBindingsByApplicationUID = {};
11041105

11051106
// If there are no bindings, nothing to do.
11061107
if (_.isEmpty(state.bindings)) {
@@ -1139,6 +1140,7 @@ function OverviewController($scope,
11391140
// pod preset covers the selector.
11401141
var applicationSelector = new LabelSelector(_.get(apiObject, 'spec.selector'));
11411142
state.bindingsByApplicationUID[applicationUID] = [];
1143+
state.deleteableBindingsByApplicationUID[applicationUID] = [];
11421144

11431145
// Look at each pod preset selector to see if it covers this API object selector.
11441146
_.each(podPresetSelectors, function(podPresetSelector, bindingName) {
@@ -1147,6 +1149,9 @@ function OverviewController($scope,
11471149
// the target. We want to show bindings both in the "application"
11481150
// object rows and the service instance rows.
11491151
state.bindingsByApplicationUID[applicationUID].push(state.bindings[bindingName]);
1152+
if (!_.get(state.bindings[bindingName], 'metadata.deletionTimestamp')) {
1153+
state.deleteableBindingsByApplicationUID[applicationUID].push(state.bindings[bindingName]);
1154+
}
11501155
state.applicationsByBinding[bindingName] = state.applicationsByBinding[bindingName] || [];
11511156
state.applicationsByBinding[bindingName].push(apiObject);
11521157
}

app/scripts/directives/overview/serviceInstanceRow.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
row.description = getDescription();
4444
};
4545

46+
row.$onChanges = function(changes) {
47+
if (changes.bindings) {
48+
row.deleteableBindings = _.reject(row.bindings, 'metadata.deletionTimestamp');
49+
}
50+
};
51+
4652
row.getSecretForBinding = function(binding) {
4753
return binding && _.get(row, ['state', 'secrets', binding.spec.secretName]);
4854
};

app/views/overview/_list-row-actions.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
</li>
2626
<!-- FIXME: Can't enable canI checks on svc cat resources until we have aggregation
2727
<li ng-if="(row.state.serviceInstances | hashSize) > 0 && {resource: 'bindings', group: 'servicecatalog.k8s.io'} | canI : 'create'" role="menuitem"> -->
28-
<li ng-if-start="('pod_presets' | enableTechPreviewFeature) && row.state.bindableServiceInstances.length" role="menuitem">
28+
<li ng-if="('pod_presets' | enableTechPreviewFeature) && row.state.bindableServiceInstances.length" role="menuitem">
2929
<a href="" ng-click="row.showOverlayPanel('bindService', {target: row.apiObject})">Create Binding</a>
3030
</li>
31-
<li ng-if-end role="menuitem">
31+
<li ng-if="('pod_presets' | enableTechPreviewFeature) && row.state.deleteableBindingsByApplicationUID[row.apiObject.metadata.uid].length" role="menuitem">
3232
<a href="" ng-click="row.showOverlayPanel('unbindService', {target: row.apiObject})">Delete Binding</a>
3333
</li>
3434
<li ng-if="row.current && ('deploymentconfigs/log' | canI : 'get')" role="menuitem">

app/views/overview/_list-row.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<div ng-if="row.overlay.panelName === 'unbindService'">
2222
<unbind-service
2323
target="row.overlay.state.target"
24-
bindings="row.bindings"
24+
bindings="row.state.deleteableBindingsByApplicationUID[row.overlay.state.target.metadata.uid]"
2525
on-close="row.closeOverlayPanel"></unbind-service>
2626
</div>
2727
</overlay-panel>

app/views/overview/_service-instance-row.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h3>
5555
<li role="menuitem" ng-if="('pod_presets' | enableTechPreviewFeature) && row.isBindable">
5656
<a href="" ng-click="row.showOverlayPanel('bindService', {target: row.apiObject})">Create Binding</a>
5757
</li>
58-
<li role="menuitem" ng-if="('pod_presets' | enableTechPreviewFeature) && row.bindings.length">
58+
<li role="menuitem" ng-if="('pod_presets' | enableTechPreviewFeature) && row.deleteableBindings.length">
5959
<a href="" ng-click="row.showOverlayPanel('unbindService', {target: row.apiObject})">Delete Binding</a>
6060
</li>
6161
<li role="menuitem">
@@ -127,7 +127,10 @@ <h3>
127127
</div>
128128
</div>
129129
<div class="col-sm-7 col-md-6 overview-bindings">
130-
<span ng-if="!(binding | isBindingReady)">
130+
<span ng-if="binding.metadata.deletionTimestamp">
131+
<status-icon status="'Pending'"></status-icon> Deleting
132+
</span>
133+
<span ng-if="!(binding | isBindingReady) && !binding.metadata.deletionTimestamp">
131134
<status-icon status="'Pending'"></status-icon> Pending
132135
</span>
133136
<a
@@ -154,7 +157,7 @@ <h3>
154157
<div ng-if="row.overlay.panelName === 'unbindService'">
155158
<unbind-service
156159
target="row.overlay.state.target"
157-
bindings="row.bindings"
160+
bindings="row.deleteableBindings"
158161
applications-by-binding="row.state.applicationsByBinding"
159162
on-close="row.closeOverlayPanel"></unbind-service>
160163
</div>

dist/scripts/scripts.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ errorNotification:!1
368368
Q.secrets = a.by("metadata.name");
369369
});
370370
}, 300), $a = function() {
371-
if (Q.bindingsByApplicationUID = {}, Q.applicationsByBinding = {}, !_.isEmpty(Q.bindings)) {
371+
if (Q.bindingsByApplicationUID = {}, Q.applicationsByBinding = {}, Q.deleteableBindingsByApplicationUID = {}, !_.isEmpty(Q.bindings)) {
372372
var a = [ z.deploymentConfigs, z.vanillaReplicationControllers, z.deployments, z.vanillaReplicaSets, z.statefulSets ];
373373
if (!_.some(a, function(a) {
374374
return !a;
@@ -380,8 +380,8 @@ c && (b[a.metadata.name] = new LabelSelector(c));
380380
}), _.each(a, function(a) {
381381
_.each(a, function(a) {
382382
var c = T(a), d = new LabelSelector(_.get(a, "spec.selector"));
383-
Q.bindingsByApplicationUID[c] = [], _.each(b, function(b, e) {
384-
b.covers(d) && (Q.bindingsByApplicationUID[c].push(Q.bindings[e]), Q.applicationsByBinding[e] = Q.applicationsByBinding[e] || [], Q.applicationsByBinding[e].push(a));
383+
Q.bindingsByApplicationUID[c] = [], Q.deleteableBindingsByApplicationUID[c] = [], _.each(b, function(b, e) {
384+
b.covers(d) && (Q.bindingsByApplicationUID[c].push(Q.bindings[e]), _.get(Q.bindings[e], "metadata.deletionTimestamp") || Q.deleteableBindingsByApplicationUID[c].push(Q.bindings[e]), Q.applicationsByBinding[e] = Q.applicationsByBinding[e] || [], Q.applicationsByBinding[e].push(a));
385385
});
386386
});
387387
});
@@ -13092,6 +13092,8 @@ return _.get(g, [ "state", "serviceClasses", a, "description" ]);
1309213092
};
1309313093
g.$doCheck = function() {
1309413094
g.notifications = e.getNotifications(g.apiObject, g.state), g.displayName = i(g.apiObject, g.serviceClasses), g.description = j();
13095+
}, g.$onChanges = function(a) {
13096+
a.bindings && (g.deleteableBindings = _.reject(g.bindings, "metadata.deletionTimestamp"));
1309513097
}, g.getSecretForBinding = function(a) {
1309613098
return a && _.get(g, [ "state", "secrets", a.spec.secretName ]);
1309713099
}, g.isBindable = d.isServiceBindable(g.apiObject, g.state.serviceClasses), g.closeOverlayPanel = function() {

dist/scripts/templates.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11649,10 +11649,10 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
1164911649
"<a ng-href=\"{{row.apiObject | editResourceURL}}\">Edit</a>\n" +
1165011650
"</li>\n" +
1165111651
"\n" +
11652-
"<li ng-if-start=\"('pod_presets' | enableTechPreviewFeature) && row.state.bindableServiceInstances.length\" role=\"menuitem\">\n" +
11652+
"<li ng-if=\"('pod_presets' | enableTechPreviewFeature) && row.state.bindableServiceInstances.length\" role=\"menuitem\">\n" +
1165311653
"<a href=\"\" ng-click=\"row.showOverlayPanel('bindService', {target: row.apiObject})\">Create Binding</a>\n" +
1165411654
"</li>\n" +
11655-
"<li ng-if-end role=\"menuitem\">\n" +
11655+
"<li ng-if=\"('pod_presets' | enableTechPreviewFeature) && row.state.deleteableBindingsByApplicationUID[row.apiObject.metadata.uid].length\" role=\"menuitem\">\n" +
1165611656
"<a href=\"\" ng-click=\"row.showOverlayPanel('unbindService', {target: row.apiObject})\">Delete Binding</a>\n" +
1165711657
"</li>\n" +
1165811658
"<li ng-if=\"row.current && ('deploymentconfigs/log' | canI : 'get')\" role=\"menuitem\">\n" +
@@ -11995,7 +11995,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
1199511995
"<bind-service target=\"row.overlay.state.target\" on-close=\"row.closeOverlayPanel\"></bind-service>\n" +
1199611996
"</div>\n" +
1199711997
"<div ng-if=\"row.overlay.panelName === 'unbindService'\">\n" +
11998-
"<unbind-service target=\"row.overlay.state.target\" bindings=\"row.bindings\" on-close=\"row.closeOverlayPanel\"></unbind-service>\n" +
11998+
"<unbind-service target=\"row.overlay.state.target\" bindings=\"row.state.deleteableBindingsByApplicationUID[row.overlay.state.target.metadata.uid]\" on-close=\"row.closeOverlayPanel\"></unbind-service>\n" +
1199911999
"</div>\n" +
1200012000
"</overlay-panel>"
1200112001
);
@@ -12247,7 +12247,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
1224712247
"<li role=\"menuitem\" ng-if=\"('pod_presets' | enableTechPreviewFeature) && row.isBindable\">\n" +
1224812248
"<a href=\"\" ng-click=\"row.showOverlayPanel('bindService', {target: row.apiObject})\">Create Binding</a>\n" +
1224912249
"</li>\n" +
12250-
"<li role=\"menuitem\" ng-if=\"('pod_presets' | enableTechPreviewFeature) && row.bindings.length\">\n" +
12250+
"<li role=\"menuitem\" ng-if=\"('pod_presets' | enableTechPreviewFeature) && row.deleteableBindings.length\">\n" +
1225112251
"<a href=\"\" ng-click=\"row.showOverlayPanel('unbindService', {target: row.apiObject})\">Delete Binding</a>\n" +
1225212252
"</li>\n" +
1225312253
"<li role=\"menuitem\">\n" +
@@ -12297,7 +12297,10 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
1229712297
"</div>\n" +
1229812298
"</div>\n" +
1229912299
"<div class=\"col-sm-7 col-md-6 overview-bindings\">\n" +
12300-
"<span ng-if=\"!(binding | isBindingReady)\">\n" +
12300+
"<span ng-if=\"binding.metadata.deletionTimestamp\">\n" +
12301+
"<status-icon status=\"'Pending'\"></status-icon> Deleting\n" +
12302+
"</span>\n" +
12303+
"<span ng-if=\"!(binding | isBindingReady) && !binding.metadata.deletionTimestamp\">\n" +
1230112304
"<status-icon status=\"'Pending'\"></status-icon> Pending\n" +
1230212305
"</span>\n" +
1230312306
"<a ng-if=\"(binding | isBindingReady) && ('secrets' | canI : 'get')\" ng-href=\"{{row.getSecretForBinding(binding) | navigateResourceURL}}\">\n" +
@@ -12319,7 +12322,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
1231912322
"<bind-service target=\"row.overlay.state.target\" on-close=\"row.closeOverlayPanel\"></bind-service>\n" +
1232012323
"</div>\n" +
1232112324
"<div ng-if=\"row.overlay.panelName === 'unbindService'\">\n" +
12322-
"<unbind-service target=\"row.overlay.state.target\" bindings=\"row.bindings\" applications-by-binding=\"row.state.applicationsByBinding\" on-close=\"row.closeOverlayPanel\"></unbind-service>\n" +
12325+
"<unbind-service target=\"row.overlay.state.target\" bindings=\"row.deleteableBindings\" applications-by-binding=\"row.state.applicationsByBinding\" on-close=\"row.closeOverlayPanel\"></unbind-service>\n" +
1232312326
"</div>\n" +
1232412327
"</overlay-panel>"
1232512328
);

0 commit comments

Comments
 (0)