Skip to content

Commit

Permalink
Display better submission status.
Browse files Browse the repository at this point in the history
Adds a text field to the right of the progress bar.  Currently this only contains progress for a RadarWeb submission, or "Submitting..." otherwise.

Puts the error message in a sheet attached to the Radar window.

Logs the failing URL and error.

This is mostly useful when RadarWeb breaks.
  • Loading branch information
nriley committed Apr 26, 2013
1 parent 14777bf commit 49b0a9d
Show file tree
Hide file tree
Showing 8 changed files with 365 additions and 369 deletions.
12 changes: 11 additions & 1 deletion QuickRadar/QRRadarSubmissionService.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ @interface QRRadarSubmissionService ()

@property (atomic, assign) CGFloat progressValue;
@property (atomic, assign) SubmissionStatus submissionStatusValue;
@property (atomic, assign) NSString *submissionStatusText;

@end

Expand Down Expand Up @@ -90,6 +91,11 @@ - (SubmissionStatus)submissionStatus
return self.submissionStatusValue;
}

- (NSString *)statusText
{
return self.submissionStatusText;
}


#define NUM_PAGES 5.0

Expand Down Expand Up @@ -130,6 +136,7 @@ - (void)submitAsyncWithProgressBlock:(void (^)())progressBlock completionBlock:(
* Page 1: login page *
**********************/

self.submissionStatusText = @"Fetching RadarWeb signin page";
QRWebScraper *loginPage = [[QRWebScraper alloc] init];
loginPage.URL = [NSURL URLWithString:@"https://bugreport.apple.com/cgi-bin/WebObjects/RadarWeb.woa/wa/signIn"];

Expand Down Expand Up @@ -170,7 +177,7 @@ - (void)submitAsyncWithProgressBlock:(void (^)())progressBlock completionBlock:(
* Page 2: JS bounce page *
**************************/

self.submissionStatusText = @"Signing into RadarWeb";
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *username = [prefs objectForKey: @"username"];
NSString *password = [self radarPassword];
Expand Down Expand Up @@ -241,6 +248,7 @@ - (void)submitAsyncWithProgressBlock:(void (^)())progressBlock completionBlock:(
***************************/


self.submissionStatusText = @"Fetching RadarWeb main page";
NSURL *mainPageURL = [[NSURL URLWithString:@"https://bugreport.apple.com"] URLByAppendingPathComponent:[bouncePageValues objectForKey:@"action"]];

QRWebScraper *mainPage = [[QRWebScraper alloc] init];
Expand Down Expand Up @@ -286,6 +294,7 @@ - (void)submitAsyncWithProgressBlock:(void (^)())progressBlock completionBlock:(
* Page 4: New Ticket Page *
***************************/

self.submissionStatusText = @"Fetching RadarWeb new ticket page";
NSURL *newTicketURL = [[NSURL URLWithString:@"https://bugreport.apple.com"] URLByAppendingPathComponent:[mainPageValues objectForKey:@"URL"]];

QRWebScraper *newTicketPage = [[QRWebScraper alloc] init];
Expand Down Expand Up @@ -350,6 +359,7 @@ - (void)submitAsyncWithProgressBlock:(void (^)())progressBlock completionBlock:(
* Page 5: Bug Submission Page *
*******************************/

self.submissionStatusText = @"Submitting bug to RadarWeb";
NSURL *bugSubmissionURL = [[NSURL URLWithString:@"https://bugreport.apple.com"] URLByAppendingPathComponent:[newTicketPageValues objectForKey:@"action"]];

QRWebScraper *bugSubmissionPage = [[QRWebScraper alloc] init];
Expand Down
1 change: 1 addition & 0 deletions QuickRadar/QRRadarWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@property (nonatomic, strong) IBOutlet NSButton *submitButton;
@property (nonatomic, strong) IBOutlet NSProgressIndicator *spinner;
@property (nonatomic, strong) IBOutlet NSProgressIndicator *progressBar;
@property (nonatomic, strong) IBOutlet NSTextField *submitStatusField;
@property (nonatomic, strong) IBOutlet NSButton *appListButton;
@property (nonatomic, strong) IBOutlet QRAppListPopover *appListPopover;
@property (nonatomic, strong) IBOutlet NSMatrix *checkboxMatrix;
Expand Down
20 changes: 13 additions & 7 deletions QuickRadar/QRRadarWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,13 @@ - (IBAction)submitRadar:(id)sender;
[dict setObject:@(selected) forKey:cell.representedObject];
}
self.submissionController.requestedOptionalServices = [NSDictionary dictionaryWithDictionary:dict];

[self.submissionController startWithProgressBlock:^{
self.progressBar.doubleValue = self.submissionController.progress;
NSString *statusText = self.submissionController.statusText;
if (statusText == nil)
statusText = @"Submitting";
self.submitStatusField.stringValue = [NSString stringWithFormat:@"%@...", statusText];
} completionBlock:^(BOOL success, NSError *error) {
if (success && radar.radarNumber > 0)
{
Expand Down Expand Up @@ -325,16 +329,18 @@ - (IBAction)submitRadar:(id)sender;
}
else
{
[NSApp presentError:error];


[NSApp presentError:error modalForWindow:self.window delegate:nil didPresentSelector:NULL contextInfo:NULL];
if (error.domain == NSURLErrorDomain)
NSLog(@"%@ - %@", [error.userInfo objectForKey:NSLocalizedDescriptionKey],
[error.userInfo objectForKey:NSURLErrorFailingURLStringErrorKey]);

[self.submitButton setEnabled:YES];
[self.spinner stopAnimation:self];
self.submitStatusField.stringValue = @"";
}

}];

}

- (void)controlTextDidChange:(NSNotification *)aNotification {
Expand Down
1 change: 1 addition & 0 deletions QuickRadar/QRSubmissionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@property (nonatomic, strong) QRRadar *radar;
@property (nonatomic, strong) NSDictionary *requestedOptionalServices;
@property (readonly) CGFloat progress;
@property (readonly) NSString *statusText;
@property (nonatomic, strong) NSWindow *submissionWindow;


Expand Down
17 changes: 17 additions & 0 deletions QuickRadar/QRSubmissionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,22 @@ - (CGFloat)progress
return accumulator/number;
}

- (NSString *)statusText
{
NSMutableString *overallStatus = nil;

for (QRSubmissionService *service in self.inProgress)
{
NSString *serviceStatus = service.statusText;
if (serviceStatus == nil)
continue;
if (overallStatus == nil)
overallStatus = [serviceStatus mutableCopy];
else
[overallStatus appendFormat:@"; %@", serviceStatus];
}

return overallStatus;
}

@end
2 changes: 1 addition & 1 deletion QuickRadar/QRSubmissionService.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ NSString * const QRTwitterSubmissionServiceIdentifier;
+ (id)settingsIconPlatformAppropriateImage;

- (SubmissionStatus)submissionStatus;

- (NSString *)statusText;

// Return YES if the requirements for using this service are met (e.g. user has entered username and password in Settings).
// Don't block this method, so don't go and check the username/pass are valid, just return YES if they're present.
Expand Down
5 changes: 5 additions & 0 deletions QuickRadar/QRSubmissionService.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ - (CGFloat)progress
return 0.0f;
}

- (NSString *)statusText
{
return nil;
}

- (void)submitAsyncWithProgressBlock:(void(^)())progressBlock completionBlock:(void(^)(BOOL success, NSError *error))completionBlock
{

Expand Down
Loading

0 comments on commit 49b0a9d

Please sign in to comment.