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

♻️ Refactor displaying domains

This commit is contained in:
2022-04-12 17:36:18 +02:00
parent f0f7a3f7d6
commit 1b8d6311ba
18 changed files with 167 additions and 78 deletions

View File

@ -51,8 +51,6 @@
C40C7F2927721FF600DDDCDC /* ActivePhpInstallation+Checks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2727721FF600DDDCDC /* ActivePhpInstallation+Checks.swift */; };
C40C7F3027722E8D00DDDCDC /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2F27722E8D00DDDCDC /* Logger.swift */; };
C40C7F3127722E8D00DDDCDC /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2F27722E8D00DDDCDC /* Logger.swift */; };
C40D88EB27F38D7600C94B40 /* DomainListProxiesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40D88EA27F38D7600C94B40 /* DomainListProxiesCell.swift */; };
C40D88EC27F38D7600C94B40 /* DomainListProxiesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40D88EA27F38D7600C94B40 /* DomainListProxiesCell.swift */; };
C412E5FC25700D5300A1FB67 /* HomebrewPackage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C412E5FB25700D5300A1FB67 /* HomebrewPackage.swift */; };
C415937F27A1B54F00D2E1B7 /* PhpFrameworks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415937E27A1B54F00D2E1B7 /* PhpFrameworks.swift */; };
C415938027A1B54F00D2E1B7 /* PhpFrameworks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415937E27A1B54F00D2E1B7 /* PhpFrameworks.swift */; };
@ -87,6 +85,8 @@
C42CFB1627DFDE7900862737 /* nginx-site.test in Resources */ = {isa = PBXBuildFile; fileRef = C42CFB1527DFDE7900862737 /* nginx-site.test */; };
C42CFB1827DFDFDC00862737 /* nginx-site-isolated.test in Resources */ = {isa = PBXBuildFile; fileRef = C42CFB1727DFDFDC00862737 /* nginx-site-isolated.test */; };
C42CFB1A27DFE8BD00862737 /* NginxConfigurationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42CFB1927DFE8BD00862737 /* NginxConfigurationTest.swift */; };
C42F26732805B4B400938AC7 /* DomainListable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42F26722805B4B400938AC7 /* DomainListable.swift */; };
C42F26742805B4B400938AC7 /* DomainListable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42F26722805B4B400938AC7 /* DomainListable.swift */; };
C43603A0275E67610028EFC6 /* AppDelegate+Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */; };
C43603A1275E67610028EFC6 /* AppDelegate+Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */; };
C43A8A1A25D9CD1000591B77 /* Utility.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A8A1925D9CD1000591B77 /* Utility.swift */; };
@ -284,7 +284,6 @@
C40C7F1D2772136000DDDCDC /* PhpEnv.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpEnv.swift; sourceTree = "<group>"; };
C40C7F2727721FF600DDDCDC /* ActivePhpInstallation+Checks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ActivePhpInstallation+Checks.swift"; sourceTree = "<group>"; };
C40C7F2F27722E8D00DDDCDC /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
C40D88EA27F38D7600C94B40 /* DomainListProxiesCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DomainListProxiesCell.swift; sourceTree = "<group>"; };
C412E5FB25700D5300A1FB67 /* HomebrewPackage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomebrewPackage.swift; sourceTree = "<group>"; };
C415937E27A1B54F00D2E1B7 /* PhpFrameworks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpFrameworks.swift; sourceTree = "<group>"; };
C415D3B62770F294005EF286 /* Actions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Actions.swift; sourceTree = "<group>"; };
@ -312,6 +311,7 @@
C42CFB1527DFDE7900862737 /* nginx-site.test */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "nginx-site.test"; sourceTree = "<group>"; };
C42CFB1727DFDFDC00862737 /* nginx-site-isolated.test */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "nginx-site-isolated.test"; sourceTree = "<group>"; };
C42CFB1927DFE8BD00862737 /* NginxConfigurationTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NginxConfigurationTest.swift; sourceTree = "<group>"; };
C42F26722805B4B400938AC7 /* DomainListable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListable.swift; sourceTree = "<group>"; };
C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+Notifications.swift"; sourceTree = "<group>"; };
C43A8A1925D9CD1000591B77 /* Utility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utility.swift; sourceTree = "<group>"; };
C43A8A1F25D9D1D700591B77 /* brew-formula.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "brew-formula.json"; sourceTree = "<group>"; };
@ -605,7 +605,6 @@
C44067F627E258410045BD4E /* DomainListPhpCell.swift */,
C44067F827E2585E0045BD4E /* DomainListTypeCell.swift */,
C4AC51FB27E27F47008528CA /* DomainListKindCell.swift */,
C40D88EA27F38D7600C94B40 /* DomainListProxiesCell.swift */,
);
path = Cells;
sourceTree = "<group>";
@ -723,6 +722,7 @@
isa = PBXGroup;
children = (
C4AF9F792754499000D44ED0 /* Valet.swift */,
C42F26722805B4B400938AC7 /* DomainListable.swift */,
C4C0E8D927F887BD002D32A9 /* Proxies */,
C4C0E8D827F887A5002D32A9 /* Sites */,
);
@ -1100,7 +1100,6 @@
C41C02A927E61A65009F26CB /* ValetSite+Fake.swift in Sources */,
C4C0E8DF27F88AEB002D32A9 /* FakeSiteScanner.swift in Sources */,
C4F2E4372752F0870020E974 /* HomebrewDiagnostics.swift in Sources */,
C40D88EB27F38D7600C94B40 /* DomainListProxiesCell.swift in Sources */,
C4CCBA6C275C567B008C7055 /* PMWindowController.swift in Sources */,
C4B585442770FE3900DA4FBE /* Command.swift in Sources */,
C44067F527E2582B0045BD4E /* DomainListNameCell.swift in Sources */,
@ -1122,6 +1121,7 @@
C4F30B03278E16BA00755FCE /* HomebrewService.swift in Sources */,
54D9E0B427E4F51E003B9AD9 /* Key.swift in Sources */,
C4C0E8E227F88B13002D32A9 /* ValetSiteScanner.swift in Sources */,
C42F26732805B4B400938AC7 /* DomainListable.swift in Sources */,
5420395F2613607600FB00FA /* Preferences.swift in Sources */,
C48D0C9325CC804200CC7490 /* XibLoadable.swift in Sources */,
54FCFD2A276C8AA4004CE748 /* CheckboxPreferenceView.swift in Sources */,
@ -1187,6 +1187,7 @@
C41CA5EE2774F8EE00A2C80E /* DomainListVC+Actions.swift in Sources */,
54D9E0B727E4F51E003B9AD9 /* HotKey.swift in Sources */,
C4205A7F27F4D21800191A39 /* ValetProxy.swift in Sources */,
C42F26742805B4B400938AC7 /* DomainListable.swift in Sources */,
C4F780C425D80B75000DBC97 /* MainMenu.swift in Sources */,
54FCFD2B276C8AA4004CE748 /* CheckboxPreferenceView.swift in Sources */,
C415D3B82770F294005EF286 /* Actions.swift in Sources */,
@ -1244,7 +1245,6 @@
C417DC75277614690015E6EE /* Helpers.swift in Sources */,
C4080FF727BD8C6400BF2C6B /* BetterAlert.swift in Sources */,
C4B97B7C275CF20A003F3378 /* App+GlobalHotkey.swift in Sources */,
C40D88EC27F38D7600C94B40 /* DomainListProxiesCell.swift in Sources */,
54D9E0B327E4F51E003B9AD9 /* HotKeysController.swift in Sources */,
C4B97B79275CF1B5003F3378 /* App+ActivationPolicy.swift in Sources */,
C4CE3BBB27B324230086CA49 /* MainMenu+Switcher.swift in Sources */,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 710 B

