Skip to content

Commit 21d7698

Browse files
Add namespace picker to service account tab on membership page
1 parent 46c6d8b commit 21d7698

File tree

4 files changed

+76
-35
lines changed

4 files changed

+76
-35
lines changed

app/scripts/controllers/membership.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ angular
219219
$scope.user = resp;
220220
});
221221

222-
223222
DataService
224223
.list('projects', {})
225224
.then(function(resp) {
@@ -364,5 +363,25 @@ angular
364363
}
365364
});
366365
});
366+
367+
368+
DataService
369+
.list('serviceaccounts', requestContext)
370+
.then(function(resp) {
371+
var serviceAccounts = _.map(resp.by('metadata.name'), function(sa) {
372+
return sa.metadata.name;
373+
});
374+
angular.extend($scope, {
375+
serviceAccounts: serviceAccounts,
376+
refreshServiceAccounts: function(search) {
377+
if(search && !_.includes($scope.serviceAccounts, search)) {
378+
$scope.serviceAccounts = [search].concat(serviceAccounts);
379+
} else {
380+
$scope.serviceAccounts = serviceAccounts;
381+
}
382+
}
383+
});
384+
});
385+
367386
}));
368387
});

app/views/membership.html

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,42 @@ <h3>
173173
class="sr-only">
174174
Name
175175
</label>
176+
177+
<!-- name entry field for everything but service accounts -->
176178
<input
179+
ng-if="newBinding.kind !== 'ServiceAccount'"
177180
type="text"
178181
class="form-control input-name"
179182
placeholder="Name"
180183
ng-model="newBinding.name">
184+
185+
<!-- name entry/picker for service accounts -->
181186
<div
182187
ng-if="newBinding.kind === 'ServiceAccount'"
183-
class="service-account-namespace hidden-sm hidden-md hidden-lg"
188+
class="service-account-name pad-bottom-sm"
189+
aria-hidden="true">
190+
<ui-select
191+
ng-model="newBinding.name"
192+
theme="bootstrap"
193+
search-enabled="true"
194+
title="Select a service account"
195+
class="select-role">
196+
<ui-select-match
197+
placeholder="Service account">
198+
<span ng-bind="newBinding.name"></span>
199+
</ui-select-match>
200+
<ui-select-choices
201+
repeat="saName in serviceAccounts | filter: $select.search"
202+
refresh="refreshServiceAccounts($select.search)"
203+
refresh-delay="200">
204+
<div>{{saName}}</div>
205+
</ui-select-choices>
206+
</ui-select>
207+
</div>
208+
<!-- namespace entry/picker for service accounts -->
209+
<div
210+
ng-if="newBinding.kind === 'ServiceAccount'"
211+
class="service-account-namespace"
184212
aria-hidden="true">
185213
<ui-select
186214
ng-model="newBinding.namespace"
@@ -207,27 +235,7 @@ <h3>
207235
<div
208236
class="col-roles"
209237
row tablet="column" flex wrap axis="start">
210-
<div
211-
ng-if="newBinding.kind === 'ServiceAccount'"
212-
class="service-account-namespace hidden-xs">
213-
<ui-select
214-
ng-model="newBinding.namespace"
215-
theme="bootstrap"
216-
search-enabled="true"
217-
title="Select a project"
218-
class="select-project">
219-
<ui-select-match
220-
placeholder="Select a project">
221-
<span ng-bind="newBinding.namespace"></span>
222-
</ui-select-match>
223-
<ui-select-choices
224-
repeat="projectName in projects | filter: $select.search"
225-
refresh="refreshProjects($select.search)"
226-
refresh-delay="200">
227-
<div>{{projectName}}</div>
228-
</ui-select-choices>
229-
</ui-select>
230-
</div>
238+
&nbsp;
231239
</div>
232240
<div class="col-add-role">
233241
<div ng-show="mode.edit" row>

