diff --git a/phpmon/Domain/SwiftUI/Domains/SecurePopoverView.swift b/phpmon/Domain/SwiftUI/Domains/SecurePopoverView.swift index ea68b043..76667013 100644 --- a/phpmon/Domain/SwiftUI/Domains/SecurePopoverView.swift +++ b/phpmon/Domain/SwiftUI/Domains/SecurePopoverView.swift @@ -16,6 +16,7 @@ struct SecurePopoverView: View { @State var name: String @State var tld: String @State var expires: Date? + var callback: () -> Void = {} var body: some View { VStack(alignment: .leading, spacing: 10) { @@ -41,6 +42,9 @@ struct SecurePopoverView: View { message: "cert_popover.secure_domain_expired".localized(expires.formatted()), color: Color.statusColorOrange ) + Button("cert_popover.cta_renewal".localized) { + callback() + }.padding(.top, 10) } else { DisclaimerView( iconName: "checkmark.circle.fill", diff --git a/phpmon/Modules/Domain List/UI/Cells/DomainListTLSCell.swift b/phpmon/Modules/Domain List/UI/Cells/DomainListTLSCell.swift index fd4a6811..22118617 100644 --- a/phpmon/Modules/Domain List/UI/Cells/DomainListTLSCell.swift +++ b/phpmon/Modules/Domain List/UI/Cells/DomainListTLSCell.swift @@ -58,7 +58,11 @@ class DomainListTLSCell: NSTableCellView, DomainListCellProtocol { let view = SecurePopoverView( name: site.getListableName(), tld: Valet.shared.config.tld, - expires: site.getListableCertificateExpiryDate() + expires: site.getListableCertificateExpiryDate(), + callback: { + App.shared.domainListWindowController? + .contentVC.checkForCertificateRenewal() + } ) let controller = NSHostingController(rootView: view) diff --git a/phpmon/Modules/Domain List/UI/DomainListVC.swift b/phpmon/Modules/Domain List/UI/DomainListVC.swift index 8edeb971..6d78dd68 100644 --- a/phpmon/Modules/Domain List/UI/DomainListVC.swift +++ b/phpmon/Modules/Domain List/UI/DomainListVC.swift @@ -40,6 +40,11 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource /// String that was last searched for. Empty by default. var lastSearchedFor = "" + /// Set to true if we already checked for expired certificates. + /// This prevents notifications about expired certificates from + /// popping up when we re-open the Domains window. + var didCheckForCertRenewal: Bool = false + // MARK: - Helper Variables var selectedSite: ValetSite? { @@ -63,6 +68,8 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource return domains[tableView.selectedRow] } + /// Timer used to determine whether this window has been busy + /// for a certain amount of time. var timer: Timer? // MARK: - Display @@ -127,7 +134,11 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource override func viewDidAppear() { super.viewDidAppear() - checkForCertificateRenewal() + + if !didCheckForCertRenewal { + checkForCertificateRenewal() + didCheckForCertRenewal = true + } } private func reloadDomainListables() { diff --git a/phpmon/en.lproj/Localizable.strings b/phpmon/en.lproj/Localizable.strings index df394b4f..ed826631 100644 --- a/phpmon/en.lproj/Localizable.strings +++ b/phpmon/en.lproj/Localizable.strings @@ -919,6 +919,7 @@ If you want to make edits to this file, please do so before upgrading. When you "cert_popover.secure_domain_traffic" = "Because this domain has been secured with a certificate, traffic to this domain is served by nginx over HTTPS."; "cert_popover.secure_domain_expired" = "The certificate expired on %@. You must renew it to continue using HTTPS without errors."; "cert_popover.secure_domain_expiring_later" = "The certificate is valid. It will expire on %@. At that point it will need to be renewed, but you will be notified."; +"cert_popover.cta_renewal" = "Renew Certificates..."; "cert_alert.title" = "One or more certificates have expired, and must be renewed."; "cert_alert.description" = "Certificates used to secure domains are usually valid for one year. Do you want PHP Monitor to unsecure and re-secure any expired domains?"; @@ -926,6 +927,6 @@ If you want to make edits to this file, please do so before upgrading. When you %@ -PHP Monitor will tell Valet to unsecure and re-secure all expired domains for you. This can take a while, as nginx may be restarted a few times if multiple domains need to be re-secured. You will be prompted about this issue every time this window opens, so it is recommended to take action now."; +PHP Monitor will tell Valet to unsecure and re-secure all expired domains for you. This can take a while, as nginx may be restarted a few times if multiple domains need to be re-secured."; "cert_alert.renew" = "Re-secure Domain(s)"; "cert_alert.cancel" = "Not Now";