-
Notifications
You must be signed in to change notification settings - Fork 385
Fix for "Disallow Empty Bug Reports" Issue #2615 #2676
base: master
Are you sure you want to change the base?
Changes from 1 commit
a2505e1
a8137a8
bceb428
d78d504
a43a06f
26bdaff
3a16297
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ protocol NewIssueTableViewControllerDelegate: class { | |
func didDismissAfterCreatingIssue(model: IssueDetailsModel) | ||
} | ||
|
||
final class NewIssueTableViewController: UITableViewController, UITextFieldDelegate { | ||
final class NewIssueTableViewController: UITableViewController, UITextFieldDelegate, UITextViewDelegate { | ||
|
||
weak var delegate: NewIssueTableViewControllerDelegate? | ||
|
||
|
@@ -103,6 +103,9 @@ final class NewIssueTableViewController: UITableViewController, UITextFieldDeleg | |
titleField.delegate = self | ||
titleField.font = Styles.Text.body.preferredFont | ||
|
||
// Setup the description textView to report if it has been edited | ||
bodyField.delegate = self | ||
|
||
// Setup markdown input view | ||
bodyField.githawkConfigure(inset: false) | ||
setupInputView() | ||
|
@@ -141,7 +144,12 @@ final class NewIssueTableViewController: UITableViewController, UITextFieldDeleg | |
/// Attempts to sends the current forms information to GitHub, on success will redirect the user to the new issue | ||
@objc func onSend() { | ||
guard let titleText = titleText else { | ||
Squawk.showError(message: NSLocalizedString("You must provide a title!", comment: "Invalid title when sending new issue")) | ||
Squawk.showIssueError(message: NSLocalizedString("You must provide a title!", comment: "Invalid title when sending new issue"), view: bodyField) | ||
return | ||
} | ||
|
||
guard let bodyText = bodyText else { | ||
Squawk.showIssueError(message: NSLocalizedString("You must provide an issue description!", comment: "Invalid description when sending new issue"), view: bodyField) | ||
return | ||
} | ||
|
||
|
@@ -155,7 +163,7 @@ final class NewIssueTableViewController: UITableViewController, UITextFieldDeleg | |
owner: owner, | ||
repo: repo, | ||
title: titleText, | ||
body: (bodyText ?? "") + signature) | ||
body: bodyText + signature) | ||
) { [weak self] result in | ||
guard let strongSelf = self else { return } | ||
strongSelf.setRightBarItemIdle() | ||
|
@@ -205,6 +213,20 @@ final class NewIssueTableViewController: UITableViewController, UITextFieldDeleg | |
bodyField.inputAccessoryView = actions | ||
} | ||
|
||
func updateSubmitButtonState() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you like to write a test for this? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can do away with that function as I mentioned. But if we don't, I sure will! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm concerned about having split that onSend function in two and if I need to write a test for it. Also concerned about writing the test. I couldn't see anywhere where we are currently testing this portion of the code. I'm unfamiliar with tests in general so if you could give me some direction on this I would appreciate it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll get back to you on this one once I have a bit more time. Let's leave it for now; it's OK :) |
||
if titleText == nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe combine these 2 ifs with an or ( navigationItem.rightBarButtonItem?.isEnabled = ( titleText == nil || bodyText == nil ) ? false : true There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hahahahah! Yes correct on both points. Totally forget the ternary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I can change this around. How should I resubmit? I close and then do a new PR right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wayni208 no need to close. Once you make a new commit to your branch it will update here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There we go! Thanks for the feedback and direction on that function. Such a more elegant way to get it done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome! Was about to say you don't have to reopen every time. 💯 |
||
navigationItem.rightBarButtonItem?.isEnabled = false | ||
return | ||
} | ||
|
||
if bodyText == nil { | ||
navigationItem.rightBarButtonItem?.isEnabled = false | ||
return | ||
} | ||
|
||
navigationItem.rightBarButtonItem?.isEnabled = true | ||
} | ||
|
||
// MARK: UITextFieldDelegate | ||
|
||
/// Called when the user taps return on the title field, moves their cursor to the body | ||
|
@@ -213,11 +235,18 @@ final class NewIssueTableViewController: UITableViewController, UITextFieldDeleg | |
return false | ||
} | ||
|
||
// MARK: UITextViewDelegatre | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Spelling - UITextViewDelegate |
||
|
||
/// Called when editing changed on the body field, enable/disable submit button based on title and body | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome you thought about the header docs! If we drop the body requirement though, this should be updated. |
||
func textViewDidChange(_ bodyField: UITextView) { | ||
updateSubmitButtonState() | ||
} | ||
|
||
// MARK: Actions | ||
|
||
/// Called when editing changed on the title field, enable/disable submit button based on title text | ||
/// Called when editing changed on the title field, enable/disable submit button based on title and body | ||
@IBAction func titleFieldEditingChanged(_ sender: Any) { | ||
navigationItem.rightBarButtonItem?.isEnabled = titleText != nil | ||
updateSubmitButtonState() | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on rewording this alert? Maybe something kinder like:
Title: "Title Required" or "Issue requires title"
Body: "Please provide a title and try again"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I like title option 2... and I like the body. Mind updating that, @wayni208?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before I resolve this and because I had made the change before you replied @BasThomas , are we good on the message as I've written it? Here are both:
Also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!