mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
👌 Offer to switch back to prev version (#141)
This commit is contained in:
@ -65,6 +65,7 @@
|
|||||||
C4232EE52612526500158FC6 /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = C4232EE42612526500158FC6 /* Credits.html */; };
|
C4232EE52612526500158FC6 /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = C4232EE42612526500158FC6 /* Credits.html */; };
|
||||||
C42759672627662800093CAE /* NSMenuExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42759662627662800093CAE /* NSMenuExtension.swift */; };
|
C42759672627662800093CAE /* NSMenuExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42759662627662800093CAE /* NSMenuExtension.swift */; };
|
||||||
C42759682627662800093CAE /* NSMenuExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42759662627662800093CAE /* NSMenuExtension.swift */; };
|
C42759682627662800093CAE /* NSMenuExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42759662627662800093CAE /* NSMenuExtension.swift */; };
|
||||||
|
C42C49DB27C2806F0074ABAC /* MainMenu+FixMyValet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42C49DA27C2806F0074ABAC /* MainMenu+FixMyValet.swift */; };
|
||||||
C43603A0275E67610028EFC6 /* AppDelegate+Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */; };
|
C43603A0275E67610028EFC6 /* AppDelegate+Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */; };
|
||||||
C43603A1275E67610028EFC6 /* AppDelegate+Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */; };
|
C43603A1275E67610028EFC6 /* AppDelegate+Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */; };
|
||||||
C43A8A1A25D9CD1000591B77 /* Utility.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A8A1925D9CD1000591B77 /* Utility.swift */; };
|
C43A8A1A25D9CD1000591B77 /* Utility.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A8A1925D9CD1000591B77 /* Utility.swift */; };
|
||||||
@ -246,6 +247,7 @@
|
|||||||
C41E87192763D42300161EE0 /* SiteListVC+ContextMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SiteListVC+ContextMenu.swift"; sourceTree = "<group>"; };
|
C41E87192763D42300161EE0 /* SiteListVC+ContextMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SiteListVC+ContextMenu.swift"; sourceTree = "<group>"; };
|
||||||
C4232EE42612526500158FC6 /* Credits.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = Credits.html; sourceTree = "<group>"; };
|
C4232EE42612526500158FC6 /* Credits.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = Credits.html; sourceTree = "<group>"; };
|
||||||
C42759662627662800093CAE /* NSMenuExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSMenuExtension.swift; sourceTree = "<group>"; };
|
C42759662627662800093CAE /* NSMenuExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSMenuExtension.swift; sourceTree = "<group>"; };
|
||||||
|
C42C49DA27C2806F0074ABAC /* MainMenu+FixMyValet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MainMenu+FixMyValet.swift"; sourceTree = "<group>"; };
|
||||||
C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+Notifications.swift"; sourceTree = "<group>"; };
|
C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+Notifications.swift"; sourceTree = "<group>"; };
|
||||||
C43A8A1925D9CD1000591B77 /* Utility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utility.swift; sourceTree = "<group>"; };
|
C43A8A1925D9CD1000591B77 /* Utility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utility.swift; sourceTree = "<group>"; };
|
||||||
C43A8A1F25D9D1D700591B77 /* brew.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = brew.json; sourceTree = "<group>"; };
|
C43A8A1F25D9D1D700591B77 /* brew.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = brew.json; sourceTree = "<group>"; };
|
||||||
@ -531,6 +533,7 @@
|
|||||||
C44CCD4827AFF3B700CE40E5 /* MainMenu+Async.swift */,
|
C44CCD4827AFF3B700CE40E5 /* MainMenu+Async.swift */,
|
||||||
C4CE3BB727B31F2E0086CA49 /* MainMenu+Switcher.swift */,
|
C4CE3BB727B31F2E0086CA49 /* MainMenu+Switcher.swift */,
|
||||||
C4CE3BB927B31F670086CA49 /* MainMenu+Composer.swift */,
|
C4CE3BB927B31F670086CA49 /* MainMenu+Composer.swift */,
|
||||||
|
C42C49DA27C2806F0074ABAC /* MainMenu+FixMyValet.swift */,
|
||||||
C47331A1247093B7009A0597 /* StatusMenu.swift */,
|
C47331A1247093B7009A0597 /* StatusMenu.swift */,
|
||||||
C48D0C9525CC80B100CC7490 /* HeaderView.swift */,
|
C48D0C9525CC80B100CC7490 /* HeaderView.swift */,
|
||||||
C48D0C9925CC888B00CC7490 /* HeaderView.xib */,
|
C48D0C9925CC888B00CC7490 /* HeaderView.xib */,
|
||||||
@ -841,6 +844,7 @@
|
|||||||
files = (
|
files = (
|
||||||
C4ACA38F25C754C100060C66 /* PhpExtension.swift in Sources */,
|
C4ACA38F25C754C100060C66 /* PhpExtension.swift in Sources */,
|
||||||
C4D8016622B1584700C6DA1B /* Startup.swift in Sources */,
|
C4D8016622B1584700C6DA1B /* Startup.swift in Sources */,
|
||||||
|
C42C49DB27C2806F0074ABAC /* MainMenu+FixMyValet.swift in Sources */,
|
||||||
C48D6C70279CD2AC00F26D7E /* PhpVersionNumber.swift in Sources */,
|
C48D6C70279CD2AC00F26D7E /* PhpVersionNumber.swift in Sources */,
|
||||||
C4B585412770FE3900DA4FBE /* Shell.swift in Sources */,
|
C4B585412770FE3900DA4FBE /* Shell.swift in Sources */,
|
||||||
C4998F0A2617633900B2526E /* PrefsWC.swift in Sources */,
|
C4998F0A2617633900B2526E /* PrefsWC.swift in Sources */,
|
||||||
|
81
phpmon/Domain/Menu/MainMenu+FixMyValet.swift
Normal file
81
phpmon/Domain/Menu/MainMenu+FixMyValet.swift
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
//
|
||||||
|
// MainMenu+FixMyValet.swift
|
||||||
|
// PHP Monitor
|
||||||
|
//
|
||||||
|
// Created by Nico Verbruggen on 20/02/2022.
|
||||||
|
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
extension MainMenu {
|
||||||
|
|
||||||
|
@objc func fixMyValet() {
|
||||||
|
let previousVersion = PhpEnv.phpInstall.version.short
|
||||||
|
|
||||||
|
if !PhpEnv.shared.availablePhpVersions.contains(PhpEnv.brewPhpVersion) {
|
||||||
|
presentAlertForMissingFormula()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !BetterAlert()
|
||||||
|
.withInformation(
|
||||||
|
title: "alert.fix_my_valet.title".localized,
|
||||||
|
subtitle: "alert.fix_my_valet.info".localized(PhpEnv.brewPhpVersion)
|
||||||
|
)
|
||||||
|
.withPrimary(text: "alert.fix_my_valet.ok".localized)
|
||||||
|
.withSecondary(text: "alert.fix_my_valet.cancel".localized)
|
||||||
|
.didSelectPrimary()
|
||||||
|
{
|
||||||
|
Log.info("The user has chosen to abort Fix My Valet")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
asyncExecution {
|
||||||
|
Actions.fixMyValet()
|
||||||
|
} success: {
|
||||||
|
if previousVersion == PhpEnv.brewPhpVersion {
|
||||||
|
self.presentAlertForSameVersion()
|
||||||
|
} else {
|
||||||
|
self.presentAlertForDifferentVersion(version: previousVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func presentAlertForMissingFormula() {
|
||||||
|
BetterAlert()
|
||||||
|
.withInformation(
|
||||||
|
title: "alert.php_formula_missing.title".localized,
|
||||||
|
subtitle: "alert.php_formula_missing.info".localized
|
||||||
|
)
|
||||||
|
.withPrimary(text: "OK")
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func presentAlertForSameVersion() {
|
||||||
|
BetterAlert()
|
||||||
|
.withInformation(
|
||||||
|
title: "alert.fix_my_valet_done.title".localized,
|
||||||
|
subtitle: "alert.fix_my_valet_done.subtitle".localized,
|
||||||
|
description: "alert.fix_my_valet_done.desc".localized
|
||||||
|
)
|
||||||
|
.withPrimary(text: "OK")
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func presentAlertForDifferentVersion(version: String) {
|
||||||
|
BetterAlert()
|
||||||
|
.withInformation(
|
||||||
|
title: "alert.fix_my_valet_done.title".localized,
|
||||||
|
subtitle: "alert.fix_my_valet_done.subtitle".localized,
|
||||||
|
description: "alert.fix_my_valet_done.desc".localized
|
||||||
|
)
|
||||||
|
.withPrimary(text: "alert.fix_my_valet_done.stay".localized(PhpEnv.brewPhpVersion))
|
||||||
|
.withSecondary(text: "alert.fix_my_valet_done.switch_back".localized(version), action: { alert in
|
||||||
|
alert.close(with: .alertSecondButtonReturn)
|
||||||
|
MainMenu.shared.switchToPhpVersion(version)
|
||||||
|
})
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -262,48 +262,6 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func fixMyValet() {
|
|
||||||
if !PhpEnv.shared.availablePhpVersions.contains(PhpEnv.brewPhpVersion) {
|
|
||||||
BetterAlert()
|
|
||||||
.withInformation(
|
|
||||||
title: "alert.php_formula_missing.title".localized,
|
|
||||||
subtitle: "alert.php_formula_missing.info".localized
|
|
||||||
)
|
|
||||||
.withPrimary(text: "OK")
|
|
||||||
.show()
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if !BetterAlert()
|
|
||||||
.withInformation(
|
|
||||||
title: "alert.fix_my_valet.title".localized,
|
|
||||||
subtitle: "alert.fix_my_valet.info".localized(PhpEnv.brewPhpVersion)
|
|
||||||
)
|
|
||||||
.withPrimary(text: "alert.fix_my_valet.ok".localized)
|
|
||||||
.withSecondary(text: "alert.fix_my_valet.cancel".localized)
|
|
||||||
.didSelectPrimary()
|
|
||||||
{
|
|
||||||
Log.info("The user has chosen to abort Fix My Valet")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
asyncExecution {
|
|
||||||
Actions.fixMyValet()
|
|
||||||
} success: {
|
|
||||||
BetterAlert()
|
|
||||||
.withInformation(
|
|
||||||
title: "alert.fix_my_valet_done.title".localized,
|
|
||||||
subtitle: "alert.fix_my_valet_done.subtitle".localized,
|
|
||||||
description: "alert.fix_my_valet_done.desc".localized
|
|
||||||
)
|
|
||||||
.withPrimary(text: "alert.fix_my_valet.ok".localized)
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc func updateGlobalComposerDependencies() {
|
@objc func updateGlobalComposerDependencies() {
|
||||||
self.updateGlobalDependencies(notify: true, completion: { _ in })
|
self.updateGlobalDependencies(notify: true, completion: { _ in })
|
||||||
}
|
}
|
||||||
|
@ -219,6 +219,8 @@ problem manually, using your own Terminal app (this just shows you the output)."
|
|||||||
// Fix My Valet Done
|
// Fix My Valet Done
|
||||||
"alert.fix_my_valet_done.title" = "Fix My Valet has completed its operations.";
|
"alert.fix_my_valet_done.title" = "Fix My Valet has completed its operations.";
|
||||||
"alert.fix_my_valet_done.subtitle" = "All appropriate services have been stopped and the correct ones restarted, and the latest version of PHP should now be active. You can now try switching to another version of PHP.";
|
"alert.fix_my_valet_done.subtitle" = "All appropriate services have been stopped and the correct ones restarted, and the latest version of PHP should now be active. You can now try switching to another version of PHP.";
|
||||||
|
"alert.fix_my_valet_done.stay" = "Stay on PHP %@";
|
||||||
|
"alert.fix_my_valet_done.switch_back" = "Switch back to PHP %@";
|
||||||
"alert.fix_my_valet_done.desc" = "If visiting sites still does not work, you may try running `valet install` again, this can fix a 502 issue (Bad Gateway).\n\nIf Valet is broken and you cannot run `valet install`, you may need to run `composer global update`. Please consult the FAQ on GitHub if you have further issues.";
|
"alert.fix_my_valet_done.desc" = "If visiting sites still does not work, you may try running `valet install` again, this can fix a 502 issue (Bad Gateway).\n\nIf Valet is broken and you cannot run `valet install`, you may need to run `composer global update`. Please consult the FAQ on GitHub if you have further issues.";
|
||||||
|
|
||||||
// Restore Homebrew Permissions
|
// Restore Homebrew Permissions
|
||||||
|
Reference in New Issue
Block a user