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:
@ -27,12 +27,12 @@ class RemovePhpExtensionCommand: BrewCommand {
|
||||
))
|
||||
|
||||
// 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
|
||||
})
|
||||
|
||||
onProgress(.create(value: 1, title: getCommandTitle(), description: "phpman.steps.success".localized))
|
||||
|
||||
let command = """
|
||||
export HOMEBREW_NO_INSTALL_UPGRADE=true; \
|
||||
export HOMEBREW_NO_INSTALL_CLEANUP=true; \
|
||||
|
@ -80,7 +80,10 @@ class ModifyPhpVersionCommand: BrewCommand {
|
||||
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)
|
||||
guard let short = try? VersionNumber
|
||||
.parse(unavailable.installedVersion!).short else {
|
||||
|
@ -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(
|
||||
onWindow: App.shared.phpExtensionManagerWindowController!.window!,
|
||||
messageText: "phpextman.warnings.removal.title".localized(ext.name),
|
||||
@ -37,7 +43,9 @@ extension PhpExtensionManagerView {
|
||||
secondButtonTitle: "generic.cancel".localized,
|
||||
style: .warning,
|
||||
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.status.busy = false
|
||||
} catch let error {
|
||||
|
@ -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) {
|
||||
VStack(alignment: .center, spacing: 0) {
|
||||
HStack {
|
||||
HStack {
|
||||
Image(systemName: bExtension.isInstalled || bExtension.hasAlternativeInstall
|
||||
Image(systemName: ext.isInstalled || ext.hasAlternativeInstall
|
||||
? "puzzlepiece.extension.fill"
|
||||
: "puzzlepiece.extension")
|
||||
.resizable()
|
||||
.frame(width: 24, height: 20)
|
||||
.foregroundColor(bExtension.hasAlternativeInstall ? Color.gray : Color.blue)
|
||||
.foregroundColor(ext.hasAlternativeInstall ? Color.gray : Color.blue)
|
||||
}.frame(width: 36, height: 24)
|
||||
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
HStack {
|
||||
Text(bExtension.name).bold()
|
||||
Text("for PHP \(bExtension.phpVersion)")
|
||||
Text(ext.name).bold()
|
||||
Text("for PHP \(ext.phpVersion)")
|
||||
.font(.system(size: 9))
|
||||
.foregroundStyle(.secondary)
|
||||
.padding(.top, 2)
|
||||
}
|
||||
if bExtension.isInstalled {
|
||||
if ext.isInstalled {
|
||||
Text("This extension is installed and can be managed by PHP Monitor.")
|
||||
.font(.system(size: 11))
|
||||
.foregroundStyle(.secondary)
|
||||
} else {
|
||||
if bExtension.hasAlternativeInstall {
|
||||
if ext.hasAlternativeInstall {
|
||||
Text("This extension is already installed via another source, and cannot be managed.")
|
||||
.font(.system(size: 11))
|
||||
.foregroundStyle(.orange)
|
||||
@ -120,14 +120,14 @@ struct PhpExtensionManagerView: View {
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
HStack {
|
||||
if bExtension.isInstalled {
|
||||
if ext.isInstalled {
|
||||
Button("phpman.buttons.uninstall".localizedForSwiftUI, role: .destructive) {
|
||||
Task { await self.confirmUninstall(bExtension) }
|
||||
self.confirmUninstall(ext)
|
||||
}
|
||||
} else {
|
||||
Button("phpman.buttons.install".localizedForSwiftUI) {
|
||||
Task { await self.runCommand(InstallPhpExtensionCommand(install: [bExtension])) }
|
||||
}.disabled(bExtension.hasAlternativeInstall)
|
||||
self.install(ext)
|
||||
}.disabled(ext.hasAlternativeInstall)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user