From 52cf7339488de76b4591d1e7b4bddb8f11fbad20 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 25 Oct 2018 22:51:01 +0200 Subject: [PATCH] Only make host editable if original cfg available --- CHANGELOG.md | 6 ++++++ .../Scenes/ConfigurationViewController.swift | 17 ++++++++--------- .../Scenes/ServiceViewController.swift | 1 - .../Resources/en.lproj/Localizable.strings | 1 - Passepartout/Sources/SwiftGen+Strings.swift | 5 ----- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02378685..3f230628 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Passepartout-iOS/Scenes/ConfigurationViewController.swift b/Passepartout-iOS/Scenes/ConfigurationViewController.swift index 011f1baf..64db865f 100644 --- a/Passepartout-iOS/Scenes/ConfigurationViewController.swift +++ b/Passepartout-iOS/Scenes/ConfigurationViewController.swift @@ -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 = { let model: TableModel = 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") } diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift index b8594a8a..45dab7a0 100644 --- a/Passepartout-iOS/Scenes/ServiceViewController.swift +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -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 diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index e5128af8..b1ec559b 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -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"; diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index 60095d57..24dad087 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -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 {