Skip to content

Commit 8baf00b

Browse files
author
OpenShift Bot
authored
Merge pull request #800 from benjaminapetersen/membership-list-update
Merged by openshift-bot
2 parents f697f50 + 405b3d6 commit 8baf00b

File tree

3 files changed

+38
-65
lines changed

3 files changed

+38
-65
lines changed

app/scripts/controllers/membership.js

+24-18
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,16 @@ angular
7171

7272
var refreshRoleBindingList = function() {
7373
DataService
74-
.list('rolebindings', requestContext, function(resp) {
74+
.list('rolebindings', requestContext, null , {
75+
errorNotification: false
76+
})
77+
.then(function(resp) {
7578
angular.extend($scope, {
7679
canShowRoles: true,
7780
roleBindings: resp.by('metadata.name'),
7881
subjectKindsForUI: MembershipService.mapRolebindingsForUI(resp.by('metadata.name'), allRoles)
7982
});
80-
resetForm();
81-
}, {
82-
errorNotification: false
83+
resetForm();
8384
});
8485
};
8586

@@ -211,21 +212,23 @@ angular
211212
});
212213

213214

214-
DataService.list('projects', {}, function(resp) {
215-
var projects = _.map(resp.by('metadata.name'), function(project) {
216-
return project.metadata.name;
217-
});
218-
angular.extend($scope, {
219-
projects: projects,
220-
refreshProjects: function(search) {
221-
if(search && !_.includes($scope.projects, search)) {
222-
$scope.projects = [search].concat(projects);
223-
} else {
224-
$scope.projects = projects;
215+
DataService
216+
.list('projects', {})
217+
.then(function(resp) {
218+
var projects = _.map(resp.by('metadata.name'), function(project) {
219+
return project.metadata.name;
220+
});
221+
angular.extend($scope, {
222+
projects: projects,
223+
refreshProjects: function(search) {
224+
if(search && !_.includes($scope.projects, search)) {
225+
$scope.projects = [search].concat(projects);
226+
} else {
227+
$scope.projects = projects;
228+
}
225229
}
226-
}
230+
});
227231
});
228-
});
229232

230233
ProjectsService
231234
.get($routeParams.project)
@@ -311,7 +314,10 @@ angular
311314
// TODO: this should be by UID, not by Kind-Name, would be less janky.
312315
// The only catch is matching them up w/Rolebindings, which do not have
313316
// the UID
314-
allRoles = MembershipService.mapRolesForUI(_.first(resp), _.last(resp));
317+
allRoles = MembershipService
318+
.mapRolesForUI(
319+
_.first(resp).by('metadata.name'),
320+
_.last(resp).by('metadata.name'));
315321
var sortedRoles = MembershipService.sortRoles(allRoles);
316322
var filteredRoles = MembershipService.filterRoles(allRoles);
317323
var includesRole = function(roleName, roles) {

app/scripts/services/membership/roles.js

+6-28
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,15 @@ angular
44
.module('openshiftConsole')
55
.factory('RolesService', function($q, DataService) {
66

7-
var listClusterRoles = function(cb, opts) {
8-
DataService.list('clusterroles', {}, cb, opts);
9-
};
10-
11-
var listRoles = function(context, cb, opts) {
12-
DataService.list('roles', context, cb, opts);
13-
};
14-
15-
// wraps the 2 API list calls in a promise for easier use, similar to above get()
167
var listAllRoles = function(context) {
17-
var deferred = $q.defer();
18-
var result = [];
19-
20-
var resolve = function(resp) {
21-
result.push(resp.by('metadata.name'));
22-
if(_.isEqual(result.length, 2)) {
23-
deferred.resolve(result);
24-
}
25-
};
26-
27-
listRoles(context, function(resp) {
28-
resolve(resp);
29-
});
30-
listClusterRoles(function(resp) {
31-
resolve(resp);
32-
});
33-
34-
return deferred.promise;
8+
return $q.all([
9+
DataService
10+
.list('roles', context, null),
11+
DataService
12+
.list('clusterroles', {}, null)
13+
]);
3514
};
3615

37-
3816
return {
3917
listAllRoles: listAllRoles
4018
};

dist/scripts/scripts.js

+8-19
Original file line numberDiff line numberDiff line change
@@ -2802,22 +2802,11 @@ getSubjectKinds:d,
28022802
mapRolebindingsForUI:e
28032803
};
28042804
} ]), angular.module("openshiftConsole").factory("RolesService", [ "$q", "DataService", function(a, b) {
2805-
var c = function(a, c) {
2806-
b.list("clusterroles", {}, a, c);
2807-
}, d = function(a, c, d) {
2808-
b.list("roles", a, c, d);
2809-
}, e = function(b) {
2810-
var e = a.defer(), f = [], g = function(a) {
2811-
f.push(a.by("metadata.name")), _.isEqual(f.length, 2) && e.resolve(f);
2812-
};
2813-
return d(b, function(a) {
2814-
g(a);
2815-
}), c(function(a) {
2816-
g(a);
2817-
}), e.promise;
2805+
var c = function(c) {
2806+
return a.all([ b.list("roles", c, null), b.list("clusterroles", {}, null) ]);
28182807
};
28192808
return {
2820-
listAllRoles:e
2809+
listAllRoles:c
28212810
};
28222811
} ]), angular.module("openshiftConsole").factory("RoleBindingsService", [ "$q", "DataService", function(a, b) {
28232812
var c = {}, d = function(a, b) {
@@ -4985,14 +4974,14 @@ details:e
49854974
}, u = function() {
49864975
d.disableAddForm = !1, d.newBinding.name = "", d.newBinding.namespace = o, d.newBinding.newRole = null;
49874976
}, v = function() {
4988-
i.list("rolebindings", n, function(a) {
4977+
i.list("rolebindings", n, null, {
4978+
errorNotification:!1
4979+
}).then(function(a) {
49894980
angular.extend(d, {
49904981
canShowRoles:!0,
49914982
roleBindings:a.by("metadata.name"),
49924983
subjectKindsForUI:k.mapRolebindingsForUI(a.by("metadata.name"), r)
49934984
}), u();
4994-
}, {
4995-
errorNotification:!1
49964985
});
49974986
}, w = function(b, c) {
49984987
d.disableAddForm = !0, l.create(b, c, o, n).then(function() {
@@ -5085,7 +5074,7 @@ roleName:c
50855074
};
50865075
g.withUser().then(function(a) {
50875076
d.user = a;
5088-
}), i.list("projects", {}, function(a) {
5077+
}), i.list("projects", {}).then(function(a) {
50895078
var b = _.map(a.by("metadata.name"), function(a) {
50905079
return a.metadata.name;
50915080
});
@@ -5146,7 +5135,7 @@ subjectName:a
51465135
}), m.listAllRoles(n, {
51475136
errorNotification:!1
51485137
}).then(function(a) {
5149-
r = k.mapRolesForUI(_.first(a), _.last(a));
5138+
r = k.mapRolesForUI(_.first(a).by("metadata.name"), _.last(a).by("metadata.name"));
51505139
var b = k.sortRoles(r), c = k.filterRoles(r), e = function(a, b) {
51515140
return _.some(b, {
51525141
metadata:{

0 commit comments

Comments
 (0)