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}
|
||||
isHomepage={link === navigationLinks[0]}
|
||||
className="ElectronNavLink"
|
||||
isNotEnabled={false}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
||||
<Navigation color={!network.isCustom && network.color} />
|
||||
<Navigation
|
||||
color={!network.isCustom && network.color}
|
||||
unsupportedTabs={network.unsupportedTabs}
|
||||
/>
|
||||
|
||||
<CustomNodeModal
|
||||
isOpen={isAddingCustomNode}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue