1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-11 05:20:07 +02:00

👌 Add modal to inform about helper scripts

This commit is contained in:
2023-01-11 18:03:10 +01:00
parent 300b10c5d8
commit e6d2c873a5
14 changed files with 66 additions and 20 deletions

View File

@@ -13,8 +13,8 @@ class Alert {
onWindow window: NSWindow, onWindow window: NSWindow,
messageText: String, messageText: String,
informativeText: String, informativeText: String,
buttonTitle: String = "OK", buttonTitle: String = "generic.ok".localized,
secondButtonTitle: String = "Cancel", secondButtonTitle: String = "generic.cancel".localized,
style: NSAlert.Style = .warning, style: NSAlert.Style = .warning,
onFirstButtonPressed: @escaping (() -> Void) onFirstButtonPressed: @escaping (() -> Void)
) { ) {

View File

@@ -125,7 +125,7 @@ class AppUpdateChecker {
subtitle: "updater.alerts.is_latest_version.subtitle".localized(App.shortVersion), subtitle: "updater.alerts.is_latest_version.subtitle".localized(App.shortVersion),
description: "" description: ""
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }
} }
@@ -174,7 +174,7 @@ class AppUpdateChecker {
NSWorkspace.shared.open(Constants.Urls.GitHubReleases) NSWorkspace.shared.open(Constants.Urls.GitHubReleases)
} }
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }
} }

View File

@@ -64,7 +64,7 @@ class Startup {
subtitle: check.subtitleText, subtitle: check.subtitleText,
description: check.descriptionText description: check.descriptionText
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }

View File

@@ -22,7 +22,7 @@ extension DomainListVC {
title: "domain_list.alert.invalid_folder_name".localized, title: "domain_list.alert.invalid_folder_name".localized,
subtitle: "domain_list.alert.invalid_folder_name_desc".localized subtitle: "domain_list.alert.invalid_folder_name_desc".localized
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
return return
} }
@@ -194,6 +194,18 @@ extension DomainListVC {
) )
} }
@objc func useInTerminal() {
guard let site = selectedSite else {
return
}
guard let version = site.isolatedPhpVersion?.versionNumber else {
return
}
self.notifyAboutUsingIsolatedPhpVersionInTerminal(version: version)
}
// MARK: - Alerts & Modals // MARK: - Alerts & Modals
private func notifyAboutModifiedSecureStatus(domain: String, secured: Bool) { private func notifyAboutModifiedSecureStatus(domain: String, secured: Bool) {
@@ -212,13 +224,27 @@ extension DomainListVC {
) )
} }
private func notifyAboutUsingIsolatedPhpVersionInTerminal(version: VersionNumber) {
BetterAlert()
.withInformation(
title: "domain_list.alerts_isolated_php_terminal.title".localized(version.short),
subtitle: "domain_list.alerts_isolated_php_terminal.subtitle".localized(
"\(version.major)\(version.minor)",
version.short
),
description: "domain_list.alerts_isolated_php_terminal.desc".localized
)
.withPrimary(text: "generic.ok".localized)
.show()
}
private func notifyAboutFailedSecureStatus(command: String) { private func notifyAboutFailedSecureStatus(command: String) {
BetterAlert() BetterAlert()
.withInformation( .withInformation(
title: "domain_list.alerts_status_not_changed.title".localized, title: "domain_list.alerts_status_not_changed.title".localized,
subtitle: "domain_list.alerts_status_not_changed.desc".localized(command) subtitle: "domain_list.alerts_status_not_changed.desc".localized(command)
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }
@@ -229,7 +255,7 @@ extension DomainListVC {
subtitle: "domain_list.alerts_isolation_failed.subtitle".localized, subtitle: "domain_list.alerts_isolation_failed.subtitle".localized,
description: "domain_list.alerts_isolation_failed.desc".localized(command) description: "domain_list.alerts_isolation_failed.desc".localized(command)
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }
} }

View File

@@ -130,6 +130,13 @@ extension DomainListVC {
menu.addItem(HeaderView.asMenuItem(text: "domain_list.site_isolation".localized)) menu.addItem(HeaderView.asMenuItem(text: "domain_list.site_isolation".localized))
menu.addItem(NSMenuItem(title: "domain_list.isolate".localized, submenu: items)) menu.addItem(NSMenuItem(title: "domain_list.isolate".localized, submenu: items))
if site.isolatedPhpVersion != nil {
menu.addItem(NSMenuItem(
title: "domain_list.use_in_terminal".localized(site.servingPhpVersion),
action: #selector(self.useInTerminal)
))
}
menu.addItem(NSMenuItem.separator()) menu.addItem(NSMenuItem.separator())
} }

