Skip to content

Commit 075822b

Browse files
Merge pull request #2259 from rhamilto/issue-109
Automatic merge from submit-queue. Replacing empty tables with empty state message Fixes #109 Replaces #497 HACK DAY! Before: ![127 0 0 1-8443-console-project-my-project-dc-browse-deployments](https://user-images.githubusercontent.com/895728/31518381-10aab73c-af6d-11e7-81e0-a650c802b9d7.png) ![127 0 0 1-8443-console-project-my-project-dc-browse-deployments 1](https://user-images.githubusercontent.com/895728/31518396-19db6d7e-af6d-11e7-8c53-949714425d25.png) After: ![localhost-9000-dev-console-project-my-project-empty-quota](https://user-images.githubusercontent.com/895728/31667665-20f0674a-b31e-11e7-8e83-8b0a047220ba.png) ![localhost-9000-dev-console-project-my-project-delete-browse-config-maps-labelfilter 7b 22matchexpressions 22- 5b 7b 22key 22- 22foo 22 22operator 22- 22exists 22 22values 22- 5b 5d 7d 5d 7d](https://user-images.githubusercontent.com/895728/31666705-2eb4f31c-b31b-11e7-98fe-96d86d643a2a.png)
2 parents c7bba0e + 5d681a3 commit 075822b

32 files changed

+891
-749
lines changed

app/scripts/controllers/builds.js

+9-18
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ angular.module('openshiftConsole')
2424
$scope.unfilteredBuildConfigs = {};
2525
$scope.buildConfigs = undefined;
2626
$scope.labelSuggestions = {};
27-
$scope.alerts = $scope.alerts || {};
28-
$scope.emptyMessage = "Loading...";
2927
$scope.latestByConfig = {};
28+
$scope.clearFilter = function() {
29+
LabelFilter.clear();
30+
};
3031

3132
var buildConfigForBuild = $filter('buildConfigForBuild');
3233

@@ -43,9 +44,9 @@ angular.module('openshiftConsole')
4344
var isPipeline = $filter('isJenkinsPipelineStrategy');
4445

4546
watches.push(DataService.watch(buildsVersion, context, function(builds) {
47+
$scope.buildsLoaded = true;
4648
// Filter out pipeline builds, which have a separate page.
4749
$scope.builds = _.omitBy(builds.by("metadata.name"), isPipeline);
48-
$scope.emptyMessage = "No builds to show";
4950
associateBuildsToBuildConfig();
5051
LabelFilter.addLabelSuggestionsFromResources($scope.builds, $scope.labelSuggestions);
5152

@@ -59,7 +60,7 @@ angular.module('openshiftConsole')
5960
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
6061
$scope.buildConfigs = LabelFilter.getLabelSelector().select($scope.unfilteredBuildConfigs);
6162
associateBuildsToBuildConfig();
62-
updateFilterWarning();
63+
updateFilterMessage();
6364
Logger.log("buildconfigs (subscribe)", $scope.buildConfigs);
6465
}));
6566

@@ -113,27 +114,17 @@ angular.module('openshiftConsole')
113114
});
114115
}
115116

116-
function updateFilterWarning() {
117+
function updateFilterMessage() {
117118
var visibleBuilds = _.omitBy($scope.latestByConfig, _.isNull);
118-
if (!LabelFilter.getLabelSelector().isEmpty() &&
119-
_.isEmpty($scope.buildConfigs) &&
120-
_.isEmpty(visibleBuilds)) {
121-
$scope.alerts["builds"] = {
122-
type: "warning",
123-
details: "The active filters are hiding all builds."
124-
};
125-
}
126-
else {
127-
delete $scope.alerts["builds"];
128-
}
119+
$scope.filterWithZeroResults = !LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.buildConfigs) && _.isEmpty(visibleBuilds);
129120
}
130121

