Skip to content

Commit

Permalink
feat(export): export a specific version of a dataset
Browse files Browse the repository at this point in the history
uses `electron-dl` package to manage downloads
  • Loading branch information
ramfox committed Oct 2, 2019
1 parent 05f6450 commit 51544e1
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 13 deletions.
28 changes: 20 additions & 8 deletions app/components/DatasetSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import classNames from 'classnames'
import Spinner from './chrome/Spinner'

import { WorkingDataset, ComponentType, Selections } from '../models/store'
import ContextMenuArea from 'react-electron-contextmenu'
import { MenuItemConstructorOptions, ipcRenderer } from 'electron'

interface HistoryListItemProps {
path: string
Expand Down Expand Up @@ -173,15 +175,25 @@ const DatasetSidebar: React.FunctionComponent<DatasetSidebarProps> = (props) =>
history.value.map((props) => {
const { path, timestamp, title } = props
const timeMessage = moment(timestamp).fromNow()
const menuItems: MenuItemConstructorOptions[] = [
{
label: 'Export this version',
click: () => {
ipcRenderer.send('export', `http://localhost:2503/export/${peername}/${name}/at/${path}?download=true&all=true`)
}
}
]
return (
<HistoryListItem
key={path}
path={path}
commitTitle={title}
timeMessage={timeMessage}
selected={selectedCommit === path}
onClick={setSelectedListItem}
/>
<ContextMenuArea menuItems={menuItems} key={path}>
<HistoryListItem
key={path}
path={path}
commitTitle={title}
timeMessage={timeMessage}
selected={selectedCommit === path}
onClick={setSelectedListItem}
/>
</ContextMenuArea>
)
})
}
Expand Down
7 changes: 7 additions & 0 deletions app/main.development.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { app, BrowserWindow, Menu, shell, ipcMain } = require('electron')
const { autoUpdater } = require('electron-updater')
const { BackendProcess } = require('./backend')
const { download } = require('electron-dl')

// versions
// must be manually updated for now
Expand Down Expand Up @@ -468,6 +469,12 @@ app.on('ready', () =>
setMenuItemEnabled(['view-on-qri-cloud'], published)
})

// catch export events
ipcMain.on('export', async (e, exportPath) => {
const win = BrowserWindow.getFocusedWindow()
await download(win, exportPath, { saveAs: true })
})

