From 9ca16e72d5351ee5d90bc44b9c32dd3ced8d2e62 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Wed, 22 Nov 2023 21:29:51 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Show=20external=20extensions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Homebrew/BrewTapFormulae.swift | 8 ++++ .../UI/PhpExtensionManagerView.swift | 47 ++++++++++++++----- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift b/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift index c1ff4e3..21baaee 100644 --- a/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift +++ b/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift @@ -25,6 +25,14 @@ struct BrewPhpExtension: Hashable, Comparable { ) } + var hasAlternativeInstall: Bool { + // Extension must be active + let isActive = PhpEnvironments.shared.currentInstall?.extensions + .contains(where: { $0.name == self.name }) ?? false + + return isActive && !isInstalled + } + static func hasInstallationReceipt(for formulaName: String) -> Bool { return FileSystem.fileExists("\(Paths.optPath)/\(formulaName)/INSTALL_RECEIPT.json") } diff --git a/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift b/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift index 109afb3..de8e8c0 100644 --- a/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift +++ b/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift @@ -81,17 +81,40 @@ struct PhpExtensionManagerView: View { HStack(alignment: .center, spacing: 7.0) { VStack(alignment: .center, spacing: 0) { HStack { - Image(systemName: bExtension.isInstalled - ? "puzzlepiece.extension.fill" - : "puzzlepiece.extension") - .resizable() - .frame(width: 16, height: 16) - .foregroundColor(Color.blue) - Text(bExtension.name).bold() - Text("for PHP \(bExtension.phpVersion)") - .font(.system(size: 9)) - .foregroundStyle(.secondary) - .padding(.top, 2) + HStack { + Image(systemName: bExtension.isInstalled || bExtension.hasAlternativeInstall + ? "puzzlepiece.extension.fill" + : "puzzlepiece.extension") + .resizable() + .frame(width: 24, height: 20) + .foregroundColor(bExtension.hasAlternativeInstall ? Color.gray : Color.blue) + }.frame(width: 48, height: 24) + + VStack(alignment: .leading, spacing: 3) { + HStack { + Text(bExtension.name).bold() + Text("for PHP \(bExtension.phpVersion)") + .font(.system(size: 9)) + .foregroundStyle(.secondary) + .padding(.top, 2) + } + if bExtension.isInstalled { + Text("This extension is installed and can be managed by PHP Monitor.") + .font(.system(size: 11)) + .foregroundStyle(.secondary) + } else { + if bExtension.hasAlternativeInstall { + Text("This external extension cannot be managed by PHP Monitor.") + .font(.system(size: 11)) + .foregroundStyle(.orange) + } else { + Text("This extension can be installed.") + .font(.system(size: 11)) + .foregroundStyle(.secondary) + } + } + + } } } .frame(maxWidth: .infinity, alignment: .leading) @@ -109,7 +132,7 @@ struct PhpExtensionManagerView: View { Task { await self.runCommand( InstallPhpExtensionCommand(install: [bExtension]) ) } - } + }.disabled(bExtension.hasAlternativeInstall) } } }