mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-08 05:30:05 +01:00
👌 Better alerts (WIP)
This commit is contained in:
@@ -57,9 +57,11 @@ class InterApp {
|
|||||||
MainMenu.shared.switchToPhpVersion(version)
|
MainMenu.shared.switchToPhpVersion(version)
|
||||||
} else {
|
} else {
|
||||||
BetterAlert().withInformation(
|
BetterAlert().withInformation(
|
||||||
title: "Unsupported version",
|
title: "alert.php_switch_unavailable.title".localized,
|
||||||
subtitle: "PHP Monitor can't switch to PHP \(version), as it may not be installed or available."
|
subtitle: "alert.php_switch_unavailable.subtitle".localized(version)
|
||||||
).withPrimary(text: "OK").show()
|
).withPrimary(
|
||||||
|
text: "alert.php_switch_unavailable.ok".localized
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ struct Preset: Codable {
|
|||||||
|
|
||||||
// Apply the PHP version if is considered a valid version
|
// Apply the PHP version if is considered a valid version
|
||||||
if self.version != nil {
|
if self.version != nil {
|
||||||
await switchToPhpVersionIfValid()
|
if await !switchToPhpVersionIfValid() {
|
||||||
|
PresetHelper.rollbackPreset = nil
|
||||||
|
Actions.restartPhpFpm()
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the configuration changes first
|
// Apply the configuration changes first
|
||||||
@@ -61,30 +65,29 @@ struct Preset: Codable {
|
|||||||
|
|
||||||
// MARK: - Apply Functionality
|
// MARK: - Apply Functionality
|
||||||
|
|
||||||
private func switchToPhpVersionIfValid() async {
|
private func switchToPhpVersionIfValid() async -> Bool {
|
||||||
if PhpEnv.shared.currentInstall.version.short == self.version! {
|
if PhpEnv.shared.currentInstall.version.short == self.version! {
|
||||||
Log.info("The version we are supposed to switch to is already active.")
|
Log.info("The version we are supposed to switch to is already active.")
|
||||||
return
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.shared.availablePhpVersions.first(where: { $0 == self.version }) != nil {
|
if PhpEnv.shared.availablePhpVersions.first(where: { $0 == self.version }) != nil {
|
||||||
await MainMenu.shared.switchToPhp(self.version!)
|
await MainMenu.shared.switchToPhp(self.version!)
|
||||||
return
|
return true
|
||||||
} else {
|
} else {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
BetterAlert()
|
BetterAlert().withInformation(
|
||||||
.withInformation(
|
title: "alert.php_switch_unavailable.title".localized,
|
||||||
title: "PHP version unavailable",
|
subtitle: "alert.php_switch_unavailable.subtitle".localized(version!),
|
||||||
subtitle: "You have specified a PHP version (\(version!)) that is unavailable.",
|
description: "alert.php_switch_unavailable.info".localized(
|
||||||
description: "Please make sure this version of PHP is installed "
|
version!,
|
||||||
+ "and you can switch to it in the dropdown. "
|
PhpEnv.shared.availablePhpVersions.joined(separator: ", ")
|
||||||
+ "Currently supported versions include: "
|
|
||||||
+ "\(PhpEnv.shared.availablePhpVersions.joined(separator: ", "))."
|
|
||||||
)
|
)
|
||||||
.withPrimary(text: "OK")
|
).withPrimary(
|
||||||
.show()
|
text: "alert.php_switch_unavailable.ok".localized
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -323,6 +323,18 @@ For optimal support of the latest versions of PHP and proper version switching,
|
|||||||
|
|
||||||
You can do this by running `composer global update` in your terminal. After that, run `valet install` again. For best results, restart PHP Monitor after that.";
|
You can do this by running `composer global update` in your terminal. After that, run `valet install` again. For best results, restart PHP Monitor after that.";
|
||||||
|
|
||||||
|
// PHP version unavailable
|
||||||
|
"alert.php_switch_unavailable.title" = "Unsupported PHP version";
|
||||||
|
"alert.php_switch_unavailable.subtitle" = "PHP Monitor can't switch to PHP %@, as it may not be installed or available. Applying this preset has been cancelled.";
|
||||||
|
"alert.php_switch_unavailable.info" = "Please make sure PHP %@ is installed and you can switch to it in the dropdown. Currently supported versions include PHP: %@.";
|
||||||
|
"alert.php_switch_unavailable.ok" = "OK";
|
||||||
|
|
||||||
|
// Revert
|
||||||
|
"alert.revert_description.title" = "Revert Configuration?";
|
||||||
|
"alert.revert_description.subtitle" = "PHP Monitor can revert to the previous configuration that was active. Here's what will be applied: \n\n%@";
|
||||||
|
"alert.revert_description.ok" = "Revert";
|
||||||
|
"alert.revert_description.cancel" = "Cancel";
|
||||||
|
|
||||||
// STARTUP
|
// STARTUP
|
||||||
|
|
||||||
/// 0. Architecture mismatch
|
/// 0. Architecture mismatch
|
||||||
|
|||||||
Reference in New Issue
Block a user