1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 03:50:08 +02:00

👌 Cleanup, fix loading issue

This commit is contained in:
2023-11-26 23:51:39 +01:00
parent ec30bee72b
commit 904d05bdce
4 changed files with 28 additions and 18 deletions

View File

@ -27,12 +27,12 @@ class RemovePhpExtensionCommand: BrewCommand {
)) ))
// Keep track of the file that contains the information about the extension // Keep track of the file that contains the information about the extension
let existing = PhpEnvironments.shared.cachedPhpInstallations[phpExtension.phpVersion]?.extensions.first(where: { ext in let existing = PhpEnvironments.shared
.cachedPhpInstallations[phpExtension.phpVersion]?
.extensions.first(where: { ext in
ext.name == phpExtension.name ext.name == phpExtension.name
}) })
onProgress(.create(value: 1, title: getCommandTitle(), description: "phpman.steps.success".localized))
let command = """ let command = """
export HOMEBREW_NO_INSTALL_UPGRADE=true; \ export HOMEBREW_NO_INSTALL_UPGRADE=true; \
export HOMEBREW_NO_INSTALL_CLEANUP=true; \ export HOMEBREW_NO_INSTALL_CLEANUP=true; \

View File

@ -80,7 +80,10 @@ class ModifyPhpVersionCommand: BrewCommand {
await self.completedOperations(onProgress) await self.completedOperations(onProgress)
} }
private func upgradeMainPhpFormula(_ unavailable: BrewPhpFormula, _ onProgress: @escaping (BrewCommandProgress) -> Void) async throws { private func upgradeMainPhpFormula(
_ unavailable: BrewPhpFormula,
_ onProgress: @escaping (BrewCommandProgress) -> Void
) async throws {
// Determine which version was previously available (that will become unavailable) // Determine which version was previously available (that will become unavailable)
guard let short = try? VersionNumber guard let short = try? VersionNumber
.parse(unavailable.installedVersion!).short else { .parse(unavailable.installedVersion!).short else {

View File

@ -27,7 +27,13 @@ extension PhpExtensionManagerView {
) )
} }
public func confirmUninstall(_ ext: BrewPhpExtension) async { public func install(_ ext: BrewPhpExtension) {
Task {
await self.runCommand(InstallPhpExtensionCommand(install: [ext]))
}
}
public func confirmUninstall(_ ext: BrewPhpExtension) {
Alert.confirm( Alert.confirm(
onWindow: App.shared.phpExtensionManagerWindowController!.window!, onWindow: App.shared.phpExtensionManagerWindowController!.window!,
messageText: "phpextman.warnings.removal.title".localized(ext.name), messageText: "phpextman.warnings.removal.title".localized(ext.name),
@ -37,7 +43,9 @@ extension PhpExtensionManagerView {
secondButtonTitle: "generic.cancel".localized, secondButtonTitle: "generic.cancel".localized,
style: .warning, style: .warning,
onFirstButtonPressed: { onFirstButtonPressed: {
Task { await self.runCommand(RemovePhpExtensionCommand(remove: ext)) } Task {
await self.runCommand(RemovePhpExtensionCommand(remove: ext))
}
} }
) )
} }
@ -62,7 +70,6 @@ extension PhpExtensionManagerView {
} }
} }
// TODO: Reload extensions
self.manager.loadExtensionData(for: self.phpVersion) self.manager.loadExtensionData(for: self.phpVersion)
self.status.busy = false self.status.busy = false
} catch let error { } catch let error {

View File

@ -77,33 +77,33 @@ struct PhpExtensionManagerView: View {
} }
} }
private func listContent(for bExtension: BrewPhpExtension) -> some View { private func listContent(for ext: BrewPhpExtension) -> some View {
HStack(alignment: .center, spacing: 7.0) { HStack(alignment: .center, spacing: 7.0) {
VStack(alignment: .center, spacing: 0) { VStack(alignment: .center, spacing: 0) {
HStack { HStack {
HStack { HStack {
Image(systemName: bExtension.isInstalled || bExtension.hasAlternativeInstall Image(systemName: ext.isInstalled || ext.hasAlternativeInstall
? "puzzlepiece.extension.fill" ? "puzzlepiece.extension.fill"
: "puzzlepiece.extension") : "puzzlepiece.extension")
.resizable() .resizable()
.frame(width: 24, height: 20) .frame(width: 24, height: 20)
.foregroundColor(bExtension.hasAlternativeInstall ? Color.gray : Color.blue) .foregroundColor(ext.hasAlternativeInstall ? Color.gray : Color.blue)
}.frame(width: 36, height: 24) }.frame(width: 36, height: 24)
VStack(alignment: .leading, spacing: 3) { VStack(alignment: .leading, spacing: 3) {
HStack { HStack {
Text(bExtension.name).bold() Text(ext.name).bold()
Text("for PHP \(bExtension.phpVersion)") Text("for PHP \(ext.phpVersion)")
.font(.system(size: 9)) .font(.system(size: 9))
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
.padding(.top, 2) .padding(.top, 2)
} }
if bExtension.isInstalled { if ext.isInstalled {
Text("This extension is installed and can be managed by PHP Monitor.") Text("This extension is installed and can be managed by PHP Monitor.")
.font(.system(size: 11)) .font(.system(size: 11))
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
} else { } else {
if bExtension.hasAlternativeInstall { if ext.hasAlternativeInstall {
Text("This extension is already installed via another source, and cannot be managed.") Text("This extension is already installed via another source, and cannot be managed.")
.font(.system(size: 11)) .font(.system(size: 11))
.foregroundStyle(.orange) .foregroundStyle(.orange)
@ -120,14 +120,14 @@ struct PhpExtensionManagerView: View {
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
HStack { HStack {
if bExtension.isInstalled { if ext.isInstalled {
Button("phpman.buttons.uninstall".localizedForSwiftUI, role: .destructive) { Button("phpman.buttons.uninstall".localizedForSwiftUI, role: .destructive) {
Task { await self.confirmUninstall(bExtension) } self.confirmUninstall(ext)
} }
} else { } else {
Button("phpman.buttons.install".localizedForSwiftUI) { Button("phpman.buttons.install".localizedForSwiftUI) {
Task { await self.runCommand(InstallPhpExtensionCommand(install: [bExtension])) } self.install(ext)
}.disabled(bExtension.hasAlternativeInstall) }.disabled(ext.hasAlternativeInstall)
} }
} }
} }