Skip to content

Commit

Permalink
馃憣 Various QoL improvements
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
nicoverbruggen committed Dec 19, 2021
1 parent ed49362 commit 267a1da
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 63 deletions.
7 changes: 5 additions & 2 deletions phpmon/Domain/Core/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
18 changes: 14 additions & 4 deletions phpmon/Domain/Menu/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -380,13 +388,15 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
)
}
window = nil
noLongerBusy()
completion(true)
}
} else {
window?.setType(info: false)
window?.progressView?.labelTitle.stringValue = "alert.composer_failure.title".localized
window?.progressView?.labelDescription.stringValue = "alert.composer_failure.info".localized
window = nil
noLongerBusy()
completion(false)
}
}
Expand Down
41 changes: 22 additions & 19 deletions phpmon/Domain/Menu/StatusMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()

if !App.shared.availablePhpVersions.contains(App.shared.brewPhpVersion) {
servicesMenu.addItem(NSMenuItem(
title: "mi_force_load_latest_unavailable".localized(App.shared.brewPhpVersion),
action: nil, keyEquivalent: "f"
))
} else {
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.addForceLoadLatestVersion()
self.setSubmenu(servicesMenu, for: services)
self.addItem(services)

}

func addForceLoadLatestVersion() {
if !App.shared.availablePhpVersions.contains(App.shared.brewPhpVersion) {
self.addItem(NSMenuItem(
title: "mi_force_load_latest_unavailable".localized(App.shared.brewPhpVersion),
action: nil, keyEquivalent: "f"
))
} else {
self.addItem(NSMenuItem(
title: "mi_force_load_latest".localized(App.shared.brewPhpVersion),
action: #selector(MainMenu.forceRestartLatestPhp), keyEquivalent: "f"))
}
}

func addValetMenuItems() {
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion phpmon/Domain/Preferences/Views/HotkeyPreferenceView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
2 changes: 1 addition & 1 deletion phpmon/Domain/Progress/ProgressWindow.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
4 changes: 2 additions & 2 deletions phpmon/Domain/Progress/ProgressWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ProgressWindowController: NSWindowController, NSWindowDelegate {
}

deinit {
print("Deinitializing Progress Window Controller")
// print("Deinitializing Progress Window Controller")
}

}
Expand All @@ -70,7 +70,7 @@ class ProgressViewController: NSViewController {
@IBOutlet weak var imageViewType: NSImageView!

deinit {
print("Deinitializing Progress View Controller")
// print("Deinitializing Progress View Controller")
}

}
66 changes: 32 additions & 34 deletions phpmon/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,33 @@

"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_configuration" = "Configuration";
"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" = "PHP Configuration";
"mi_limits" = "Limits Configuration";
"mi_memory_limit" = "Memory Limit";
"mi_post_max_size" = "Max POST";
"mi_upload_max_filesize" = "Max Upload";

"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";
Expand Down Expand Up @@ -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 Monitor鈥檚 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.";

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

Expand All @@ -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_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. You鈥檒l have to fix this
problem manually, using your own Terminal app (this just shows you the output).";

"alert.composer_success.title" = "Global dependencies updated";
"alert.composer_success.info" = "Your global Composer dependencies have been updated.";

"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. You鈥檒l have to manually fix this problem in your own terminal.";
"alert.composer_success.title" = "Composer鈥檚 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";
Expand Down

0 comments on commit 267a1da

Please sign in to comment.