mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Passing extra routes where to find clusterId
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
e005985621
commit
0a8663a166
@ -9,8 +9,10 @@ import { General } from "./general";
|
|||||||
import { WizardLayout } from "../layout/wizard-layout";
|
import { WizardLayout } from "../layout/wizard-layout";
|
||||||
import { ClusterIcon } from "../cluster-icon";
|
import { ClusterIcon } from "../cluster-icon";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { getMatchedCluster } from "../cluster-manager/cluster-view.route";
|
import { getMatchedClusterId } from "../cluster-manager/cluster-view.route";
|
||||||
import { navigate } from "../../navigation";
|
import { navigate } from "../../navigation";
|
||||||
|
import { clusterSettingsRoute } from "./cluster-settings.route";
|
||||||
|
import { clusterStore } from "../../../common/cluster-store";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ClusterSettings extends React.Component {
|
export class ClusterSettings extends React.Component {
|
||||||
@ -34,7 +36,7 @@ export class ClusterSettings extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const cluster = getMatchedCluster();
|
const cluster = clusterStore.getById(getMatchedClusterId([clusterSettingsRoute]));
|
||||||
if (!cluster) return null;
|
if (!cluster) return null;
|
||||||
const header = (
|
const header = (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import { hasLoadedView, initView, lensViews, refreshViews } from "./lens-views";
|
|||||||
export class ClusterManager extends React.Component {
|
export class ClusterManager extends React.Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
disposeOnUnmount(this, [
|
disposeOnUnmount(this, [
|
||||||
reaction(getMatchedClusterId, initView, {
|
reaction(() => getMatchedClusterId(), initView, {
|
||||||
fireImmediately: true
|
fireImmediately: true
|
||||||
}),
|
}),
|
||||||
reaction(() => [
|
reaction(() => [
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { ipcRenderer } from "electron";
|
|||||||
import { matchPath, RouteProps } from "react-router";
|
import { matchPath, RouteProps } from "react-router";
|
||||||
import { buildURL, navigation } from "../../navigation";
|
import { buildURL, navigation } from "../../navigation";
|
||||||
import { clusterStore, getHostedClusterId } from "../../../common/cluster-store";
|
import { clusterStore, getHostedClusterId } from "../../../common/cluster-store";
|
||||||
import { clusterSettingsRoute } from "../+cluster-settings/cluster-settings.route";
|
|
||||||
|
|
||||||
export interface IClusterViewRouteParams {
|
export interface IClusterViewRouteParams {
|
||||||
clusterId: string;
|
clusterId: string;
|
||||||
@ -16,12 +15,12 @@ export const clusterViewRoute: RouteProps = {
|
|||||||
|
|
||||||
export const clusterViewURL = buildURL<IClusterViewRouteParams>(clusterViewRoute.path)
|
export const clusterViewURL = buildURL<IClusterViewRouteParams>(clusterViewRoute.path)
|
||||||
|
|
||||||
export function getMatchedClusterId(): string {
|
export function getMatchedClusterId(extraRoutes: RouteProps[] = []): string {
|
||||||
const matched = matchPath<IClusterViewRouteParams>(navigation.location.pathname, {
|
const matched = matchPath<IClusterViewRouteParams>(navigation.location.pathname, {
|
||||||
exact: true,
|
exact: true,
|
||||||
path: [
|
path: [
|
||||||
clusterViewRoute.path,
|
clusterViewRoute.path,
|
||||||
clusterSettingsRoute.path,
|
...extraRoutes.map(route => route.path)
|
||||||
].flat(),
|
].flat(),
|
||||||
})
|
})
|
||||||
if (matched) {
|
if (matched) {
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import { cssNames, IClassName, autobind } from "../../utils";
|
|||||||
import { Badge } from "../badge";
|
import { Badge } from "../badge";
|
||||||
import { navigate } from "../../navigation";
|
import { navigate } from "../../navigation";
|
||||||
import { addClusterURL } from "../+add-cluster";
|
import { addClusterURL } from "../+add-cluster";
|
||||||
import { clusterSettingsURL } from "../+cluster-settings";
|
import { clusterSettingsURL, clusterSettingsRoute } from "../+cluster-settings";
|
||||||
import { landingURL } from "../+landing-page";
|
import { landingURL } from "../+landing-page";
|
||||||
import { Tooltip } from "../tooltip";
|
import { Tooltip } from "../tooltip";
|
||||||
import { ConfirmDialog } from "../confirm-dialog";
|
import { ConfirmDialog } from "../confirm-dialog";
|
||||||
@ -124,7 +124,7 @@ export class ClustersMenu extends React.Component<Props> {
|
|||||||
key={cluster.id}
|
key={cluster.id}
|
||||||
showErrors={true}
|
showErrors={true}
|
||||||
cluster={cluster}
|
cluster={cluster}
|
||||||
isActive={cluster.id === getMatchedClusterId()}
|
isActive={cluster.id === getMatchedClusterId([clusterSettingsRoute])}
|
||||||
onClick={() => this.showCluster(cluster.id)}
|
onClick={() => this.showCluster(cluster.id)}
|
||||||
onContextMenu={() => this.showContextMenu(cluster)}
|
onContextMenu={() => this.showContextMenu(cluster)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user