131122
LabelFilter.onActiveFiltersChanged(function(labelSelector) {
132123
// trigger a digest loop
133-
$scope.$apply(function() {
124+
$scope.$evalAsync(function() {
134125
$scope.buildConfigs = labelSelector.select($scope.unfilteredBuildConfigs);
135126
associateBuildsToBuildConfig();
136-
updateFilterWarning();
127+
updateFilterMessage();
137128
});
138129
});
139130

app/scripts/controllers/configMaps.js

+7-14
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,17 @@ angular.module('openshiftConsole')
1616
LabelFilter,
1717
ProjectsService) {
1818
$scope.projectName = $routeParams.project;
19-
$scope.alerts = $scope.alerts || {};
2019
$scope.loaded = false;
2120
$scope.labelSuggestions = {};
2221
$scope.configMapsVersion = APIService.getPreferredVersion('configmaps');
22+
$scope.clearFilter = function () {
23+
LabelFilter.clear();
24+
};
2325
var watches = [];
2426
var configMaps;
2527

26-
var updateFilterWarning = function() {
27-
if (!LabelFilter.getLabelSelector().isEmpty() &&
28-
_.isEmpty($scope.configMaps) &&
29-
!_.isEmpty(configMaps)) {
30-
$scope.alerts["config-maps"] = {
31-
type: "warning",
32-
details: "The active filters are hiding all config maps."
33-
};
34-
} else {
35-
delete $scope.alerts["config-maps"];
36-
}
28+
var updateFilterMessage = function() {
29+
$scope.filterWithZeroResults = !LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.configMaps) && !_.isEmpty(configMaps);
3730
};
3831

3932
var updateLabelSuggestions = function() {
@@ -44,7 +37,7 @@ angular.module('openshiftConsole')
4437
var updateConfigMaps = function() {
4538
var filteredConfigMaps = LabelFilter.getLabelSelector().select(configMaps);
4639
$scope.configMaps = _.sortBy(filteredConfigMaps, 'metadata.name');
47-
updateFilterWarning();
40+
updateFilterMessage();
4841
};
4942

5043
ProjectsService
@@ -60,7 +53,7 @@ angular.module('openshiftConsole')
6053
}));
6154

6255
LabelFilter.onActiveFiltersChanged(function() {
63-
$scope.$apply(updateConfigMaps);
56+
$scope.$evalAsync(updateConfigMaps);
6457
});
6558

6659
$scope.$on('$destroy', function(){

app/scripts/controllers/deployments.js

+34-48
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ angular.module('openshiftConsole')
2424
$scope.unfilteredDeployments = {};
2525
$scope.replicationControllersByDC = {};
2626
$scope.labelSuggestions = {};
27-
$scope.alerts = $scope.alerts || {};
2827
$scope.emptyMessage = "Loading...";
2928
$scope.expandedDeploymentConfigRow = {};
3029
$scope.unfilteredReplicaSets = {};
3130
$scope.unfilteredReplicationControllers = {};
31+
$scope.showEmptyState = true;
32+
$scope.clearFilter = function() {
33+
LabelFilter.clear();
34+
};
3235

3336
var replicaSets, deploymentsByUID;
3437
var annotation = $filter('annotation');
@@ -38,6 +41,26 @@ angular.module('openshiftConsole')
3841
var replicationControllersVersion = APIService.getPreferredVersion('replicationcontrollers');
3942
var replicaSetsVersion = APIService.getPreferredVersion('replicasets');
4043

44+
function updateFilterMessage() {
45+
46+
var unfilteredDeploymentsEmpty =
47+
_.isEmpty($scope.unfilteredDeploymentConfigs) &&
48+
_.isEmpty($scope.unfilteredReplicationControllers) &&
49+
_.isEmpty($scope.unfilteredDeployments) &&
50+
_.isEmpty($scope.unfilteredReplicaSets);
51+
52+
var isFiltering = !LabelFilter.getLabelSelector().isEmpty();
53+
54+
var filteredDeploymentsEmpty =
55+
_.isEmpty($scope.deploymentConfigs) &&
56+
_.isEmpty($scope.replicationControllersByDC['']) &&
57+
_.isEmpty($scope.deployments) &&
58+
_.isEmpty($scope.replicaSets);
59+
60+
$scope.showEmptyState = unfilteredDeploymentsEmpty;
61+
$scope.filterWithZeroResults = isFiltering && filteredDeploymentsEmpty && !unfilteredDeploymentsEmpty;
62+
}
63+
4164
var groupReplicaSets = function() {
4265
if (!replicaSets || !deploymentsByUID) {
4366
return;
@@ -58,6 +81,7 @@ angular.module('openshiftConsole')
5881
$scope.latestReplicaSetByDeploymentUID[deploymentUID] =
5982
DeploymentsService.getActiveReplicaSet(replicaSets, deploymentsByUID[deploymentUID]);
6083
});
84+
updateFilterMessage();
6185
};
6286

6387
var watches = [];
@@ -82,7 +106,7 @@ angular.module('openshiftConsole')
82106
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
83107
$scope.replicationControllersByDC[''] = LabelFilter.getLabelSelector().select($scope.replicationControllersByDC['']);
84108
}
85-
updateFilterWarning();
109+
updateFilterMessage();
86110

87111
if (!action) {
88112
// Loading of the page that will create deploymentConfigDeploymentsInProgress structure, which will associate running deployment to his deploymentConfig.
@@ -121,6 +145,7 @@ angular.module('openshiftConsole')
121145
}));
122146

