1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

add setting to dismiss seed phrase backup reminder (#10967)

This commit is contained in:
Alex Donesky 2021-05-05 08:58:29 -05:00 committed by Dan Miller
parent fbe1da81a5
commit ce8b173f56
9 changed files with 81 additions and 6 deletions

View File

@ -556,6 +556,12 @@
"dismiss": { "dismiss": {
"message": "Dismiss" "message": "Dismiss"
}, },
"dismissReminderDescriptionField": {
"message": "Turn this on to dismiss the recovery phrase backup reminder message. We highly recommend that you back up your seed phrase to avoid loss of funds"
},
"dismissReminderField": {
"message": "Dismiss recovery phrase backup reminder"
},
"done": { "done": {
"message": "Done" "message": "Done"
}, },

View File

@ -43,6 +43,7 @@ export default class PreferencesController {
useBlockie: false, useBlockie: false,
useNonceField: false, useNonceField: false,
usePhishDetect: true, usePhishDetect: true,
dismissSeedBackUpReminder: false,
// WARNING: Do not use feature flags for security-sensitive things. // WARNING: Do not use feature flags for security-sensitive things.
// Feature flag toggling is available in the global namespace // Feature flag toggling is available in the global namespace
@ -669,7 +670,7 @@ export default class PreferencesController {
/** /**
* A setter for the `useLedgerLive` property * A setter for the `useLedgerLive` property
* @param {bool} domain - Value for ledger live support * @param {bool} useLedgerLive - Value for ledger live support
* @returns {Promise<string>} A promise of the update to useLedgerLive * @returns {Promise<string>} A promise of the update to useLedgerLive
*/ */
async setLedgerLivePreference(useLedgerLive) { async setLedgerLivePreference(useLedgerLive) {
@ -685,6 +686,17 @@ export default class PreferencesController {
return this.store.getState().useLedgerLive; return this.store.getState().useLedgerLive;
} }
/**
* A setter for the user preference to dismiss the seed phrase backup reminder
* @param {bool} dismissBackupReminder- User preference for dismissing the back up reminder
* @returns {void}
*/
async setDismissSeedBackUpReminder(dismissSeedBackUpReminder) {
await this.store.updateState({
dismissSeedBackUpReminder,
});
}
// //
// PRIVATE METHODS // PRIVATE METHODS
// //

View File

@ -735,6 +735,10 @@ export default class MetamaskController extends EventEmitter {
preferencesController.addKnownMethodData, preferencesController.addKnownMethodData,
preferencesController, preferencesController,
), ),
setDismissSeedBackUpReminder: nodeify(
this.preferencesController.setDismissSeedBackUpReminder,
this.preferencesController,
),
// AddressController // AddressController
setAddressBook: nodeify( setAddressBook: nodeify(

View File

@ -52,6 +52,7 @@ const mapStateToProps = (state) => {
connectedStatusPopoverHasBeenShown, connectedStatusPopoverHasBeenShown,
defaultHomeActiveTabName, defaultHomeActiveTabName,
swapsState, swapsState,
dismissSeedBackUpReminder,
} = metamask; } = metamask;
const accountBalance = getCurrentEthBalance(state); const accountBalance = getCurrentEthBalance(state);
const { forgottenPassword, threeBoxLastUpdated } = appState; const { forgottenPassword, threeBoxLastUpdated } = appState;
@ -84,7 +85,8 @@ const mapStateToProps = (state) => {
unconfirmedTransactionsCount: unconfirmedTransactionsCountSelector(state), unconfirmedTransactionsCount: unconfirmedTransactionsCountSelector(state),
shouldShowSeedPhraseReminder: shouldShowSeedPhraseReminder:
seedPhraseBackedUp === false && seedPhraseBackedUp === false &&
(parseInt(accountBalance, 16) > 0 || tokens.length > 0), (parseInt(accountBalance, 16) > 0 || tokens.length > 0) &&
dismissSeedBackUpReminder === false,
isPopup, isPopup,
isNotification, isNotification,
threeBoxSynced, threeBoxSynced,

View File

@ -38,6 +38,8 @@ export default class AdvancedTab extends PureComponent {
ipfsGateway: PropTypes.string.isRequired, ipfsGateway: PropTypes.string.isRequired,
useLedgerLive: PropTypes.bool.isRequired, useLedgerLive: PropTypes.bool.isRequired,
setLedgerLivePreference: PropTypes.func.isRequired, setLedgerLivePreference: PropTypes.func.isRequired,
setDismissSeedBackUpReminder: PropTypes.func.isRequired,
dismissSeedBackUpReminder: PropTypes.bool.isRequired,
}; };
state = { state = {
@ -258,7 +260,7 @@ export default class AdvancedTab extends PureComponent {
data-testid="advanced-setting-custom-nonce" data-testid="advanced-setting-custom-nonce"
> >
<div className="settings-page__content-item"> <div className="settings-page__content-item">
<span>{this.context.t('nonceField')}</span> <span>{t('nonceField')}</span>
<div className="settings-page__content-description"> <div className="settings-page__content-description">
{t('nonceFieldDescription')} {t('nonceFieldDescription')}
</div> </div>
@ -494,6 +496,38 @@ export default class AdvancedTab extends PureComponent {
); );
} }
renderDismissSeedBackupReminderControl() {
const { t } = this.context;
const {
dismissSeedBackUpReminder,
setDismissSeedBackUpReminder,
} = this.props;
return (
<div
className="settings-page__content-row"
data-testid="advanced-setting-dismiss-reminder"
>
<div className="settings-page__content-item">
<span>{t('dismissReminderField')}</span>
<div className="settings-page__content-description">
{t('dismissReminderDescriptionField')}
</div>
</div>
<div className="settings-page__content-item">
<div className="settings-page__content-item-col">
<ToggleButton
value={dismissSeedBackUpReminder}
onToggle={(value) => setDismissSeedBackUpReminder(!value)}
offLabel={t('off')}
onLabel={t('on')}
/>
</div>
</div>
</div>
);
}
render() { render() {
const { warning } = this.props; const { warning } = this.props;
@ -511,6 +545,7 @@ export default class AdvancedTab extends PureComponent {
{this.renderThreeBoxControl()} {this.renderThreeBoxControl()}
{this.renderIpfsGatewayControl()} {this.renderIpfsGatewayControl()}
{this.renderLedgerLiveControl()} {this.renderLedgerLiveControl()}
{this.renderDismissSeedBackupReminderControl()}
</div> </div>
); );
} }

View File

@ -23,7 +23,7 @@ describe('AdvancedTab Component', () => {
}, },
); );
expect(root.find('.settings-page__content-row')).toHaveLength(11); expect(root.find('.settings-page__content-row')).toHaveLength(12);
}); });
it('should update autoLockTimeLimit', () => { it('should update autoLockTimeLimit', () => {

View File

@ -12,6 +12,7 @@ import {
setUseNonceField, setUseNonceField,
setIpfsGateway, setIpfsGateway,
setLedgerLivePreference, setLedgerLivePreference,
setDismissSeedBackUpReminder,
} from '../../../store/actions'; } from '../../../store/actions';
import { getPreferences } from '../../../selectors'; import { getPreferences } from '../../../selectors';
import AdvancedTab from './advanced-tab.component'; import AdvancedTab from './advanced-tab.component';
@ -28,6 +29,7 @@ export const mapStateToProps = (state) => {
useNonceField, useNonceField,
ipfsGateway, ipfsGateway,
useLedgerLive, useLedgerLive,
dismissSeedBackUpReminder,
} = metamask; } = metamask;
const { showFiatInTestnets, autoLockTimeLimit } = getPreferences(state); const { showFiatInTestnets, autoLockTimeLimit } = getPreferences(state);
@ -42,6 +44,7 @@ export const mapStateToProps = (state) => {
useNonceField, useNonceField,
ipfsGateway, ipfsGateway,
useLedgerLive, useLedgerLive,
dismissSeedBackUpReminder,
}; };
}; };
@ -71,8 +74,12 @@ export const mapDispatchToProps = (dispatch) => {
setIpfsGateway: (value) => { setIpfsGateway: (value) => {
return dispatch(setIpfsGateway(value)); return dispatch(setIpfsGateway(value));
}, },
setLedgerLivePreference: (value) => setLedgerLivePreference: (value) => {
dispatch(setLedgerLivePreference(value)), return dispatch(setLedgerLivePreference(value));
},
setDismissSeedBackUpReminder: (value) => {
return dispatch(setDismissSeedBackUpReminder(value));
},
}; };
}; };

