Skip to content

Commit

Permalink
export user config (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
bukinoshita committed Dec 30, 2017
1 parent 923dc6e commit a447857
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"classnames": "^2.2.5",
"electron-is-dev": "^0.3.0",
"electron-next": "^3.1.3",
"fs-extra": "^5.0.0",
"prop-types": "^15.6.0",
"uid-promise": "^1.0.0"
},
Expand Down
4 changes: 3 additions & 1 deletion renderer/pages/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import Page from './../layouts/page'
import Row from './../components/row'
import Hero from './../components/hero'

import { exportUser } from './../services/settings'

class Settings extends Component {
constructor() {
super()
Expand All @@ -35,7 +37,7 @@ class Settings extends Component {
<li>
Import tasks <span>soon</span>
</li>
<li>
<li onClick={exportUser}>
Export tasks <span>soon</span>
</li>
<li>
Expand Down
22 changes: 22 additions & 0 deletions renderer/services/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'

// Packages
const { writeJSON } = require('fs-extra')
const { remote } = require('electron')

// Services
const { getUser } = require('./api')

export const exportUser = () => {
remote.dialog.showSaveDialog(
undefined,
{ defaultPath: '~/taskr.json' },
fileName => {
if (fileName) {
const user = getUser()

writeJSON(fileName, user).catch(err => console.log(err))
}
}
)
}

0 comments on commit a447857

Please sign in to comment.