mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Allow items to provide savePanel options.
This commit is contained in:
@@ -3,7 +3,7 @@ Pane = require '../src/pane'
|
||||
PaneAxis = require '../src/pane-axis'
|
||||
PaneContainer = require '../src/pane-container'
|
||||
|
||||
describe "Pane", ->
|
||||
fdescribe "Pane", ->
|
||||
deserializerDisposable = null
|
||||
|
||||
class Item extends Model
|
||||
@@ -414,7 +414,7 @@ describe "Pane", ->
|
||||
pane.getActiveItem().path = __filename
|
||||
pane.getActiveItem().saveAs = jasmine.createSpy("saveAs")
|
||||
pane.saveActiveItemAs()
|
||||
expect(atom.showSaveDialogSync).toHaveBeenCalledWith(__filename)
|
||||
expect(atom.showSaveDialogSync).toHaveBeenCalledWith(defaultPath: __filename)
|
||||
expect(pane.getActiveItem().saveAs).toHaveBeenCalledWith('/selected/path')
|
||||
|
||||
describe "when the current item does not have a saveAs method", ->
|
||||
|
||||
@@ -783,11 +783,12 @@ class Atom extends Model
|
||||
showSaveDialog: (callback) ->
|
||||
callback(showSaveDialogSync())
|
||||
|
||||
showSaveDialogSync: (defaultPath) ->
|
||||
defaultPath ?= @project?.getPaths()[0]
|
||||
showSaveDialogSync: (options={}) ->
|
||||
currentWindow = @getCurrentWindow()
|
||||
dialog = remote.require('dialog')
|
||||
dialog.showSaveDialog currentWindow, {title: 'Save File', defaultPath}
|
||||
options.title ?= 'Save File'
|
||||
options.defaultPath ?= @project?.getPaths()[0]
|
||||
dialog.showSaveDialog currentWindow, options
|
||||
|
||||
saveSync: ->
|
||||
if storageKey = @constructor.getStateKey(@project?.getPaths(), @mode)
|
||||
|
||||
@@ -492,8 +492,9 @@ class Pane extends Model
|
||||
saveItemAs: (item, nextAction) ->
|
||||
return unless item?.saveAs?
|
||||
|
||||
itemPath = item.getPath?()
|
||||
newItemPath = atom.showSaveDialogSync(itemPath)
|
||||
saveOptions = item.getSaveOptions?() or {}
|
||||
saveOptions.defaultPath ?= item.getPath()
|
||||
newItemPath = atom.showSaveDialogSync(saveOptions)
|
||||
if newItemPath
|
||||
try
|
||||
item.saveAs(newItemPath)
|
||||
|
||||
Reference in New Issue
Block a user