disconnectAccount -> disconnectSite; close popover

feature/default_network_editable
Erik Marks 5 years ago
parent ca135a4342
commit c7d945e62d
  1. 2
      app/_locales/en/messages.json
  2. 19
      ui/app/pages/connected-sites/connected-sites.component.js
  3. 23
      ui/app/pages/connected-sites/connected-sites.container.js

@ -19,7 +19,7 @@
"disconnectSite": { "disconnectSite": {
"message": "Disconnect $1?" "message": "Disconnect $1?"
}, },
"disconnectAccountConfirmationDescription": { "disconnectSiteConfirmationDescription": {
"message": "Are you sure you want to disconnect? You may lose site functionality." "message": "Are you sure you want to disconnect? You may lose site functionality."
}, },
"dismiss": { "dismiss": {

@ -2,7 +2,6 @@ import PropTypes from 'prop-types'
import React, { Component } from 'react' import React, { Component } from 'react'
import ConnectedSitesList from '../../components/app/connected-sites-list' import ConnectedSitesList from '../../components/app/connected-sites-list'
import Popover from '../../components/ui/popover/popover.component' import Popover from '../../components/ui/popover/popover.component'
import { DEFAULT_ROUTE } from '../../helpers/constants/routes'
import Button from '../../components/ui/button' import Button from '../../components/ui/button'
export default class ConnectSites extends Component { export default class ConnectSites extends Component {
@ -15,10 +14,10 @@ export default class ConnectSites extends Component {
} }
static propTypes = { static propTypes = {
connectedDomains: PropTypes.arrayOf(PropTypes.object).isRequired,
accountLabel: PropTypes.string.isRequired, accountLabel: PropTypes.string.isRequired,
disconnectAccount: PropTypes.func.isRequired, closePopover: PropTypes.func.isRequired,
history: PropTypes.object.isRequired, connectedDomains: PropTypes.arrayOf(PropTypes.object).isRequired,
disconnectSite: PropTypes.func.isRequired,
tabToConnect: PropTypes.object, tabToConnect: PropTypes.object,
legacyExposeAccount: PropTypes.func.isRequired, legacyExposeAccount: PropTypes.func.isRequired,
getOpenMetamaskTabsIds: PropTypes.func.isRequired, getOpenMetamaskTabsIds: PropTypes.func.isRequired,
@ -49,10 +48,10 @@ export default class ConnectSites extends Component {
} }
disconnect = () => { disconnect = () => {
const { disconnectAccount } = this.props const { disconnectSite } = this.props
const { sitePendingDisconnect } = this.state const { sitePendingDisconnect } = this.state
disconnectAccount(sitePendingDisconnect.domainKey) disconnectSite(sitePendingDisconnect.domainKey)
this.clearSitePendingDisconnect() this.clearSitePendingDisconnect()
} }
@ -66,7 +65,7 @@ export default class ConnectSites extends Component {
} }
render () { render () {
const { accountLabel, history, legacyExposeAccount, tabToConnect, connectedDomains } = this.props const { accountLabel, closePopover, connectedDomains, legacyExposeAccount, tabToConnect } = this.props
const { t } = this.context const { t } = this.context
const { sitePendingDisconnect } = this.state const { sitePendingDisconnect } = this.state
return ( return (
@ -74,8 +73,8 @@ export default class ConnectSites extends Component {
? ( ? (
<Popover <Popover
title={t('disconnectSite', [sitePendingDisconnect.domainName])} title={t('disconnectSite', [sitePendingDisconnect.domainName])}
subtitle={t('disconnectAccountConfirmationDescription')} subtitle={t('disconnectSiteConfirmationDescription')}
onClose={() => history.push(DEFAULT_ROUTE)} onClose={closePopover}
footer={( footer={(
<> <>
<Button type="secondary" onClick={this.clearSitePendingDisconnect}> <Button type="secondary" onClick={this.clearSitePendingDisconnect}>
@ -96,7 +95,7 @@ export default class ConnectSites extends Component {
? t('connectedSitesDescription', [accountLabel]) ? t('connectedSitesDescription', [accountLabel])
: t('connectedSitesEmptyDescription', [accountLabel]) : t('connectedSitesEmptyDescription', [accountLabel])
} }
onClose={() => history.push(DEFAULT_ROUTE)} onClose={closePopover}
footer={ footer={
tabToConnect tabToConnect
? ( ? (

@ -8,6 +8,7 @@ import {
getPermittedAccountsForCurrentTab, getPermittedAccountsForCurrentTab,
getSelectedAddress, getSelectedAddress,
} from '../../selectors/selectors' } from '../../selectors/selectors'
import { DEFAULT_ROUTE } from '../../helpers/constants/routes'
import { getOriginFromUrl } from '../../helpers/utils/util' import { getOriginFromUrl } from '../../helpers/utils/util'
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
@ -36,7 +37,7 @@ const mapStateToProps = (state) => {
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = (dispatch) => {
return { return {
getOpenMetamaskTabsIds: () => dispatch(getOpenMetamaskTabsIds()), getOpenMetamaskTabsIds: () => dispatch(getOpenMetamaskTabsIds()),
disconnectAccount: (domainKey, domain) => { disconnectSite: (domainKey, domain) => {
const permissionMethodNames = domain.permissions.map(({ parentCapability }) => parentCapability) const permissionMethodNames = domain.permissions.map(({ parentCapability }) => parentCapability)
dispatch(removePermissionsFor({ dispatch(removePermissionsFor({
[domainKey]: permissionMethodNames, [domainKey]: permissionMethodNames,
@ -47,17 +48,31 @@ const mapDispatchToProps = (dispatch) => {
} }
const mergeProps = (stateProps, dispatchProps, ownProps) => { const mergeProps = (stateProps, dispatchProps, ownProps) => {
const { domains, selectedAddress, tabToConnect } = stateProps
const { const {
disconnectAccount, domains,
selectedAddress,
tabToConnect,
connectedDomains,
} = stateProps
const {
disconnectSite,
legacyExposeAccounts: dispatchLegacyExposeAccounts, legacyExposeAccounts: dispatchLegacyExposeAccounts,
} = dispatchProps } = dispatchProps
const { history } = ownProps
const closePopover = () => history.push(DEFAULT_ROUTE)
return { return {
...ownProps, ...ownProps,
...stateProps, ...stateProps,
...dispatchProps, ...dispatchProps,
disconnectAccount: (domainKey) => disconnectAccount(domainKey, domains[domainKey]), closePopover,
disconnectSite: (domainKey) => {
disconnectSite(domainKey, domains[domainKey])
if (connectedDomains.length === 1) {
closePopover()
}
},
legacyExposeAccount: () => dispatchLegacyExposeAccounts(tabToConnect.origin, selectedAddress), legacyExposeAccount: () => dispatchLegacyExposeAccounts(tabToConnect.origin, selectedAddress),
} }
} }

Loading…
Cancel
Save