View File

@ -72,6 +72,7 @@ export const BUY_ETH = 'BUY_ETH';
export const TOGGLE_ACCOUNT_MENU = 'TOGGLE_ACCOUNT_MENU'; export const TOGGLE_ACCOUNT_MENU = 'TOGGLE_ACCOUNT_MENU';
// preferences
export const SET_USE_BLOCKIE = 'SET_USE_BLOCKIE'; export const SET_USE_BLOCKIE = 'SET_USE_BLOCKIE';
export const SET_USE_NONCEFIELD = 'SET_USE_NONCEFIELD'; export const SET_USE_NONCEFIELD = 'SET_USE_NONCEFIELD';
export const UPDATE_CUSTOM_NONCE = 'UPDATE_CUSTOM_NONCE'; export const UPDATE_CUSTOM_NONCE = 'UPDATE_CUSTOM_NONCE';

View File

@ -2561,6 +2561,14 @@ export function setLastActiveTime() {
}; };
} }
export function setDismissSeedBackUpReminder(value) {
return async (dispatch) => {
dispatch(showLoadingIndication());
await promisifiedBackground.setDismissSeedBackUpReminder(value);
dispatch(hideLoadingIndication());
};
}
export function setConnectedStatusPopoverHasBeenShown() { export function setConnectedStatusPopoverHasBeenShown() {
return () => { return () => {
background.setConnectedStatusPopoverHasBeenShown((err) => { background.setConnectedStatusPopoverHasBeenShown((err) => {