diff --git a/phpmon/Domain/Integrations/Valet/Valet.swift b/phpmon/Domain/Integrations/Valet/Valet.swift index 6aaafea..b54166f 100644 --- a/phpmon/Domain/Integrations/Valet/Valet.swift +++ b/phpmon/Domain/Integrations/Valet/Valet.swift @@ -78,13 +78,20 @@ class Valet { Notify the user about a non-default TLD being set. */ public static func notifyAboutUnsupportedTLD() { - if Valet.shared.config.tld != "test" { + if Valet.shared.config.tld != "test" && Preferences.isEnabled(.warnAboutNonStandardTLD) + { DispatchQueue.main.async { BetterAlert().withInformation( title: "alert.warnings.tld_issue.title".localized, subtitle: "alert.warnings.tld_issue.subtitle".localized, description: "alert.warnings.tld_issue.description".localized - ).withPrimary(text: "OK").show() + ) + .withPrimary(text: "OK") + .withTertiary(text: "alert.do_not_tell_again".localized, action: { alert in + Preferences.update(.warnAboutNonStandardTLD, value: false) + alert.close(with: .alertThirdButtonReturn) + }) + .show() } } } diff --git a/phpmon/Domain/Preferences/PreferenceName.swift b/phpmon/Domain/Preferences/PreferenceName.swift index 7b68921..221e8ce 100644 --- a/phpmon/Domain/Preferences/PreferenceName.swift +++ b/phpmon/Domain/Preferences/PreferenceName.swift @@ -26,6 +26,9 @@ enum PreferenceName: String { case iconTypeToDisplay = "icon_type_to_display" case fullPhpVersionDynamicIcon = "full_php_in_menu_bar" + // WARNINGS + case warnAboutNonStandardTLD = "warn_about_non_standard_tld" + // NOTIFICATIONS case notifyAboutVersionChange = "notify_about_version_change" case notifyAboutPhpFpmRestart = "notify_about_php_fpm_restart" @@ -60,6 +63,7 @@ enum PreferenceName: String { .showPhpDoctorSuggestions, // Notifications + .warnAboutNonStandardTLD, .notifyAboutVersionChange, .notifyAboutPhpFpmRestart, .notifyAboutServices, diff --git a/phpmon/Domain/Preferences/Preferences.swift b/phpmon/Domain/Preferences/Preferences.swift index d60b9f0..4e7f29a 100644 --- a/phpmon/Domain/Preferences/Preferences.swift +++ b/phpmon/Domain/Preferences/Preferences.swift @@ -57,6 +57,7 @@ class Preferences { PreferenceName.fullPhpVersionDynamicIcon.rawValue: false, /// Preferences: Notifications + PreferenceName.warnAboutNonStandardTLD.rawValue: true, PreferenceName.notifyAboutVersionChange.rawValue: true, PreferenceName.notifyAboutPhpFpmRestart.rawValue: true, PreferenceName.notifyAboutServices.rawValue: true, diff --git a/phpmon/Domain/Preferences/PrefsVC.swift b/phpmon/Domain/Preferences/PrefsVC.swift index 346f6ec..3e1542f 100644 --- a/phpmon/Domain/Preferences/PrefsVC.swift +++ b/phpmon/Domain/Preferences/PrefsVC.swift @@ -188,6 +188,16 @@ class GenericPreferenceVC: NSViewController { ) } + func getWarnAboutNonStandardTLD() -> NSView { + return CheckboxPreferenceView.make( + sectionText: "prefs.warnings".localized, + descriptionText: "prefs.warn_about_non_standard_tld_desc".localized, + checkboxText: "prefs.warn_about_non_standard_tld".localized, + preference: .warnAboutNonStandardTLD, + action: {} + ) + } + func getDisplayMenuSectionPV( _ localizationKey: String, _ preference: PreferenceName, @@ -249,7 +259,8 @@ class NotificationPreferencesVC: GenericPreferenceVC { vc.getNotifyAboutSecureTogglePV(), vc.getNotifyAboutGlobalComposerStatusPV(), vc.getNotifyAboutServicesPV(), - vc.getNotifyAboutPhpFpmChangePV() + vc.getNotifyAboutPhpFpmChangePV(), + vc.getWarnAboutNonStandardTLD() ] return vc diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index 7b6e6d2..501356b 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -227,6 +227,7 @@ "prefs.integrations" = "Integrations:"; "prefs.updates" = "Updates:"; "prefs.notifications" = "Notifications:"; +"prefs.warnings" = "Warnings:"; "prefs.menu_contents" = "Features in Menu:"; "prefs.icon_options.php" = "Display PHP Icon"; @@ -279,6 +280,9 @@ "prefs.notify_about_composer_success_desc" = "Displays a notification when the global Composer configuration was successfully updated."; "prefs.notify_about_composer_success" = "Notify about global composer update"; +"prefs.warn_about_non_standard_tld_desc" = "If you use a non-standard TLD, you may not wish to get repeated notifications about this."; +"prefs.warn_about_non_standard_tld" = "Warn about non-standard TLD"; + "prefs.display_global_version_switcher_desc" = "If disabled, you will not be able to change the globally linked PHP version via the main menu."; "prefs.display_global_version_switcher" = "PHP Switcher"; @@ -548,6 +552,7 @@ If you are seeing this message but are confused why this folder has gone missing "alert.warnings.tld_issue.title" = "You are not using `.test` as the TLD for Valet."; "alert.warnings.tld_issue.subtitle" = "Using a non-default TLD may not work correctly and is not officially supported."; "alert.warnings.tld_issue.description" = "PHP Monitor will remain functional, but there might be issues: the app might not correctly show which domains have been secured. For optimal results, go to your Valet configuration file (config.json in the Valet directory) and change the TLD back to `test`."; +"alert.do_not_tell_again" = "Don't Tell Me Again"; // WARNINGS