Skip to content
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

Update storage filter empty state to new standard #2341

Merged
merged 1 commit into from
Oct 23, 2017
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
17 changes: 5 additions & 12 deletions app/scripts/controllers/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ angular.module('openshiftConsole')
$scope.labelSuggestions = {};
$scope.alerts = $scope.alerts || {};
$scope.outOfClaims = false;
$scope.clearFilter = function() {
LabelFilter.clear();
};

var setOutOfClaimsWarning = function() {
var isHidden = AlertMessageService.isAlertPermanentlyHidden("storage-quota-limit-reached", $scope.projectName);
Expand Down Expand Up @@ -64,22 +67,12 @@ angular.module('openshiftConsole')
}));

function updateFilterWarning() {
if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.pvcs) && !$.isEmptyObject($scope.unfilteredPVCs)) {
$scope.alerts["storage"] = {
type: "warning",
details: "The active filters are hiding all persistent volume claims."
};
$scope.filterWithZeroResults = true;
}
else {
delete $scope.alerts["storage"];
$scope.filterWithZeroResults = false;
}
$scope.filterWithZeroResults = !LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.pvcs) && !$.isEmptyObject($scope.unfilteredPVCs);
}

LabelFilter.onActiveFiltersChanged(function(labelSelector) {
// trigger a digest loop
$scope.$apply(function() {
$scope.$evalAsync(function() {
$scope.pvcs = labelSelector.select($scope.unfilteredPVCs);
updateFilterWarning();
});
Expand Down
21 changes: 13 additions & 8 deletions app/views/storage.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ <h1>
Loading...
</p>
<div ng-if="pvcsLoaded" class="empty-state-message text-center">
<h2>No persistent volume claims.</h2>
<p ng-if="!filterWithZeroResults">
No persistent volume claims have been added to project {{projectName}}.
</p>
<p ng-if="project && ('persistentvolumeclaims' | canI : 'create') && !filterWithZeroResults">
<a ng-if="!outOfClaims" ng-href="project/{{project.metadata.name}}/create-pvc" class="btn btn-primary">Create Storage</a>
<a ng-if="outOfClaims" href="" class="btn btn-primary disabled" aria-disabled="true">Create Storage</a>
</p>
<div ng-if="!filterWithZeroResults">
<h2>No persistent volume claims.</h2>
<p>
No persistent volume claims have been added to project {{projectName}}.
</p>
<p ng-if="project && ('persistentvolumeclaims' | canI : 'create') && !filterWithZeroResults">
<a ng-if="!outOfClaims" ng-href="project/{{project.metadata.name}}/create-pvc" class="btn btn-primary">Create Storage</a>
<a ng-if="outOfClaims" href="" class="btn btn-primary disabled" aria-disabled="true">Create Storage</a>
</p>
</div>
<div ng-if="filterWithZeroResults">
<h2>The filter is hiding all persistent volume claims. <a href="" ng-click="clearFilter()">Clear Filter</a></h2>
</div>
</div>
</div>
<table ng-if="(pvcs | hashSize) > 0" class="table table-bordered table-mobile table-layout-fixed">
Expand Down
11 changes: 5 additions & 6 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6604,7 +6604,9 @@ r.unwatchAll(c);
});
}));
} ]), angular.module("openshiftConsole").controller("StorageController", [ "$routeParams", "$scope", "AlertMessageService", "DataService", "ProjectsService", "QuotaService", "$filter", "LabelFilter", "Logger", function(e, t, n, a, r, o, i, s, c) {
t.projectName = e.project, t.pvcs = {}, t.unfilteredPVCs = {}, t.labelSuggestions = {}, t.alerts = t.alerts || {}, t.outOfClaims = !1;
t.projectName = e.project, t.pvcs = {}, t.unfilteredPVCs = {}, t.labelSuggestions = {}, t.alerts = t.alerts || {}, t.outOfClaims = !1, t.clearFilter = function() {
s.clear();
};
var l = function() {
var e = n.isAlertPermanentlyHidden("storage-quota-limit-reached", t.projectName);
if (t.outOfClaims = o.isAnyStorageQuotaExceeded(t.quotas, t.clusterQuotas), !e && t.outOfClaims) {
Expand All @@ -6627,15 +6629,12 @@ return n.permanentlyHideAlert("storage-quota-limit-reached", t.projectName), !0;
}, u = [];
r.get(e.project).then(_.spread(function(e, n) {
function r() {
s.getLabelSelector().isEmpty() || !$.isEmptyObject(t.pvcs) || $.isEmptyObject(t.unfilteredPVCs) ? (delete t.alerts.storage, t.filterWithZeroResults = !1) : (t.alerts.storage = {
type: "warning",
details: "The active filters are hiding all persistent volume claims."
}, t.filterWithZeroResults = !0);
t.filterWithZeroResults = !s.getLabelSelector().isEmpty() && $.isEmptyObject(t.pvcs) && !$.isEmptyObject(t.unfilteredPVCs);
}
t.project = e, u.push(a.watch("persistentvolumeclaims", n, function(e) {
t.pvcsLoaded = !0, t.unfilteredPVCs = e.by("metadata.name"), s.addLabelSuggestionsFromResources(t.unfilteredPVCs, t.labelSuggestions), s.setLabelSuggestions(t.labelSuggestions), t.pvcs = s.getLabelSelector().select(t.unfilteredPVCs), r(), c.log("pvcs (subscribe)", t.unfilteredPVCs);
})), s.onActiveFiltersChanged(function(e) {
t.$apply(function() {
t.$evalAsync(function() {
t.pvcs = e.select(t.unfilteredPVCs), r();
});
}), t.$on("$destroy", function() {
Expand Down
7 changes: 6 additions & 1 deletion dist/scripts/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -13589,15 +13589,20 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"Loading...\n" +
"</p>\n" +
"<div ng-if=\"pvcsLoaded\" class=\"empty-state-message text-center\">\n" +
"<div ng-if=\"!filterWithZeroResults\">\n" +
"<h2>No persistent volume claims.</h2>\n" +
"<p ng-if=\"!filterWithZeroResults\">\n" +
"<p>\n" +
"No persistent volume claims have been added to project {{projectName}}.\n" +
"</p>\n" +
"<p ng-if=\"project && ('persistentvolumeclaims' | canI : 'create') && !filterWithZeroResults\">\n" +
"<a ng-if=\"!outOfClaims\" ng-href=\"project/{{project.metadata.name}}/create-pvc\" class=\"btn btn-primary\">Create Storage</a>\n" +
"<a ng-if=\"outOfClaims\" href=\"\" class=\"btn btn-primary disabled\" aria-disabled=\"true\">Create Storage</a>\n" +
"</p>\n" +
"</div>\n" +
"<div ng-if=\"filterWithZeroResults\">\n" +
"<h2>The filter is hiding all persistent volume claims. <a href=\"\" ng-click=\"clearFilter()\">Clear Filter</a></h2>\n" +
"</div>\n" +
"</div>\n" +
"</div>\n" +
"<table ng-if=\"(pvcs | hashSize) > 0\" class=\"table table-bordered table-mobile table-layout-fixed\">\n" +
"<colgroup>\n" +
Expand Down