From 2d00cd8127ff4933f9fb33390cedf3ea65121d46 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Tue, 7 Aug 2018 21:16:42 +0100 Subject: [PATCH] Don't display 404 errors when using the "Jump to..." box Currently, typing an ID in the "Jump to..." box in the header allows the user to jump directly to an object with a given ID. However, if a GET for an object with that ID for the supported objects (currently Story, Project, and Project Group) results in a 404, an error notification is created, which gives a needless impression of something going wrong. The lack of an object in the list of things with the entered ID is sufficient indication that the object doesn't exist, without the extra error message. This commit adds a notification interceptor which stops 404 errors raised between the "Jump to..." GET requests being sent and all of them being resolved from being displayed to the user. There is a small chance that this could cause useful 404 errors to be missed, but the user would have to do something to cause it whilst the other requests are still in-flight, which seems unlikely enough to be acceptable to me. Change-Id: I723d61479370e49b1e36ede0a118ad5d4464907f Story: 2000466 Task: 2751 Story: 2002140 Task: 19830 --- .../storyboard/controller/header_controller.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/storyboard/controller/header_controller.js b/src/app/storyboard/controller/header_controller.js index 69a44bec..a1c7c46d 100644 --- a/src/app/storyboard/controller/header_controller.js +++ b/src/app/storyboard/controller/header_controller.js @@ -22,7 +22,7 @@ angular.module('storyboard').controller('HeaderController', function ($q, $scope, $rootScope, $state, $modal, NewStoryService, Session, SessionState, CurrentUser, Criteria, Notification, Priority, Project, Story, ProjectGroup, NewWorklistService, - NewBoardService, SessionModalService) { + NewBoardService, SessionModalService, Severity) { 'use strict'; function resolveCurrentUser() { @@ -172,11 +172,23 @@ angular.module('storyboard').controller('HeaderController', searchString = searchString || ''; var searches = []; + var headerGET = false; + + Notification.intercept(function(message) { + if (message.type === 'http' && + message.severity === Severity.ERROR && + message.message === 404 && + headerGET + ) { + return true; + } + }); if (searchString.match(/^[0-9]+$/)) { var getProjectGroupDeferred = $q.defer(); var getProjectDeferred = $q.defer(); var getStoryDeferred = $q.defer(); + headerGET = true; ProjectGroup.get({id: searchString}, function (result) { @@ -214,6 +226,7 @@ angular.module('storyboard').controller('HeaderController', searches.push(Story.criteriaResolver(searchString, 5)); } $q.all(searches).then(function (searchResults) { + headerGET = false; var criteria = [ Criteria.create('Text', searchString) ];