Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Support drag and drop urlbar icon onto bookmark folders
Browse files Browse the repository at this point in the history
Fix #11180

This mostly just reverts a subset of:
d82f171

This is only for 0.19.x and 0.20.x

Master can get a better fix so tests and refactoring will be done in:
#11226

Since the tests would not be valid past 0.20.x I'm not covering any new
0.19.x and 0.20.x only tests here.  Also we don't have drag and drop
under tets at all.  In master with the refactor since we have bookmark
toolbar width in state we'll be able to do everything in the reducer and so also be able
to add tests.

Auditors: @bsclifton
  • Loading branch information
bbondy committed Oct 1, 2017
1 parent 3b3fba2 commit 7671ae9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 6 additions & 2 deletions app/renderer/components/bookmarks/bookmarksToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const dndData = require('../../../../js/dndData')
const isWindows = require('../../../common/lib/platformUtil').isWindows()
const frameStateUtil = require('../../../../js/state/frameStateUtil')
const bookmarkUtil = require('../../../common/lib/bookmarkUtil')
const siteUtil = require('../../../../js/state/siteUtil')

// Styles
const globalStyles = require('../styles/global')
Expand All @@ -58,13 +59,16 @@ class BookmarksToolbar extends React.Component {
const bookmark = dnd.prepareBookmarkDataFromCompatible(e.dataTransfer)
if (bookmark) {
// Figure out the droppedOn element filtering out the source drag item
const bookmarkKey = bookmark.get('bookmarkKey')
let bookmarkKey = bookmark.get('bookmarkKey')
if (bookmarkKey === undefined) {
bookmarkKey = siteUtil.getSiteKey(bookmark)
}
const droppedOn = getClosestFromPos(e.clientX, bookmarkKey)
if (droppedOn.selectedRef) {
const isLeftSide = dnd.isLeftSide(ReactDOM.findDOMNode(droppedOn.selectedRef), e.clientX)
const droppedOnKey = droppedOn.selectedRef.props.bookmarkKey
const isDestinationParent = droppedOn.selectedRef.state.isFolder && droppedOn && droppedOn.isDroppedOn
appActions.moveSite(bookmark.get('bookmarkKey'), droppedOnKey, isLeftSide, isDestinationParent)
appActions.moveSite(bookmarkKey, droppedOnKey, isLeftSide, isDestinationParent)
dnd.onDragEnd()
}
return
Expand Down
5 changes: 4 additions & 1 deletion app/renderer/components/navigation/urlBarIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ class UrlBarIcon extends React.Component {
onDragStart (e) {
dndData.setupDataTransferURL(e.dataTransfer, this.props.location, this.props.title)
dndData.setupDataTransferBraveData(e.dataTransfer, dragTypes.TAB, {
tabId: this.props.tabId
tabId: this.props.tabId,
location: this.props.location,
title: this.props.title,
partitionNumber: this.props.partitionNumber
})
}

Expand Down
7 changes: 4 additions & 3 deletions js/dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const appActions = require('./actions/appActions')
const ReactDOM = require('react-dom')
const dndData = require('./dndData')
const dragTypes = require('./constants/dragTypes')
const siteTags = require('./constants/siteTags')
const appStoreRenderer = require('./stores/appStoreRenderer')
const {getCurrentWindowId} = require('../app/renderer/currentWindow')
const {ESC} = require('../app/common/constants/keyCodes.js')
Expand Down Expand Up @@ -135,9 +136,9 @@ module.exports.isMiddle = (domNode, clientX) => {
module.exports.prepareBookmarkDataFromCompatible = (dataTransfer) => {
let bookmark = dndData.getDragData(dataTransfer, dragTypes.BOOKMARK)
if (!bookmark) {
const dragData = dndData.getDragData(dataTransfer, dragTypes.TAB)
if (dragData) {
windowActions.onFrameBookmark(dragData.get('tabId'))
bookmark = dndData.getDragData(dataTransfer, dragTypes.TAB)
if (bookmark) {
appActions.addSite(bookmark, siteTags.BOOKMARK)
}
}
return bookmark
Expand Down

0 comments on commit 7671ae9

Please sign in to comment.