Skip to content

Fix runtime error when ProjectsService.list() fails #156

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 1 commit into from
Aug 25, 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
8 changes: 7 additions & 1 deletion dist/origin-web-common-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -2565,6 +2565,11 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR
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.
var IMMUTABLE_RESOURCE = {
imagestreamimages: true
Expand Down Expand Up @@ -3024,8 +3029,9 @@ angular.module('openshiftCommonServices')
return projectData;
}, function(error) {
// If the request fails, don't try to list projects again without `forceRefresh`.
cachedProjectData = {};
cachedProjectData = DataService.createData([]);
cachedProjectDataIncomplete = true;
return $q.reject();
});
},

Expand Down
8 changes: 7 additions & 1 deletion dist/origin-web-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4430,6 +4430,11 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR
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.
var IMMUTABLE_RESOURCE = {
imagestreamimages: true
Expand Down Expand Up @@ -4889,8 +4894,9 @@ angular.module('openshiftCommonServices')
return projectData;
}, function(error) {
// If the request fails, don't try to list projects again without `forceRefresh`.
cachedProjectData = {};
cachedProjectData = DataService.createData([]);
cachedProjectDataIncomplete = true;
return $q.reject();
});
},

Expand Down
4 changes: 3 additions & 1 deletion dist/origin-web-common.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,8 @@ return new URI({
protocol:protocol,
hostname:hostPort
}).toString();
}, DataService.prototype.createData = function(array) {
return new Data(array);
};
var IMMUTABLE_RESOURCE = {
imagestreamimages:!0
Expand Down Expand Up @@ -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 = projectData, projectData;
}, function(error) {
cachedProjectData = {}, cachedProjectDataIncomplete = !0;
return cachedProjectData = DataService.createData([]), cachedProjectDataIncomplete = !0, $q.reject();
}));
},
isProjectListIncomplete:function() {
Expand Down
5 changes: 5 additions & 0 deletions src/services/dataService.js
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,11 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR
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.
var IMMUTABLE_RESOURCE = {
imagestreamimages: true
Expand Down
3 changes: 2 additions & 1 deletion src/services/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ angular.module('openshiftCommonServices')
return projectData;
}, function(error) {
// If the request fails, don't try to list projects again without `forceRefresh`.
cachedProjectData = {};
cachedProjectData = DataService.createData([]);
cachedProjectDataIncomplete = true;
return $q.reject();
});
},

Expand Down