mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
disconnectAccount -> disconnectSite; close popover
This commit is contained in:
parent
ca135a4342
commit
c7d945e62d
@ -19,7 +19,7 @@
|
||||
"disconnectSite": {
|
||||
"message": "Disconnect $1?"
|
||||
},
|
||||
"disconnectAccountConfirmationDescription": {
|
||||
"disconnectSiteConfirmationDescription": {
|
||||
"message": "Are you sure you want to disconnect? You may lose site functionality."
|
||||
},
|
||||
"dismiss": {
|
||||
|
@ -2,7 +2,6 @@ import PropTypes from 'prop-types'
|
||||
import React, { Component } from 'react'
|
||||
import ConnectedSitesList from '../../components/app/connected-sites-list'
|
||||
import Popover from '../../components/ui/popover/popover.component'
|
||||
import { DEFAULT_ROUTE } from '../../helpers/constants/routes'
|
||||
import Button from '../../components/ui/button'
|
||||
|
||||
export default class ConnectSites extends Component {
|
||||
@ -15,10 +14,10 @@ export default class ConnectSites extends Component {
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
connectedDomains: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
accountLabel: PropTypes.string.isRequired,
|
||||
disconnectAccount: PropTypes.func.isRequired,
|
||||
history: PropTypes.object.isRequired,
|
||||
closePopover: PropTypes.func.isRequired,
|
||||
connectedDomains: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
disconnectSite: PropTypes.func.isRequired,
|
||||
tabToConnect: PropTypes.object,
|
||||
legacyExposeAccount: PropTypes.func.isRequired,
|
||||
getOpenMetamaskTabsIds: PropTypes.func.isRequired,
|
||||
@ -49,10 +48,10 @@ export default class ConnectSites extends Component {
|
||||
}
|
||||
|
||||
disconnect = () => {
|
||||
const { disconnectAccount } = this.props
|
||||
const { disconnectSite } = this.props
|
||||
const { sitePendingDisconnect } = this.state
|
||||
|
||||
disconnectAccount(sitePendingDisconnect.domainKey)
|
||||
disconnectSite(sitePendingDisconnect.domainKey)
|
||||
this.clearSitePendingDisconnect()
|
||||
}
|
||||
|
||||
@ -66,7 +65,7 @@ export default class ConnectSites extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { accountLabel, history, legacyExposeAccount, tabToConnect, connectedDomains } = this.props
|
||||
const { accountLabel, closePopover, connectedDomains, legacyExposeAccount, tabToConnect } = this.props
|
||||
const { t } = this.context
|
||||
const { sitePendingDisconnect } = this.state
|
||||
return (
|
||||
@ -74,8 +73,8 @@ export default class ConnectSites extends Component {
|
||||
? (
|
||||
<Popover
|
||||
title={t('disconnectSite', [sitePendingDisconnect.domainName])}
|
||||
subtitle={t('disconnectAccountConfirmationDescription')}
|
||||
onClose={() => history.push(DEFAULT_ROUTE)}
|
||||
subtitle={t('disconnectSiteConfirmationDescription')}
|
||||
onClose={closePopover}
|
||||
footer={(
|
||||
<>
|
||||
<Button type="secondary" onClick={this.clearSitePendingDisconnect}>
|
||||
@ -96,7 +95,7 @@ export default class ConnectSites extends Component {
|
||||
? t('connectedSitesDescription', [accountLabel])
|
||||
: t('connectedSitesEmptyDescription', [accountLabel])
|
||||
}
|
||||
onClose={() => history.push(DEFAULT_ROUTE)}
|
||||
onClose={closePopover}
|
||||
footer={
|
||||
tabToConnect
|
||||
? (
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
getPermittedAccountsForCurrentTab,
|
||||
getSelectedAddress,
|
||||
} from '../../selectors/selectors'
|
||||
import { DEFAULT_ROUTE } from '../../helpers/constants/routes'
|
||||
import { getOriginFromUrl } from '../../helpers/utils/util'
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
@ -36,7 +37,7 @@ const mapStateToProps = (state) => {
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
getOpenMetamaskTabsIds: () => dispatch(getOpenMetamaskTabsIds()),
|
||||
disconnectAccount: (domainKey, domain) => {
|
||||
disconnectSite: (domainKey, domain) => {
|
||||
const permissionMethodNames = domain.permissions.map(({ parentCapability }) => parentCapability)
|
||||
dispatch(removePermissionsFor({
|
||||
[domainKey]: permissionMethodNames,
|
||||
@ -47,17 +48,31 @@ const mapDispatchToProps = (dispatch) => {
|
||||
}
|
||||
|
||||
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
||||
const { domains, selectedAddress, tabToConnect } = stateProps
|
||||
const {
|
||||
disconnectAccount,
|
||||
domains,
|
||||
selectedAddress,
|
||||
tabToConnect,
|
||||
connectedDomains,
|
||||
} = stateProps
|
||||
const {
|
||||
disconnectSite,
|
||||
legacyExposeAccounts: dispatchLegacyExposeAccounts,
|
||||
} = dispatchProps
|
||||
const { history } = ownProps
|
||||
|
||||
const closePopover = () => history.push(DEFAULT_ROUTE)
|
||||
|
||||
return {
|
||||
...ownProps,
|
||||
...stateProps,
|
||||
...dispatchProps,
|
||||
disconnectAccount: (domainKey) => disconnectAccount(domainKey, domains[domainKey]),
|
||||
closePopover,
|
||||
disconnectSite: (domainKey) => {
|
||||
disconnectSite(domainKey, domains[domainKey])
|
||||
if (connectedDomains.length === 1) {
|
||||
closePopover()
|
||||
}
|
||||
},
|
||||
legacyExposeAccount: () => dispatchLegacyExposeAccounts(tabToConnect.origin, selectedAddress),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user