123147
watches.push(DataService.watch(deploymentConfigsVersion, context, function(deploymentConfigs) {
148+
$scope.deploymentConfigsLoaded = true;
124149
$scope.unfilteredDeploymentConfigs = deploymentConfigs.by("metadata.name");
125150
LabelFilter.addLabelSuggestionsFromResources($scope.unfilteredDeploymentConfigs, $scope.labelSuggestions);
126151
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
@@ -131,7 +156,7 @@ angular.module('openshiftConsole')
131156
$scope.unfilteredReplicationControllers = $scope.replicationControllersByDC[''];
132157
$scope.replicationControllersByDC[''] = LabelFilter.getLabelSelector().select($scope.replicationControllersByDC['']);
133158
}
134-
updateFilterWarning();
159+
updateFilterMessage();
135160
Logger.log("deploymentconfigs (subscribe)", $scope.deploymentConfigs);
136161
}));
137162

@@ -144,54 +169,15 @@ angular.module('openshiftConsole')
144169
Logger.log("deployments (subscribe)", $scope.unfilteredDeployments);
145170
}));
146171

147-
function updateFilterWarning() {
148-
var isFiltering = !LabelFilter.getLabelSelector().isEmpty();
149-
if (!isFiltering) {
150-
delete $scope.alerts["deployments"];
151-
return;
152-
}
153-
154-
var unfilteredDeploymentsEmpty =
155-
_.isEmpty($scope.unfilteredDeploymentConfigs) &&
156-
_.isEmpty($scope.unfilteredReplicationControllers) &&
157-
_.isEmpty($scope.unfilteredDeployments) &&
158-
_.isEmpty($scope.unfilteredReplicaSets);
159-
if (unfilteredDeploymentsEmpty) {
160-
delete $scope.alerts["deployments"];
161-
return;
162-
}
163-
164-
var filteredDeploymentsEmpty =
165-
_.isEmpty($scope.deploymentConfigs) &&
166-
_.isEmpty($scope.replicationControllersByDC['']) &&
167-
_.isEmpty($scope.deployments) &&
168-
_.isEmpty($scope.replicaSets);
169-
if (!filteredDeploymentsEmpty) {
170-
delete $scope.alerts["deployments"];
171-
return;
172-
}
173-
174-
$scope.alerts["deployments"] = {
175-
type: "warning",
176-
details: "The active filters are hiding all deployments."
177-
};
178-
}
179-
180-
$scope.showEmptyMessage = function() {
181-
if ($filter('hashSize')($scope.replicationControllersByDC) === 0) {
182-
return true;
183-
}
184-
185-
if ($filter('hashSize')($scope.replicationControllersByDC) === 1 && $scope.replicationControllersByDC['']) {
186-
return true;
187-
}
188-
189-
return false;
172+
// Does the deployment config table have content?
173+
$scope.showDeploymentConfigTable = function() {
174+
var size = _.size($scope.replicationControllersByDC);
175+
return size > 1 || (size === 1 && !$scope.replicationControllersByDC['']);
190176
};
191177

192178
LabelFilter.onActiveFiltersChanged(function(labelSelector) {
193179
// trigger a digest loop
194-
$scope.$apply(function() {
180+
$scope.$evalAsync(function() {
195181
$scope.deploymentConfigs = labelSelector.select($scope.unfilteredDeploymentConfigs);
196182
$scope.replicationControllersByDC = DeploymentsService.associateDeploymentsToDeploymentConfig($scope.replicationControllers, $scope.deploymentConfigs, true);
197183
if ($scope.replicationControllersByDC['']) {
@@ -200,7 +186,7 @@ angular.module('openshiftConsole')
200186
}
201187
$scope.deployments = labelSelector.select($scope.unfilteredDeployments);
202188
$scope.replicaSets = labelSelector.select($scope.unfilteredReplicaSets);
203-
updateFilterWarning();
189+
updateFilterMessage();
204190
});
205191
});
206192

app/scripts/controllers/images.js

+9-16
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ angular.module('openshiftConsole')
2323
$scope.missingStatusTagsByImageStream = {};
2424
$scope.builds = {};
2525
$scope.labelSuggestions = {};
26-
$scope.alerts = $scope.alerts || {};
27-
$scope.emptyMessage = "Loading...";
26+
$scope.clearFilter = function() {
27+
LabelFilter.clear();
28+
};
2829

2930
var imageStreamsVersion = APIService.getPreferredVersion('imagestreams');
3031

@@ -35,13 +36,13 @@ angular.module('openshiftConsole')
3536
.then(_.spread(function(project, context) {
3637
$scope.project = project;
3738
watches.push(DataService.watch(imageStreamsVersion, context, function(imageStreams) {
39+
$scope.imageStreamsLoaded = true;
3840
$scope.unfilteredImageStreams = imageStreams.by("metadata.name");
3941
LabelFilter.addLabelSuggestionsFromResources($scope.unfilteredImageStreams, $scope.labelSuggestions);
4042
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
4143
$scope.imageStreams = LabelFilter.getLabelSelector().select($scope.unfilteredImageStreams);
42-
$scope.emptyMessage = "No image streams to show";
4344
updateMissingStatusTags();
44-
updateFilterWarning();
45+
updateFilterMessage();
4546
Logger.log("image streams (subscribe)", $scope.imageStreams);
4647
}));
4748

@@ -71,23 +72,15 @@ angular.module('openshiftConsole')
7172
});
7273
}
7374

74-
function updateFilterWarning() {
75-
if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.imageStreams) && !$.isEmptyObject($scope.unfilteredImageStreams)) {
76-
$scope.alerts["imageStreams"] = {
77-
type: "warning",
78-
details: "The active filters are hiding all image streams."
79-
};
80-
}
81-
else {
82-
delete $scope.alerts["imageStreams"];
83-
}
75+
function updateFilterMessage() {
76+
$scope.filterWithZeroResults = !LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.imageStreams) && !_.isEmpty($scope.unfilteredImageStreams);
8477
}
8578

8679
LabelFilter.onActiveFiltersChanged(function(labelSelector) {
8780
// trigger a digest loop
88-
$scope.$apply(function() {
81+
$scope.$evalAsync(function() {
8982
$scope.imageStreams = labelSelector.select($scope.unfilteredImageStreams);
90-
updateFilterWarning();
83+
updateFilterMessage();
9184
});
9285
});
9386

app/scripts/controllers/otherResources.js

+10-17
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ angular.module('openshiftConsole')
1414
APIService) {
1515
$scope.projectName = $routeParams.project;
1616
$scope.labelSuggestions = {};
17-
$scope.alerts = $scope.alerts || {};
18-
$scope.emptyMessage = "Select a resource from the list above ...";
1917
$scope.kindSelector = {disabled: true};
2018
$scope.kinds = _.filter(APIService.availableKinds(), function(kind) {
2119
switch (kind.kind) {
@@ -47,6 +45,9 @@ angular.module('openshiftConsole')
4745
return true;
4846
}
4947
});
48+
$scope.clearFilter = function () {
49+
LabelFilter.clear();
50+
};
5051

5152
var isListable = function(kind) {
5253
if(!kind) {
@@ -125,16 +126,8 @@ angular.module('openshiftConsole')
125126
}
126127
}));
127128

128-
function updateFilterWarning() {
129-
if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.resources) && !$.isEmptyObject($scope.unfilteredResources)) {
130-
$scope.alerts["resources"] = {
131-
type: "warning",
132-
details: "The active filters are hiding all " + APIService.kindToResource($scope.kindSelector.selected.kind, true) + "."
133-
};
134-
}
135-
else {
136-
delete $scope.alerts["resources"];
137-
}
129+
function updateFilterMessage() {
130+
$scope.filterWithZeroResults = !LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.resources) && !_.isEmpty($scope.unfilteredResources);
138131
}
139132