After

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -384,7 +384,7 @@
<scene sceneID="4XS-kY-YIS">
<objects>
<windowController storyboardIdentifier="domainListWindow" id="8Ec-9q-82s" customClass="DomainListWC" customModule="PHP_Monitor" customModuleProvider="target" sceneMemberID="viewController">
<window key="window" title="Domains" subtitle="Linked &amp; Parked" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="raw-02-3Q1">
<window key="window" separatorStyle="line" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="raw-02-3Q1">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="425" y="461" width="600" height="263"/>
@ -437,7 +437,7 @@
</windowController>
<customObject id="VCP-dF-cqM" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-374" y="746"/>
<point key="canvasLocation" x="-374" y="745.5"/>
</scene>
<!--Window Controller-->
<scene sceneID="HTI-x5-rOp">
@ -532,7 +532,7 @@ Gw
</connections>
</button>
<button wantsLayer="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="n5T-nn-k3j">
<rect key="frame" x="13" y="13" width="82" height="32"/>
<rect key="frame" x="13" y="13" width="81" height="32"/>
<buttonCell key="cell" type="push" title="Tertiary" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="mzA-Uu-gyf">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@ -651,7 +651,7 @@ Gw
<color key="fillColor" name="windowBackgroundColor" catalog="System" colorSpace="catalog"/>
</box>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="PVw-cM-qAB">
<rect key="frame" x="363" y="13" width="104" height="32"/>
<rect key="frame" x="364" y="13" width="103" height="32"/>
<buttonCell key="cell" type="push" title="Create Link" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="WwW-Wv-I8s">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@ -732,7 +732,7 @@ Gw
</textFieldCell>
</textField>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="900-Z2-tID">
<rect key="frame" x="229" y="23" width="128" height="14"/>
<rect key="frame" x="230" y="23" width="128" height="14"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="That link already exists." id="jOt-n6-TQf">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="systemRedColor" catalog="System" colorSpace="catalog"/>

