mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
👌 Handle errors when adding moved folder
This commit is contained in:
@ -28,6 +28,11 @@ class AddSiteVC: NSViewController, NSTextFieldDelegate {
|
||||
loadStaticLocalisedStrings()
|
||||
}
|
||||
|
||||
private func dismissView(outcome: NSApplication.ModalResponse) {
|
||||
guard let window = self.view.window, let parent = window.sheetParent else { return }
|
||||
parent.endSheet(window, returnCode: outcome)
|
||||
}
|
||||
|
||||
// MARK: - Localisation
|
||||
|
||||
func loadStaticLocalisedStrings() {
|
||||
@ -42,9 +47,23 @@ class AddSiteVC: NSViewController, NSTextFieldDelegate {
|
||||
let path = self.pathControl.url!.path
|
||||
let name = self.linkName.stringValue
|
||||
|
||||
// TODO: Check if the path still exists
|
||||
if !FileManager.default.fileExists(atPath: path) {
|
||||
Alert.confirm(
|
||||
onWindow: self.view.window!,
|
||||
messageText: "site_list.alert.folder_missing.title".localized,
|
||||
informativeText: "site_list.alert.folder_missing.desc".localized,
|
||||
buttonTitle: "site_list.alert.folder_missing.cancel".localized,
|
||||
secondButtonTitle: "site_list.alert.folder_missing.return".localized,
|
||||
onFirstButtonPressed: {
|
||||
self.dismissView(outcome: .cancel)
|
||||
}
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
Shell.run("cd '\(path)' && \(Paths.valet) link '\(name)'", requiresPath: true)
|
||||
self.view.window!.close()
|
||||
|
||||
self.dismissView(outcome: .OK)
|
||||
|
||||
// Reset search
|
||||
App.shared.siteListWindowController?
|
||||
@ -61,7 +80,7 @@ class AddSiteVC: NSViewController, NSTextFieldDelegate {
|
||||
}
|
||||
|
||||
@IBAction func pressedCancel(_ sender: Any) {
|
||||
self.view.window!.close()
|
||||
self.dismissView(outcome: .cancel)
|
||||
}
|
||||
|
||||
@IBAction func pressedSecure(_ sender: Any) {
|
||||
|
@ -62,16 +62,15 @@ class SiteListWC: PMWindowController, NSSearchFieldDelegate, NSToolbarDelegate {
|
||||
|
||||
func selectFolder() {
|
||||
let dialog = NSOpenPanel()
|
||||
dialog.title = "Select a Folder"
|
||||
dialog.message = "site_list.add.modal_description".localized
|
||||
dialog.showsResizeIndicator = true
|
||||
dialog.showsHiddenFiles = false
|
||||
dialog.allowsMultipleSelection = false
|
||||
dialog.canChooseDirectories = true
|
||||
dialog.canChooseFiles = false
|
||||
|
||||
if (dialog.runModal() == NSApplication.ModalResponse.OK) {
|
||||
dialog.beginSheetModal(for: self.window!) { response in
|
||||
let result = dialog.url
|
||||
if (result != nil) {
|
||||
if (result != nil && response == .OK) {
|
||||
let path: String = result!.path
|
||||
self.showSitePopup(path)
|
||||
}
|
||||
|
@ -67,7 +67,7 @@
|
||||
"site_list.alerts_status_changed.desc" = "The domain '%@' is now %@.";
|
||||
|
||||
"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_link.confirm_link" = "No files will be removed. You can always link the folder again by clicking on the + button and selecting the original folder.";
|
||||
|
||||
"site_link.close" = "Close";
|
||||
"site_link.switch_to_php" = "Switch to PHP %@";
|
||||
@ -85,6 +85,16 @@
|
||||
"site_list.add.errors.empty" = "You must enter a name.";
|
||||
"site_list.add.errors.already_exists" = "A link with that name already exists.";
|
||||
|
||||
// ADD SITE ERROR: FOLDER MISSING SINCE SELECTION
|
||||
|
||||
"site_list.alert.folder_missing.desc" = "The folder you chose no longer seems to exist. Do you want to cancel adding this folder? If you moved the folder, you could always put it back and try again.";
|
||||
"site_list.alert.folder_missing.title" = "Folder missing!";
|
||||
"site_list.alert.folder_missing.cancel" = "Cancel Link";
|
||||
"site_list.alert.folder_missing.return" = "OK";
|
||||
|
||||
|
||||
"site_list.add.modal_description" = "First, select which folder you would like to link.";
|
||||
|
||||
// SITE LIST ACTIONS
|
||||
|
||||
"site_list.unlink" = "Unlink Directory";
|
||||
|
Reference in New Issue
Block a user