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 url = getBuyEthUrl({ network, address, amount })
|
||||
if (url) {
|
||||
this.platform.openWindow({ url })
|
||||
this.platform.openTab({ url })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,18 @@ class ExtensionPlatform {
|
||||
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) {
|
||||
return new Promise((resolve, reject) => {
|
||||
extension.windows.create(options, (newWindow) => {
|
||||
@ -68,7 +80,7 @@ class ExtensionPlatform {
|
||||
if (route) {
|
||||
extensionURL += `#${route}`
|
||||
}
|
||||
this.openWindow({ url: extensionURL })
|
||||
this.openTab({ url: extensionURL })
|
||||
if (getEnvironmentType() !== ENVIRONMENT_TYPE_BACKGROUND) {
|
||||
window.close()
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ function mapDispatchToProps (dispatch) {
|
||||
dispatch(actions.showModal({ name: 'ACCOUNT_DETAILS' }))
|
||||
},
|
||||
viewOnEtherscan: (address, network, rpcPrefs) => {
|
||||
global.platform.openWindow({ url: genAccountLink(address, network, rpcPrefs) })
|
||||
global.platform.openTab({ url: genAccountLink(address, network, rpcPrefs) })
|
||||
},
|
||||
showRemoveAccountConfirmationModal: (identity) => {
|
||||
return dispatch(actions.showModal({ name: 'CONFIRM_REMOVE_ACCOUNT', identity }))
|
||||
|
@ -40,7 +40,7 @@ class TokenMenuDropdown extends Component {
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
const url = genAccountLink(this.props.token.address, this.props.network)
|
||||
global.platform.openWindow({ url })
|
||||
global.platform.openTab({ url })
|
||||
this.props.onClose()
|
||||
}}
|
||||
text={this.context.t('viewOnEtherscan')}
|
||||
|
@ -62,7 +62,7 @@ export default class AccountDetailsModal extends Component {
|
||||
type="secondary"
|
||||
className="account-modal__button"
|
||||
onClick={() => {
|
||||
global.platform.openWindow({ url: genAccountLink(address, network, rpcPrefs) })
|
||||
global.platform.openTab({ url: genAccountLink(address, network, rpcPrefs) })
|
||||
}}
|
||||
>
|
||||
{rpcPrefs.blockExplorerUrl
|
||||
|
@ -7,7 +7,7 @@ import AccountDetailsModal from '../account-details-modal'
|
||||
describe('Account Details Modal', function () {
|
||||
let wrapper
|
||||
|
||||
global.platform = { openWindow: sinon.spy() }
|
||||
global.platform = { openTab: sinon.spy() }
|
||||
|
||||
const props = {
|
||||
hideModal: sinon.spy(),
|
||||
@ -53,12 +53,12 @@ describe('Account Details Modal', function () {
|
||||
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 etherscanLink = modalButton.first()
|
||||
|
||||
etherscanLink.simulate('click')
|
||||
assert(global.platform.openWindow.calledOnce)
|
||||
assert(global.platform.openTab.calledOnce)
|
||||
})
|
||||
|
||||
it('shows export private key modal when clicked', function () {
|
||||
|
@ -15,7 +15,7 @@ export default class PermissionsConnectFooter extends Component {
|
||||
<div
|
||||
className="permissions-connect-footer__text--link"
|
||||
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') }
|
||||
</div>
|
||||
|
@ -146,7 +146,7 @@ export default class ShiftListItem extends Component {
|
||||
width: '200px',
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
onClick={() => global.platform.openWindow({ url })}
|
||||
onClick={() => global.platform.openTab({ url })}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
|
@ -233,7 +233,7 @@ export default class SignatureRequestOriginal extends Component {
|
||||
<span
|
||||
className="request-signature__help-link"
|
||||
onClick={() => {
|
||||
global.platform.openWindow({
|
||||
global.platform.openTab({
|
||||
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 etherscanUrl = `https://${prefix}etherscan.io/tx/${hash}`
|
||||
|
||||
global.platform.openWindow({ url: etherscanUrl })
|
||||
global.platform.openTab({ url: etherscanUrl })
|
||||
}
|
||||
|
||||
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) => {
|
||||
|
@ -88,7 +88,7 @@ class ConnectScreen extends Component {
|
||||
<Button
|
||||
type="primary"
|
||||
large
|
||||
onClick={() => global.platform.openWindow({
|
||||
onClick={() => global.platform.openTab({
|
||||
url: 'https://google.com/chrome',
|
||||
})}
|
||||
>
|
||||
|
@ -50,7 +50,7 @@ export default class AccountImportSubview extends Component {
|
||||
textDecoration: 'underline',
|
||||
}}
|
||||
onClick={() => {
|
||||
global.platform.openWindow({
|
||||
global.platform.openTab({
|
||||
url: 'https://metamask.zendesk.com/hc/en-us/articles/360015289932',
|
||||
})
|
||||
}}
|
||||
|
@ -1761,7 +1761,7 @@ export function showSendTokenPage () {
|
||||
export function buyEth (opts) {
|
||||
return (dispatch) => {
|
||||
const url = getBuyEthUrl(opts)
|
||||
global.platform.openWindow({ url })
|
||||
global.platform.openTab({ url })
|
||||
dispatch({
|
||||
type: actionConstants.BUY_ETH,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user