View File

@ -11,4 +11,5 @@ import AppKit
protocol DomainListCellProtocol {
func populateCell(with site: ValetSite)
func populateCell(with proxy: ValetProxy)
}

View File

@ -30,4 +30,8 @@ class DomainListKindCell: NSTableCellView, DomainListCellProtocol
imageViewType.contentTintColor = NSColor.tertiaryLabelColor
}
func populateCell(with proxy: ValetProxy) {
imageViewType.image = NSImage(named: "IconProxy")
}
}

View File

@ -17,10 +17,12 @@ class DomainListNameCell: NSTableCellView, DomainListCellProtocol
@IBOutlet weak var labelPathName: NSTextField!
func populateCell(with site: ValetSite) {
// Show the name of the site (including tld)
labelSiteName.stringValue = "\(site.name).\(Valet.shared.config.tld)"
// Show the absolute path, except make sure to replace the /Users/username segment with ~ for readability
labelSiteName.stringValue = "\(site.name).\(site.tld)"
labelPathName.stringValue = site.absolutePathRelative
}
func populateCell(with proxy: ValetProxy) {
labelSiteName.stringValue = "\(proxy.domain).\(proxy.tld)"
labelPathName.stringValue = proxy.target
}
}

View File

@ -34,6 +34,15 @@ class DomainListPhpCell: NSTableCellView, DomainListCellProtocol
imageViewPhpVersionOK.image = NSImage(named: "Checkmark")
imageViewPhpVersionOK.toolTip = "domain_list.tooltips.checkmark".localized(site.composerPhp)
}
buttonPhpVersion.isHidden = false
imageViewPhpVersionOK.isHidden = false
}
func populateCell(with proxy: ValetProxy) {
buttonPhpVersion.isHidden = true
imageViewPhpVersionOK.isHidden = true
return
}
@IBAction func pressedPhpVersion(_ sender: Any) {

View File

@ -1,37 +0,0 @@
//
// DomainListNameCell.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 16/03/2022.
// Copyright © 2022 Nico Verbruggen. All rights reserved.
//
import Cocoa
import AppKit
class DomainListProxiesCell: NSTableCellView, DomainListCellProtocol
{
static let reusableName = "domainListProxiesCell"
@IBOutlet weak var textFieldPrimary: NSTextField!
@IBOutlet weak var textFieldAdditional: NSTextField!
@IBOutlet weak var buttonProxyList: NSButton!
func populateCell(with site: ValetSite) {
/*
// Show the first proxy
textFieldPrimary.stringValue = (site.proxies.count == 0)
? ""
: site.proxies[0]
// Show additional proxy count
textFieldAdditional.stringValue = site.proxies.count > 1
? "and \(site.proxies.count - 1) more active"
: site.proxies.count == 1 ? "(active)" : ""
// Show button
buttonProxyList.isHidden = site.proxies.count == 0
*/
}
}

View File

@ -16,9 +16,14 @@ class DomainListTLSCell: NSTableCellView, DomainListCellProtocol
@IBOutlet weak var imageViewLock: NSImageView!
func populateCell(with site: ValetSite) {
// Show the green or red lock based on whether the site was secured
imageViewLock.contentTintColor = site.secured
? NSColor(named: "IconColorGreen") // green
? NSColor(named: "IconColorGreen")
: NSColor(named: "IconColorRed")
}
func populateCell(with proxy: ValetProxy) {
imageViewLock.contentTintColor = proxy.target.contains("https")
? NSColor(named: "IconColorGreen")
: NSColor(named: "IconColorRed")
}
}

