From 7fd30d7c54a1eee46fd42b6fb963924dd17a757e Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Mon, 10 Oct 2022 21:49:43 +0200 Subject: [PATCH 1/6] =?UTF-8?q?=E2=9C=A8=20Add=20preference=20to=20disable?= =?UTF-8?q?=20TLD=20alert=20(#206)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Domain/Integrations/Valet/Valet.swift | 11 +++++++++-- phpmon/Domain/Preferences/PreferenceName.swift | 4 ++++ phpmon/Domain/Preferences/Preferences.swift | 1 + phpmon/Domain/Preferences/PrefsVC.swift | 13 ++++++++++++- phpmon/Localizable.strings | 5 +++++ 5 files changed, 31 insertions(+), 3 deletions(-) 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 From f4448e064069e16cd9f4f72fbe794f36941f95c0 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Mon, 10 Oct 2022 21:49:51 +0200 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=94=A7=20Bump=20version=20number?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHP Monitor.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 40c7222..85872ac 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -1741,7 +1741,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 976; + CURRENT_PROJECT_VERSION = 978; DEAD_CODE_STRIPPING = YES; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; @@ -1752,7 +1752,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 5.6.2; + MARKETING_VERSION = 5.6.3; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1769,7 +1769,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 976; + CURRENT_PROJECT_VERSION = 978; DEAD_CODE_STRIPPING = YES; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; @@ -1780,7 +1780,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 5.6.2; + MARKETING_VERSION = 5.6.3; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; From 5c69133c42f0835d60ec125835a003509ddcafb4 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Thu, 20 Oct 2022 20:44:44 +0200 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=91=8C=20Add=20`brew=20tap=20homebrew?= =?UTF-8?q?/services`=20instruction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This now recommends the appropriate solution for #208. --- phpmon/Localizable.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index 501356b..e81d050 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -508,7 +508,7 @@ If you are seeing this message but are confused why this folder has gone missing /// Cannot retrieve services "startup.errors.services_json_error.title" = "Cannot determine services status"; "startup.errors.services_json_error.subtitle" = "PHP Monitor usually queries `brew` using the following command to test if the services can be retrieved: `sudo brew services info nginx --json`.\n\nPHP Monitor could not interpret this response."; -"startup.errors.services_json_error.desc" = "This can happen if your Homebrew installation is out of date, in which case Homebrew won't return JSON yet. You can usually fix this by running `brew update`. You can also try running `sudo brew services info nginx --json` in your terminal of choice."; +"startup.errors.services_json_error.desc" = "This can happen if your Homebrew installation is out of date, in which case Homebrew won't return JSON yet. You can usually fix this by running `brew update` or `brew tap homebrew/services`. You can also try running `sudo brew services info nginx --json` in your terminal of choice."; /// Issue with `which` alias "startup.errors.which_alias_issue.title" = "A configuration issue was detected"; From b134e62328ba17601056e4f53b0d3c05bffe0bf4 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sat, 22 Oct 2022 16:41:54 +0200 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=90=9B=20Handle=20empty=20output=20fo?= =?UTF-8?q?r=20`brew=20info`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Domain/Integrations/Homebrew/HomebrewDiagnostics.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpmon/Domain/Integrations/Homebrew/HomebrewDiagnostics.swift b/phpmon/Domain/Integrations/Homebrew/HomebrewDiagnostics.swift index 4d4aff0..d6a8eec 100644 --- a/phpmon/Domain/Integrations/Homebrew/HomebrewDiagnostics.swift +++ b/phpmon/Domain/Integrations/Homebrew/HomebrewDiagnostics.swift @@ -77,7 +77,7 @@ class HomebrewDiagnostics { private static func hasAliasConflict() -> Bool { let tapAlias = Shell.pipe("\(Paths.brew) info shivammathur/php/php --json") - if tapAlias.contains("brew tap shivammathur/php") || tapAlias.contains("Error") { + if tapAlias.contains("brew tap shivammathur/php") || tapAlias.contains("Error") || tapAlias.isEmpty { Log.info("The user does not appear to have tapped: shivammathur/php") return false } else { From 9a11d2efedef311c3db69121177307152087019e Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sat, 22 Oct 2022 16:42:26 +0200 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=94=A7=20Bump=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHP Monitor.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 85872ac..6e91d4a 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -1741,7 +1741,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 978; + CURRENT_PROJECT_VERSION = 980; DEAD_CODE_STRIPPING = YES; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; @@ -1769,7 +1769,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 978; + CURRENT_PROJECT_VERSION = 980; DEAD_CODE_STRIPPING = YES; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; From e62b03d0703b302adc91af91035f7fc9b61c3bdf Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sat, 22 Oct 2022 16:43:05 +0200 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=91=8C=20Style=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Domain/Integrations/Valet/Valet.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpmon/Domain/Integrations/Valet/Valet.swift b/phpmon/Domain/Integrations/Valet/Valet.swift index b54166f..fe79b7f 100644 --- a/phpmon/Domain/Integrations/Valet/Valet.swift +++ b/phpmon/Domain/Integrations/Valet/Valet.swift @@ -78,8 +78,7 @@ class Valet { Notify the user about a non-default TLD being set. */ public static func notifyAboutUnsupportedTLD() { - if Valet.shared.config.tld != "test" && Preferences.isEnabled(.warnAboutNonStandardTLD) - { + if Valet.shared.config.tld != "test" && Preferences.isEnabled(.warnAboutNonStandardTLD) { DispatchQueue.main.async { BetterAlert().withInformation( title: "alert.warnings.tld_issue.title".localized,