Skip to content

Other resources list update #1572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions app/scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,7 @@ angular.extend(window.OPENSHIFT_CONSTANTS, {
DISABLE_WILDCARD_ROUTES: true,

// 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
AVAILABLE_KINDS_BLACKLIST: [
// These are k8s kinds that are not supported in the current release of OpenShift
{kind: 'Binding', group: ''},
"Ingress",

// These are things like DCPs that aren't actually persisted resources
"DeploymentConfigRollback"
],
AVAILABLE_KINDS_BLACKLIST: [],

ENABLE_TECH_PREVIEW_FEATURE: {
// Enable the new landing page and service catalog experience
Expand Down
36 changes: 28 additions & 8 deletions app/scripts/controllers/otherResources.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
'use strict';

/**
* @ngdoc function
* @name openshiftConsole.controller:OtherResourcesController
* @description
* # ProjectController
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('OtherResourcesController', function ($routeParams, $location, $scope, AlertMessageService, AuthorizationService, DataService, ProjectsService, $filter, LabelFilter, Logger, APIService ) {
.controller('OtherResourcesController', function (
$routeParams,
$location,
$scope,
AlertMessageService,
AuthorizationService,
DataService,
ProjectsService,
$filter,
LabelFilter,
Logger,
APIService) {
$scope.projectName = $routeParams.project;
$scope.labelSuggestions = {};
$scope.alerts = $scope.alerts || {};
Expand Down Expand Up @@ -44,6 +48,19 @@ angular.module('openshiftConsole')
}
});

var isListable = function(kind) {
if(!kind) {
return;
}
var rgv = APIService.kindToResourceGroupVersion(kind);
var apiInfo = APIService.apiInfo(rgv);
return apiInfo && apiInfo.verbs ?
_.contains(apiInfo.verbs, 'list') :
// if we don't have apiInfo, default to show the item
// this can happen if the api server is not current
true;
};

$scope.getReturnURL = function() {
var kind = _.get($scope, 'kindSelector.selected.kind');
if (!kind) {
Expand Down Expand Up @@ -93,6 +110,9 @@ angular.module('openshiftConsole')
resource: APIService.kindToResource(kind.kind),
group: kind.group || ''
};
if(!isListable(kind)) {
return false;
}
// exclude 'projectrequests', subresources, and REVIEW_RESOURCES from the list
if (AuthorizationService.checkResource(resourceAndGroup.resource)) {
return AuthorizationService.canI(resourceAndGroup, "list", $scope.projectName);
Expand Down
28 changes: 16 additions & 12 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1234,10 +1234,7 @@ DEFAULT_HPA_CPU_TARGET_PERCENT:80,
DISABLE_OVERVIEW_METRICS:!1,
DISABLE_CUSTOM_METRICS:!1,
DISABLE_WILDCARD_ROUTES:!0,
AVAILABLE_KINDS_BLACKLIST:[ {
kind:"Binding",
group:""
}, "Ingress", "DeploymentConfigRollback" ],
AVAILABLE_KINDS_BLACKLIST:[],
ENABLE_TECH_PREVIEW_FEATURE:{
service_catalog_landing_page:!1,
template_service_broker:!1,
Expand Down Expand Up @@ -7016,21 +7013,28 @@ return !1;
default:
return !0;
}
}), c.getReturnURL = function() {
});
var n = function(a) {
if (a) {
var b = k.kindToResourceGroupVersion(a), c = k.apiInfo(b);
return !c || !c.verbs || _.contains(c.verbs, "list");
}
};
c.getReturnURL = function() {
var b = _.get(c, "kindSelector.selected.kind");
return b ? URI.expand("project/{projectName}/browse/other?kind={kind}&group={group}", {
projectName:a.project,
kind:b,
group:_.get(c, "kindSelector.selected.group", "")
}).toString() :"";
};
var n;
var o;
c.isDuplicateKind = function(a) {
return n || (n = _.countBy(c.kinds, "kind")), n[a] > 1;
return o || (o = _.countBy(c.kinds, "kind")), o[a] > 1;
}, d.getAlerts().forEach(function(a) {
c.alerts[a.name] = a.data;
}), d.clearAlerts();
var o = function(a, b) {
var p = function(a, b) {
return _.some(c.kinds, function(c) {
return c.kind === a && (!c.group && !b || c.group === b);
});
Expand All @@ -7041,14 +7045,14 @@ var b = {
resource:k.kindToResource(a.kind),
group:a.group || ""
};
return !!e.checkResource(b.resource) && e.canI(b, "list", c.projectName);
}), 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 || ""));
return !!n(a) && (!!e.checkResource(b.resource) && e.canI(b, "list", c.projectName));
}), 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 || ""));
})), c.loadKind = m, c.$watch("kindSelector.selected", function() {
c.alerts = {}, m();
});
var p = h("humanizeKind");
var q = h("humanizeKind");
c.matchKind = function(a, b) {
return p(a).toLowerCase().indexOf(b.toLowerCase()) !== -1;
return q(a).toLowerCase().indexOf(b.toLowerCase()) !== -1;
}, i.onActiveFiltersChanged(function(a) {
c.$apply(function() {
c.resources = a.select(c.unfilteredResources), l();
Expand Down