View File

@ -28,4 +28,10 @@ class DomainListTypeCell: NSTableCellView, DomainListCellProtocol
// PHP version
labelPhpVersion.stringValue = site.composerPhp == "???" ? "Any PHP" : "PHP \(site.composerPhp)"
}
func populateCell(with proxy: ValetProxy) {
labelDriver.stringValue = "Proxy"
labelPhpVersion.stringValue = "Active"
return
}
}

View File

@ -19,7 +19,7 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
// MARK: - Variables
/// List of sites that will be displayed in this view. Originates from the `Valet` object.
var sites: [ValetSite] = []
var domains: [DomainListable] = []
/// Array that contains various apps that might open a particular site directory.
var applications: [Application] {
@ -38,7 +38,14 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
if tableView.selectedRow == -1 {
return nil
}
return sites[tableView.selectedRow]
return domains[tableView.selectedRow] as? ValetSite
}
var selectedProxy: ValetProxy? {
if tableView.selectedRow == -1 {
return nil
}
return domains[tableView.selectedRow] as? ValetProxy
}
var timer: Timer? = nil
@ -78,9 +85,10 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
override func viewDidLoad() {
tableView.doubleAction = #selector(self.doubleClicked(sender:))
if !Valet.shared.sites.isEmpty {
// Preloaded list
sites = Valet.shared.sites
domains = Valet.getDomainListable()
searchedFor(text: lastSearchedFor)
} else {
reloadSites()
@ -142,7 +150,7 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
waitAndExecute {
Valet.shared.reloadSites()
} completion: { [self] in
sites = Valet.shared.sites
domains = Valet.shared.sites
searchedFor(text: lastSearchedFor)
}
}
@ -150,23 +158,23 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
func applySortDescriptor(_ descriptor: NSSortDescriptor) {
sortDescriptor = descriptor
var sorted = self.sites
var sorted = self.domains
switch descriptor.key {
case "Secure":
sorted = self.sites.sorted { $0.secured && !$1.secured }; break
sorted = self.domains.sorted { $0.getListableSecured() && !$1.getListableSecured() }; break
case "Domain":
sorted = self.sites.sorted { $0.absolutePath < $1.absolutePath }; break
sorted = self.domains.sorted { $0.getListableAbsolutePath() < $1.getListableAbsolutePath() }; break
case "PHP":
sorted = self.sites.sorted { $0.servingPhpVersion < $1.servingPhpVersion }; break
sorted = self.domains.sorted { $0.getListablePhpVersion() < $1.getListablePhpVersion() }; break
case "Kind":
sorted = self.sites.sorted { ($0.aliasPath == nil) && !($1.aliasPath == nil) }; break
sorted = self.domains.sorted { $0.getListableKind() < $1.getListableKind() }; break
case "Type":
sorted = self.sites.sorted { $0.driver ?? "ZZZ" < $1.driver ?? "ZZZ" }; break
sorted = self.domains.sorted { $0.getListableType() < $1.getListableType() }; break
default: break;
}
self.sites = descriptor.ascending ? sorted.reversed() : sorted
self.domains = descriptor.ascending ? sorted.reversed() : sorted
}
func addedNewSite(name: String, secure: Bool) {
@ -178,13 +186,13 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
}
private func find(_ name: String, _ secure: Bool = false) {
sites = Valet.shared.sites
domains = Valet.getDomainListable()
searchedFor(text: "")
if let site = sites.enumerated().first(where: { $0.element.name == name }) {
if let site = domains.enumerated().first(where: { $0.element.getListableName() == name }) {
DispatchQueue.main.async {
self.tableView.selectRowIndexes([site.offset], byExtendingSelection: false)
self.tableView.scrollRowToVisible(site.offset)
if (secure && !site.element.secured) {
if (secure && !site.element.getListableSecured()) {
self.toggleSecure()
}
}
@ -194,7 +202,7 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
// MARK: - Table View Delegate
func numberOfRows(in tableView: NSTableView) -> Int {
return sites.count
return domains.count
}
func tableView(_ tableView: NSTableView, sortDescriptorsDidChange oldDescriptors: [NSSortDescriptor]) {
@ -220,7 +228,13 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
guard let userCell = tableView.makeView(withIdentifier: identifier, owner: self)
as? DomainListCellProtocol else { return nil }
userCell.populateCell(with: sites[row])
if let site = domains[row] as? ValetSite {
userCell.populateCell(with: site)
}
if let proxy = domains[row] as? ValetProxy {
userCell.populateCell(with: proxy)
}
return userCell as? NSView
}
@ -255,7 +269,7 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
let searchString = text.lowercased()
if searchString.isEmpty {
sites = Valet.shared.sites
domains = Valet.getDomainListable()
reloadTable()
@ -266,9 +280,9 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
.split(separator: " ")
.map { return String($0) }
sites = Valet.shared.sites.filter({ site in
domains = Valet.getDomainListable().filter({ site in
return !splitSearchString.map { searchString in
return site.name.lowercased().contains(searchString)
return site.getListableName().lowercased().contains(searchString)
}.contains(false)
})

View File

@ -10,9 +10,13 @@ import Foundation
class NginxConfiguration {
/** Contents of the Nginx file in question, as a string. */
var contents: String!
/** The name of the domain, usually derived from the name of the file. */
var domain: String
/** The TLD of the domain, usually derived from the name of the file. */
var tld: String
init(filePath: String) {
@ -47,7 +51,7 @@ class NginxConfiguration {
}()
/**
Retrieves which isolated version is active for this domain.
Retrieves which isolated version is active for this domain (if applicable).
*/
lazy var isolatedVersion: String? = {
let regex = try! NSRegularExpression(

View File

@ -0,0 +1,25 @@
//
// DomainListable.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 12/04/2022.
// Copyright © 2022 Nico Verbruggen. All rights reserved.
//
import Foundation
protocol DomainListable {
func getListableName() -> String
func getListableSecured() -> Bool
func getListableAbsolutePath() -> String
func getListablePhpVersion() -> String
func getListableKind() -> String
func getListableType() -> String
}

View File

@ -8,7 +8,7 @@
import Foundation
class ValetProxy
class ValetProxy: DomainListable
{
var domain: String
var tld: String
@ -19,4 +19,30 @@ class ValetProxy
self.tld = configuration.tld
self.target = configuration.proxy!
}
// MARK: - DomainListable Protocol
func getListableName() -> String {
return self.domain
}
func getListableSecured() -> Bool {
return false
}
func getListableAbsolutePath() -> String {
return self.domain
}
func getListablePhpVersion() -> String {
return ""
}
func getListableKind() -> String {
return "proxy"
}
func getListableType() -> String {
return "proxy"
}
}

View File

@ -8,7 +8,7 @@
import Foundation
class ValetSite {
class ValetSite: DomainListable {
/// Name of the site. Does not include the TLD.
var name: String
@ -220,7 +220,7 @@ class ValetSite {
}
}
// MARK: File Parsing
// MARK: - File Parsing
public static func isolatedVersion(_ filePath: String) -> String? {
if Filesystem.fileExists(filePath) {
@ -231,4 +231,30 @@ class ValetSite {
return nil
}
// MARK: - DomainListable Protocol
func getListableName() -> String {
return self.name
}
func getListableSecured() -> Bool {
return self.secured
}
func getListableAbsolutePath() -> String {
return self.absolutePath
}
func getListablePhpVersion() -> String {
return self.servingPhpVersion
}
func getListableKind() -> String {
return (self.aliasPath == nil) ? "linked" : "parked"
}
func getListableType() -> String {
return self.driver ?? "ZZZ"
}
}

View File

@ -67,6 +67,10 @@ class Valet {
return self.shared.features.contains(feature)
}
public static func getDomainListable() -> [DomainListable] {
return self.shared.sites + self.shared.proxies
}
/**
We don't want to load the initial config.json file as soon as the class is initialised.

View File

@ -69,7 +69,7 @@
// SITE LIST
"domain_list.title" = "Domains";
"domain_list.subtitle" = "Linked & Parked";
"domain_list.subtitle" = "";
"domain_list.tooltips.isolated" = "This domain is isolated and using PHP %@ instead of the globally linked PHP.";
"domain_list.tooltips.checkmark" = "This domain is being served with a version of PHP that is compatible with this requirement (PHP %@). Click on the PHP version next to this checkmark to find out more information about how this requirement was determined.";