140133
function loadKind() {
@@ -158,13 +151,13 @@ angular.module('openshiftConsole')
158151
LabelFilter.addLabelSuggestionsFromResources($scope.unfilteredResources, $scope.labelSuggestions);
159152
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
160153
$scope.resources = LabelFilter.getLabelSelector().select($scope.unfilteredResources);
161-
$scope.emptyMessage = "No " + APIService.kindToResource(selected.kind, true) + " to show";
162-
updateFilterWarning();
154+
$scope.resourceName = APIService.kindToResource(selected.kind, true);
155+
updateFilterMessage();
163156
});
164157
}
165158
$scope.loadKind = loadKind;
166159
$scope.$watch("kindSelector.selected", function() {
167-
$scope.alerts = {};
160+
LabelFilter.clear();
168161
loadKind();
169162
});
170163

@@ -175,9 +168,9 @@ angular.module('openshiftConsole')
175168

176169
LabelFilter.onActiveFiltersChanged(function(labelSelector) {
177170
// trigger a digest loop
178-
$scope.$apply(function() {
171+
$scope.$evalAsync(function() {
179172
$scope.resources = labelSelector.select($scope.unfilteredResources);
180-
updateFilterWarning();
173+
updateFilterMessage();
181174
});
182175
});
183176
});

0 commit comments

Comments
 (0)