1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-04-06 19:10:08 +02:00

Add button in popover for domain w/ expired certificate

This commit is contained in:
2025-10-31 14:23:58 +01:00
parent 9245b0cfe3
commit 233e344eee
4 changed files with 23 additions and 3 deletions

View File

@@ -16,6 +16,7 @@ struct SecurePopoverView: View {
@State var name: String @State var name: String
@State var tld: String @State var tld: String
@State var expires: Date? @State var expires: Date?
var callback: () -> Void = {}
var body: some View { var body: some View {
VStack(alignment: .leading, spacing: 10) { VStack(alignment: .leading, spacing: 10) {
@@ -41,6 +42,9 @@ struct SecurePopoverView: View {
message: "cert_popover.secure_domain_expired".localized(expires.formatted()), message: "cert_popover.secure_domain_expired".localized(expires.formatted()),
color: Color.statusColorOrange color: Color.statusColorOrange
) )
Button("cert_popover.cta_renewal".localized) {
callback()
}.padding(.top, 10)
} else { } else {
DisclaimerView( DisclaimerView(
iconName: "checkmark.circle.fill", iconName: "checkmark.circle.fill",

View File

@@ -58,7 +58,11 @@ class DomainListTLSCell: NSTableCellView, DomainListCellProtocol {
let view = SecurePopoverView( let view = SecurePopoverView(
name: site.getListableName(), name: site.getListableName(),
tld: Valet.shared.config.tld, tld: Valet.shared.config.tld,
expires: site.getListableCertificateExpiryDate() expires: site.getListableCertificateExpiryDate(),
callback: {
App.shared.domainListWindowController?
.contentVC.checkForCertificateRenewal()
}
) )
let controller = NSHostingController(rootView: view) let controller = NSHostingController(rootView: view)

View File

@@ -40,6 +40,11 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
/// String that was last searched for. Empty by default. /// String that was last searched for. Empty by default.
var lastSearchedFor = "" 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 // MARK: - Helper Variables
var selectedSite: ValetSite? { var selectedSite: ValetSite? {
@@ -63,6 +68,8 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
return domains[tableView.selectedRow] return domains[tableView.selectedRow]
} }
/// Timer used to determine whether this window has been busy
/// for a certain amount of time.
var timer: Timer? var timer: Timer?
// MARK: - Display // MARK: - Display
@@ -127,7 +134,11 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
override func viewDidAppear() { override func viewDidAppear() {
super.viewDidAppear() super.viewDidAppear()
if !didCheckForCertRenewal {
checkForCertificateRenewal() checkForCertificateRenewal()
didCheckForCertRenewal = true
}
} }
private func reloadDomainListables() { private func reloadDomainListables() {

View File

@@ -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_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_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.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.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?"; "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.renew" = "Re-secure Domain(s)";
"cert_alert.cancel" = "Not Now"; "cert_alert.cancel" = "Not Now";