1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 03:20:23 +01:00

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>
This commit is contained in:
Olusegun Akintayo 2022-09-29 07:34:20 +04:00 committed by GitHub
parent 0bc1eeaf37
commit 7b94ac5eca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 18 deletions

View File

@ -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 };
}
}

View File

@ -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 = '',

View File

@ -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

View File

@ -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);

View File

@ -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 = {

View File

@ -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>