1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-06 19:40:08 +02:00

🚧 WIP: Changes related to unavailable formulae

This commit is contained in:
2024-11-22 17:42:28 +01:00
parent 9710ffa8da
commit 48bb782e33
2 changed files with 17 additions and 12 deletions

View File

@ -47,14 +47,15 @@ struct BrewPhpFormula: Equatable {
var hasUpgrade: Bool { var hasUpgrade: Bool {
return upgradeVersion != nil return upgradeVersion != nil
} }
var hasFormulaFile: Bool { var hasFormulaFile: Bool {
guard let version = shortVersion else { guard let version = shortVersion else {
return false return false
} }
return FileSystem.fileExists( return FileSystem.fileExists(
"\(Paths.tapPath)/shivammathur/homebrew-php/Formula/php@\(version).rb" "\(Paths.tapPath)/shivammathur/homebrew-php/Formula/php@\(version).rb"
.replacingOccurrences(of: "php@" + PhpEnvironments.brewPhpAlias, with: "php")
) )
} }

View File

@ -269,16 +269,7 @@ struct PhpVersionManagerView: View {
.font(.system(size: 11)) .font(.system(size: 11))
.foregroundColor(.gray) .foregroundColor(.gray)
} else if !formula.hasFormulaFile { } else if !formula.hasFormulaFile {
HStack(spacing: 5) { unavailableFormula()
Text("phpman.version.unavailable".localizedForSwiftUI)
.font(.system(size: 11))
.foregroundColor(.gray)
HelpButton(action: {
// Show an alert that displays information about the missing formula
// and what can be done to fix this particular issue.
// Running `brew tap shivammathur/php` generally works, I think.
})
}
} else { } else {
Text("phpman.version.available_for_installation".localizedForSwiftUI) Text("phpman.version.available_for_installation".localizedForSwiftUI)
.font(.system(size: 11)) .font(.system(size: 11))
@ -294,6 +285,19 @@ struct PhpVersionManagerView: View {
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
} }
private func unavailableFormula() -> some View {
HStack(spacing: 5) {
Text("phpman.version.unavailable".localizedForSwiftUI)
.font(.system(size: 11))
.foregroundColor(.gray)
HelpButton(action: {
// Show an alert that displays information about the missing formula
// and what can be done to fix this particular issue.
// Running `brew tap shivammathur/php` generally works, I think.
})
}
}
private func formulaIcon(for formula: BrewPhpFormula) -> some View { private func formulaIcon(for formula: BrewPhpFormula) -> some View {
Image(systemName: formula.icon) Image(systemName: formula.icon)
.resizable() .resizable()