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

Commit

Permalink
Merge pull request #12515 from NejcZdovc/hotfix/#12476-drop
Browse files Browse the repository at this point in the history
Fixes dnd for url bar icon
  • Loading branch information
cezaraugusto authored Jan 5, 2018
2 parents 233e7e3 + ca6afa3 commit ec24079
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
23 changes: 18 additions & 5 deletions app/renderer/components/bookmarks/bookmarksToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,32 @@ class BookmarksToolbar extends React.Component {
}
return bookmarkRef.props.bookmarkKey !== sourceKey
}), e.clientX)
const bookmark = dnd.prepareBookmarkDataFromCompatible(e.dataTransfer)
let bookmark = dnd.prepareBookmarkDataFromCompatible(e.dataTransfer)
if (bookmark) {
// Figure out the droppedOn element filtering out the source drag item
const bookmarkKey = bookmark.get('key')
let bookmarkKey = bookmark.get('key')
let tabDrop = false

// When we have key null is only when we are getting data from TAB transfer type
if (bookmarkKey == null) {
tabDrop = true
}

const droppedOn = getClosestFromPos(e.clientX, bookmarkKey)
if (droppedOn.selectedRef) {
const isRightSide = !dnd.isLeftSide(ReactDOM.findDOMNode(droppedOn.selectedRef), e.clientX)
const droppedOnKey = droppedOn.selectedRef.props.bookmarkKey
const isDestinationParent = droppedOn.selectedRef.state.isFolder && droppedOn && droppedOn.isDroppedOn
if (bookmark.get('type') === siteTags.BOOKMARK_FOLDER) {
appActions.moveBookmarkFolder(bookmark.get('key'), droppedOnKey, isRightSide, isDestinationParent)
if (tabDrop) {
const parentKey = isDestinationParent ? droppedOnKey : null
bookmark = bookmark.set('parentFolderId', parentKey)
appActions.addBookmark(bookmark)
} else {
appActions.moveBookmark(bookmark.get('key'), droppedOnKey, isRightSide, isDestinationParent)
if (bookmark.get('type') === siteTags.BOOKMARK_FOLDER) {
appActions.moveBookmarkFolder(bookmarkKey, droppedOnKey, isRightSide, isDestinationParent)
} else {
appActions.moveBookmark(bookmarkKey, droppedOnKey, isRightSide, isDestinationParent)
}
}
dnd.onDragEnd()
}
Expand Down
4 changes: 2 additions & 2 deletions app/renderer/components/navigation/urlBarIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ 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
location: this.props.location,
title: this.props.title
})
}

Expand Down Expand Up @@ -160,7 +161,6 @@ class UrlBarIcon extends React.Component {

// used in other functions
props.title = activeFrame.get('title', '')
props.tabId = activeFrame.get('tabId', tabState.TAB_ID_NONE)

return props
}
Expand Down
11 changes: 0 additions & 11 deletions app/renderer/reducers/frameReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const appActions = require('../../../js/actions/appActions')
const frameStateUtil = require('../../../js/state/frameStateUtil')
const {getSourceAboutUrl, getSourceMagnetUrl} = require('../../../js/lib/appUrlUtil')
const {isURL, isPotentialPhishingUrl, getUrlFromInput} = require('../../../js/lib/urlutil')
const bookmarkUtil = require('../../common/lib/bookmarkUtil')

const setFullScreen = (state, action) => {
const index = frameStateUtil.getIndexByTabId(state, action.tabId)
Expand Down Expand Up @@ -257,16 +256,6 @@ const frameReducer = (state, action, immutableAction) => {
case windowConstants.WINDOW_SET_FULL_SCREEN:
state = setFullScreen(state, action)
break
case windowConstants.WINDOW_ON_FRAME_BOOKMARK:
{
// TODO make this an appAction that gets the bookmark data from tabState
const frameProps = frameStateUtil.getFrameByTabId(state, action.tabId)
if (frameProps) {
const bookmark = bookmarkUtil.getDetailFromFrame(frameProps)
appActions.addBookmark(bookmark)
}
break
}
// TODO(bbondy): We should remove this window action completely and just go directly to
// the browser process with an app action.
case windowConstants.WINDOW_TAB_MOVE: {
Expand Down
7 changes: 0 additions & 7 deletions js/actions/windowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1128,13 +1128,6 @@ const windowActions = {
})
},

onFrameBookmark: function (tabId) {
dispatch({
actionType: windowConstants.WINDOW_ON_FRAME_BOOKMARK,
tabId
})
},

onStop: function (isFocused, shouldRender) {
dispatch({
actionType: windowConstants.WINDOW_ON_STOP,
Expand Down
1 change: 0 additions & 1 deletion js/constants/windowConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const windowConstants = {
WINDOW_ON_GO_FORWARD_LONG: _,
WINDOW_ON_CERT_ERROR: _,
WINDOW_ON_TAB_PAGE_CONTEXT_MENU: _,
WINDOW_ON_FRAME_BOOKMARK: _,
WINDOW_ON_STOP: _,
WINDOW_ON_MORE_BOOKMARKS_MENU: _,
WINDOW_ON_SHOW_BOOKMARK_FOLDER_MENU: _,
Expand Down
8 changes: 7 additions & 1 deletion js/dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const windowActions = require('./actions/windowActions')
const appActions = require('./actions/appActions')
const ReactDOM = require('react-dom')
const dndData = require('./dndData')
const Immutable = require('immutable')
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 @@ -137,7 +139,11 @@ module.exports.prepareBookmarkDataFromCompatible = (dataTransfer) => {
if (!bookmark) {
const dragData = dndData.getDragData(dataTransfer, dragTypes.TAB)
if (dragData) {
windowActions.onFrameBookmark(dragData.get('tabId'))
bookmark = Immutable.fromJS({
location: dragData.get('location'),
title: dragData.get('title'),
type: siteTags.BOOKMARK
})
}
}
return bookmark
Expand Down

0 comments on commit ec24079

Please sign in to comment.