From e5d2157b27cda746f5a7c193f22c0addf4663ef3 Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 12 Jul 2018 16:40:48 +0200 Subject: [PATCH] Help: add button to open user data folder closes #1085 --- src/components/OpenUserDataDirectoryBtn.js | 30 ++++++++++++++++++++ src/components/SettingsPage/sections/Help.js | 7 +++++ src/helpers/resolveUserDataDirectory.js | 10 +++++++ static/i18n/en/app.yml | 4 +++ static/i18n/fr/app.yml | 4 +++ 5 files changed, 55 insertions(+) create mode 100644 src/components/OpenUserDataDirectoryBtn.js create mode 100644 src/helpers/resolveUserDataDirectory.js diff --git a/src/components/OpenUserDataDirectoryBtn.js b/src/components/OpenUserDataDirectoryBtn.js new file mode 100644 index 00000000..bae4c3b1 --- /dev/null +++ b/src/components/OpenUserDataDirectoryBtn.js @@ -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 ( + + ) + } +} + +export default translate()(OpenUserDataDirectoryBtn) diff --git a/src/components/SettingsPage/sections/Help.js b/src/components/SettingsPage/sections/Help.js index d4adb2d4..2f35d122 100644 --- a/src/components/SettingsPage/sections/Help.js +++ b/src/components/SettingsPage/sections/Help.js @@ -9,6 +9,7 @@ import resolveLogsDirectory from 'helpers/resolveLogsDirectory' import { urls } from 'config/urls' import ExportLogsBtn from 'components/ExportLogsBtn' +import OpenUserDataDirectoryBtn from 'components/OpenUserDataDirectoryBtn' import CleanButton from '../CleanButton' import ResetButton from '../ResetButton' import AboutRowItem from '../AboutRowItem' @@ -56,6 +57,12 @@ class SectionHelp extends PureComponent { > + + + { + 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 diff --git a/static/i18n/en/app.yml b/static/i18n/en/app.yml index c59fc4bb..73a966eb 100644 --- a/static/i18n/en/app.yml +++ b/static/i18n/en/app.yml @@ -382,6 +382,10 @@ settings: title: Remove account subTitle: Are you sure? desc: The account will no longer be included in your portfolio. This operation does not affect your assets. Accounts can always be re-added. + openUserDataDirectory: + title: 'Open user data directory' + desc: 'Open the user data directory' + btn: 'Open' exportLogs: title: Export logs desc: 'Exporting Ledger Live logs may be necessary for troubleshooting purposes.' diff --git a/static/i18n/fr/app.yml b/static/i18n/fr/app.yml index c59fc4bb..73a966eb 100644 --- a/static/i18n/fr/app.yml +++ b/static/i18n/fr/app.yml @@ -382,6 +382,10 @@ settings: title: Remove account subTitle: Are you sure? desc: The account will no longer be included in your portfolio. This operation does not affect your assets. Accounts can always be re-added. + openUserDataDirectory: + title: 'Open user data directory' + desc: 'Open the user data directory' + btn: 'Open' exportLogs: title: Export logs desc: 'Exporting Ledger Live logs may be necessary for troubleshooting purposes.'