Check an item's allowed locations when moving/copying to pane

This commit is contained in:
Jason Rudolph
2017-06-07 12:59:54 -04:00
parent 5c5fb28da1
commit 296e407284
2 changed files with 30 additions and 0 deletions

View File

@@ -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', () => {

View File

@@ -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)
}