Skip to content

Commit

Permalink
Enable import menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
ashchan committed Jan 24, 2022
1 parent d9b034e commit adce4a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion macOS/Commands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct DesktopCommands: Commands {
Button("Import...") {
NotificationCenter.default.post(name: .willImportNotification, object: nil)
}
.disabled(true)
Button("Export...") {
NotificationCenter.default.post(name: .willExportNotification, object: nil)
}
Expand Down
14 changes: 13 additions & 1 deletion macOS/Views/Sidebar/Sidebar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ private extension Sidebar {
}

func importPortfolios() {
// TODO
if let importUrl = showImportDialog() {
// TODO
}
}

func exportPortfolios() {
Expand Down Expand Up @@ -201,6 +203,16 @@ private extension Sidebar {
let response = savePanel.runModal()
return response == .OK ? savePanel.url : nil
}

func showImportDialog() -> URL? {
let openPanel = NSOpenPanel()
openPanel.allowedFileTypes = ["json"]
openPanel.allowsMultipleSelection = false
openPanel.canChooseDirectories = false
openPanel.canChooseFiles = true
let response = openPanel.runModal()
return response == .OK ? openPanel.url : nil
}
}

struct Sidebar_Previews: PreviewProvider {
Expand Down

0 comments on commit adce4a9

Please sign in to comment.