mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Hide network form buttons when form is viewOnly
This commit is contained in:
parent
8a1820c537
commit
1373a90e27
@ -329,7 +329,6 @@ export default class NetworkForm extends PureComponent {
|
|||||||
viewOnly,
|
viewOnly,
|
||||||
isCurrentRpcTarget,
|
isCurrentRpcTarget,
|
||||||
networksTabIsInAddMode,
|
networksTabIsInAddMode,
|
||||||
isFullScreen,
|
|
||||||
} = this.props
|
} = this.props
|
||||||
const {
|
const {
|
||||||
networkName,
|
networkName,
|
||||||
@ -343,25 +342,12 @@ export default class NetworkForm extends PureComponent {
|
|||||||
const deletable = !networksTabIsInAddMode && !isCurrentRpcTarget && !viewOnly
|
const deletable = !networksTabIsInAddMode && !isCurrentRpcTarget && !viewOnly
|
||||||
|
|
||||||
const isSubmitDisabled = (
|
const isSubmitDisabled = (
|
||||||
viewOnly ||
|
|
||||||
this.stateIsUnchanged() ||
|
this.stateIsUnchanged() ||
|
||||||
!rpcUrl ||
|
!rpcUrl ||
|
||||||
!chainId ||
|
!chainId ||
|
||||||
Object.values(errors).some((x) => x)
|
Object.values(errors).some((x) => x)
|
||||||
)
|
)
|
||||||
|
|
||||||
// The secondary button is either the form cancel button, or a "back"
|
|
||||||
// button. It is never disabled in the popup, and sometimes disabled in
|
|
||||||
// the fullscreen UI.
|
|
||||||
const secondaryButtonDisabled = (
|
|
||||||
isFullScreen && (viewOnly || this.stateIsUnchanged())
|
|
||||||
)
|
|
||||||
const secondaryButtonMessageKey = (
|
|
||||||
!isFullScreen && viewOnly
|
|
||||||
? 'back'
|
|
||||||
: 'cancel'
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="networks-tab__network-form">
|
<div className="networks-tab__network-form">
|
||||||
{viewOnly ? null : this.renderWarning()}
|
{viewOnly ? null : this.renderWarning()}
|
||||||
@ -400,6 +386,8 @@ export default class NetworkForm extends PureComponent {
|
|||||||
'optionalBlockExplorerUrl',
|
'optionalBlockExplorerUrl',
|
||||||
)}
|
)}
|
||||||
<div className="network-form__footer">
|
<div className="network-form__footer">
|
||||||
|
{!viewOnly && (
|
||||||
|
<>
|
||||||
{
|
{
|
||||||
deletable && (
|
deletable && (
|
||||||
<Button
|
<Button
|
||||||
@ -413,9 +401,9 @@ export default class NetworkForm extends PureComponent {
|
|||||||
<Button
|
<Button
|
||||||
type="default"
|
type="default"
|
||||||
onClick={this.onCancel}
|
onClick={this.onCancel}
|
||||||
disabled={secondaryButtonDisabled}
|
disabled={this.stateIsUnchanged()}
|
||||||
>
|
>
|
||||||
{t(secondaryButtonMessageKey)}
|
{t('cancel')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="secondary"
|
type="secondary"
|
||||||
@ -424,6 +412,8 @@ export default class NetworkForm extends PureComponent {
|
|||||||
>
|
>
|
||||||
{ t('save') }
|
{ t('save') }
|
||||||
</Button>
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user