dist/scripts/scripts.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5532,6 +5532,16 @@ showAllRoles:function() {
55325532
d.toggle.roles = !d.toggle.roles, d.toggle.roles ? d.filteredRoles = b :(d.filteredRoles = c, e(d.newBinding.role, c) || (d.newBinding.role = null));
55335533
}
55345534
});
5535+
}), i.list("serviceaccounts", n).then(function(a) {
5536+
var b = _.map(a.by("metadata.name"), function(a) {
5537+
return a.metadata.name;
5538+
});
5539+
angular.extend(d, {
5540+
serviceAccounts:b,
5541+
refreshServiceAccounts:function(a) {
5542+
a && !_.includes(d.serviceAccounts, a) ? d.serviceAccounts = [ a ].concat(b) :d.serviceAccounts = b;
5543+
}
5544+
});
55355545
});
55365546
}));
55375547
} ]), angular.module("openshiftConsole").controller("BuildsController", [ "$routeParams", "$scope", "AlertMessageService", "DataService", "$filter", "LabelFilter", "Logger", "$location", "BuildsService", "ProjectsService", function(a, b, c, d, e, f, g, h, i, j) {

dist/scripts/templates.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10307,22 +10307,22 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
1030710307
"<label ng-attr-for=\"newBindingName\" class=\"sr-only\">\n" +
1030810308
"Name\n" +
1030910309
"</label>\n" +
10310-
"<input type=\"text\" class=\"form-control input-name\" placeholder=\"Name\" ng-model=\"newBinding.name\">\n" +
10311-
"<div ng-if=\"newBinding.kind === 'ServiceAccount'\" class=\"service-account-namespace hidden-sm hidden-md hidden-lg\" aria-hidden=\"true\">\n" +
10312-
"<ui-select ng-model=\"newBinding.namespace\" theme=\"bootstrap\" search-enabled=\"true\" title=\"Select a project\" class=\"select-role\">\n" +
10313-
"<ui-select-match placeholder=\"Select a project\">\n" +
10314-
"<span ng-bind=\"newBinding.namespace\"></span>\n" +
10310+
"\n" +
10311+
"<input ng-if=\"newBinding.kind !== 'ServiceAccount'\" type=\"text\" class=\"form-control input-name\" placeholder=\"Name\" ng-model=\"newBinding.name\">\n" +
10312+
"\n" +
10313+
"<div ng-if=\"newBinding.kind === 'ServiceAccount'\" class=\"service-account-name pad-bottom-sm\" aria-hidden=\"true\">\n" +
10314+
"<ui-select ng-model=\"newBinding.name\" theme=\"bootstrap\" search-enabled=\"true\" title=\"Select a service account\" class=\"select-role\">\n" +
10315+
"<ui-select-match placeholder=\"Service account\">\n" +
10316+
"<span ng-bind=\"newBinding.name\"></span>\n" +
1031510317
"</ui-select-match>\n" +
10316-
"<ui-select-choices repeat=\"projectName in projects | filter: $select.search\" refresh=\"refreshProjects($select.search)\" refresh-delay=\"200\">\n" +
10317-
"<div>{{projectName}}</div>\n" +
10318+
"<ui-select-choices repeat=\"saName in serviceAccounts | filter: $select.search\" refresh=\"refreshServiceAccounts($select.search)\" refresh-delay=\"200\">\n" +
10319+
"<div>{{saName}}</div>\n" +
1031810320
"</ui-select-choices>\n" +
1031910321
"</ui-select>\n" +
1032010322
"</div>\n" +
10321-
"</div>\n" +
10322-
"<div class=\"action-set\" flex row tablet=\"column\" mobile=\"column\">\n" +
10323-
"<div class=\"col-roles\" row tablet=\"column\" flex wrap axis=\"start\">\n" +
10324-
"<div ng-if=\"newBinding.kind === 'ServiceAccount'\" class=\"service-account-namespace hidden-xs\">\n" +
10325-
"<ui-select ng-model=\"newBinding.namespace\" theme=\"bootstrap\" search-enabled=\"true\" title=\"Select a project\" class=\"select-project\">\n" +
10323+
"\n" +
10324+
"<div ng-if=\"newBinding.kind === 'ServiceAccount'\" class=\"service-account-namespace\" aria-hidden=\"true\">\n" +
10325+
"<ui-select ng-model=\"newBinding.namespace\" theme=\"bootstrap\" search-enabled=\"true\" title=\"Select a project\" class=\"select-role\">\n" +
1032610326
"<ui-select-match placeholder=\"Select a project\">\n" +
1032710327
"<span ng-bind=\"newBinding.namespace\"></span>\n" +
1032810328
"</ui-select-match>\n" +
@@ -10332,6 +10332,10 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
1033210332
"</ui-select>\n" +
1033310333
"</div>\n" +
1033410334
"</div>\n" +
10335+
"<div class=\"action-set\" flex row tablet=\"column\" mobile=\"column\">\n" +
10336+
"<div class=\"col-roles\" row tablet=\"column\" flex wrap axis=\"start\">\n" +
10337+
"&nbsp;\n" +
10338+
"</div>\n" +
1033510339
"<div class=\"col-add-role\">\n" +
1033610340
"<div ng-show=\"mode.edit\" row>\n" +
1033710341
"<ui-select ng-if=\"filteredRoles.length\" ng-model=\"newBinding.newRole\" theme=\"bootstrap\" search-enabled=\"true\" title=\"new {{subjectKind.name}} role\" class=\"select-role\" flex>\n" +

0 commit comments

Comments
 (0)