Skip to content

Commit

Permalink
Merge branch 'master' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Oct 13, 2017
2 parents e52eb51 + 81676b8 commit fe5eb6f
Show file tree
Hide file tree
Showing 36 changed files with 1,142 additions and 59 deletions.
926 changes: 909 additions & 17 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -53,7 +53,7 @@
"chai-as-promised": "^7.1.1",
"chokidar": "^1.6.0",
"devtron": "^1.0.0",
"electron": "1.6.14",
"electron": "1.6.15",
"electron-devtools-installer": "^2.0.0",
"electron-mocha": "^4.0.3",
"electron-packager": "^9.1.0",
Expand Down
1 change: 1 addition & 0 deletions res/keymaps/project.en.yml
Expand Up @@ -153,6 +153,7 @@ darwin:
- Cmd+ArrowRight
delete: Backspace
enter: Enter
preview: Space
contract: Escape
home: Home
end: End
Expand Down
4 changes: 4 additions & 0 deletions res/menu/app.yml
Expand Up @@ -69,6 +69,9 @@ linux:
label: '&Paste'
accelerator: 'CmdOrCtrl+V'
role: 'paste'
- &all
label: 'Select All'
role: 'selectall'
- type: 'separator'
- &preferences
label: 'Prefere&nces …'
Expand Down Expand Up @@ -180,6 +183,7 @@ darwin:
- *cut
- *copy
- *paste
- *all
- *view
- label: 'Window'
role: 'window'
Expand Down
2 changes: 2 additions & 0 deletions res/strings/renderer.en.yml
@@ -1,6 +1,7 @@
sidebar:
lists: Lists
tags: Tags
imports: Last Import
trash: Deleted Items
toolbar:
import: Import Photos
Expand Down Expand Up @@ -323,6 +324,7 @@ activity:
load: Loading metadata …
save: Saving metadata …
ontology:
load: Loading ontology …
import: Importing vocabularies …
vocab:
save: Saving vocabulary …
Expand Down
13 changes: 13 additions & 0 deletions src/actions/imports.js
@@ -0,0 +1,13 @@
'use strict'

const { IMPORTS } = require('../constants')

module.exports = {
restore(payload, meta) {
return {
type: IMPORTS.RESTORE,
payload,
meta
}
}
}
1 change: 1 addition & 0 deletions src/actions/index.js
Expand Up @@ -7,6 +7,7 @@ module.exports = {
context: require('./context'),
edit: require('./edit'),
history: require('./history'),
imports: require('./imports'),
intl: require('./intl'),
item: require('./item'),
keymap: require('./keymap'),
Expand Down
8 changes: 4 additions & 4 deletions src/actions/item.js
Expand Up @@ -20,7 +20,7 @@ module.exports = {
return {
type: ITEM.IMPORT,
payload,
meta: { cmd: 'project', history: 'add', ...meta }
meta: { cmd: 'project', history: 'add', search: true, ...meta }
}
},

Expand Down Expand Up @@ -167,11 +167,11 @@ module.exports = {
}
},

