Only make host editable if original cfg available

This commit is contained in:
Davide De Rosa 2018-10-25 22:51:01 +02:00
parent 205bef822e
commit 52cf733948
5 changed files with 14 additions and 16 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Changed
- Host parameters are read-only if there isn't an original configuration to revert to.
## 1.0 beta 1084 (2018-10-24)
### Fixed

View File

@ -38,21 +38,22 @@ class ConfigurationViewController: UIViewController, TableModelHost {
private lazy var configuration: SessionProxy.ConfigurationBuilder = initialConfiguration.builder()
var isEditable = false
var originalConfigurationURL: URL?
private var isEditable: Bool {
return originalConfigurationURL != nil
}
weak var delegate: ConfigurationModificationDelegate?
// MARK: TableModelHost
lazy var model: TableModel<SectionType, RowType> = {
let model: TableModel<SectionType, RowType> = TableModel()
let hasConfigurationURL = isEditable && (originalConfigurationURL != nil)
// sections
model.add(.communication)
if hasConfigurationURL {
if isEditable {
model.add(.reset)
}
model.add(.tls)
@ -64,15 +65,13 @@ class ConfigurationViewController: UIViewController, TableModelHost {
model.setHeader(L10n.Configuration.Sections.Other.header, for: .other)
// footers
if hasConfigurationURL {
if isEditable {
model.setFooter(L10n.Configuration.Sections.Reset.footer, for: .reset)
} else if isEditable {
model.setFooter(L10n.Configuration.Sections.Communication.Footer.editable, for: .communication)
}
// rows
model.set([.cipher, .digest, .compressionFrame], in: .communication)
if hasConfigurationURL {
if isEditable {
model.set([.resetOriginal], in: .reset)
}
model.set([.client, .tlsWrapping], in: .tls)
@ -94,7 +93,7 @@ class ConfigurationViewController: UIViewController, TableModelHost {
override func viewDidLoad() {
super.viewDidLoad()
guard let _ = initialConfiguration else {
fatalError("Initial configuration not set")
}

View File

@ -154,7 +154,6 @@ class ServiceViewController: UIViewController, TableModelHost {
let vc = destination as? ConfigurationViewController
vc?.title = L10n.Service.Cells.Host.Parameters.caption
vc?.initialConfiguration = uncheckedHostProfile.parameters.sessionConfiguration
vc?.isEditable = true
vc?.originalConfigurationURL = ProfileConfigurationFactory.shared.configurationURL(for: uncheckedHostProfile)
vc?.delegate = self

View File

@ -126,7 +126,6 @@
//"provider.preset.sections.main.footer" = "Tap info button to disclose technical details.";
"configuration.sections.communication.header" = "Communication";
"configuration.sections.communication.footer.editable" = "Make sure to match server communication parameters, otherwise you will end up with broken connectivity.";
"configuration.sections.reset.footer" = "If you ended up with broken connectivity after changing the communication parameters, tap to revert to the original configuration.";
"configuration.sections.tls.header" = "TLS";
"configuration.sections.other.header" = "Other";

View File

@ -205,11 +205,6 @@ internal enum L10n {
internal enum Communication {
/// Communication
internal static let header = L10n.tr("Localizable", "configuration.sections.communication.header")
internal enum Footer {
/// Make sure to match server communication parameters, otherwise you will end up with broken connectivity.
internal static let editable = L10n.tr("Localizable", "configuration.sections.communication.footer.editable")
}
}
internal enum Other {