From 6f7e3c27e2f984f28021e0c4fd03b1c948a9c7a0 Mon Sep 17 00:00:00 2001 From: James Prado Date: Wed, 4 Oct 2017 00:13:49 -0400 Subject: [PATCH] Fix regressions introduced in #241 (#247) * Fix location query * Remove unnecessary polyfill * Fix tslint error & update history types * Parse search str using Node Query String * Revert "Parse search str using Node Query String" This reverts commit 0a482dabf29c3fbcbfd3112b974d6b98c14dca2e. * fix formatting * Add query-string * Rename App container to TabSection & pass it location prop * Add react-router withRouter HOC to NavigationLink * various adjustments/finalizations * Add location to props interface --- .../Header/components/Navigation.tsx | 13 +---- .../Header/components/NavigationLink.tsx | 18 ++++-- common/components/Header/index.tsx | 6 +- .../{App => TabSection}/NotificationRow.tsx | 8 +-- .../{App => TabSection}/Notifications.scss | 0 .../{App => TabSection}/Notifications.tsx | 4 +- .../containers/{App => TabSection}/index.tsx | 8 +-- common/containers/Tabs/ENS/components/ENS.tsx | 6 +- .../containers/Tabs/GenerateWallet/index.tsx | 6 +- common/containers/Tabs/Help/index.tsx | 6 +- .../containers/Tabs/SendTransaction/index.tsx | 18 +++--- common/containers/Tabs/Swap/index.tsx | 6 +- common/containers/Tabs/ViewWallet/index.tsx | 6 +- common/containers/index.ts | 4 +- package-lock.json | 58 +++++++++---------- package.json | 2 + 16 files changed, 78 insertions(+), 91 deletions(-) rename common/containers/{App => TabSection}/NotificationRow.tsx (85%) rename common/containers/{App => TabSection}/Notifications.scss (100%) rename common/containers/{App => TabSection}/Notifications.tsx (93%) rename common/containers/{App => TabSection}/index.tsx (93%) diff --git a/common/components/Header/components/Navigation.tsx b/common/components/Header/components/Navigation.tsx index c4a8a224..a070717f 100644 --- a/common/components/Header/components/Navigation.tsx +++ b/common/components/Header/components/Navigation.tsx @@ -36,7 +36,6 @@ const tabs = [ ]; interface Props { - location: object; color?: string; } @@ -62,7 +61,7 @@ export default class Navigation extends Component { */ public render() { - const { location, color } = this.props; + const { color } = this.props; const borderStyle: BorderStyle = {}; if (color) { @@ -80,7 +79,6 @@ export default class Navigation extends Component { @@ -89,13 +87,7 @@ export default class Navigation extends Component {
    {tabs.map(link => { - return ( - - ); + return ; })}
@@ -104,7 +96,6 @@ export default class Navigation extends Component { diff --git a/common/components/Header/components/NavigationLink.tsx b/common/components/Header/components/NavigationLink.tsx index 2b290287..12c478d5 100644 --- a/common/components/Header/components/NavigationLink.tsx +++ b/common/components/Header/components/NavigationLink.tsx @@ -1,6 +1,6 @@ import classnames from 'classnames'; import React from 'react'; -import { Link } from 'react-router-dom'; +import { Link, withRouter } from 'react-router-dom'; import translate, { translateRaw } from 'translations'; import './NavigationLink.scss'; @@ -10,12 +10,19 @@ interface Props { to?: string; external?: boolean; }; - location: any; } -export default class NavigationLink extends React.Component { +interface InjectedLocation extends Props { + location: { pathname: string }; +} + +class NavigationLink extends React.Component { + get injected() { + return this.props as InjectedLocation; + } public render() { - const { link, location } = this.props; + const { link } = this.props; + const { location } = this.injected; const linkClasses = classnames({ 'NavigationLink-link': true, 'is-disabled': !link.to, @@ -48,3 +55,6 @@ export default class NavigationLink extends React.Component { return
  • {linkEl}
  • ; } } + +// withRouter is a HOC which provides NavigationLink with a react-router location prop +export default withRouter(NavigationLink); diff --git a/common/components/Header/index.tsx b/common/components/Header/index.tsx index ec4d9fba..85918477 100644 --- a/common/components/Header/index.tsx +++ b/common/components/Header/index.tsx @@ -17,7 +17,6 @@ import { getKeyByValue } from 'utils/helpers'; import './index.scss'; interface Props { - location: {}; languageSelection: string; nodeSelection: string; gasPriceGwei: number; @@ -124,10 +123,7 @@ export default class Header extends Component { - + ); } diff --git a/common/containers/App/NotificationRow.tsx b/common/containers/TabSection/NotificationRow.tsx similarity index 85% rename from common/containers/App/NotificationRow.tsx rename to common/containers/TabSection/NotificationRow.tsx index 64cfb74a..f194cdd4 100644 --- a/common/containers/App/NotificationRow.tsx +++ b/common/containers/TabSection/NotificationRow.tsx @@ -19,12 +19,8 @@ export default class NotificationRow extends Component { return (
    - - {level} - -
    - {msg} -
    + {level} +
    {msg}