aboutsummaryrefslogtreecommitdiffstats
path: root/packages/react-shared/src
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-07 20:25:15 +0800
committerFabio Berger <me@fabioberger.com>2018-03-07 20:25:15 +0800
commit6f8a70834b72d678cd9d171d7bb0a3a2cfb4134d (patch)
tree7d9030c062e22043cd49f27527c9d4537e41e618 /packages/react-shared/src
parent327cc307b35bf4a38c86f87c45718fd456025035 (diff)
downloaddexon-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/react-shared/src')
-rw-r--r--packages/react-shared/src/ts/components/nested_sidebar_menu.tsx2
-rw-r--r--packages/react-shared/src/ts/components/version_drop_down.tsx11
-rw-r--r--packages/react-shared/src/ts/utils/utils.ts6
3 files changed, 4 insertions, 15 deletions
diff --git a/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx
index 6a3cf2615..f562b3113 100644
--- a/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx
+++ b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx
@@ -18,6 +18,7 @@ export interface NestedSidebarMenuProps {
onMenuItemClick?: () => void;
selectedVersion?: string;
versions?: string[];
+ onVersionSelected?: (semver: string) => void;
}
export interface NestedSidebarMenuState {}
@@ -69,6 +70,7 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N
<VersionDropDown
selectedVersion={this.props.selectedVersion}
versions={this.props.versions}
+ onVersionSelected={this.props.onVersionSelected}
/>
</div>
)}
diff --git a/packages/react-shared/src/ts/components/version_drop_down.tsx b/packages/react-shared/src/ts/components/version_drop_down.tsx
index 86fe43507..d9e49b205 100644
--- a/packages/react-shared/src/ts/components/version_drop_down.tsx
+++ b/packages/react-shared/src/ts/components/version_drop_down.tsx
@@ -8,6 +8,7 @@ import { utils } from '../utils/utils';
export interface VersionDropDownProps {
selectedVersion: string;
versions: string[];
+ onVersionSelected: (semver: string) => void;
}
export interface VersionDropDownState {}
@@ -33,14 +34,6 @@ export class VersionDropDown extends React.Component<VersionDropDownProps, Versi
return items;
}
private _updateSelectedVersion(e: any, index: number, 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}`;
+ this.props.onVersionSelected(semver);
}
}
diff --git a/packages/react-shared/src/ts/utils/utils.ts b/packages/react-shared/src/ts/utils/utils.ts
index 0d2e045b8..ebe896bbc 100644
--- a/packages/react-shared/src/ts/utils/utils.ts
+++ b/packages/react-shared/src/ts/utils/utils.ts
@@ -30,12 +30,6 @@ export const utils = {
const id = name.replace(/ /g, '-');
return id;
},
- getCurrentBaseUrl() {
- const port = window.location.port;
- const hasPort = !_.isUndefined(port);
- const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`;
- return baseUrl;
- },
getEtherScanLinkIfExists(addressOrTxHash: string, networkId: number, suffix: EtherscanLinkSuffixes): string {
const networkName = constants.NETWORK_NAME_BY_ID[networkId];
if (_.isUndefined(networkName)) {