From 06bc4ddb9a0918f42f6c0a15b75571b2e113724e Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Wed, 3 Apr 2024 14:11:45 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Improve=20removing=20indirect=20?= =?UTF-8?q?dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mind you, the interaction with the domain list controller also needs to be abstracted away, but this is fine, for now. --- phpmon/Domain/SwiftUI/Domains/VersionPopoverView.swift | 9 ++++++++- .../Modules/Domain List/UI/Cells/DomainListPhpCell.swift | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/phpmon/Domain/SwiftUI/Domains/VersionPopoverView.swift b/phpmon/Domain/SwiftUI/Domains/VersionPopoverView.swift index b63f01d..2ca408b 100644 --- a/phpmon/Domain/SwiftUI/Domains/VersionPopoverView.swift +++ b/phpmon/Domain/SwiftUI/Domains/VersionPopoverView.swift @@ -14,6 +14,8 @@ struct VersionPopoverView: View { @State var validPhpVersions: [VersionNumber] + @State var prefersIsolationSuggestions: Bool + @State var parent: NSPopover! let rows = [ @@ -38,7 +40,7 @@ struct VersionPopoverView: View { message: "alert.php_suggestions".localized, color: Color("AppColor") ) - if Valet.enabled(feature: .isolatedSites) { + if prefersIsolationSuggestions { LazyVGrid(columns: self.rows, alignment: .leading, spacing: 5, content: { ForEach(validPhpVersions, id: \.self) { version in Button("site_link.isolate_php".localized(version.short), action: { @@ -162,6 +164,7 @@ struct DisclaimerView: View { constraint: "" ), validPhpVersions: [], + prefersIsolationSuggestions: false, parent: nil ) } @@ -177,6 +180,7 @@ struct DisclaimerView: View { constraint: "^8.1" ), validPhpVersions: [], + prefersIsolationSuggestions: false, parent: nil ) } @@ -193,6 +197,7 @@ struct DisclaimerView: View { isolated: "8.0" ), validPhpVersions: [], + prefersIsolationSuggestions: false, parent: nil ) } @@ -209,6 +214,7 @@ struct DisclaimerView: View { isolated: "7.4" ), validPhpVersions: [], + prefersIsolationSuggestions: false, parent: nil ) } @@ -230,6 +236,7 @@ struct DisclaimerView: View { VersionNumber(major: 8, minor: 3, patch: 0), VersionNumber(major: 8, minor: 4, patch: 0) ], + prefersIsolationSuggestions: true, parent: nil ) } diff --git a/phpmon/Modules/Domain List/UI/Cells/DomainListPhpCell.swift b/phpmon/Modules/Domain List/UI/Cells/DomainListPhpCell.swift index 1e486b4..f22b84b 100644 --- a/phpmon/Modules/Domain List/UI/Cells/DomainListPhpCell.swift +++ b/phpmon/Modules/Domain List/UI/Cells/DomainListPhpCell.swift @@ -70,7 +70,12 @@ class DomainListPhpCell: NSTableCellView, DomainListCellProtocol { let button = self.buttonPhpVersion! let popover = NSPopover() - let view = VersionPopoverView(site: site, validPhpVersions: validPhpSuggestions, parent: popover) + let view = VersionPopoverView( + site: site, + validPhpVersions: validPhpSuggestions, + prefersIsolationSuggestions: Valet.enabled(feature: .isolatedSites), + parent: popover + ) popover.contentViewController = NSHostingController(rootView: view) popover.behavior = .transient