1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-04-02 01:30:07 +02:00

Improved UI for automatic fixes

This commit is contained in:
2025-08-18 12:43:24 +02:00
parent d52d46218a
commit 5d42481fcc
4 changed files with 26 additions and 25 deletions

View File

@@ -138,27 +138,12 @@ class BrewDiagnostics {
} }
} }
public static func verifyAndInstallThirdPartyTaps() async { public static func verifyThirdPartyTaps() async {
let requiredTaps = [ let requiredTaps = [
"shivammathur/php", "shivammathur/php",
"shivammathur/extensions" "shivammathur/extensions"
] ]
var requiredInstall = false
// Install required taps if missing (if possible)
for tap in requiredTaps where !installedTaps.contains(tap) {
Log.info("Required tap `\(tap)` is missing... will install!")
await Shell.quiet("brew tap \(tap)")
Log.info("Completed command. Will verify installation later...")
requiredInstall = true
}
// Reload the list of taps after installing
if requiredInstall {
await loadInstalledTaps()
}
// Check the status of the installed taps // Check the status of the installed taps
for tap in requiredTaps { for tap in requiredTaps {
if installedTaps.contains(tap) { if installedTaps.contains(tap) {

View File

@@ -56,10 +56,9 @@ extension MainMenu {
// Actually detect the PHP versions // Actually detect the PHP versions
await PhpEnvironments.detectPhpVersions() await PhpEnvironments.detectPhpVersions()
// Verify and install third party taps (if missing) // Verify third party taps
// This may fail if the user has no internet, at which point // The missing tap(s) will be actionable later
// the missing tap(s) will be actionable as a warning await BrewDiagnostics.verifyThirdPartyTaps()
await BrewDiagnostics.verifyAndInstallThirdPartyTaps()
// Check for an alias conflict // Check for an alias conflict
await BrewDiagnostics.checkForCaskConflict() await BrewDiagnostics.checkForCaskConflict()

View File

@@ -100,7 +100,9 @@ class WarningManager: ObservableObject {
] }, ] },
url: "https://github.com/shivammathur/homebrew-php", url: "https://github.com/shivammathur/homebrew-php",
fix: { fix: {
await delay(seconds: 10)
await Shell.quiet("brew tap shivammathur/php") await Shell.quiet("brew tap shivammathur/php")
await BrewDiagnostics.loadInstalledTaps()
await WarningManager.shared.checkEnvironment() await WarningManager.shared.checkEnvironment()
} }
), ),
@@ -116,6 +118,7 @@ class WarningManager: ObservableObject {
url: "https://github.com/shivammathur/homebrew-extensions", url: "https://github.com/shivammathur/homebrew-extensions",
fix: { fix: {
await Shell.quiet("brew tap shivammathur/extensions") await Shell.quiet("brew tap shivammathur/extensions")
await BrewDiagnostics.loadInstalledTaps()
await WarningManager.shared.checkEnvironment() await WarningManager.shared.checkEnvironment()
} }
), ),

View File

@@ -13,6 +13,7 @@ struct WarningView: View {
@State var paragraphs: [String] @State var paragraphs: [String]
@State var documentationUrl: String? @State var documentationUrl: String?
@State var automaticFix: (() async -> Void)? @State var automaticFix: (() async -> Void)?
@State var busyFixing: Bool = false
var body: some View { var body: some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
@@ -40,12 +41,25 @@ struct WarningView: View {
HStack { HStack {
if let automaticFix { if let automaticFix {
Button("Fix Automatically") { Button(
Task { action: {
await automaticFix() Task {
busyFixing = true
await automaticFix()
busyFixing = false
}
},
label: {
if busyFixing {
ProgressView()
.progressViewStyle(CircularProgressViewStyle())
.scaleEffect(0.6)
}
Text("Fix Automatically")
} }
} )
} .disabled(busyFixing) }
if let documentationUrl { if let documentationUrl {
Button("Learn More") { Button("Learn More") {