diff --git a/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView+Actions.swift b/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView+Actions.swift index 8c4cbad..dda3f44 100644 --- a/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView+Actions.swift +++ b/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView+Actions.swift @@ -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( diff --git a/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift b/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift index 13bedb7..efa5de9 100644 --- a/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift +++ b/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift @@ -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) } } diff --git a/phpmon/en.lproj/Localizable.strings b/phpmon/en.lproj/Localizable.strings index bdf88b8..7905440 100644 --- a/phpmon/en.lproj/Localizable.strings +++ b/phpmon/en.lproj/Localizable.strings @@ -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!";