From 2b7bb3f35288cd77ead1b8e51f29c764ed389c23 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sun, 14 May 2023 12:04:25 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Show=20repair=20button=20in=20ve?= =?UTF-8?q?rsion=20manager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SwiftUI/PhpManager/PhpFormulaeView.swift | 22 ++++++++++++++----- phpmon/Localizable.strings | 4 ++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift b/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift index 0b311bf..a814641 100644 --- a/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift +++ b/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift @@ -134,15 +134,19 @@ struct PhpFormulaeView: View { .frame(width: 16, height: 16) .foregroundColor(formula.iconColor) .padding(.horizontal, 5) - VStack(alignment: .leading) { + VStack(alignment: .leading, spacing: 2) { Text(formula.displayName).bold() if formula.isInstalled && formula.hasUpgrade { - Text("\(formula.installedVersion!) installed, \(formula.upgradeVersion!) available.") - .font(.system(size: 11)) - .foregroundColor(.gray) + Text("phpman.version.has_update".localized( + formula.installedVersion!, + formula.upgradeVersion! + )) + .font(.system(size: 11)) + .foregroundColor(.gray) } else if formula.isInstalled && formula.installedVersion != nil { - Text("\(formula.installedVersion!) is currently installed.").font(.system(size: 11)) + Text("phpman.version.installed".localized(formula.installedVersion!)) + .font(.system(size: 11)) .foregroundColor(.gray) } else { Text("phpman.version.available_for_installation".localizedForSwiftUI) @@ -151,13 +155,19 @@ struct PhpFormulaeView: View { } if !formula.healthy { - Text("This PHP installation is broken.") + Text("phpman.version.broken".localizedForSwiftUI) .font(.system(size: 11)) .foregroundColor(.red) } } .frame(maxWidth: .infinity, alignment: .leading) + if !formula.healthy { + Button("phpman.buttons.repair".localizedForSwiftUI, role: .destructive) { + Task { await self.repairAll() } + } + } + if formula.isInstalled { Button("phpman.buttons.uninstall".localizedForSwiftUI, role: .destructive) { Task { await self.confirmUninstall(formula) } diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index 6f1bde2..76bd2ce 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -94,10 +94,14 @@ "phpman.busy.title" = "Checking for updates!"; "phpman.busy.description.outdated" = "Checking if any PHP version is outdated..."; +"phpman.version.broken" = "This version appears to be broken, you can attempt repair."; +"phpman.version.has_update" = "Version %@ installed, %@ available."; +"phpman.version.installed" = "Version %@ is currently installed."; "phpman.version.available_for_installation" = "This version can be installed."; "phpman.buttons.uninstall" = "Uninstall"; "phpman.buttons.install" = "Install"; "phpman.buttons.update" = "Update"; +"phpman.buttons.repair" = "Repair"; "phpman.title" = "PHP Version Manager"; "phpman.description" = "**PHP Version Manager** lets you install, upgrade and delete different PHP versions via Homebrew without needing to run the commands in the terminal yourself.";