Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Merge pull request #633 from dat-land/fix-buttons
Browse files Browse the repository at this point in the history
Fix buttons
  • Loading branch information
okdistribute authored Feb 17, 2020
2 parents 27512f9 + aa1c2c7 commit 8582d4b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/actions/dat-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export default class DatMiddleware {
await mkdirp(this.dataDir)
} catch (_) {}

const [ datOpts, paused ] = await Promise.all([
const [datOpts, paused] = await Promise.all([
readJSON(joinPath(this.dataDir, 'dats.json')),
readJSON(joinPath(this.dataDir, 'paused.json'))
])
Expand Down
24 changes: 19 additions & 5 deletions app/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ const stat = promisify(fs.stat)

function showOpenDialog (props) {
if (process.env.RUNNING_IN_SPECTRON && process.env.OPEN_RESULT) {
return [path.resolve(__dirname, process.env.OPEN_RESULT)]
return new Promise((resolve, reject) => {
resolve({
cancelled: false,
filePaths: [path.resolve(__dirname, process.env.OPEN_RESULT)]
})
})
}
return remote.dialog.showOpenDialog(props)
}
Expand All @@ -23,12 +28,21 @@ export const copyLink = link => {
export const closeShareDat = () => ({ type: 'DIALOGS_LINK_CLOSE' })

export const createDat = () => dispatch => {
const files = showOpenDialog({
showOpenDialog({
properties: ['openDirectory']
})
if (!files || !files.length) return
const path = files[0]
addDat({ path })(dispatch)
.then(({ filePaths, cancelled }) => {
if (cancelled) return
if (!filePaths) {
console.error('Did not get files from the open dialog, closing')
return
}
const path = filePaths[0]
addDat({ path })(dispatch)
})
.catch(err => {
console.error(err)
})
}
export const requestDownload = key => ({
type: 'REQUEST_DOWNLOAD',
Expand Down
11 changes: 1 addition & 10 deletions app/components/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@ import React from 'react'
import styled from 'styled-components'

const BaseButton = styled.button.attrs(props => ({
...props,
onClick: props => {
if (props.trigger) {
return function (e) {
e.stopPropagation()
props.trigger.apply(this, [e])
}
}
return undefined
}
...props
}))`
text-transform: uppercase;
letter-spacing: 0.025em;
Expand Down
5 changes: 4 additions & 1 deletion app/components/finder-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const FinderButton = ({ dat, onClick }) => (
<Button.Icon
icon={<Icon name='open-in-finder' />}
className='row-action btn-finder'
trigger={() => shell.openExternal(`file://${resolve(dat.path)}`, () => {})}
onClick={ev => {
ev.stopPropagation()
shell.openExternal(`file://${resolve(dat.path)}`, () => {})
}}
/>
)

Expand Down
2 changes: 1 addition & 1 deletion app/components/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const Inspect = ({
CHANGE...
</TextButton>
</Row>
<Row label='Files:' style={{padding: 0}}>
<Row label='Files:' style={{ padding: 0 }}>
<FileList
dat={dat}
fallback={<div className='f7 f6-l pa2'>N/A</div>}
Expand Down
4 changes: 3 additions & 1 deletion app/components/table-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ const Row = ({
if (!metadata) return null
const { title } = metadata
const placeholderTitle = `#${key}`
// TODO: inspectDat needs more work!
// onClick={() => inspectDat(dat.key)} className='selectable'>
return (
<Tr onClick={() => inspectDat(dat.key)} className='selectable'>
<Tr>
<td className='cell-1'>
<div
className='w2 center'
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ app.on('ready', () => {
nodeIntegration: false,
preload: `${__dirname}/preload.js`
}
: {}
: {
nodeIntegration: true
}
)
})
win.loadURL(`file://${__dirname}/index.html#${process.env.NODE_ENV}`)
Expand Down

0 comments on commit 8582d4b

Please sign in to comment.