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';
export default class BackupController {
@ -65,13 +64,6 @@ export default class BackupController {
date.getMinutes(),
)}_${prefixZero(date.getDay())}.json`;
exportAsFile(userDataFileName, result);
this._trackMetaMetricsEvent({
event: 'User Data Exported',
category: 'Backup',
});
return result;
return { fileName: userDataFileName, data: result };
}
}

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

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

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

@ -15,7 +15,7 @@ import {
EVENT_NAMES,
} from '../../../../../shared/constants/metametrics';
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 {
static contextTypes = {

@ -21,7 +21,7 @@ import {
LEDGER_USB_VENDOR_ID,
} from '../../../../shared/constants/hardware-wallets';
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 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.
* chrome blocks uploading same file twice.
*
*/
event.target.value = '';
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() {
const { t } = this.context;
return (
@ -256,9 +266,7 @@ export default class AdvancedTab extends PureComponent {
<Button
type="secondary"
large
onClick={() => {
this.props.backupUserData();
}}
onClick={() => this.backupUserData()}
>
{t('backup')}
</Button>

Loading…
Cancel
Save