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

👌 Various QoL improvements

- Ensure composer global update cannot run twice (#71)
- Set busy status when updating dependencies (#71)
- Further reorganized menu items (#69)
- Use consistent capitals in menu items
- Fix preferences screen layout (auto newlines due to fixed width)
This commit is contained in:
2021-12-19 12:27:34 +01:00
parent ed49362291
commit 267a1dac94
7 changed files with 78 additions and 64 deletions

View File

@ -334,11 +334,14 @@
<objects>
<viewController title="Preferences" storyboardIdentifier="preferences" showSeguePresentationStyle="single" id="AW2-rV-rbS" customClass="PrefsVC" customModule="PHP_Monitor" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" wantsLayer="YES" id="Pf1-A5-3Xz">
<rect key="frame" x="0.0" y="0.0" width="574" height="498"/>
<rect key="frame" x="0.0" y="0.0" width="550" height="498"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView distribution="fillEqually" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="k57-O3-Yyj">
<rect key="frame" x="0.0" y="15" width="574" height="468"/>
<rect key="frame" x="0.0" y="15" width="550" height="468"/>
<constraints>
<constraint firstAttribute="width" constant="550" id="eOC-yS-nl6"/>
</constraints>
</stackView>
</subviews>
<constraints>

View File

@ -131,10 +131,6 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
menu.addItem(NSMenuItem.separator())
// Add services
menu.addServicesMenuItems()
menu.addItem(NSMenuItem.separator())
// Add information about services & actions
menu.addPhpConfigurationMenuItems()
menu.addItem(NSMenuItem.separator())
@ -332,6 +328,18 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
}
func updateGlobalDependencies(notify: Bool, completion: @escaping (Bool) -> Void) {
App.shared.busy = true
setBusyImage()
self.update()
let noLongerBusy = {
App.shared.busy = false
DispatchQueue.main.async { [self] in
self.updatePhpVersionInStatusBar()
self.update()
}
}
var window: ProgressWindowController? = ProgressWindowController.display(
title: "alert.composer_progress.title".localized,
description: "alert.composer_progress.info".localized
@ -380,6 +388,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
)
}
window = nil
noLongerBusy()
completion(true)
}
} else {
@ -387,6 +396,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
window?.progressView?.labelTitle.stringValue = "alert.composer_failure.title".localized
window?.progressView?.labelDescription.stringValue = "alert.composer_failure.info".localized
window = nil
noLongerBusy()
completion(false)
}
}

View File