ipcMain.on('block-menus', (e, blockMenus) => {
const blockableMenus = [
'about-qri-desktop',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
"classnames": "2.2.6",
"deep-equal": "1.1.0",
"electron-debug": "3.0.1",
"electron-dl": "1.14.0",
"electron-updater": "4.1.2",
"eslint-utils": "1.4.2",
"font-awesome": "4.7.0",
Expand Down
59 changes: 54 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3789,6 +3789,15 @@ electron-devtools-installer@2.2.4:
rimraf "^2.5.2"
semver "^5.3.0"

electron-dl@1.14.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/electron-dl/-/electron-dl-1.14.0.tgz#1466f1b945664ca3d784268307c2b935728177bf"
integrity sha512-4okyei42a1mLsvLK7hLrIfd20EQzB18nIlLTwBV992aMSmTGLUEFRTmO1MfSslGNrzD8nuPuy1l/VxO8so4lig==
dependencies:
ext-name "^5.0.0"
pupa "^1.0.0"
unused-filename "^1.0.0"

electron-download@^4.1.0, electron-download@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/electron-download/-/electron-download-4.1.1.tgz#02e69556705cc456e520f9e035556ed5a015ebe8"
Expand Down Expand Up @@ -4410,6 +4419,21 @@ express@4.17.1:
utils-merge "1.0.1"
vary "~1.1.2"

ext-list@^2.0.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/ext-list/-/ext-list-2.2.2.tgz#0b98e64ed82f5acf0f2931babf69212ef52ddd37"
integrity sha512-u+SQgsubraE6zItfVA0tBuCBhfU9ogSRnsvygI7wht9TS510oLkBRXBsqopeUG/GBOIQyKZO9wjTqIu/sf5zFA==
dependencies:
mime-db "^1.28.0"

ext-name@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ext-name/-/ext-name-5.0.0.tgz#70781981d183ee15d13993c8822045c506c8f0a6"
integrity sha512-yblEwXAbGv1VQDmow7s38W77hzAgJAO50ztBLMcUyUBfxv1HC+LGwtiEN+Co6LtlqT/5uwVOxsD4TNIilWhwdQ==
dependencies:
ext-list "^2.0.0"
sort-keys-length "^1.0.0"

extend-shallow@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
Expand Down Expand Up @@ -6903,6 +6927,11 @@ mime-db@1.40.0:
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.40.0.tgz#a65057e998db090f732a68f6c276d387d4126c32"
integrity sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==

mime-db@^1.28.0:
version "1.42.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.42.0.tgz#3e252907b4c7adb906597b4b65636272cf9e7bac"
integrity sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==

mime-types@^2.1.12, mime-types@~2.1.19, mime-types@~2.1.24:
version "2.1.24"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.24.tgz#b6f8d0b3e951efb77dedeca194cff6d16f676f81"
Expand Down Expand Up @@ -7047,6 +7076,11 @@ mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkd
dependencies:
minimist "0.0.8"

modify-filename@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/modify-filename/-/modify-filename-1.1.0.tgz#9a2dec83806fbb2d975f22beec859ca26b393aa1"
integrity sha1-mi3sg4Bvuy2XXyK+7IWcoms5OqE=

moment@2.20.1:
version "2.20.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd"
Expand Down Expand Up @@ -8258,6 +8292,11 @@ punycode@^2.1.0, punycode@^2.1.1:
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==

pupa@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/pupa/-/pupa-1.0.0.tgz#9a9568a5af7e657b8462a6e9d5328743560ceff6"
integrity sha1-mpVopa9+ZXuEYqbp1TKHQ1YM7/Y=

pure-color@^1.2.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/pure-color/-/pure-color-1.3.0.tgz#1fe064fb0ac851f0de61320a8bf796836422f33e"
Expand Down Expand Up @@ -9444,6 +9483,13 @@ snapdragon@^0.8.1:
source-map-resolve "^0.5.0"
use "^3.1.0"

sort-keys-length@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/sort-keys-length/-/sort-keys-length-1.0.1.tgz#9cb6f4f4e9e48155a6aa0671edd336ff1479a188"
integrity sha1-nLb09OnkgVWmqgZx7dM2/xR5oYg=
dependencies:
sort-keys "^1.0.0"

sort-keys@^1.0.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad"
Expand Down Expand Up @@ -9546,11 +9592,6 @@ spectron-fake-dialog@0.0.1:
resolved "https://registry.yarnpkg.com/spectron-fake-dialog/-/spectron-fake-dialog-0.0.1.tgz#ffd5cfadcac64eb957340389f047529c4a68e23a"
integrity sha512-ToNQH3MLVj7aw7oT3CjIvs+r3E2swhx4gNA9Utrorl46aiJetBm3WngK+TOcS15YBm9N1fF34vQP/wQWq99RwA==

spectron-keys@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/spectron-keys/-/spectron-keys-0.0.1.tgz#45c3aa535e85fe5f5c71fd18cfa43927826f65db"
integrity sha1-RcOqU16F/l9ccf0Yz6Q5J4JvZds=

spectron@7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/spectron/-/spectron-7.0.0.tgz#2a16ea2b2fbe6149f5fa9fa1a2be601f5878e00c"
Expand Down Expand Up @@ -10381,6 +10422,14 @@ unset-value@^1.0.0:
has-value "^0.3.1"
isobject "^3.0.0"

unused-filename@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unused-filename/-/unused-filename-1.0.0.tgz#d340880f71ae2115ebaa1325bef05cc6684469c6"
integrity sha1-00CID3GuIRXrqhMlvvBcxmhEacY=
dependencies:
modify-filename "^1.1.0"
path-exists "^3.0.0"

upath@^1.1.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/upath/-/upath-1.2.0.tgz#8f66dbcd55a883acdae4408af8b035a5044c1894"
Expand Down

0 comments on commit 51544e1

Please sign in to comment.