Fix 3box replacement for MV3 (#15851)

* refactor backup controller to return the data to be backed up
    and do the actual backup in the UI.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Move export-utils to ui/helpers as it's only used in the UI now.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* use context to call event tracker.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Don't make backup function inline.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
feature/default_network_editable
Olusegun Akintayo 2 years ago committed by GitHub
parent 0bc1eeaf37
commit 7b94ac5eca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      app/scripts/controllers/backup.js
  2. 2
      ui/components/ui/export-text-container/export-text-container.component.js
  3. 2
      ui/helpers/utils/export-utils.js
  4. 2
      ui/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js
  5. 2
      ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.component.js
  6. 18
      ui/pages/settings/advanced-tab/advanced-tab.component.js

@ -1,4 +1,3 @@
import { exportAsFile } from '../../../shared/modules/export-utils';
import { prependZero } from '../../../shared/modules/string-utils'; import { prependZero } from '../../../shared/modules/string-utils';
export default class BackupController { export default class BackupController {
@ -65,13 +64,6 @@ export default class BackupController {
date.getMinutes(), date.getMinutes(),
)}_${prefixZero(date.getDay())}.json`; )}_${prefixZero(date.getDay())}.json`;
exportAsFile(userDataFileName, result); return { fileName: userDataFileName, data: result };
this._trackMetaMetricsEvent({
event: 'User Data Exported',
category: 'Backup',
});
return result;
} }
} }

@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import Copy from '../icon/copy-icon.component'; import Copy from '../icon/copy-icon.component';
import { useI18nContext } from '../../../hooks/useI18nContext'; import { useI18nContext } from '../../../hooks/useI18nContext';
import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard'; import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard';
import { exportAsFile } from '../../../../shared/modules/export-utils'; import { exportAsFile } from '../../../helpers/utils/export-utils';
function ExportTextContainer({ function ExportTextContainer({
text = '', text = '',

@ -1,4 +1,4 @@
import { getRandomFileName } from '../../ui/helpers/utils/util'; import { getRandomFileName } from './util';
export function exportAsFile(filename, data, type = 'text/csv') { export function exportAsFile(filename, data, type = 'text/csv') {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign

@ -10,7 +10,7 @@ import {
EVENT, EVENT,
EVENT_NAMES, EVENT_NAMES,
} from '../../../../../shared/constants/metametrics'; } from '../../../../../shared/constants/metametrics';
import { exportAsFile } from '../../../../../shared/modules/export-utils'; import { exportAsFile } from '../../../../helpers/utils/export-utils';
import DraggableSeed from './draggable-seed.component'; import DraggableSeed from './draggable-seed.component';
const EMPTY_SEEDS = Array(12).fill(null); const EMPTY_SEEDS = Array(12).fill(null);

@ -15,7 +15,7 @@ import {
EVENT_NAMES, EVENT_NAMES,
} from '../../../../../shared/constants/metametrics'; } from '../../../../../shared/constants/metametrics';
import { returnToOnboardingInitiatorTab } from '../../onboarding-initiator-util'; import { returnToOnboardingInitiatorTab } from '../../onboarding-initiator-util';
import { exportAsFile } from '../../../../../shared/modules/export-utils'; import { exportAsFile } from '../../../../helpers/utils/export-utils';
export default class RevealSeedPhrase extends PureComponent { export default class RevealSeedPhrase extends PureComponent {
static contextTypes = { static contextTypes = {

@ -21,7 +21,7 @@ import {
LEDGER_USB_VENDOR_ID, LEDGER_USB_VENDOR_ID,
} from '../../../../shared/constants/hardware-wallets'; } from '../../../../shared/constants/hardware-wallets';
import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import { exportAsFile } from '../../../../shared/modules/export-utils'; import { exportAsFile } from '../../../helpers/utils/export-utils';
import ActionableMessage from '../../../components/ui/actionable-message'; import ActionableMessage from '../../../components/ui/actionable-message';
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url'; import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
@ -155,7 +155,6 @@ export default class AdvancedTab extends PureComponent {
/** /**
* so that we can restore same file again if we want to. * so that we can restore same file again if we want to.
* chrome blocks uploading same file twice. * chrome blocks uploading same file twice.
*
*/ */
event.target.value = ''; event.target.value = '';
try { try {
@ -237,6 +236,17 @@ export default class AdvancedTab extends PureComponent {
); );
} }
backupUserData = async () => {
const { fileName, data } = await this.props.backupUserData();
exportAsFile(fileName, data);
this.context.trackEvent({
event: 'User Data Exported',
category: 'Backup',
properties: {},
});
};
renderUserDataBackup() { renderUserDataBackup() {
const { t } = this.context; const { t } = this.context;
return ( return (
@ -256,9 +266,7 @@ export default class AdvancedTab extends PureComponent {
<Button <Button
type="secondary" type="secondary"
large large
onClick={() => { onClick={() => this.backupUserData()}
this.props.backupUserData();
}}
> >
{t('backup')} {t('backup')}
</Button> </Button>

Loading…
Cancel
Save