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

Bookmark manager style update #4658

Merged
merged 6 commits into from
Oct 11, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions js/about/bookmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,19 @@ class BookmarksList extends ImmutableComponent {
}
}
render () {
const props = !this.props.sortable ? {
sortingDisabled: true
const props = !this.props.draggable ? {
sortingDisabled: !this.props.sortable
} : {
onDoubleClick: this.onDoubleClick,
onDragStart: this.onDragStart,
onDragOver: this.onDragOver,
onDrop: this.onDrop,
sortingDisabled: false
sortingDisabled: !this.props.sortable
}

return <div>
<SortableTable headings={['Title', 'Last Visited']}
defaultHeading='Title'
rows={this.props.bookmarks.map((entry) => [
{
cell: <BookmarkTitleCell siteDetail={entry} />,
Expand All @@ -192,11 +193,12 @@ class BookmarksList extends ImmutableComponent {
}
])}
rowObjects={this.props.bookmarks}
defaultHeading='Title'
columnClassNames={['title', 'date']}
tableID={this.props.tableID}
addHoverClass
multiSelect
onDoubleClick={this.onDoubleClick}
{...props}
columnClassNames={['title', 'date']}
contextMenuName='bookmark'
onContextMenu={aboutActions.contextMenu} />
</div>
Expand Down Expand Up @@ -288,7 +290,9 @@ class AboutBookmarks extends React.Component {
? this.searchedBookmarks(this.state.search, this.state.bookmarks)
: this.bookmarksInFolder
}
sortable={!this.state.search} />
sortable={false}
draggable={!this.state.search}
tableID={this.selectedFolderId} />
</div>
</div>
</div>
Expand Down
15 changes: 13 additions & 2 deletions js/components/sortableTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ class SortableTable extends ImmutableComponent {
return tableSort(this.table)
}
onClick (e) {
const targetElement = e.target.parentNode
// Work backwards until element is TR
let targetElement = e.target
while (targetElement) {
if (targetElement.tagName === 'TR') break
targetElement = targetElement.parentNode
}
if (!targetElement) return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice for parent traversing!!!


if (eventUtil.isForSecondaryAction(e)) {
if (targetElement.className.includes(' selected')) {
Expand Down Expand Up @@ -81,7 +87,12 @@ class SortableTable extends ImmutableComponent {
? (typeof this.props.totalRowObjects[parseInt(tableID)][index].toJS === 'function'
? this.props.totalRowObjects[parseInt(tableID)][index].toJS()
: this.props.totalRowObjects[parseInt(tableID)][index])
: null
: (this.props.rowObjects.size > 0 || this.props.rowObjects.length > 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of non multi table selection. 👍

? (typeof this.props.rowObjects.toJS === 'function'
? this.props.rowObjects.get(index).toJS()
: this.props.rowObjects[index])
: null

if (handlerInput) {
handlerInputs.push(handlerInput)
}
Expand Down