Remove all but cluster url param when navigating
This commit is contained in:
parent
d5421266f5
commit
03f7d28aff
|
@ -12,6 +12,7 @@ import { ACCOUNT_ALIASES, ACCOUNT_ALIASES_PLURAL } from "./providers/accounts";
|
||||||
import TabbedPage from "components/TabbedPage";
|
import TabbedPage from "components/TabbedPage";
|
||||||
import TopAccountsCard from "components/TopAccountsCard";
|
import TopAccountsCard from "components/TopAccountsCard";
|
||||||
import SupplyCard from "components/SupplyCard";
|
import SupplyCard from "components/SupplyCard";
|
||||||
|
import { pickCluster } from "utils/url";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
|
@ -22,7 +23,9 @@ function App() {
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="row align-items-end">
|
<div className="row align-items-end">
|
||||||
<div className="col">
|
<div className="col">
|
||||||
<Link to={location => ({ ...location, pathname: "/" })}>
|
<Link
|
||||||
|
to={location => ({ ...pickCluster(location), pathname: "/" })}
|
||||||
|
>
|
||||||
<img src={Logo} width="250" alt="Solana Explorer" />
|
<img src={Logo} width="250" alt="Solana Explorer" />
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { useClusterModal } from "providers/cluster";
|
import { useClusterModal } from "providers/cluster";
|
||||||
import ClusterStatusButton from "components/ClusterStatusButton";
|
import ClusterStatusButton from "components/ClusterStatusButton";
|
||||||
|
import { pickCluster } from "utils/url";
|
||||||
|
|
||||||
export type Tab = "Transactions" | "Accounts" | "Supply";
|
export type Tab = "Transactions" | "Accounts" | "Supply";
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ function NavLink({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
to={location => ({ ...location, pathname: href })}
|
to={location => ({ ...pickCluster(location), pathname: href })}
|
||||||
className={classes}
|
className={classes}
|
||||||
>
|
>
|
||||||
{tab}
|
{tab}
|
||||||
|
|
|
@ -1,9 +1,26 @@
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
|
import { Location } from "history";
|
||||||
|
|
||||||
export function useQuery() {
|
export function useQuery() {
|
||||||
return new URLSearchParams(useLocation().search);
|
return new URLSearchParams(useLocation().search);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function pickCluster(location: Location): Location {
|
||||||
|
const cluster = new URLSearchParams(location.search).get("cluster");
|
||||||
|
|
||||||
|
let search = "";
|
||||||
|
if (cluster) {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
params.set("cluster", cluster);
|
||||||
|
search = params.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...location,
|
||||||
|
search
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function findGetParameter(parameterName: string): string | null {
|
export function findGetParameter(parameterName: string): string | null {
|
||||||
let result = null,
|
let result = null,
|
||||||
tmp = [];
|
tmp = [];
|
||||||
|
|
Loading…
Reference in New Issue