mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
Create new tabs instead of windows in most cases (#8347)
* openExtensionInBrowser: create tab, not window * open tabs instead of windows in most cases
This commit is contained in:
parent
c26d272649
commit
1f49772ca3
@ -1894,7 +1894,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
const network = this.networkController.getNetworkState()
|
const network = this.networkController.getNetworkState()
|
||||||
const url = getBuyEthUrl({ network, address, amount })
|
const url = getBuyEthUrl({ network, address, amount })
|
||||||
if (url) {
|
if (url) {
|
||||||
this.platform.openWindow({ url })
|
this.platform.openTab({ url })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,18 @@ class ExtensionPlatform {
|
|||||||
extension.runtime.reload()
|
extension.runtime.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openTab (options) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
extension.tabs.create(options, (newTab) => {
|
||||||
|
const error = checkForError()
|
||||||
|
if (error) {
|
||||||
|
return reject(error)
|
||||||
|
}
|
||||||
|
return resolve(newTab)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
openWindow (options) {
|
openWindow (options) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
extension.windows.create(options, (newWindow) => {
|
extension.windows.create(options, (newWindow) => {
|
||||||
@ -68,7 +80,7 @@ class ExtensionPlatform {
|
|||||||
if (route) {
|
if (route) {
|
||||||
extensionURL += `#${route}`
|
extensionURL += `#${route}`
|
||||||
}
|
}
|
||||||
this.openWindow({ url: extensionURL })
|
this.openTab({ url: extensionURL })
|
||||||
if (getEnvironmentType() !== ENVIRONMENT_TYPE_BACKGROUND) {
|
if (getEnvironmentType() !== ENVIRONMENT_TYPE_BACKGROUND) {
|
||||||
window.close()
|
window.close()
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ function mapDispatchToProps (dispatch) {
|
|||||||
dispatch(actions.showModal({ name: 'ACCOUNT_DETAILS' }))
|
dispatch(actions.showModal({ name: 'ACCOUNT_DETAILS' }))
|
||||||
},
|
},
|
||||||
viewOnEtherscan: (address, network, rpcPrefs) => {
|
viewOnEtherscan: (address, network, rpcPrefs) => {
|
||||||
global.platform.openWindow({ url: genAccountLink(address, network, rpcPrefs) })
|
global.platform.openTab({ url: genAccountLink(address, network, rpcPrefs) })
|
||||||
},
|
},
|
||||||
showRemoveAccountConfirmationModal: (identity) => {
|
showRemoveAccountConfirmationModal: (identity) => {
|
||||||
return dispatch(actions.showModal({ name: 'CONFIRM_REMOVE_ACCOUNT', identity }))
|
return dispatch(actions.showModal({ name: 'CONFIRM_REMOVE_ACCOUNT', identity }))
|
||||||
|
@ -40,7 +40,7 @@ class TokenMenuDropdown extends Component {
|
|||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
const url = genAccountLink(this.props.token.address, this.props.network)
|
const url = genAccountLink(this.props.token.address, this.props.network)
|
||||||
global.platform.openWindow({ url })
|
global.platform.openTab({ url })
|
||||||
this.props.onClose()
|
this.props.onClose()
|
||||||
}}
|
}}
|
||||||
text={this.context.t('viewOnEtherscan')}
|
text={this.context.t('viewOnEtherscan')}
|
||||||
|
@ -62,7 +62,7 @@ export default class AccountDetailsModal extends Component {
|
|||||||
type="secondary"
|
type="secondary"
|
||||||
className="account-modal__button"
|
className="account-modal__button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
global.platform.openWindow({ url: genAccountLink(address, network, rpcPrefs) })
|
global.platform.openTab({ url: genAccountLink(address, network, rpcPrefs) })
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{rpcPrefs.blockExplorerUrl
|
{rpcPrefs.blockExplorerUrl
|
||||||
|
@ -7,7 +7,7 @@ import AccountDetailsModal from '../account-details-modal'
|
|||||||
describe('Account Details Modal', function () {
|
describe('Account Details Modal', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
global.platform = { openWindow: sinon.spy() }
|
global.platform = { openTab: sinon.spy() }
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
hideModal: sinon.spy(),
|
hideModal: sinon.spy(),
|
||||||
@ -53,12 +53,12 @@ describe('Account Details Modal', function () {
|
|||||||
assert.equal(props.setAccountLabel.getCall(0).args[1], 'New Label')
|
assert.equal(props.setAccountLabel.getCall(0).args[1], 'New Label')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens new window when view block explorer is clicked', function () {
|
it('opens new tab when view block explorer is clicked', function () {
|
||||||
const modalButton = wrapper.find('.account-modal__button')
|
const modalButton = wrapper.find('.account-modal__button')
|
||||||
const etherscanLink = modalButton.first()
|
const etherscanLink = modalButton.first()
|
||||||
|
|
||||||
etherscanLink.simulate('click')
|
etherscanLink.simulate('click')
|
||||||
assert(global.platform.openWindow.calledOnce)
|
assert(global.platform.openTab.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows export private key modal when clicked', function () {
|
it('shows export private key modal when clicked', function () {
|
||||||
|
@ -15,7 +15,7 @@ export default class PermissionsConnectFooter extends Component {
|
|||||||
<div
|
<div
|
||||||
className="permissions-connect-footer__text--link"
|
className="permissions-connect-footer__text--link"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
global.platform.openWindow({ url: 'https://medium.com/metamask/privacy-mode-is-now-enabled-by-default-1c1c957f4d57' })
|
global.platform.openTab({ url: 'https://medium.com/metamask/privacy-mode-is-now-enabled-by-default-1c1c957f4d57' })
|
||||||
}}
|
}}
|
||||||
>{ t('learnMore') }
|
>{ t('learnMore') }
|
||||||
</div>
|
</div>
|
||||||
|
@ -146,7 +146,7 @@ export default class ShiftListItem extends Component {
|
|||||||
width: '200px',
|
width: '200px',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
}}
|
}}
|
||||||
onClick={() => global.platform.openWindow({ url })}
|
onClick={() => global.platform.openTab({ url })}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
@ -233,7 +233,7 @@ export default class SignatureRequestOriginal extends Component {
|
|||||||
<span
|
<span
|
||||||
className="request-signature__help-link"
|
className="request-signature__help-link"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
global.platform.openWindow({
|
global.platform.openTab({
|
||||||
url: 'https://metamask.zendesk.com/hc/en-us/articles/360015488751',
|
url: 'https://metamask.zendesk.com/hc/en-us/articles/360015488751',
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
@ -33,7 +33,7 @@ export default class TransactionActivityLog extends PureComponent {
|
|||||||
const prefix = prefixForNetwork(metamaskNetworkId)
|
const prefix = prefixForNetwork(metamaskNetworkId)
|
||||||
const etherscanUrl = `https://${prefix}etherscan.io/tx/${hash}`
|
const etherscanUrl = `https://${prefix}etherscan.io/tx/${hash}`
|
||||||
|
|
||||||
global.platform.openWindow({ url: etherscanUrl })
|
global.platform.openTab({ url: etherscanUrl })
|
||||||
}
|
}
|
||||||
|
|
||||||
renderInlineRetry (index, activity) {
|
renderInlineRetry (index, activity) {
|
||||||
|
@ -56,7 +56,7 @@ export default class TransactionListItemDetails extends PureComponent {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
global.platform.openWindow({ url: getBlockExplorerUrlForTx(metamaskNetworkId, hash, rpcPrefs) })
|
global.platform.openTab({ url: getBlockExplorerUrlForTx(metamaskNetworkId, hash, rpcPrefs) })
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCancel = (event) => {
|
handleCancel = (event) => {
|
||||||
|
@ -88,7 +88,7 @@ class ConnectScreen extends Component {
|
|||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
large
|
large
|
||||||
onClick={() => global.platform.openWindow({
|
onClick={() => global.platform.openTab({
|
||||||
url: 'https://google.com/chrome',
|
url: 'https://google.com/chrome',
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
@ -50,7 +50,7 @@ export default class AccountImportSubview extends Component {
|
|||||||
textDecoration: 'underline',
|
textDecoration: 'underline',
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
global.platform.openWindow({
|
global.platform.openTab({
|
||||||
url: 'https://metamask.zendesk.com/hc/en-us/articles/360015289932',
|
url: 'https://metamask.zendesk.com/hc/en-us/articles/360015289932',
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
@ -1761,7 +1761,7 @@ export function showSendTokenPage () {
|
|||||||
export function buyEth (opts) {
|
export function buyEth (opts) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
const url = getBuyEthUrl(opts)
|
const url = getBuyEthUrl(opts)
|
||||||
global.platform.openWindow({ url })
|
global.platform.openTab({ url })
|
||||||
dispatch({
|
dispatch({
|
||||||
type: actionConstants.BUY_ETH,
|
type: actionConstants.BUY_ETH,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user