diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-07 20:25:15 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-07 20:25:15 +0800 |
commit | 6f8a70834b72d678cd9d171d7bb0a3a2cfb4134d (patch) | |
tree | 7d9030c062e22043cd49f27527c9d4537e41e618 /packages/website/ts/pages | |
parent | 327cc307b35bf4a38c86f87c45718fd456025035 (diff) | |
download | dexon-sol-tools-6f8a70834b72d678cd9d171d7bb0a3a2cfb4134d.tar dexon-sol-tools-6f8a70834b72d678cd9d171d7bb0a3a2cfb4134d.tar.gz dexon-sol-tools-6f8a70834b72d678cd9d171d7bb0a3a2cfb4134d.tar.bz2 dexon-sol-tools-6f8a70834b72d678cd9d171d7bb0a3a2cfb4134d.tar.lz dexon-sol-tools-6f8a70834b72d678cd9d171d7bb0a3a2cfb4134d.tar.xz dexon-sol-tools-6f8a70834b72d678cd9d171d7bb0a3a2cfb4134d.tar.zst dexon-sol-tools-6f8a70834b72d678cd9d171d7bb0a3a2cfb4134d.zip |
Add onSelectedVersion callback so it can be handled in any way the caller wishes
Diffstat (limited to 'packages/website/ts/pages')
-rw-r--r-- | packages/website/ts/pages/documentation/doc_page.tsx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/website/ts/pages/documentation/doc_page.tsx b/packages/website/ts/pages/documentation/doc_page.tsx index e0d7b272d..1281219c6 100644 --- a/packages/website/ts/pages/documentation/doc_page.tsx +++ b/packages/website/ts/pages/documentation/doc_page.tsx @@ -13,6 +13,7 @@ import { configs } from 'ts/utils/configs'; import { constants } from 'ts/utils/constants'; import { docUtils } from 'ts/utils/doc_utils'; import { Translate } from 'ts/utils/translate'; +import { utils } from 'ts/utils/utils'; const ZERO_EX_JS_VERSION_MISSING_TOPLEVEL_PATH = '0.32.4'; @@ -80,6 +81,7 @@ export class DocPage extends React.Component<DocPageProps, DocPageState> { menuSubsectionsBySection={menuSubsectionsBySection} docsInfo={this.props.docsInfo} translate={this.props.translate} + onVersionSelected={this._onVersionSelected.bind(this)} /> <Documentation selectedVersion={this.props.docsVersion} @@ -89,6 +91,7 @@ export class DocPage extends React.Component<DocPageProps, DocPageState> { sidebarHeader={<SidebarHeader title={this.props.docsInfo.displayName} />} sourceUrl={sourceUrl} topBarHeight={60} + onVersionSelected={this._onVersionSelected.bind(this)} /> </div> ); @@ -141,4 +144,15 @@ export class DocPage extends React.Component<DocPageProps, DocPageState> { const sourceUrl = `${url}/blob/${tagPrefix}%40${this.props.docsVersion}/packages${pkg}`; return sourceUrl; } + private _onVersionSelected(semver: string) { + let path = window.location.pathname; + const lastChar = path[path.length - 1]; + if (_.isFinite(_.parseInt(lastChar))) { + const pathSections = path.split('/'); + pathSections.pop(); + path = pathSections.join('/'); + } + const baseUrl = utils.getCurrentBaseUrl(); + window.location.href = `${baseUrl}${path}/${semver}${window.location.hash}`; + } } |