Skip to content

Commit

Permalink
Update membership filter to use MEMBERSHIP_WHITELIST in Constants.js
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminapetersen committed Oct 30, 2017
1 parent fe5fdfe commit c888e06
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
10 changes: 10 additions & 0 deletions app/scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ angular.extend(window.OPENSHIFT_CONSTANTS, {
{resource: 'services', group: ''},
{resource: 'statefulsets', group: 'apps'}
],
MEMBERSHIP_WHITELIST: [
"admin",
"basic-user",
"edit",
"system:deployer",
"system:image-builder",
"system:image-puller",
"system:image-pusher",
"view",
],
// TODO:
// This map can drive both the drawer & toast messages by
// updating it to the following format:
Expand Down
5 changes: 2 additions & 3 deletions app/scripts/services/membership/membership.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

angular
.module('openshiftConsole')
.factory('MembershipService', function($filter) {
.factory('MembershipService', function($filter, Constants) {

var annotation = $filter('annotation');

Expand Down Expand Up @@ -120,8 +120,7 @@ angular

var filterRoles = function(roles) {
return _.filter(roles, function(item) {
// system-only must be explicitly <string> 'true' to hide the annotation
return annotation(item, 'systemOnly') !== 'true';
return _.includes(Constants.MEMBERSHIP_WHITELIST, item.metadata.name);
});
};

Expand Down
8 changes: 5 additions & 3 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ group: ""
resource: "statefulsets",
group: "apps"
} ],
MEMBERSHIP_WHITELIST: [ "admin", "basic-user", "edit", "system:deployer", "system:image-builder", "system:image-puller", "system:image-pusher", "view" ],
EVENTS_TO_SHOW: {
FailedCreate: !0,
FailedDelete: !0,
Expand Down Expand Up @@ -2343,8 +2344,9 @@ t[e.tag] = t[e.tag] || {}, t[e.tag].name = e.tag, t[e.tag].status = angular.copy
}), t;
}
};
}), angular.module("openshiftConsole").factory("MembershipService", [ "$filter", function(e) {
var t = e("annotation"), n = function() {
}), angular.module("openshiftConsole").factory("MembershipService", [ "$filter", "Constants", function(e, t) {
e("annotation");
var n = function() {
return _.reduce(_.slice(arguments), function(e, t, n) {
return t ? _.isEqual(n, 0) ? t : e + "-" + t : e;
}, "");
Expand Down Expand Up @@ -2398,7 +2400,7 @@ return _.sortBy(e, "metadata.name");
},
filterRoles: function(e) {
return _.filter(e, function(e) {
return "true" !== t(e, "systemOnly");
return _.includes(t.MEMBERSHIP_WHITELIST, e.metadata.name);
});
},
mapRolesForUI: function(e, t) {
Expand Down

0 comments on commit c888e06

Please sign in to comment.