Redirect from /catalog to last catalog page (#3807)

* Redirect from /catalog to last catalog page

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Cleaning up

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Cleaning up more

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Splitting url params to pass in catalogURL()

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev authored and GitHub committed 2021-09-29 09:04:54 +03:00
1 parent 8bca8dd7dc
commit 6b123dc4c0
5 files changed
+23 -10

No files matched your search

@@ -25,7 +25,7 @@ import React from "react";
import { Redirect, Route, Switch } from "react-router";
import { disposeOnUnmount, observer } from "mobx-react";
import { BottomBar } from "./bottom-bar";
import { Catalog } from "../+catalog";
import { Catalog, previousActiveTab } from "../+catalog";
import { Preferences } from "../+preferences";
import { AddCluster } from "../+add-cluster";
import { ClusterView } from "./cluster-view";
@@ -40,6 +40,7 @@ import { reaction } from "mobx";
import { navigation } from "../../navigation";
import { setEntityOnRouteMatch } from "../../../main/catalog-sources/helpers/general-active-sync";
import { TopBar } from "../layout/topbar";
import { catalogURL, getPreviousTabUrl } from "../../../common/routes";
@observer
export class ClusterManager extends React.Component {
@@ -56,6 +57,7 @@ export class ClusterManager extends React.Component {
<main>
<div id="lens-views"/>
<Switch>
<Redirect exact from={catalogURL()} to={getPreviousTabUrl(previousActiveTab.get())}/>
<Route component={Welcome} {...routes.welcomeRoute} />
<Route component={Catalog} {...routes.catalogRoute} />
<Route component={Preferences} {...routes.preferencesRoute} />
@@ -33,7 +33,6 @@ import { clusterActivateHandler } from "../../../common/cluster-ipc";
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
import { navigate } from "../../navigation";
import { catalogURL, ClusterViewRouteParams } from "../../../common/routes";
import { previousActiveTab } from "../+catalog";
interface Props extends RouteComponentProps<ClusterViewRouteParams> {
}
@@ -85,7 +84,7 @@ export class ClusterView extends React.Component<Props> {
const disconnected = values[1];
if (hasLoadedView(this.clusterId) && disconnected) {
navigate(`${catalogURL()}/${previousActiveTab.get()}`); // redirect to catalog when active cluster get disconnected/not available
navigate(catalogURL()); // redirect to catalog when active cluster get disconnected/not available
}
}),
]);