1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 14:15:06 +01:00
metamask-extension/ui/pages/settings/networks-tab/networks-tab-content/networks-tab-content.js

53 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-11-04 22:48:21 +01:00
import React from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
2021-11-04 22:48:21 +01:00
import NetworksForm from '../networks-form';
import NetworksList from '../networks-list';
import { getProviderConfig } from '../../../../ducks/metamask/metamask';
2021-11-04 22:48:21 +01:00
import {
DEFAULT_ROUTE,
NETWORKS_ROUTE,
} from '../../../../helpers/constants/routes';
2021-11-04 22:48:21 +01:00
const NetworksTabContent = ({
networkDefaultedToProvider,
networkIsSelected,
networksToRender,
selectedNetwork,
shouldRenderNetworkForm,
}) => {
const providerConfig = useSelector(getProviderConfig);
const history = useHistory();
2021-11-04 22:48:21 +01:00
return (
<>
<NetworksList
networkDefaultedToProvider={networkDefaultedToProvider}
networkIsSelected={networkIsSelected}
networksToRender={networksToRender}
selectedNetworkConfigurationId={selectedNetwork.networkConfigurationId}
2021-11-04 22:48:21 +01:00
/>
{shouldRenderNetworkForm ? (
<NetworksForm
isCurrentRpcTarget={providerConfig.rpcUrl === selectedNetwork.rpcUrl}
2021-11-04 22:48:21 +01:00
networksToRender={networksToRender}
selectedNetwork={selectedNetwork}
submitCallback={() => history.push(DEFAULT_ROUTE)}
cancelCallback={() => history.push(NETWORKS_ROUTE)}
2021-11-04 22:48:21 +01:00
/>
) : null}
</>
);
};
NetworksTabContent.propTypes = {
networkDefaultedToProvider: PropTypes.bool,
networkIsSelected: PropTypes.bool,
networksToRender: PropTypes.arrayOf(PropTypes.object).isRequired,
selectedNetwork: PropTypes.object,
shouldRenderNetworkForm: PropTypes.bool.isRequired,
};
export default NetworksTabContent;