-
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 2 commits
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("An issue title is required. Please add a title and try again.", comment: "Invalid title when sending new issue"), view: bodyField) | ||
return | ||
} | ||
|
||
guard let bodyText = bodyText else { | ||
Squawk.showIssueError(message: NSLocalizedString("Please provide as much of a detailed description possible and try again.", 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,10 @@ 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 :) |
||
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. Like @BasThomas mentioned, you actually can just leave it as
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 see what you did there. 😀 |
||
} | ||
|
||
// MARK: UITextFieldDelegate | ||
|
||
/// Called when the user taps return on the title field, moves their cursor to the body | ||
|
@@ -213,11 +225,18 @@ final class NewIssueTableViewController: UITableViewController, UITextFieldDeleg | |
return false | ||
} | ||
|
||
// MARK: 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.
Hm, I think this might be a bit confusing. Of course a good issue description is welcome, but not required. GitHub itself allows an empty body; I think we shouldn't fight that.
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.
How about we just throw up an "Are you sure you want to submit this issue with no description?" confirmation before send?
#2615
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.
@BasThomas @Huddie
I've made a few changes and reverted back to the original behavior where it would turn on the submit button once the titleField had changes. I've also added a confirmation dialogue notifying the user they have no description text and asking if they still want to submit or return to then form to add one.
I had to do a funky deal to get the dialogue correct. I split the onSend function in two because of the @objc function call in the accessibility button function and I needed another function to call on if the user decided to go ahead with the submit. I'm pretty certain this could have been done an easier way so please take a look and give me some direction if there is a better way to implement this.
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.
To be honest I'm still in favor of allowing an empty description.
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.
@BasThomas as in not popping an alert before sending an empty description?
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.
Exactly!