diff --git a/src/renderer/components/+preferences/preferences.tsx b/src/renderer/components/+preferences/preferences.tsx index aa4c8aad68..0e1231cd2f 100644 --- a/src/renderer/components/+preferences/preferences.tsx +++ b/src/renderer/components/+preferences/preferences.tsx @@ -23,7 +23,7 @@ import "./preferences.scss"; import { makeObservable, observable } from "mobx"; import { observer } from "mobx-react"; import React from "react"; -import { matchPath, Redirect, Route, RouteComponentProps, RouteProps, Switch } from "react-router"; +import { matchPath, Redirect, Route, RouteProps, Switch } from "react-router"; import { appRoute, @@ -39,7 +39,7 @@ import { telemetryURL, } from "../../../common/routes"; import { AppPreferenceRegistry, RegisteredAppPreference } from "../../../extensions/registries/app-preference-registry"; -import { navigate, navigation } from "../../navigation"; +import { navigateWithoutHistoryChange, navigation } from "../../navigation"; import { SettingLayout } from "../layout/setting-layout"; import { SubTitle } from "../layout/sub-title"; import { Tab, Tabs } from "../tabs"; @@ -47,42 +47,23 @@ import { Application } from "./application"; import { Kubernetes } from "./kubernetes"; import { LensProxy } from "./proxy"; import { Telemetry } from "./telemetry"; -import { boundMethod } from "autobind-decorator"; - -interface Props extends RouteComponentProps { -} @observer -export class Preferences extends React.Component { +export class Preferences extends React.Component { @observable historyLength: number | undefined; - constructor(props: Props) { + constructor(props: {}) { super(props); makeObservable(this); } - componentDidMount() { - this.historyLength = this.props.history?.length; - } - - @boundMethod - onClose() { - const stepsToGoBack = navigation.length - this.historyLength + 1; - - if (isNaN(stepsToGoBack)) { - navigation.goBack(); - } else { - navigation.go(-stepsToGoBack); - } - } - renderNavigation() { const extensions = AppPreferenceRegistry.getInstance().getItems().filter(e => !e.showInPreferencesTab); const currentLocation = navigation.location.pathname; const isActive = (route: RouteProps) => !!matchPath(currentLocation, { path: route.path, exact: route.exact }); return ( - navigate(url)}> + navigateWithoutHistoryChange({ pathname: url })}>
Preferences
@@ -101,7 +82,6 @@ export class Preferences extends React.Component { navigation={this.renderNavigation()} className="Preferences" contentGaps={false} - back={this.onClose} > diff --git a/src/renderer/navigation/helpers.ts b/src/renderer/navigation/helpers.ts index 5b11232bb0..75e43543ad 100644 --- a/src/renderer/navigation/helpers.ts +++ b/src/renderer/navigation/helpers.ts @@ -38,6 +38,10 @@ export function navigate(location: LocationDescriptor) { } } +export function navigateWithoutHistoryChange(location: Partial) { + navigation.merge(location, true); +} + export function createPageParam(init: PageParamInit) { return new PageParam(init, navigation); }