From 626afe554a95021555940efc1b9d2f788ddba39e Mon Sep 17 00:00:00 2001 From: aitrean Date: Thu, 8 Feb 2018 23:02:56 -0500 Subject: [PATCH] Forward query arguments during redirect (#990) * Transfer query arguments over with routing. * Create a Query Redirect wrapper. * Add RedirectWithQuery component to SendTransaction index redirect. * Correct hash-query ordering. --- common/Root.tsx | 14 ++++++----- common/components/RedirectWithQuery.tsx | 25 +++++++++++++++++++ .../containers/Tabs/SendTransaction/index.tsx | 5 ++-- 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 common/components/RedirectWithQuery.tsx diff --git a/common/Root.tsx b/common/Root.tsx index 7ae3f165..0de08d6f 100644 --- a/common/Root.tsx +++ b/common/Root.tsx @@ -17,6 +17,7 @@ import { Store } from 'redux'; import { pollOfflineStatus } from 'actions/config'; import { AppState } from 'reducers'; import { RouteNotFound } from 'components/RouteNotFound'; +import { RedirectWithQuery } from 'components/RedirectWithQuery'; import 'what-input'; interface Props { @@ -94,14 +95,15 @@ export default class Root extends Component { const LegacyRoutes = withRouter(props => { const { history } = props; - const { pathname, hash } = props.location; + const { pathname } = props.location; + let { hash } = props.location; if (pathname === '/') { + hash = hash.split('?')[0]; switch (hash) { case '#send-transaction': case '#offline-transaction': - history.push('/send-transaction'); - break; + return ; case '#generate-wallet': history.push('/'); break; @@ -125,9 +127,9 @@ const LegacyRoutes = withRouter(props => { return ( - - - + + + ); }); diff --git a/common/components/RedirectWithQuery.tsx b/common/components/RedirectWithQuery.tsx new file mode 100644 index 00000000..58b6e9de --- /dev/null +++ b/common/components/RedirectWithQuery.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Redirect } from 'react-router'; + +interface RouterProps { + from: string; + to: string; + strictArg?: boolean; + exactArg?: boolean; + pushArg?: boolean; +} + +export class RedirectWithQuery extends React.Component { + public render() { + const { from, to, strictArg, exactArg, pushArg } = this.props; + return ( + + ); + } +} diff --git a/common/containers/Tabs/SendTransaction/index.tsx b/common/containers/Tabs/SendTransaction/index.tsx index e0954a60..c19a4022 100644 --- a/common/containers/Tabs/SendTransaction/index.tsx +++ b/common/containers/Tabs/SendTransaction/index.tsx @@ -6,7 +6,8 @@ import { UnlockHeader } from 'components/ui'; import { SideBar } from './components/index'; import { getWalletInst } from 'selectors/wallet'; import { AppState } from 'reducers'; -import { RouteComponentProps, Route, Switch, Redirect } from 'react-router'; +import { RouteComponentProps, Route, Switch } from 'react-router'; +import { RedirectWithQuery } from 'components/RedirectWithQuery'; import { WalletInfo, RequestPayment, @@ -68,7 +69,7 @@ class SendTransaction extends React.Component { exact={true} path={currentPath} render={() => ( -