preview({ id, photos }, meta) {
preview(payload, meta) {
return {
type: ITEM.PREVIEW,
payload: { id, photos },
meta: { ipc: true, ...meta }
payload,
meta: { cmd: 'project', ...meta }
}
},

Expand Down
19 changes: 19 additions & 0 deletions src/commands/item.js
Expand Up @@ -12,10 +12,12 @@ const { text } = require('../value')
const act = require('../actions')
const mod = require('../models')
const { get, pluck, pick, remove } = require('../common/util')
const { darwin } = require('../common/os')
const { ITEM, DC } = require('../constants')
const { keys } = Object
const { isArray } = Array
const { writeFileAsync: write } = require('fs')
const { win } = require('../window')

const {
getItemTemplate,
Expand Down Expand Up @@ -478,6 +480,22 @@ class ToggleTags extends Command {
}
}

class Preview extends Command {
static get action() { return ITEM.PREVIEW }

*exec() {
if (!darwin) return

const { photos } = this.action.payload
const paths = yield select(state =>
photos.map(id => get(state.photos, [id, 'path'])))

if (paths.length > 0) {
win.current.previewFile(paths[0])
}
}
}

class AddTag extends Command {
static get action() { return ITEM.TAG.CREATE }

Expand Down Expand Up @@ -541,6 +559,7 @@ module.exports = {
Split,
Restore,
Save,
Preview,
AddTag,
RemoveTag,
ToggleTags,
Expand Down
8 changes: 8 additions & 0 deletions src/components/icons.js
Expand Up @@ -167,6 +167,14 @@ i('Chevron16', (
</svg>
))

i('Clock', (
<svg width="16" height="16">
<g className="line" fill="currentColor">
<path d="M8.5,0A7.5,7.5,0,1,0,16,7.5,7.5,7.5,0,0,0,8.5,0Zm0,14A6.5,6.5,0,1,1,15,7.5,6.507,6.507,0,0,1,8.5,14Zm3.354-3.854a.5.5,0,1,1-.707.707l-3-3A.507.507,0,0,1,8,7.5v-5a.5.5,0,0,1,1,0V7.293Z"/>
</g>
</svg>
))

i('Copy', (
<svg width="16" height="16">
<g className="line" fill="currentColor">
Expand Down
17 changes: 9 additions & 8 deletions src/components/input.js
Expand Up @@ -17,11 +17,9 @@ class BufferedInput extends PureComponent {
}

componentWillReceiveProps({ value }) {
this.setState({ value })
this.clearResetTimeout()

this.hasBeenCommitted = false
this.hasBeenCancelled = false
this.setState({ value })
}

componentWillUnmount() {
Expand Down Expand Up @@ -54,11 +52,14 @@ class BufferedInput extends PureComponent {

commit(force) {
if (force || this.isValid) {
this.props.onCommit(this.state.value, this.hasChanged, force)
this.hasBeenCommitted = true

if (this.hasChanged && this.props.delay > 0) {
this.tm = setTimeout(this.reset, this.props.delay)
if (!this.hasBeenCommitted) {
this.hasBeenCommitted = true
this.props.onCommit(this.state.value, this.hasChanged, force)

if (this.hasChanged && this.props.delay > 0) {
this.clearResetTimeout()
this.tm = setTimeout(this.reset, this.props.delay)
}
}

} else {
Expand Down
26 changes: 21 additions & 5 deletions src/components/item/iterable.js
Expand Up @@ -34,12 +34,28 @@ class ItemIterable extends PureComponent {
}
}

handleOpen = () => {
const { item, onItemOpen } = this.props
// Subtle: when an item is not selected, we need to select
// on mouse down, because the mouse down may kick-off a
// drag event. If the item is already selected, we handle
// selection in the click event for the same reason!
handleMouseDown = (event) => {
if (this.props.isSelected) {
this.wasSelected = true
} else {
this.wasSelected = false
this.handleSelect(event)
}
}

onItemOpen({
id: item.id, photos: item.photos
})
handleClick = (event) => {
if (this.props.isSelected && this.wasSelected) {
this.handleSelect(event)
}
}

handleOpen = () => {
const { id, photos } = this.props.item
this.props.onItemOpen({ id, photos })
}

handleSelect = (event) => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/item/iterator.js
Expand Up @@ -107,7 +107,7 @@ class ItemIterator extends Iterator {
this.props.onItemOpen(this.current())
break
case 'preview':
this.props.onItemPreview(this.current())
this.preview(this.current())
break
case 'clear':
this.clearSelection()
Expand Down Expand Up @@ -162,6 +162,10 @@ class ItemIterator extends Iterator {
this.props.onSelect({ items }, mod, { throttle })
}

preview({ id, photos }) {
this.props.onItemPreview({ id, photos })
}

connect(element) {
return (this.isDisabled) ? element : this.props.dt(element)
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/item/panel.js
Expand Up @@ -59,6 +59,7 @@ class ItemPanel extends PureComponent {
selections,
isDisabled,
isItemOpen,
onItemPreview,
onMaximize,
onModeChange,
onNoteCreate,
Expand Down Expand Up @@ -109,6 +110,7 @@ class ItemPanel extends PureComponent {
onCreate={this.handlePhotoCreate}
onDelete={onPhotoDelete}
onExpand={onPhotoExpand}
onItemPreview={onItemPreview}
onSelect={onPhotoSelect}
onSort={onPhotoSort}
onSelectionSort={onSelectionSort}
Expand Down Expand Up @@ -159,6 +161,7 @@ class ItemPanel extends PureComponent {
onEdit: func.isRequired,
onEditCancel: func,
onItemOpen: func.isRequired,
onItemPreview: func.isRequired,
onItemSave: func.isRequired,
onItemTagAdd: func.isRequired,
onItemTagRemove: func.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions src/components/item/table-row.js
Expand Up @@ -45,8 +45,8 @@ class ItemTableRow extends ItemIterable {
<tr
className={cx(this.classes)}
ref={this.setContainer}
onMouseDown={isSelected ? null : this.handleSelect}
onClick={isSelected ? this.handleSelect : null}
onMouseDown={this.handleMouseDown}
onClick={this.handleClick}
onDoubleClick={this.handleOpen}
onContextMenu={this.handleContextMenu}>
{this.mapColumns(({ column, isMainColumn, next, prev }) =>
Expand Down
6 changes: 3 additions & 3 deletions src/components/item/tile.js
Expand Up @@ -10,7 +10,7 @@ const cx = require('classnames')

class ItemTile extends ItemIterable {
render() {
const { item, cache, photos, size, tags, isSelected } = this.props
const { item, cache, photos, size, tags } = this.props

return this.connect(
<li
Expand All @@ -23,8 +23,8 @@ class ItemTile extends ItemIterable {
photos={photos}
tags={tags}
size={size}
onMouseDown={isSelected ? null : this.handleSelect}
onClick={isSelected ? this.handleSelect : null}
onMouseDown={this.handleMouseDown}
onClick={this.handleClick}
onDoubleClick={this.handleOpen}
onContextMenu={this.handleContextMenu}/>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/list/index.js
@@ -1,6 +1,7 @@
'use strict'

module.exports = {
...require('./last-import'),
...require('./node'),
...require('./trash'),
...require('./tree')
Expand Down
28 changes: 28 additions & 0 deletions src/components/list/last-import.js
@@ -0,0 +1,28 @@
'use strict'

const React = require('react')
const cx = require('classnames')
const { IconClock } = require('../icons')
const { FormattedMessage } = require('react-intl')
const { bool, func } = require('prop-types')


const LastImportListNode = ({ isSelected, onClick }) => (
<li
className={cx({ active: isSelected })}
onClick={isSelected ? null : onClick}>
<IconClock/>
<div className="name">
<FormattedMessage id="sidebar.imports"/>
</div>
</li>
)

LastImportListNode.propTypes = {
isSelected: bool,
onClick: func.isRequired
}

module.exports = {
LastImportListNode
}
3 changes: 1 addition & 2 deletions src/components/list/trash.js
Expand Up @@ -2,13 +2,12 @@

const React = require('react')
const { PureComponent } = React
const PropTypes = require('prop-types')
const cx = require('classnames')
const { IconTrash } = require('../icons')
const { FormattedMessage } = require('react-intl')
const { DropTarget } = require('react-dnd')
const { DND } = require('../../constants')
const { bool, func } = PropTypes
const { bool, func } = require('prop-types')


class TrashListNode extends PureComponent {
Expand Down
3 changes: 3 additions & 0 deletions src/components/photo/grid.js
Expand Up @@ -144,6 +144,9 @@ class PhotoGrid extends PhotoIterator {
case 'open':
this.handleItemOpen(this.current())
break
case 'preview':
this.preview(this.current())
break
case 'expand':
case 'enter':
this.expand(this.current())
Expand Down
6 changes: 6 additions & 0 deletions src/components/photo/iterator.js
Expand Up @@ -223,6 +223,11 @@ class PhotoIterator extends Iterator {
}
}

preview({ id, item }) {
this.props.onItemPreview({ id: item, photos: [id] })
}


connect(element) {
return this.isSortable ? this.props.dt(element) : element
}
Expand Down Expand Up @@ -262,6 +267,7 @@ class PhotoIterator extends Iterator {
onDelete: func.isRequired,
onExpand: func.isRequired,
onItemOpen: func.isRequired,
onItemPreview: func.isRequired,
onSelect: func.isRequired,
onSort: func.isRequired,
onSelectionSort: func.isRequired
Expand Down
3 changes: 3 additions & 0 deletions src/components/photo/list.js
Expand Up @@ -139,6 +139,9 @@ class PhotoList extends PhotoIterator {
case 'open':
this.handleItemOpen(this.current())
break
case 'preview':
this.preview(this.current())
break
case 'delete':
this.handleDelete(this.current())
this.select(this.next() || this.prev())
Expand Down

0 comments on commit fe5eb6f

Please sign in to comment.