mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Check an item's allowed locations when moving/copying to pane
This commit is contained in:
@@ -480,6 +480,26 @@ describe('WorkspaceElement', () => {
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
describe('::moveActiveItemToNearestPaneInDirection(direction, params)', () => {
|
||||
describe('when the item is not allowed in nearest pane in the given direction', () => {
|
||||
it('does not move or copy the active item', function () {
|
||||
const item = {
|
||||
element: document.createElement('div'),
|
||||
getAllowedLocations: () => ['left', 'right'],
|
||||
}
|
||||
|
||||
workspace.getBottomDock().show()
|
||||
startingPane.activate()
|
||||
startingPane.activateItem(item)
|
||||
workspaceElement.moveActiveItemToNearestPaneInDirection('below', {keepOriginal: false})
|
||||
expect(workspace.paneForItem(item)).toBe(startingPane)
|
||||
|
||||
workspaceElement.moveActiveItemToNearestPaneInDirection('below', {keepOriginal: true})
|
||||
expect(workspace.paneForItem(item)).toBe(startingPane)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('mousing over docks', () => {
|
||||
|
||||
@@ -213,12 +213,22 @@ class PaneContainer {
|
||||
|
||||
moveActiveItemToPane (destPane) {
|
||||
const item = this.activePane.getActiveItem()
|
||||
|
||||
if (typeof item.getAllowedLocations === 'function' && !item.getAllowedLocations().includes(destPane.getContainer().getLocation())) {
|
||||
return
|
||||
}
|
||||
|
||||
this.activePane.moveItemToPane(item, destPane)
|
||||
destPane.setActiveItem(item)
|
||||
}
|
||||
|
||||
copyActiveItemToPane (destPane) {
|
||||
const item = this.activePane.copyActiveItem()
|
||||
|
||||
if (typeof item.getAllowedLocations === 'function' && !item.getAllowedLocations().includes(destPane.getContainer().getLocation())) {
|
||||
return
|
||||
}
|
||||
|
||||
destPane.activateItem(item)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user