1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-04-02 09:30: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 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",

View File

@@ -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)

View File

@@ -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() {

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_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";