1
0
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:
Erik Marks 2020-10-28 13:36:52 -07:00
parent 8a1820c537
commit 1373a90e27

View File

@ -329,7 +329,6 @@ export default class NetworkForm extends PureComponent {
viewOnly,
isCurrentRpcTarget,
networksTabIsInAddMode,
isFullScreen,
} = this.props
const {
networkName,
@ -343,25 +342,12 @@ export default class NetworkForm extends PureComponent {
const deletable = !networksTabIsInAddMode && !isCurrentRpcTarget && !viewOnly
const isSubmitDisabled = (
viewOnly ||
this.stateIsUnchanged() ||
!rpcUrl ||
!chainId ||
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 (
<div className="networks-tab__network-form">
{viewOnly ? null : this.renderWarning()}
@ -400,30 +386,34 @@ export default class NetworkForm extends PureComponent {
'optionalBlockExplorerUrl',
)}
<div className="network-form__footer">
{
deletable && (
{!viewOnly && (
<>
{
deletable && (
<Button
type="danger"
onClick={this.onDelete}
>
{ t('delete') }
</Button>
)
}
<Button
type="danger"
onClick={this.onDelete}
type="default"
onClick={this.onCancel}
disabled={this.stateIsUnchanged()}
>
{ t('delete') }
{t('cancel')}
</Button>
)
}
<Button
type="default"
onClick={this.onCancel}
disabled={secondaryButtonDisabled}
>
{t(secondaryButtonMessageKey)}
</Button>
<Button
type="secondary"
disabled={isSubmitDisabled}
onClick={this.onSubmit}
>
{ t('save') }
</Button>
<Button
type="secondary"
disabled={isSubmitDisabled}
onClick={this.onSubmit}
>
{ t('save') }
</Button>
</>
)}
</div>
</div>
)