Commit 346e3146 by Sam Padgett Committed by GitHub

Merge pull request #156 from spadgett/fix-projects-list-failure

Fix runtime error when ProjectsService.list() fails
parents d980b0e1 a9347180
...@@ -2565,6 +2565,11 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR ...@@ -2565,6 +2565,11 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR
return new URI({protocol: protocol, hostname: hostPort}).toString(); return new URI({protocol: protocol, hostname: hostPort}).toString();
}; };
// Used by ProjectsService when a list fails.
DataService.prototype.createData = function(array) {
return new Data(array);
};
// Immutables are flagged here as we should not need to fetch them more than once. // Immutables are flagged here as we should not need to fetch them more than once.
var IMMUTABLE_RESOURCE = { var IMMUTABLE_RESOURCE = {
imagestreamimages: true imagestreamimages: true
...@@ -3024,8 +3029,9 @@ angular.module('openshiftCommonServices') ...@@ -3024,8 +3029,9 @@ angular.module('openshiftCommonServices')
return projectData; return projectData;
}, function(error) { }, function(error) {
// If the request fails, don't try to list projects again without `forceRefresh`. // If the request fails, don't try to list projects again without `forceRefresh`.
cachedProjectData = {}; cachedProjectData = DataService.createData([]);
cachedProjectDataIncomplete = true; cachedProjectDataIncomplete = true;
return $q.reject();
}); });
}, },
......
...@@ -4433,6 +4433,11 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR ...@@ -4433,6 +4433,11 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR
return new URI({protocol: protocol, hostname: hostPort}).toString(); return new URI({protocol: protocol, hostname: hostPort}).toString();
}; };
// Used by ProjectsService when a list fails.
DataService.prototype.createData = function(array) {
return new Data(array);
};
// Immutables are flagged here as we should not need to fetch them more than once. // Immutables are flagged here as we should not need to fetch them more than once.
var IMMUTABLE_RESOURCE = { var IMMUTABLE_RESOURCE = {
imagestreamimages: true imagestreamimages: true
...@@ -4892,8 +4897,9 @@ angular.module('openshiftCommonServices') ...@@ -4892,8 +4897,9 @@ angular.module('openshiftCommonServices')
return projectData; return projectData;
}, function(error) { }, function(error) {
// If the request fails, don't try to list projects again without `forceRefresh`. // If the request fails, don't try to list projects again without `forceRefresh`.
cachedProjectData = {}; cachedProjectData = DataService.createData([]);
cachedProjectDataIncomplete = true; cachedProjectDataIncomplete = true;
return $q.reject();
}); });
}, },
......
...@@ -1783,6 +1783,8 @@ return new URI({ ...@@ -1783,6 +1783,8 @@ return new URI({
protocol:protocol, protocol:protocol,
hostname:hostPort hostname:hostPort
}).toString(); }).toString();
}, DataService.prototype.createData = function(array) {
return new Data(array);
}; };
var IMMUTABLE_RESOURCE = { var IMMUTABLE_RESOURCE = {
imagestreamimages:!0 imagestreamimages:!0
...@@ -2021,7 +2023,7 @@ list:function(forceRefresh) { ...@@ -2021,7 +2023,7 @@ list:function(forceRefresh) {
return cachedProjectData && !forceRefresh ? (Logger.debug("ProjectsService: returning cached project data"), $q.when(cachedProjectData)) :(Logger.debug("ProjectsService: listing projects, force refresh", forceRefresh), DataService.list("projects", {}).then(function(projectData) { return cachedProjectData && !forceRefresh ? (Logger.debug("ProjectsService: returning cached project data"), $q.when(cachedProjectData)) :(Logger.debug("ProjectsService: listing projects, force refresh", forceRefresh), DataService.list("projects", {}).then(function(projectData) {
return cachedProjectData = projectData, projectData; return cachedProjectData = projectData, projectData;
}, function(error) { }, function(error) {
cachedProjectData = {}, cachedProjectDataIncomplete = !0; return cachedProjectData = DataService.createData([]), cachedProjectDataIncomplete = !0, $q.reject();
})); }));
}, },
isProjectListIncomplete:function() { isProjectListIncomplete:function() {
......
...@@ -1359,6 +1359,11 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR ...@@ -1359,6 +1359,11 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR
return new URI({protocol: protocol, hostname: hostPort}).toString(); return new URI({protocol: protocol, hostname: hostPort}).toString();
}; };
// Used by ProjectsService when a list fails.
DataService.prototype.createData = function(array) {
return new Data(array);
};
// Immutables are flagged here as we should not need to fetch them more than once. // Immutables are flagged here as we should not need to fetch them more than once.
var IMMUTABLE_RESOURCE = { var IMMUTABLE_RESOURCE = {
imagestreamimages: true imagestreamimages: true
......
...@@ -105,8 +105,9 @@ angular.module('openshiftCommonServices') ...@@ -105,8 +105,9 @@ angular.module('openshiftCommonServices')
return projectData; return projectData;
}, function(error) { }, function(error) {
// If the request fails, don't try to list projects again without `forceRefresh`. // If the request fails, don't try to list projects again without `forceRefresh`.
cachedProjectData = {}; cachedProjectData = DataService.createData([]);
cachedProjectDataIncomplete = true; cachedProjectDataIncomplete = true;
return $q.reject();
}); });
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment