mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
✨ Allow unlinking of sites
This commit is contained in:
@ -765,7 +765,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 100;
|
||||
CURRENT_PROJECT_VERSION = 105;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = phpmon/Info.plist;
|
||||
@ -790,7 +790,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 100;
|
||||
CURRENT_PROJECT_VERSION = 105;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = phpmon/Info.plist;
|
||||
|
@ -613,7 +613,7 @@ Gw
|
||||
<scene sceneID="aZt-6w-TFl">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="siteList" id="JZI-Vd-9oq" customClass="SiteListVC" customModule="PHP_Monitor" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" misplaced="YES" id="rIZ-4U-bhj">
|
||||
<view key="view" id="rIZ-4U-bhj">
|
||||
<rect key="frame" x="0.0" y="0.0" width="550" height="309"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
|
@ -27,6 +27,30 @@ class Alert {
|
||||
return alert.runModal() == .alertFirstButtonReturn
|
||||
}
|
||||
|
||||
public static func confirm(
|
||||
onWindow window: NSWindow,
|
||||
messageText: String,
|
||||
informativeText: String,
|
||||
buttonTitle: String = "OK",
|
||||
secondButtonTitle: String = "Cancel",
|
||||
style: NSAlert.Style = .warning,
|
||||
onFirstButtonPressed: @escaping (() -> Void)
|
||||
) {
|
||||
let alert = NSAlert.init()
|
||||
alert.alertStyle = style
|
||||
alert.messageText = messageText
|
||||
alert.informativeText = informativeText
|
||||
alert.addButton(withTitle: buttonTitle)
|
||||
if (!secondButtonTitle.isEmpty) {
|
||||
alert.addButton(withTitle: secondButtonTitle)
|
||||
}
|
||||
alert.beginSheetModal(for: window) { response in
|
||||
if response == .alertFirstButtonReturn {
|
||||
onFirstButtonPressed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static func notify(message: String, info: String, style: NSAlert.Style = .informational) {
|
||||
_ = present(
|
||||
messageText: message,
|
||||
|
@ -202,6 +202,30 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
||||
Shell.run("open \(selectedSite!.absolutePath!)")
|
||||
}
|
||||
|
||||
@objc public func unlinkSite() {
|
||||
guard let site = selectedSite else {
|
||||
return
|
||||
}
|
||||
|
||||
if site.aliasPath == nil {
|
||||
return
|
||||
}
|
||||
|
||||
Alert.confirm(
|
||||
onWindow: view.window!,
|
||||
messageText: "site_list.confirm_unlink".localized
|
||||
.replacingOccurrences(of: "%@", with: site.name),
|
||||
informativeText: "site_link.confirm_link".localized,
|
||||
buttonTitle: "site_list.unlink".localized,
|
||||
secondButtonTitle: "Cancel",
|
||||
style: .critical,
|
||||
onFirstButtonPressed: {
|
||||
Shell.run("valet unlink \(site.name!)", requiresPath: true)
|
||||
self.reloadSites()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - (Search) Text Field Delegate
|
||||
|
||||
func searchedFor(text: String) {
|
||||
@ -232,6 +256,15 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
||||
return
|
||||
}
|
||||
|
||||
if (site.aliasPath != nil) {
|
||||
menu.addItem(
|
||||
withTitle: "site_list.unlink".localized,
|
||||
action: #selector(self.unlinkSite),
|
||||
keyEquivalent: "U"
|
||||
)
|
||||
menu.addItem(NSMenuItem.separator())
|
||||
}
|
||||
|
||||
menu.addItem(
|
||||
withTitle: site.secured
|
||||
? "site_list.unsecure".localized
|
||||
|
@ -59,8 +59,12 @@
|
||||
"site_list.alerts_status_changed.title" = "SSL Status Changed";
|
||||
"site_list.alerts_status_changed.desc" = "The domain '{@1}' is now {@2}.";
|
||||
|
||||
"site_list.confirm_unlink" = "Are you sure you want to unlink '%@'?";
|
||||
"site_link.confirm_link" = "No files will be removed. If needed, the site will need to be relinked via the command line.";
|
||||
|
||||
// SITE LIST ACTIONS
|
||||
|
||||
"site_list.unlink" = "Unlink";
|
||||
"site_list.secure" = "Secure";
|
||||
"site_list.unsecure" = "Unsecure";
|
||||
"site_list.open_in_finder" = "Open in Finder";
|
||||
|
Reference in New Issue
Block a user