mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
🎨 Extract function: Pane::isItemAllowed(item)
This commit is contained in:
@@ -214,9 +214,7 @@ class PaneContainer {
|
||||
moveActiveItemToPane (destPane) {
|
||||
const item = this.activePane.getActiveItem()
|
||||
|
||||
if (typeof item.getAllowedLocations === 'function' && !item.getAllowedLocations().includes(destPane.getContainer().getLocation())) {
|
||||
return
|
||||
}
|
||||
if (!destPane.isItemAllowed(item)) { return }
|
||||
|
||||
this.activePane.moveItemToPane(item, destPane)
|
||||
destPane.setActiveItem(item)
|
||||
@@ -225,9 +223,7 @@ class PaneContainer {
|
||||
copyActiveItemToPane (destPane) {
|
||||
const item = this.activePane.copyActiveItem()
|
||||
|
||||
if (typeof item.getAllowedLocations === 'function' && !item.getAllowedLocations().includes(destPane.getContainer().getLocation())) {
|
||||
return
|
||||
}
|
||||
if (!destPane.isItemAllowed(item)) { return }
|
||||
|
||||
destPane.activateItem(item)
|
||||
}
|
||||
|
||||
@@ -91,6 +91,17 @@ class Pane
|
||||
@container = container
|
||||
container.didAddPane({pane: this})
|
||||
|
||||
# Private: Determine whether the given item is allowed to exist in this pane.
|
||||
#
|
||||
# * `item` the Item
|
||||
#
|
||||
# Returns a {Boolean}.
|
||||
isItemAllowed: (item) ->
|
||||
if (typeof item.getAllowedLocations isnt 'function')
|
||||
true
|
||||
else
|
||||
item.getAllowedLocations().includes(@getContainer().getLocation())
|
||||
|
||||
setFlexScale: (@flexScale) ->
|
||||
@emitter.emit 'did-change-flex-scale', @flexScale
|
||||
@flexScale
|
||||
|
||||
Reference in New Issue
Block a user