Skip to content

Disambiguate kinds on other resources by showing group #1478

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
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
8 changes: 8 additions & 0 deletions app/scripts/controllers/otherResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ angular.module('openshiftConsole')
}).toString();
};

var counts;
$scope.isDuplicateKind = function(kind) {
if(!counts) {
counts = _.countBy($scope.kinds, 'kind');
}
return counts[kind] > 1;
};

// get and clear any alerts
AlertMessageService.getAlerts().forEach(function(alert) {
$scope.alerts[alert.name] = alert.data;
Expand Down
1 change: 1 addition & 0 deletions app/views/other-resources.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ <h1>Other Resources</h1>
<ui-select-match placeholder="Choose a resource to list...">{{$select.selected.kind | humanizeKind : true}}</ui-select-match>
<ui-select-choices repeat="kind in kinds | filter : {kind: $select.search} : matchKind | orderBy : 'kind'">
<div ng-bind-html="(kind.kind | humanizeKind : true) | highlight: $select.search"></div>
<small ng-if="isDuplicateKind(kind.kind)" ng-bind-html="kind.group | highlight: $select.search" class="text-muted"></small>
</ui-select-choices>
</ui-select>
<div class="vertical-divider"></div>
Expand Down
12 changes: 8 additions & 4 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7482,10 +7482,14 @@ projectName:a.project,
kind:b,
group:_.get(c, "kindSelector.selected.group", "")
}).toString() :"";
};
var n;
c.isDuplicateKind = function(a) {
return n || (n = _.countBy(c.kinds, "kind")), n[a] > 1;
}, d.getAlerts().forEach(function(a) {
c.alerts[a.name] = a.data;
}), d.clearAlerts();
var n = function(a, b) {
var o = function(a, b) {
return _.some(c.kinds, function(c) {
return c.kind === a && (!c.group && !b || c.group === b);
});
Expand All @@ -7497,13 +7501,13 @@ 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 && n(a.kind, a.group) && (_.set(c, "kindSelector.selected.kind", a.kind), _.set(c, "kindSelector.selected.group", a.group || ""));
}), 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 || ""));
})), c.loadKind = m, c.$watch("kindSelector.selected", function() {
c.alerts = {}, m();
});
var o = h("humanizeKind");
var p = h("humanizeKind");
c.matchKind = function(a, b) {
return o(a).toLowerCase().indexOf(b.toLowerCase()) !== -1;
return p(a).toLowerCase().indexOf(b.toLowerCase()) !== -1;
}, i.onActiveFiltersChanged(function(a) {
c.$apply(function() {
c.resources = a.select(c.unfilteredResources), l();
Expand Down
1 change: 1 addition & 0 deletions dist/scripts/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -11667,6 +11667,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"<ui-select-match placeholder=\"Choose a resource to list...\">{{$select.selected.kind | humanizeKind : true}}</ui-select-match>\n" +
"<ui-select-choices repeat=\"kind in kinds | filter : {kind: $select.search} : matchKind | orderBy : 'kind'\">\n" +
"<div ng-bind-html=\"(kind.kind | humanizeKind : true) | highlight: $select.search\"></div>\n" +
"<small ng-if=\"isDuplicateKind(kind.kind)\" ng-bind-html=\"kind.group | highlight: $select.search\" class=\"text-muted\"></small>\n" +
"</ui-select-choices>\n" +
"</ui-select>\n" +
"<div class=\"vertical-divider\"></div>\n" +
Expand Down