Show proper error message for missing job template form

when visiting the job template page for a job template that has been deleted or doesn't exist, we want to show the 404 error message, not an error message about tags or labels.
This commit is contained in:
Jared Tabor
2016-07-13 15:38:38 -07:00
parent c60b8986de
commit f9de8db89a
3 changed files with 79 additions and 64 deletions

View File

@@ -448,7 +448,7 @@ export default
} }
}); });
}; };
if($state.params.id !== "null"){
Rest.setUrl(defaultUrl + $state.params.id + Rest.setUrl(defaultUrl + $state.params.id +
"/labels"); "/labels");
Rest.get() Rest.get()
@@ -472,7 +472,16 @@ export default
}); });
Wait("stop"); Wait("stop");
}); });
}).error(function(){
// job template id is null in this case
$scope.$emit("choicesReady");
}); });
}
else {
// job template doesn't exist
$scope.$emit("choicesReady");
}
}) })
.error(function (data, status) { .error(function (data, status) {
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {

View File

@@ -1,10 +1,11 @@
export default ['$scope', 'Refresh', 'tagSearchService', export default ['$scope', 'Refresh', 'tagSearchService', '$stateParams',
function($scope, Refresh, tagSearchService) { function($scope, Refresh, tagSearchService, $stateParams) {
// JSONify passed field elements that can be searched // JSONify passed field elements that can be searched
$scope.list = angular.fromJson($scope.list); $scope.list = angular.fromJson($scope.list);
// Access config lines from list spec // Access config lines from list spec
$scope.listConfig = $scope.$parent.list; $scope.listConfig = $scope.$parent.list;
// Grab options for the left-dropdown of the searchbar // Grab options for the left-dropdown of the searchbar
if($stateParams.id !== "null"){
tagSearchService.getSearchTypes($scope.list, $scope.endpoint) tagSearchService.getSearchTypes($scope.list, $scope.endpoint)
.then(function(searchTypes) { .then(function(searchTypes) {
$scope.searchTypes = searchTypes; $scope.searchTypes = searchTypes;
@@ -12,6 +13,7 @@ export default ['$scope', 'Refresh', 'tagSearchService',
// currently selected option of the left-dropdown // currently selected option of the left-dropdown
$scope.currentSearchType = $scope.searchTypes[0]; $scope.currentSearchType = $scope.searchTypes[0];
}); });
}
// shows/hide the search type dropdown // shows/hide the search type dropdown
$scope.toggleTypeDropdown = function() { $scope.toggleTypeDropdown = function() {

View File

@@ -84,7 +84,9 @@ export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', '$log', fu
if (needsRequest.length) { if (needsRequest.length) {
// make the options request to reutrn the typeOptions // make the options request to reutrn the typeOptions
Rest.setUrl(needsRequest[0].basePath ? GetBasePath(needsRequest[0].basePath) : basePath); var url = needsRequest[0].basePath ? GetBasePath(needsRequest[0].basePath) : basePath;
if(url.indexOf('null') === 0 ){
Rest.setUrl(url);
Rest.options() Rest.options()
.success(function (data) { .success(function (data) {
try { try {
@@ -119,6 +121,8 @@ export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', '$log', fu
hdr: 'Error!', hdr: 'Error!',
msg: 'Getting type options failed'}); msg: 'Getting type options failed'});
}); });
}
} else { } else {
Wait("stop"); Wait("stop");
defer.resolve(joinOptions()); defer.resolve(joinOptions());