Skip to content

Commit 4a5a355

Browse files
Update the Other Resources Page to only show resources supporting the 'List' verb
- also empty out AVAILABLE_KINDS_BLACKLIST
1 parent da9b22a commit 4a5a355

File tree

3 files changed

+45
-26
lines changed

3 files changed

+45
-26
lines changed

app/scripts/constants.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,7 @@ angular.extend(window.OPENSHIFT_CONSTANTS, {
8080

8181
// This blacklist hides certain kinds from the "Other Resources" page because they are unpersisted, disallowed for most end users, or not supported by openshift but exist in kubernetes
8282
AVAILABLE_KINDS_BLACKLIST: [
83-
// These are k8s kinds that are not supported in the current release of OpenShift
84-
{kind: 'Binding', group: ''},
85-
"Ingress",
86-
87-
// These are things like DCPs that aren't actually persisted resources
88-
"DeploymentConfigRollback"
83+
"ReplicationControllerDummy"
8984
],
9085

9186
ENABLE_TECH_PREVIEW_FEATURE: {

app/scripts/controllers/otherResources.js

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
'use strict';
22

3-
/**
4-
* @ngdoc function
5-
* @name openshiftConsole.controller:OtherResourcesController
6-
* @description
7-
* # ProjectController
8-
* Controller of the openshiftConsole
9-
*/
103
angular.module('openshiftConsole')
11-
.controller('OtherResourcesController', function ($routeParams, $location, $scope, AlertMessageService, AuthorizationService, DataService, ProjectsService, $filter, LabelFilter, Logger, APIService ) {
4+
.controller('OtherResourcesController', function (
5+
$routeParams,
6+
$location,
7+
$scope,
8+
AlertMessageService,
9+
AuthorizationService,
10+
DataService,
11+
ProjectsService,
12+
$filter,
13+
LabelFilter,
14+
Logger,
15+
APIService) {
1216
$scope.projectName = $routeParams.project;
1317
$scope.labelSuggestions = {};
1418
$scope.alerts = $scope.alerts || {};
@@ -44,6 +48,19 @@ angular.module('openshiftConsole')
4448
}
4549
});
4650

51+
var isListable = function(kind) {
52+
if(!kind) {
53+
return;
54+
}
55+
var rgv = APIService.kindToResourceGroupVersion(kind);
56+
var apiInfo = APIService.apiInfo(rgv);
57+
return apiInfo && apiInfo.verbs ?
58+
_.contains(apiInfo.verbs, 'list') :
59+
// if we don't have apiInfo, default to show the item
60+
// this can happen if the api server is not current
61+
true;
62+
};
63+
4764
$scope.getReturnURL = function() {
4865
var kind = _.get($scope, 'kindSelector.selected.kind');
4966
if (!kind) {
@@ -93,6 +110,9 @@ angular.module('openshiftConsole')
93110
resource: APIService.kindToResource(kind.kind),
94111
group: kind.group || ''
95112
};
113+
if(!isListable(kind)) {
114+
return false;
115+
}
96116
// exclude 'projectrequests', subresources, and REVIEW_RESOURCES from the list
97117
if (AuthorizationService.checkResource(resourceAndGroup.resource)) {
98118
return AuthorizationService.canI(resourceAndGroup, "list", $scope.projectName);

dist/scripts/scripts.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,10 +1234,7 @@ DEFAULT_HPA_CPU_TARGET_PERCENT:80,
12341234
DISABLE_OVERVIEW_METRICS:!1,
12351235
DISABLE_CUSTOM_METRICS:!1,
12361236
DISABLE_WILDCARD_ROUTES:!0,
1237-
AVAILABLE_KINDS_BLACKLIST:[ {
1238-
kind:"Binding",
1239-
group:""
1240-
}, "Ingress", "DeploymentConfigRollback" ],
1237+
AVAILABLE_KINDS_BLACKLIST:[],
12411238
ENABLE_TECH_PREVIEW_FEATURE:{
12421239
service_catalog_landing_page:!1,
12431240
template_service_broker:!1,
@@ -7016,21 +7013,28 @@ return !1;
70167013
default:
70177014
return !0;
70187015
}
7019-
}), c.getReturnURL = function() {
7016+
});
7017+
var n = function(a) {
7018+
if (a) {
7019+
var b = k.kindToResourceGroupVersion(a), c = k.apiInfo(b);
7020+
return !c || !c.verbs || _.contains(c.verbs, "list");
7021+
}
7022+
};
7023+
c.getReturnURL = function() {
70207024
var b = _.get(c, "kindSelector.selected.kind");
70217025
return b ? URI.expand("project/{projectName}/browse/other?kind={kind}&group={group}", {
70227026
projectName:a.project,
70237027
kind:b,
70247028
group:_.get(c, "kindSelector.selected.group", "")
70257029
}).toString() :"";
70267030
};
7027-
var n;
7031+
var o;
70287032
c.isDuplicateKind = function(a) {
7029-
return n || (n = _.countBy(c.kinds, "kind")), n[a] > 1;
7033+
return o || (o = _.countBy(c.kinds, "kind")), o[a] > 1;
70307034
}, d.getAlerts().forEach(function(a) {
70317035
c.alerts[a.name] = a.data;
70327036
}), d.clearAlerts();
7033-
var o = function(a, b) {
7037+
var p = function(a, b) {
70347038
return _.some(c.kinds, function(c) {
70357039
return c.kind === a && (!c.group && !b || c.group === b);
70367040
});
@@ -7041,14 +7045,14 @@ var b = {
70417045
resource:k.kindToResource(a.kind),
70427046
group:a.group || ""
70437047
};
7044-
return !!e.checkResource(b.resource) && e.canI(b, "list", c.projectName);
7045-
}), c.project = b, c.context = d, c.kindSelector.disabled = !1, a.kind && o(a.kind, a.group) && (_.set(c, "kindSelector.selected.kind", a.kind), _.set(c, "kindSelector.selected.group", a.group || ""));
7048+
return !!n(a) && (!!e.checkResource(b.resource) && e.canI(b, "list", c.projectName));
7049+
}), c.project = b, c.context = d, c.kindSelector.disabled = !1, a.kind && p(a.kind, a.group) && (_.set(c, "kindSelector.selected.kind", a.kind), _.set(c, "kindSelector.selected.group", a.group || ""));
70467050
})), c.loadKind = m, c.$watch("kindSelector.selected", function() {
70477051
c.alerts = {}, m();
70487052
});
7049-
var p = h("humanizeKind");
7053+
var q = h("humanizeKind");
70507054
c.matchKind = function(a, b) {
7051-
return p(a).toLowerCase().indexOf(b.toLowerCase()) !== -1;
7055+
return q(a).toLowerCase().indexOf(b.toLowerCase()) !== -1;
70527056
}, i.onActiveFiltersChanged(function(a) {
70537057
c.$apply(function() {
70547058
c.resources = a.select(c.unfilteredResources), l();

0 commit comments

Comments
 (0)