View File

@@ -120,7 +120,7 @@ import Foundation
subtitle: "alert.composer_missing.subtitle".localized, subtitle: "alert.composer_missing.subtitle".localized,
description: "alert.composer_missing.desc".localized description: "alert.composer_missing.desc".localized
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }

View File

@@ -140,7 +140,7 @@ class HomebrewDiagnostics {
title: "alert.php_alias_conflict.title".localized, title: "alert.php_alias_conflict.title".localized,
subtitle: "alert.php_alias_conflict.info".localized subtitle: "alert.php_alias_conflict.info".localized
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }
} }

View File

@@ -82,7 +82,7 @@ class Valet {
subtitle: "alert.warnings.tld_issue.subtitle".localized, subtitle: "alert.warnings.tld_issue.subtitle".localized,
description: "alert.warnings.tld_issue.description".localized description: "alert.warnings.tld_issue.description".localized
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.withTertiary(text: "alert.do_not_tell_again".localized, action: { alert in .withTertiary(text: "alert.do_not_tell_again".localized, action: { alert in
Preferences.update(.warnAboutNonStandardTLD, value: false) Preferences.update(.warnAboutNonStandardTLD, value: false)
alert.close(with: .alertThirdButtonReturn) alert.close(with: .alertThirdButtonReturn)
@@ -176,7 +176,7 @@ class Valet {
Constants.MinimumRecommendedValetVersion Constants.MinimumRecommendedValetVersion
) )
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }
} else { } else {

View File

@@ -34,7 +34,7 @@ extension MainMenu {
subtitle: "alert.fix_homebrew_permissions_done.subtitle".localized, subtitle: "alert.fix_homebrew_permissions_done.subtitle".localized,
description: "alert.fix_homebrew_permissions_done.desc".localized description: "alert.fix_homebrew_permissions_done.desc".localized
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} failure: { error in } failure: { error in
BetterAlert.show(for: error as! HomebrewPermissionError) BetterAlert.show(for: error as! HomebrewPermissionError)
@@ -182,7 +182,7 @@ extension MainMenu {
subtitle: "preset_help_info".localized, subtitle: "preset_help_info".localized,
description: "preset_help_desc".localized description: "preset_help_desc".localized
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.withTertiary(text: "", action: { alert in .withTertiary(text: "", action: { alert in
NSWorkspace.shared.open(Constants.Urls.FrequentlyAskedQuestions) NSWorkspace.shared.open(Constants.Urls.FrequentlyAskedQuestions)
alert.close(with: .OK) alert.close(with: .OK)

View File

@@ -48,7 +48,7 @@ extension MainMenu {
title: "alert.php_formula_missing.title".localized, title: "alert.php_formula_missing.title".localized,
subtitle: "alert.php_formula_missing.info".localized subtitle: "alert.php_formula_missing.info".localized
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }
@@ -59,7 +59,7 @@ extension MainMenu {
subtitle: "alert.fix_my_valet_done.subtitle".localized, subtitle: "alert.fix_my_valet_done.subtitle".localized,
description: "alert.fix_my_valet_done.desc".localized description: "alert.fix_my_valet_done.desc".localized
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }

View File

@@ -115,6 +115,6 @@ class BetterAlert {
return BetterAlert().withInformation( return BetterAlert().withInformation(
title: "\(key).title".localized, title: "\(key).title".localized,
subtitle: "\(key).description".localized subtitle: "\(key).description".localized
).withPrimary(text: "OK").show() ).withPrimary(text: "generic.ok".localized).show()
} }
} }

View File

@@ -33,7 +33,7 @@ extension ActivePhpInstallation {
subtitle: "alert.php_fpm_broken.info".localized, subtitle: "alert.php_fpm_broken.info".localized,
description: "alert.php_fpm_broken.description".localized description: "alert.php_fpm_broken.description".localized
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }
} }

View File

@@ -124,7 +124,7 @@ struct ServiceView: View {
subtitle: "alert.warnings.service_missing.subtitle".localized, subtitle: "alert.warnings.service_missing.subtitle".localized,
description: "alert.warnings.service_missing.description".localized description: "alert.warnings.service_missing.description".localized
) )
.withPrimary(text: "OK") .withPrimary(text: "generic.ok".localized)
.show() .show()
} }
} label: { } label: {

View File

@@ -86,6 +86,7 @@
// GENERIC // GENERIC
"generic.ok" = "OK"; "generic.ok" = "OK";
"generic.cancel" = "Cancel";
"generic.retry" = "Retry"; "generic.retry" = "Retry";
"generic.notice" = "Notice"; "generic.notice" = "Notice";
@@ -194,6 +195,18 @@
"domain_list.detected_apps" = "Detected Applications"; "domain_list.detected_apps" = "Detected Applications";
"domain_list.system_apps" = "System Applications"; "domain_list.system_apps" = "System Applications";
"domain_list.unproxy" = "Remove Proxy"; "domain_list.unproxy" = "Remove Proxy";
"domain_list.use_in_terminal" = "Open PHP %@ in Terminal";
"domain_list.alerts_isolated_php_terminal.title" = "You can use PHP %@ in a specific terminal!";
"domain_list.alerts_isolated_php_terminal.subtitle" = "Sadly, PHP Monitor cannot open a terminal for you (and type in the appropriate commands). You'll have to manually source the helper script in order to use this specific version of PHP. To do this, you can type the following in a terminal of choice:
. pm%@
This will source the helper script as generated by PHP Monitor and enable the use of PHP %@ for that specific terminal.
This has no effect on other terminals, only for the particular terminal session that you are using it on. (i.e. if you have multiple tabs in your terminal app, other tabs & windows are unaffected.)";
"domain_list.alerts_isolated_php_terminal.desc" = "If this doesn't work, you may wish to check PHP Doctor via the First Aid menu here in PHP Monitor. More information about this feature can also be found on GitHub (on the wiki on PHP Monitor's repository). This alert is included to improve visibility of this feature.";
"domain_list.warning.spaces" = "Warning! This site has a space in its folder.\nThe site will not be reachable via the browser."; "domain_list.warning.spaces" = "Warning! This site has a space in its folder.\nThe site will not be reachable via the browser.";
@@ -623,7 +636,7 @@ COMMON TROUBLESHOOTING TIPS
"warnings.refresh.button.description" = "Press this button once you've fixed an issue. This will cause PHP Monitor to re-evaluate your environment. If it's really fixed, the recommendation should disappear."; "warnings.refresh.button.description" = "Press this button once you've fixed an issue. This will cause PHP Monitor to re-evaluate your environment. If it's really fixed, the recommendation should disappear.";
"warnings.helper_permissions.title" = "PHP Monitors helpers are currently unavailable."; "warnings.helper_permissions.title" = "PHP Monitors helpers are currently unavailable.";
"warnings.helper_permissions.description" = "PHP Monitor comes with various helper binaries. Using these binaries allows you to easily invoke a specific version of PHP without switching the linked PHP version."; "warnings.helper_permissions.description" = "PHP Monitor comes with various helper scripts. Using these scripts allows you to easily invoke a specific version of PHP without switching the linked PHP version.";
"warnings.helper_permissions.unavailable" = "However, these helpers are potentially *unavailable* because PHP Monitor cannot currently create or update the required symlinks."; "warnings.helper_permissions.unavailable" = "However, these helpers are potentially *unavailable* because PHP Monitor cannot currently create or update the required symlinks.";
"warnings.helper_permissions.symlink" = "If you do not wish to make `/usr/local/bin` writable, you can add PHP Monitor's helper directory to your `PATH` variable to make this warning go away. (Click on ”Learn More” to find out how to fix this issue.)"; "warnings.helper_permissions.symlink" = "If you do not wish to make `/usr/local/bin` writable, you can add PHP Monitor's helper directory to your `PATH` variable to make this warning go away. (Click on ”Learn More” to find out how to fix this issue.)";