diff --git a/phpmon/Domain/Menu/MainMenu+Actions.swift b/phpmon/Domain/Menu/MainMenu+Actions.swift index ad95113..3a8194c 100644 --- a/phpmon/Domain/Menu/MainMenu+Actions.swift +++ b/phpmon/Domain/Menu/MainMenu+Actions.swift @@ -145,7 +145,7 @@ extension MainMenu { } } - @objc func rollbackPreset() { + private func performRollback() { asyncExecution { PresetHelper.rollbackPreset?.apply() PresetHelper.rollbackPreset = nil @@ -153,6 +153,24 @@ extension MainMenu { } } + @objc func rollbackPreset() { + guard let preset = PresetHelper.rollbackPreset else { + return + } + + BetterAlert().withInformation( + title: "alert.revert_description.title".localized, + subtitle: "alert.revert_description.subtitle".localized( + preset.textDescription + ) + ) + .withPrimary(text: "alert.revert_description.ok".localized, action: { _ in + self.performRollback() + }) + .withSecondary(text: "alert.revert_description.cancel".localized) + .show() + } + @objc func togglePreset(sender: PresetMenuItem) { asyncExecution { sender.preset?.apply() diff --git a/phpmon/Domain/Presets/Preset.swift b/phpmon/Domain/Presets/Preset.swift index 8fad54e..a92629f 100644 --- a/phpmon/Domain/Presets/Preset.swift +++ b/phpmon/Domain/Presets/Preset.swift @@ -21,6 +21,32 @@ struct Preset: Codable { configuration = "configuration" } + var textDescription: String { + var text = "" + + if self.version != nil { + text += "Switches to PHP \(self.version!).\n" + } + + if !self.extensions.isEmpty { + text += "\nApplies the following extensions:\n" + } + + for (ext, extValue) in self.extensions { + text += "• \(ext): \(extValue ? "enabled" : "disabled") \n" + } + + if !self.configuration.isEmpty { + text += "\nApplies the following configuration values:\n" + } + + for (key, value) in self.configuration { + text += "• \(key)=\(value ?? "(empty)") \n" + } + + return text + } + // MARK: Applying /**