@ -39,38 +39,36 @@ class StatusMenu : NSMenu {
}
func addServicesMenuItems() {
self.addItem(HeaderView.asMenuItem(text: "mi_active_services".localized))
let services = NSMenuItem(title: "mi_manage_services".localized, action: nil, keyEquivalent: "")
let servicesMenu = NSMenu()
servicesMenu.addItem(NSMenuItem(title: "mi_restart_dnsmasq".localized, action: #selector(MainMenu.restartDnsMasq), keyEquivalent: "d"))
servicesMenu.addItem(NSMenuItem(title: "mi_restart_php_fpm".localized, action: #selector(MainMenu.restartPhpFpm), keyEquivalent: "p"))
servicesMenu.addItem(NSMenuItem(title: "mi_restart_nginx".localized, action: #selector(MainMenu.restartNginx), keyEquivalent: "n"))
servicesMenu.addItem(
NSMenuItem(title: "mi_stop_all_services".localized, action: #selector(MainMenu.stopAllServices), keyEquivalent: "s"),
withKeyModifier: [.command, .shift])
servicesMenu.addItem(NSMenuItem(title: "mi_restart_all_services".localized, action: #selector(MainMenu.restartAllServices), keyEquivalent: "s"))
for item in servicesMenu.items {
item.target = MainMenu.shared
}
self.setSubmenu(servicesMenu, for: services)
self.addForceLoadLatestVersion()
self.addItem(services)
}
func addForceLoadLatestVersion() {
if !App.shared.availablePhpVersions.contains(App.shared.brewPhpVersion) {
self.addItem(NSMenuItem(
servicesMenu.addItem(NSMenuItem(
title: "mi_force_load_latest_unavailable".localized(App.shared.brewPhpVersion),
action: nil, keyEquivalent: "f"
))
} else {
self.addItem(NSMenuItem(
servicesMenu.addItem(NSMenuItem(
title: "mi_force_load_latest".localized(App.shared.brewPhpVersion),
action: #selector(MainMenu.forceRestartLatestPhp), keyEquivalent: "f"))
}
servicesMenu.addItem(NSMenuItem(title: "mi_restart_dnsmasq".localized, action: #selector(MainMenu.restartDnsMasq), keyEquivalent: "d"))
servicesMenu.addItem(NSMenuItem(title: "mi_restart_php_fpm".localized, action: #selector(MainMenu.restartPhpFpm), keyEquivalent: "p"))
servicesMenu.addItem(NSMenuItem(title: "mi_restart_nginx".localized, action: #selector(MainMenu.restartNginx), keyEquivalent: "n"))
servicesMenu.addItem(
NSMenuItem(title: "mi_stop_all_services".localized, action: #selector(MainMenu.stopAllServices), keyEquivalent: "s"),
withKeyModifier: [.command, .shift])
servicesMenu.addItem(NSMenuItem(title: "mi_restart_all_services".localized, action: #selector(MainMenu.restartAllServices), keyEquivalent: "s"))
for item in servicesMenu.items {
item.target = MainMenu.shared
}
self.setSubmenu(servicesMenu, for: services)
self.addItem(services)
}
func addValetMenuItems() {
@ -94,7 +92,7 @@ class StatusMenu : NSMenu {
self.addItem(NSMenuItem.separator())
self.addItem(HeaderView.asMenuItem(text: "mi_composer".localized))
self.addItem(NSMenuItem(title: "mi_global_composer".localized, action: #selector(MainMenu.openGlobalComposerFolder), keyEquivalent: "g"))
self.addItem(NSMenuItem(title: "mi_update_global_composer".localized, action: #selector(MainMenu.updateComposerDependencies), keyEquivalent: ""))
self.addItem(NSMenuItem(title: "mi_update_global_composer".localized, action: App.shared.busy ? nil : #selector(MainMenu.updateComposerDependencies), keyEquivalent: ""))
if (App.shared.busy) {
return
@ -127,6 +125,11 @@ class StatusMenu : NSMenu {
self.addItem(NSMenuItem.separator())
self.addItem(NSMenuItem(title: "mi_php_refresh".localized, action: #selector(MainMenu.reloadPhpMonitorMenu), keyEquivalent: "r"))
self.addItem(NSMenuItem.separator())
self.addServicesMenuItems()
}
private func addSwitchToPhpMenuItems() {

View File

@ -63,7 +63,7 @@
<constraint firstItem="B8f-nb-Y0A" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" constant="5" id="2Zu-h3-qb0"/>
<constraint firstItem="iUx-vA-jg4" firstAttribute="leading" secondItem="gBj-K1-Q2I" secondAttribute="trailing" constant="12" symbolic="YES" id="3fW-pY-HBu"/>
<constraint firstItem="gBj-K1-Q2I" firstAttribute="top" secondItem="B8f-nb-Y0A" secondAttribute="top" id="7JI-pU-DnQ"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="iUx-vA-jg4" secondAttribute="trailing" constant="112" id="AVQ-1M-kE4"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="iUx-vA-jg4" secondAttribute="trailing" constant="50" id="AVQ-1M-kE4"/>
<constraint firstItem="iUx-vA-jg4" firstAttribute="top" secondItem="gBj-K1-Q2I" secondAttribute="top" id="O2C-aI-XFS"/>
<constraint firstItem="Bcg-X1-qca" firstAttribute="top" secondItem="gBj-K1-Q2I" secondAttribute="bottom" constant="8" id="Sly-aj-yUl"/>
<constraint firstAttribute="trailing" secondItem="Bcg-X1-qca" secondAttribute="trailing" constant="20" symbolic="YES" id="UPo-Il-l81"/>

View File

@ -11,7 +11,7 @@
<objects>
<windowController storyboardIdentifier="progressWindow" id="LSr-Iw-X1T" customClass="ProgressWindowController" customModule="PHP_Monitor" customModuleProvider="target" sceneMemberID="viewController">
<window key="window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="none" frameAutosaveName="" titlebarAppearsTransparent="YES" titleVisibility="hidden" id="PD9-0p-i0S" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" utility="YES" HUD="YES"/>
<windowStyleMask key="styleMask" titled="YES" closable="YES" utility="YES"/>
<windowPositionMask key="initialPositionMask" rightStrut="YES" topStrut="YES"/>
<rect key="contentRect" x="2080" y="1145" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>

View File

@ -56,7 +56,7 @@ class ProgressWindowController: NSWindowController, NSWindowDelegate {
}
deinit {
print("Deinitializing Progress Window Controller")
// print("Deinitializing Progress Window Controller")
}
}
@ -70,7 +70,7 @@ class ProgressViewController: NSViewController {
@IBOutlet weak var imageViewType: NSImageView!
deinit {
print("Deinitializing Progress View Controller")
// print("Deinitializing Progress View Controller")
}
}

View File

@ -19,17 +19,17 @@
"mi_diagnostics" = "Diagnostics";
"mi_active_services" = "Active Services";
"mi_restart_php_fpm" = "Restart service: php";
"mi_restart_nginx" = "Restart service: nginx";
"mi_restart_dnsmasq" = "Restart service: dnsmasq";
"mi_manage_services" = "Manage services";
"mi_restart_all_services" = "Restart all services";
"mi_stop_all_services" = "Stop all services";
"mi_force_load_latest" = "Force load (latest) PHP %@";
"mi_force_load_latest_unavailable" = "Force load unavailable (PHP %@ not installed)";
"mi_php_refresh" = "Refresh information";
"mi_restart_php_fpm" = "Restart Service: php";
"mi_restart_nginx" = "Restart Service: nginx";
"mi_restart_dnsmasq" = "Restart Service: dnsmasq";
"mi_manage_services" = "Manage Services";
"mi_restart_all_services" = "Restart All Services";
"mi_stop_all_services" = "Stop All Services";
"mi_force_load_latest" = "Force Load (Latest) PHP %@";
"mi_force_load_latest_unavailable" = "Force Load Unavailable (PHP %@ Not Installed)";
"mi_php_refresh" = "Refresh Information";
"mi_configuration" = "Configuration";
"mi_configuration" = "PHP Configuration";
"mi_limits" = "Limits Configuration";
"mi_memory_limit" = "Memory Limit";
"mi_post_max_size" = "Max POST";
@ -37,15 +37,15 @@
"mi_composer" = "Composer";
"mi_valet_config" = "Locate Valet folder (.config/valet)";
"mi_php_config" = "Locate PHP configuration file (php.ini)";
"mi_global_composer" = "Locate global composer.json file (.composer)";
"mi_phpinfo" = "Show current configuration (phpinfo)";
"mi_update_global_composer" = "Update global Composer dependencies";
"mi_php_config" = "Locate PHP Configuration File (php.ini)";
"mi_global_composer" = "Locate Global Composer File (.composer)";
"mi_phpinfo" = "Show Current Configuration (phpinfo)";
"mi_update_global_composer" = "Update Global Composer Dependencies...";
"mi_detected_extensions" = "Detected Extensions";
"mi_no_extensions_detected" = "No additional extensions detected.";
"mi_valet" = "Laravel Valet";
"mi_sitelist" = "View linked & parked domains...";
"mi_sitelist" = "View Linked and Parked Domains...";
"mi_preferences" = "Preferences...";
"mi_quit" = "Quit PHP Monitor";
@ -93,30 +93,25 @@
"prefs.switcher" = "Switcher:";
"prefs.auto_restart_services_title" = "Auto-restart PHP-FPM";
"prefs.auto_restart_services_desc" = "When checked, will automatically restart PHP-FPM when\nyou check or uncheck an extension. Slightly slower when enabled, \nbut this applies the extension change immediately for all sites \nyou're serving, no need to restart PHP-FPM manually.";
"prefs.auto_restart_services_desc" = "When checked, will automatically restart PHP-FPM when you check or uncheck an extension. Slightly slower when enabled, but this applies the extension change immediately for all sites you're serving, no need to restart PHP-FPM manually.";
"prefs.dynamic_icon_title" = "Display dynamic icon in menu bar";
"prefs.dynamic_icon_desc" = "If you uncheck this box, the truck icon will always be visible.\nIf checked, it will display the major version number of the\ncurrently linked PHP version.";
"prefs.dynamic_icon_desc" = "If you uncheck this box, the truck icon will always be visible. If checked, it will display the major version number of the currently linked PHP version.";
"prefs.display_full_php_version" = "Display full PHP version in menu bar";
"prefs.display_full_php_version_desc" = "Display the full version instead of the major version only.\n(This may be undesirable on smaller displays,\nso this is disabled by default.)";
"prefs.display_full_php_version_desc" = "Display the full version instead of the major version only. (This may be undesirable on smaller displays, so this is disabled by default.)";
"prefs.use_internal_switcher" = "Use PHP Monitors own version switcher";
"prefs.use_internal_switcher_desc" =
"By default, PHP Monitor will attempt to use Laravel Valet
in order to switch PHP versions. If you prefer a different
switcher or are having issues with `valet use php`, you may
use PHP Monitor's own switcher which is slightly faster,
but might cause issues with permissions in your Homebrew
directories, since PHP Monitor controls the services.";
"By default, PHP Monitor will attempt to use Laravel Valet in order to switch PHP versions. If you prefer a different switcher or are having issues with `valet use php`, you may use PHP Monitor's own switcher which is slightly faster, but might cause issues with permissions in your Homebrew directories, since PHP Monitor controls the services.";
"prefs.auto_composer_update_title" = "Automatically run `composer global update`";
"prefs.auto_composer_update_desc" = "When checked, will automatically ask Composer to run\n`global update` whenever you switch versions. This will update\nall global dependencies every time you switch.";
"prefs.auto_composer_update_title" = "Automatically update global dependencies";
"prefs.auto_composer_update_desc" = "When checked, will automatically ask Composer to run `composer global update` whenever you switch between different PHP versions. You will be able to see what changes are being made, or should this fail.";
"prefs.shortcut_set" = "Set global shortcut";
"prefs.shortcut_listening" = "<listening for keypress>";
"prefs.shortcut_clear" = "Clear";
"prefs.shortcut_desc" = "If a shortcut combination is set up, you can toggle PHP Monitor\nwherever you are by pressing the key combination you chose.\n(Cancel choosing a shortcut by pressing the spacebar.)";
"prefs.shortcut_desc" = "If a shortcut combination is set up, you can toggle PHP Monitor wherever you are by pressing the key combination you chose. (Cancel choosing a shortcut by pressing the spacebar.)";
// NOTIFICATIONS
@ -136,13 +131,16 @@ directories, since PHP Monitor controls the services.";
// Composer Update
"alert.composer_progress.title" = "Updating global dependencies...";
"alert.composer_progress.info" = "Your global Composer dependencies are being updated. Please wait a bit!";
"alert.composer_progress.info" = "You can see the progress in the terminal output below.";
"alert.composer_success.title" = "Global dependencies updated";
"alert.composer_success.info" = "Your global Composer dependencies have been updated.";
"alert.composer_failure.title" = "Something went wrong!";
"alert.composer_failure.info" = "Your global Composer dependencies could not be updated.
You can find more information in the terminal output below. Youll have to fix this
problem manually, using your own Terminal app (this just shows you the output).";
"alert.composer_failure.title" = "Updating global dependencies failed";
"alert.composer_failure.info" = "Something went wrong updating your global Composer dependencies. You can find more information in the terminal output below. Youll have to manually fix this problem in your own terminal.";
"alert.composer_success.title" = "Composers done updating!";
"alert.composer_success.info" = "Your global Composer dependencies have been successfully updated.";
// Force Reload Started
"alert.force_reload.title" = "PHP Monitor will force reload the latest version of PHP";