mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-06 19:40:08 +02:00
✨ Ask for confirmation before removing extensions
This commit is contained in:
@ -27,6 +27,21 @@ extension PhpExtensionManagerView {
|
||||
)
|
||||
}
|
||||
|
||||
public func confirmUninstall(_ ext: BrewPhpExtension) async {
|
||||
Alert.confirm(
|
||||
onWindow: App.shared.phpExtensionManagerWindowController!.window!,
|
||||
messageText: "phpextman.warnings.removal.title".localized(ext.name),
|
||||
informativeText: "phpextman.warnings.removal.desc".localized(ext.name),
|
||||
buttonTitle: "phpextman.warnings.removal.button".localized,
|
||||
buttonIsDestructive: true,
|
||||
secondButtonTitle: "generic.cancel".localized,
|
||||
style: .warning,
|
||||
onFirstButtonPressed: {
|
||||
Task { await self.runCommand(RemovePhpExtensionCommand(remove: ext)) }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public func runCommand(_ command: BrewCommand) async {
|
||||
if PhpEnvironments.shared.isBusy {
|
||||
self.presentErrorAlert(
|
||||
|
@ -122,16 +122,11 @@ struct PhpExtensionManagerView: View {
|
||||
HStack {
|
||||
if bExtension.isInstalled {
|
||||
Button("phpman.buttons.uninstall".localizedForSwiftUI, role: .destructive) {
|
||||
#warning("Removal should ask for confirmation")
|
||||
Task { await self.runCommand(
|
||||
RemovePhpExtensionCommand(remove: bExtension)
|
||||
) }
|
||||
Task { await self.confirmUninstall(bExtension) }
|
||||
}
|
||||
} else {
|
||||
Button("phpman.buttons.install".localizedForSwiftUI) {
|
||||
Task { await self.runCommand(
|
||||
InstallPhpExtensionCommand(install: [bExtension])
|
||||
) }
|
||||
Task { await self.runCommand(InstallPhpExtensionCommand(install: [bExtension])) }
|
||||
}.disabled(bExtension.hasAlternativeInstall)
|
||||
}
|
||||
}
|
||||
|
@ -106,6 +106,12 @@
|
||||
"phpextman.description" = "**PHP Extension Manager** lets you manage different PHP extensions with a simple click of the button. Because Homebrew is used, extensions won't need to be compiled on the fly using `pecl`.";
|
||||
"phpextman.disclaimer" = "Certain extensions may require other dependencies to be installed, but generally speaking installing extensions should be much faster than installing PHP versions.";
|
||||
|
||||
"phpextman.warnings.removal.title" = "Uninstall the extension `%@`?";
|
||||
"phpextman.warnings.removal.desc" = "The extension and its unique configuration file will be removed. The extension's functionality will no longer be available for this PHP installation. Are you sure?
|
||||
|
||||
(If the extension is enabled using a non-standard filename, it will not be removed. So if you don't want the .ini file to be removed, it's best to simply rename it to something else. In that case, the extension will only be disabled as part of the clean-up process.)";
|
||||
"phpextman.warnings.removal.button" = "Uninstall";
|
||||
|
||||
// PHPMAN
|
||||
|
||||
"phpman.busy.title" = "Checking for updates!";
|
||||
|
Reference in New Issue
Block a user