Display the 'no pull requests' error a little more intelligently

This commit is contained in:
R. Tyler Croy 2012-04-13 21:13:40 -07:00
parent 8e65643ff6
commit 6be975e6cf
3 changed files with 9 additions and 6 deletions

View File

@ -38,7 +38,7 @@ try{((($receiver = smalltalk.send(smalltalk.send(self['@repos'], "_size", []), "
smalltalk.send(smalltalk.send(smalltalk.send(self['@repos'], "_keys", []), "_reversed", []), "_do_", [(function(repo){var fullname=nil;
(fullname=smalltalk.send(smalltalk.send(self['@username'], "__comma", [unescape("/")]), "__comma", [repo]));return smalltalk.send((smalltalk.PullRequest || PullRequest), "_fetchFor_withEachDo_finally_", [fullname, (function(pull){var stack=nil;
(stack=smalltalk.send(self['@repos'], "_at_ifAbsent_", [repo, (function(){return nil;})]));return (($receiver = stack) != nil && $receiver != undefined) ? (function(){return smalltalk.send(stack, "_add_", [pull]);})() : nil;}), (function(success){var stack=nil;
smalltalk.send((typeof console == 'undefined' ? nil : console), "_log_", [smalltalk.send(unescape("Finding%20pull%20requests%20succeeded%3F%20"), "__comma", [success])]);(stack=smalltalk.send(self['@repos'], "_at_ifAbsent_", [repo, (function(){return nil;})]));return ((($receiver = ((($receiver = smalltalk.send(stack, "_size", [])).klass === smalltalk.Number) ? $receiver >(0) : smalltalk.send($receiver, "__gt", [(0)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_activateRepo_", [repo]);})() : (function(){smalltalk.send(self, "_hideSpinner", []);return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self, "_activateRepo_", [repo]);}), (function(){smalltalk.send(self, "_hideSpinner", []);return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})]));})]);})]);
(stack=smalltalk.send(self['@repos'], "_at_ifAbsent_", [repo, (function(){return nil;})]));return ((($receiver = ((($receiver = smalltalk.send(stack, "_size", [])).klass === smalltalk.Number) ? $receiver >(0) : smalltalk.send($receiver, "__gt", [(0)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_activateRepo_", [repo]);})() : (function(){smalltalk.send(self, "_hideSpinner", []);return ((($receiver = smalltalk.send(smalltalk.send(self['@repos'], "_size", []), "__eq", [(1)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})]));})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self, "_activateRepo_", [repo]);}), (function(){smalltalk.send(self, "_hideSpinner", []);return ((($receiver = smalltalk.send(smalltalk.send(self['@repos'], "_size", []), "__eq", [(1)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})]));})]));})]);})]);
return self;
} catch(e) {if(e.name === 'stReturn' && e.selector === '_loadPullRequests'){return e.fn()} throw(e)}}
}),

View File

@ -49,12 +49,12 @@ try{((($receiver = smalltalk.send(smalltalk.send(self['@repos'], "_size", []), "
smalltalk.send(smalltalk.send(smalltalk.send(self['@repos'], "_keys", []), "_reversed", []), "_do_", [(function(repo){var fullname=nil;
(fullname=smalltalk.send(smalltalk.send(self['@username'], "__comma", [unescape("/")]), "__comma", [repo]));return smalltalk.send((smalltalk.PullRequest || PullRequest), "_fetchFor_withEachDo_finally_", [fullname, (function(pull){var stack=nil;
(stack=smalltalk.send(self['@repos'], "_at_ifAbsent_", [repo, (function(){return nil;})]));return (($receiver = stack) != nil && $receiver != undefined) ? (function(){return smalltalk.send(stack, "_add_", [pull]);})() : nil;}), (function(success){var stack=nil;
smalltalk.send((typeof console == 'undefined' ? nil : console), "_log_", [smalltalk.send(unescape("Finding%20pull%20requests%20succeeded%3F%20"), "__comma", [success])]);(stack=smalltalk.send(self['@repos'], "_at_ifAbsent_", [repo, (function(){return nil;})]));return ((($receiver = ((($receiver = smalltalk.send(stack, "_size", [])).klass === smalltalk.Number) ? $receiver >(0) : smalltalk.send($receiver, "__gt", [(0)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_activateRepo_", [repo]);})() : (function(){smalltalk.send(self, "_hideSpinner", []);return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self, "_activateRepo_", [repo]);}), (function(){smalltalk.send(self, "_hideSpinner", []);return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})]));})]);})]);
(stack=smalltalk.send(self['@repos'], "_at_ifAbsent_", [repo, (function(){return nil;})]));return ((($receiver = ((($receiver = smalltalk.send(stack, "_size", [])).klass === smalltalk.Number) ? $receiver >(0) : smalltalk.send($receiver, "__gt", [(0)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_activateRepo_", [repo]);})() : (function(){smalltalk.send(self, "_hideSpinner", []);return ((($receiver = smalltalk.send(smalltalk.send(self['@repos'], "_size", []), "__eq", [(1)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})]));})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self, "_activateRepo_", [repo]);}), (function(){smalltalk.send(self, "_hideSpinner", []);return ((($receiver = smalltalk.send(smalltalk.send(self['@repos'], "_size", []), "__eq", [(1)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_displayError_", ["No pull requests found"]);})]));})]));})]);})]);
return self;
} catch(e) {if(e.name === 'stReturn' && e.selector === '_loadPullRequests'){return e.fn()} throw(e)}},
args: [],
source: unescape('loadPullRequests%0A%09%28repos%20size%29%20%3D%200%20ifTrue%3A%20%5B%0A%09%09self%20displayError%3A%20%27No%20repos%20found%27.%0A%09%09self%20hideSpinner.%0A%09%09%5E%20false%0A%09%5D.%0A%0A%09repos%20keys%20reversed%20do%3A%20%5B%20%3Arepo%20%7C%0A%09%09%7C%20fullname%20%7C%0A%09%09fullname%20%3A%3D%20username%2C%20%27/%27%2C%20repo.%0A%09%09PullRequest%20fetchFor%3A%20fullname%0A%09%09%09withEachDo%3A%20%5B%20%3Apull%20%7C%0A%09%09%09%09%7C%20stack%20%7C%0A%09%09%09%09stack%20%3A%3D%20%28repos%20at%3A%20repo%20ifAbsent%3A%20%5Bnil%5D%29.%0A%09%09%09%09stack%20ifNotNil%3A%20%5B%20stack%20add%3A%20pull%20%5D.%0A%09%09%09%5D%0A%09%09%09finally%3A%20%5B%20%3A%20success%20%7C%0A%09%09%09%09%7C%20stack%20%7C%0A%09%09%09%09console%20log%3A%20%27Finding%20pull%20requests%20succeeded%3F%20%27%2C%20success.%0A%09%09%09%09stack%20%3A%3D%20%28repos%20at%3A%20repo%20ifAbsent%3A%20%5B%5D%29.%0A%09%09%09%09%28stack%20size%29%20%3E%200%0A%09%09%09%09%09ifTrue%3A%20%5B%20self%20activateRepo%3A%20repo%20%5D%0A%09%09%09%09%09ifFalse%3A%20%5B%20self%20hideSpinner.%20self%20displayError%3A%20%27No%20pull%20requests%20found%27.%5D.%0A%09%09%09%5D%0A%09%5D.'),
messageSends: ["ifTrue:", unescape("%3D"), "size", "displayError:", "hideSpinner", "do:", "reversed", "keys", unescape("%2C"), "fetchFor:withEachDo:finally:", "at:ifAbsent:", "ifNotNil:", "add:", "log:", "ifTrue:ifFalse:", unescape("%3E"), "activateRepo:"],
source: unescape('loadPullRequests%0A%09%28repos%20size%29%20%3D%200%20ifTrue%3A%20%5B%0A%09%09self%20displayError%3A%20%27No%20repos%20found%27.%0A%09%09self%20hideSpinner.%0A%09%09%5E%20false%0A%09%5D.%0A%0A%09repos%20keys%20reversed%20do%3A%20%5B%20%3Arepo%20%7C%0A%09%09%7C%20fullname%20%7C%0A%09%09fullname%20%3A%3D%20username%2C%20%27/%27%2C%20repo.%0A%09%09PullRequest%20fetchFor%3A%20fullname%0A%09%09%09withEachDo%3A%20%5B%20%3Apull%20%7C%0A%09%09%09%09%7C%20stack%20%7C%0A%09%09%09%09stack%20%3A%3D%20%28repos%20at%3A%20repo%20ifAbsent%3A%20%5Bnil%5D%29.%0A%09%09%09%09stack%20ifNotNil%3A%20%5B%20stack%20add%3A%20pull%20%5D.%0A%09%09%09%5D%0A%09%09%09finally%3A%20%5B%20%3A%20success%20%7C%0A%09%09%09%09%7C%20stack%20%7C%0A%09%09%09%09stack%20%3A%3D%20%28repos%20at%3A%20repo%20ifAbsent%3A%20%5B%5D%29.%0A%09%09%09%09%28stack%20size%29%20%3E%200%0A%09%09%09%09%09ifTrue%3A%20%5B%20self%20activateRepo%3A%20repo%20%5D%0A%09%09%09%09%09ifFalse%3A%20%5B%0A%09%09%09%09%09%09self%20hideSpinner.%0A%09%09%09%09%09%09%22%20We%20really%20only%20need%20to%20display%20this%20error%20if%20we%27re%20on%20a%20repo%20page%22%0A%09%09%09%09%09%09%28repos%20size%29%20%3D%201%20ifTrue%3A%20%5B%20self%20displayError%3A%20%27No%20pull%20requests%20found%27.%20%5D%0A%09%09%09%09%09%5D.%0A%09%09%09%5D%0A%09%5D.'),
messageSends: ["ifTrue:", unescape("%3D"), "size", "displayError:", "hideSpinner", "do:", "reversed", "keys", unescape("%2C"), "fetchFor:withEachDo:finally:", "at:ifAbsent:", "ifNotNil:", "add:", "ifTrue:ifFalse:", unescape("%3E"), "activateRepo:"],
referencedClasses: ["PullRequest"]
}),
smalltalk.DespairApp);

View File

@ -33,11 +33,14 @@ loadPullRequests
]
finally: [ : success |
| stack |
console log: 'Finding pull requests succeeded? ', success.
stack := (repos at: repo ifAbsent: []).
(stack size) > 0
ifTrue: [ self activateRepo: repo ]
ifFalse: [ self hideSpinner. self displayError: 'No pull requests found'.].
ifFalse: [
self hideSpinner.
" We really only need to display this error if we're on a repo page"
(repos size) = 1 ifTrue: [ self displayError: 'No pull requests found'. ]
].
]
].
!