1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-03-27 22:40:08 +01: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 = [
"shivammathur/php",
"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
for tap in requiredTaps {
if installedTaps.contains(tap) {

View File

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

View File

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

View File

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