Disable tabs by network configuration (#1952)

* Adds unsupported tabs configuration by network

* Removes unused reference

* Adding network config to solve merge conflict

* Updating from develop

* Update to develop

* Update

* Update

* Update

* Deletes unused file
This commit is contained in:
Alejandro Cavallero 2018-07-03 15:31:55 -03:00 committed by Daniel Ternyak
parent c52a975aad
commit bb2965e4df
6 changed files with 31 additions and 3 deletions

View File

@ -54,6 +54,7 @@ class ElectronNav extends React.Component<Props, State> {
link={link}
isHomepage={link === navigationLinks[0]}
className="ElectronNavLink"
isNotEnabled={false}
/>
))}
</ul>

View File

@ -3,9 +3,11 @@ import React, { PureComponent } from 'react';
import { navigationLinks } from 'config';
import NavigationLink from 'components/NavigationLink';
import './Navigation.scss';
import { TAB } from './constants';
interface Props {
color?: string | false;
unsupportedTabs?: TAB[];
}
interface State {
@ -30,7 +32,7 @@ export default class Navigation extends PureComponent<Props, State> {
*/
public render() {
const { color } = this.props;
const { color, unsupportedTabs } = this.props;
const borderStyle: BorderStyle = {};
if (color) {
@ -58,6 +60,9 @@ export default class Navigation extends PureComponent<Props, State> {
link={link}
isHomepage={link === navigationLinks[0]}
className="NavigationLink"
isNotEnabled={
unsupportedTabs && unsupportedTabs.map(tab => tab.toString()).includes(link.name)
}
/>
))}
</ul>

View File

@ -0,0 +1,10 @@
export enum TAB {
VIEW = 'NAV_VIEW',
CREATE = 'NAV_GENERATEWALLET',
SWAP = 'NAV_SWAP',
CONTRACTS = 'NAV_CONTRACTS',
ENS = 'NAV_ENS',
SIGN = 'NAV_SIGN',
TXSTATUS = 'NAV_TXSTATUS',
BROADCAST = 'NAV_BROADCAST'
}

View File

@ -122,7 +122,10 @@ class Header extends Component<Props, State> {
</section>
</section>
<Navigation color={!network.isCustom && network.color} />
<Navigation
color={!network.isCustom && network.color}
unsupportedTabs={network.unsupportedTabs}
/>
<CustomNodeModal
isOpen={isAddingCustomNode}

View File

@ -9,13 +9,18 @@ interface Props extends RouteComponentProps<{}> {
link: NavigationLink;
isHomepage: boolean;
className: string;
isNotEnabled?: boolean;
}
class NavigationLinkClass extends React.PureComponent<Props, {}> {
public render() {
const { link, location, isHomepage, className } = this.props;
const { link, location, isHomepage, className, isNotEnabled } = this.props;
let isActive = false;
if (isNotEnabled) {
return null;
}
if (!link.external) {
// isActive if
// 1) Current path is the same as link

View File

@ -1,3 +1,5 @@
import { TAB } from 'components/Header/components/constants';
type StaticNetworkIds =
| 'ETH'
| 'Ropsten'
@ -70,6 +72,7 @@ interface StaticNetworkConfig {
isTestnet?: boolean;
gasPriceSettings: GasPriceSetting;
shouldEstimateGasPrice?: boolean;
unsupportedTabs?: TAB[];
}
interface CustomNetworkConfig {
@ -80,6 +83,7 @@ interface CustomNetworkConfig {
unit: string;
chainId: number;
dPathFormats: DPathFormats | null;
unsupportedTabs?: TAB[];
}
type NetworkConfig = CustomNetworkConfig | StaticNetworkConfig;