Gaëtan Renaudeau
7 years ago
committed by
GitHub
5 changed files with 55 additions and 0 deletions
@ -0,0 +1,30 @@ |
|||
// @flow
|
|||
|
|||
import React, { Component } from 'react' |
|||
import logger from 'logger' |
|||
import { shell } from 'electron' |
|||
import { translate } from 'react-i18next' |
|||
|
|||
import resolveUserDataDirectory from 'helpers/resolveUserDataDirectory' |
|||
import Button from 'components/base/Button' |
|||
|
|||
class OpenUserDataDirectoryBtn extends Component<{ |
|||
t: *, |
|||
}> { |
|||
handleOpenUserDataDirectory = async () => { |
|||
const userDataDirectory = resolveUserDataDirectory() |
|||
logger.log(`Opening user data directory: ${userDataDirectory}`) |
|||
shell.openItem(userDataDirectory) |
|||
} |
|||
|
|||
render() { |
|||
const { t } = this.props |
|||
return ( |
|||
<Button primary small onClick={this.handleOpenUserDataDirectory}> |
|||
{t('app:settings.openUserDataDirectory.btn')} |
|||
</Button> |
|||
) |
|||
} |
|||
} |
|||
|
|||
export default translate()(OpenUserDataDirectoryBtn) |
@ -0,0 +1,10 @@ |
|||
// @flow
|
|||
|
|||
const resolveUserDataDirectory = () => { |
|||
const { LEDGER_CONFIG_DIRECTORY } = process.env |
|||
if (LEDGER_CONFIG_DIRECTORY) return LEDGER_CONFIG_DIRECTORY |
|||
const electron = require('electron') |
|||
return (electron.app || electron.remote.app).getPath('userData') |
|||
} |
|||
|
|||
export default resolveUserDataDirectory |
Loading…
Reference in new issue