1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 12:00:09 +02:00

👌 Show alert with what will be rolled back

This commit is contained in:
2022-06-03 23:52:40 +02:00
parent 01288154a7
commit 94df551b4b
2 changed files with 45 additions and 1 deletions

View File

@ -145,7 +145,7 @@ extension MainMenu {
} }
} }
@objc func rollbackPreset() { private func performRollback() {
asyncExecution { asyncExecution {
PresetHelper.rollbackPreset?.apply() PresetHelper.rollbackPreset?.apply()
PresetHelper.rollbackPreset = nil 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) { @objc func togglePreset(sender: PresetMenuItem) {
asyncExecution { asyncExecution {
sender.preset?.apply() sender.preset?.apply()

View File

@ -21,6 +21,32 @@ struct Preset: Codable {
configuration = "configuration" 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 // MARK: Applying
/** /**