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:
parent
c52a975aad
commit
bb2965e4df
|
@ -54,6 +54,7 @@ class ElectronNav extends React.Component<Props, State> {
|
||||||
link={link}
|
link={link}
|
||||||
isHomepage={link === navigationLinks[0]}
|
isHomepage={link === navigationLinks[0]}
|
||||||
className="ElectronNavLink"
|
className="ElectronNavLink"
|
||||||
|
isNotEnabled={false}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -3,9 +3,11 @@ import React, { PureComponent } from 'react';
|
||||||
import { navigationLinks } from 'config';
|
import { navigationLinks } from 'config';
|
||||||
import NavigationLink from 'components/NavigationLink';
|
import NavigationLink from 'components/NavigationLink';
|
||||||
import './Navigation.scss';
|
import './Navigation.scss';
|
||||||
|
import { TAB } from './constants';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
color?: string | false;
|
color?: string | false;
|
||||||
|
unsupportedTabs?: TAB[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
|
@ -30,7 +32,7 @@ export default class Navigation extends PureComponent<Props, State> {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const { color } = this.props;
|
const { color, unsupportedTabs } = this.props;
|
||||||
const borderStyle: BorderStyle = {};
|
const borderStyle: BorderStyle = {};
|
||||||
|
|
||||||
if (color) {
|
if (color) {
|
||||||
|
@ -58,6 +60,9 @@ export default class Navigation extends PureComponent<Props, State> {
|
||||||
link={link}
|
link={link}
|
||||||
isHomepage={link === navigationLinks[0]}
|
isHomepage={link === navigationLinks[0]}
|
||||||
className="NavigationLink"
|
className="NavigationLink"
|
||||||
|
isNotEnabled={
|
||||||
|
unsupportedTabs && unsupportedTabs.map(tab => tab.toString()).includes(link.name)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -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'
|
||||||
|
}
|
|
@ -122,7 +122,10 @@ class Header extends Component<Props, State> {
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<Navigation color={!network.isCustom && network.color} />
|
<Navigation
|
||||||
|
color={!network.isCustom && network.color}
|
||||||
|
unsupportedTabs={network.unsupportedTabs}
|
||||||
|
/>
|
||||||
|
|
||||||
<CustomNodeModal
|
<CustomNodeModal
|
||||||
isOpen={isAddingCustomNode}
|
isOpen={isAddingCustomNode}
|
||||||
|
|
|
@ -9,13 +9,18 @@ interface Props extends RouteComponentProps<{}> {
|
||||||
link: NavigationLink;
|
link: NavigationLink;
|
||||||
isHomepage: boolean;
|
isHomepage: boolean;
|
||||||
className: string;
|
className: string;
|
||||||
|
isNotEnabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
class NavigationLinkClass extends React.PureComponent<Props, {}> {
|
class NavigationLinkClass extends React.PureComponent<Props, {}> {
|
||||||
public render() {
|
public render() {
|
||||||
const { link, location, isHomepage, className } = this.props;
|
const { link, location, isHomepage, className, isNotEnabled } = this.props;
|
||||||
let isActive = false;
|
let isActive = false;
|
||||||
|
|
||||||
|
if (isNotEnabled) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!link.external) {
|
if (!link.external) {
|
||||||
// isActive if
|
// isActive if
|
||||||
// 1) Current path is the same as link
|
// 1) Current path is the same as link
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { TAB } from 'components/Header/components/constants';
|
||||||
|
|
||||||
type StaticNetworkIds =
|
type StaticNetworkIds =
|
||||||
| 'ETH'
|
| 'ETH'
|
||||||
| 'Ropsten'
|
| 'Ropsten'
|
||||||
|
@ -70,6 +72,7 @@ interface StaticNetworkConfig {
|
||||||
isTestnet?: boolean;
|
isTestnet?: boolean;
|
||||||
gasPriceSettings: GasPriceSetting;
|
gasPriceSettings: GasPriceSetting;
|
||||||
shouldEstimateGasPrice?: boolean;
|
shouldEstimateGasPrice?: boolean;
|
||||||
|
unsupportedTabs?: TAB[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CustomNetworkConfig {
|
interface CustomNetworkConfig {
|
||||||
|
@ -80,6 +83,7 @@ interface CustomNetworkConfig {
|
||||||
unit: string;
|
unit: string;
|
||||||
chainId: number;
|
chainId: number;
|
||||||
dPathFormats: DPathFormats | null;
|
dPathFormats: DPathFormats | null;
|
||||||
|
unsupportedTabs?: TAB[];
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetworkConfig = CustomNetworkConfig | StaticNetworkConfig;
|
type NetworkConfig = CustomNetworkConfig | StaticNetworkConfig;
|
||||||
|
|
Loading…
Reference in New Issue