Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Fix for "Disallow Empty Bug Reports" Issue #2615 #2676

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions Classes/New Issue/NewIssueTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,26 @@ 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() {
if let bodyText = bodyText {
self.finishSend()
BasThomas marked this conversation as resolved.
Show resolved Hide resolved
} else {
let submitAlert = UIAlertController(title: "Please Provide Description", message: "Are you certain you want to submit this issue without a description?", preferredStyle: UIAlertControllerStyle.alert)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indent

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just do .alert it will infer the type


submitAlert.addAction(UIAlertAction(title: "Submit", style: .default, handler: { (action: UIAlertAction!) in
BasThomas marked this conversation as resolved.
Show resolved Hide resolved
self.finishSend()
}))

submitAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action: UIAlertAction!) in
submitAlert .dismiss(animated: true, completion: nil)
BasThomas marked this conversation as resolved.
Show resolved Hide resolved
}))

present(submitAlert, animated: true, completion: nil)
BasThomas marked this conversation as resolved.
Show resolved Hide resolved
}

}
func finishSend() {
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
}

Expand Down Expand Up @@ -205,7 +223,7 @@ final class NewIssueTableViewController: UITableViewController, UITextFieldDeleg
bodyField.inputAccessoryView = actions
}

// MARK: UITextFieldDelegate
// MARK: UITextFieldDelegate

/// Called when the user taps return on the title field, moves their cursor to the body
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
Expand All @@ -215,7 +233,7 @@ final class NewIssueTableViewController: UITableViewController, UITextFieldDeleg

// 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
}
Expand Down
5 changes: 5 additions & 0 deletions Classes/Systems/Squawk+GitHawk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ extension Squawk {
triggerHaptic()
}

static func showIssueError(message: String, view: UIView?) {
Squawk.shared.show(in: view, config: errorConfig(text: message))
triggerHaptic()
}

}