parent
8d2ce2e7ae
commit
0f43255676
|
@ -95,6 +95,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
|
|||
try? fm.removeItem(at: url)
|
||||
return true
|
||||
}
|
||||
if let warning = parsedFile.warning {
|
||||
ParsedFile.alertImportWarning(url: url, in: root, withWarning: warning) {
|
||||
if $0 {
|
||||
self.handleParsedFile(parsedFile, in: root)
|
||||
} else {
|
||||
try? fm.removeItem(at: url)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
handleParsedFile(parsedFile, in: root)
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ internal enum StoryboardSegue {
|
|||
case disclaimerSegueIdentifier = "DisclaimerSegueIdentifier"
|
||||
case importHostSegueIdentifier = "ImportHostSegueIdentifier"
|
||||
case selectProfileSegueIdentifier = "SelectProfileSegueIdentifier"
|
||||
case showImportedHostsSegueIdentifier = "ShowImportedHostsSegueIdentifier"
|
||||
case versionSegueIdentifier = "VersionSegueIdentifier"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,12 @@ class ImportedHostsViewController: UITableViewController {
|
|||
|
||||
title = L10n.ImportedHosts.title
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
parsedFile = nil
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
@ -56,22 +62,40 @@ class ImportedHostsViewController: UITableViewController {
|
|||
present(alert, animated: true, completion: nil)
|
||||
return
|
||||
}
|
||||
if let selectedIP = tableView.indexPathForSelectedRow {
|
||||
tableView.deselectRow(at: selectedIP, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
|
||||
guard let cell = sender as? UITableViewCell, let indexPath = tableView.indexPath(for: cell) else {
|
||||
return false
|
||||
}
|
||||
let url = pendingConfigurationURLs[indexPath.row]
|
||||
guard let parsedFile = ParsedFile.from(url, withErrorAlertIn: self) else {
|
||||
if let selectedIP = tableView.indexPathForSelectedRow {
|
||||
tableView.deselectRow(at: selectedIP, animated: true)
|
||||
|
||||
// segue parses configuration file if not yet
|
||||
if parsedFile == nil {
|
||||
guard let cell = sender as? UITableViewCell, let indexPath = tableView.indexPath(for: cell) else {
|
||||
return false
|
||||
}
|
||||
let url = pendingConfigurationURLs[indexPath.row]
|
||||
guard let parsedFile = ParsedFile.from(url, withErrorAlertIn: self) else {
|
||||
deselectSelectedRow()
|
||||
return false
|
||||
}
|
||||
self.parsedFile = parsedFile
|
||||
|
||||
// postpone segue until alert dismissal
|
||||
if let warning = parsedFile.warning {
|
||||
ParsedFile.alertImportWarning(url: url, in: self, withWarning: warning) {
|
||||
self.deselectSelectedRow()
|
||||
if $0 {
|
||||
self.perform(segue: StoryboardSegue.Organizer.importHostSegueIdentifier)
|
||||
} else {
|
||||
self.parsedFile = nil
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
self.parsedFile = parsedFile
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -86,6 +110,12 @@ class ImportedHostsViewController: UITableViewController {
|
|||
@IBAction private func close() {
|
||||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
private func deselectSelectedRow() {
|
||||
if let selectedIP = tableView.indexPathForSelectedRow {
|
||||
tableView.deselectRow(at: selectedIP, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ImportedHostsViewController {
|
||||
|
|
|
@ -176,7 +176,7 @@ class OrganizerViewController: UITableViewController, TableModelHost {
|
|||
}
|
||||
|
||||
private func addNewHost() {
|
||||
perform(segue: StoryboardSegue.Organizer.importHostSegueIdentifier)
|
||||
perform(segue: StoryboardSegue.Organizer.showImportedHostsSegueIdentifier)
|
||||
}
|
||||
|
||||
private func removeProfile(at indexPath: IndexPath) {
|
||||
|
|
|
@ -194,7 +194,7 @@
|
|||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<segue destination="oga-go-FqD" kind="show" id="kwN-PZ-Zg5"/>
|
||||
<segue destination="oga-go-FqD" kind="show" identifier="ImportHostSegueIdentifier" id="kwN-PZ-Zg5"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
|
@ -293,7 +293,7 @@
|
|||
<connections>
|
||||
<segue destination="NVA-bQ-iIE" kind="presentation" identifier="AddProviderSegueIdentifier" modalPresentationStyle="formSheet" id="Win-5U-mIc"/>
|
||||
<segue destination="a3d-vD-Pr7" kind="presentation" identifier="AboutSegueIdentifier" id="fd4-we-46n"/>
|
||||
<segue destination="z6E-m6-Op0" kind="presentation" identifier="ImportHostSegueIdentifier" modalPresentationStyle="formSheet" id="TZv-OK-8vU"/>
|
||||
<segue destination="z6E-m6-Op0" kind="presentation" identifier="ShowImportedHostsSegueIdentifier" modalPresentationStyle="formSheet" id="TZv-OK-8vU"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="bGp-H5-24W" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
@ -567,6 +567,6 @@
|
|||
</resources>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="HW6-RJ-VFY"/>
|
||||
<segue reference="qQl-B5-moM"/>
|
||||
<segue reference="kwN-PZ-Zg5"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
</document>
|
||||
|
|
Loading…
Reference in New Issue