mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix CRDs not updating in Sidebar (#4288)
This commit is contained in:
parent
333d77f66a
commit
673f20fb74
@ -92,6 +92,8 @@ export class CrdList extends React.Component {
|
|||||||
tableId="crd"
|
tableId="crd"
|
||||||
className="CrdList"
|
className="CrdList"
|
||||||
store={crdStore}
|
store={crdStore}
|
||||||
|
// Don't subscribe the `crdStore` because <Sidebar> already has and is always mounted
|
||||||
|
subscribeStores={false}
|
||||||
items={items}
|
items={items}
|
||||||
sortingCallbacks={sortingCallbacks}
|
sortingCallbacks={sortingCallbacks}
|
||||||
searchFilters={Object.values(sortingCallbacks)}
|
searchFilters={Object.values(sortingCallbacks)}
|
||||||
|
|||||||
@ -36,10 +36,12 @@ import { kubeSelectedUrlParam, toggleDetails } from "../kube-detail-params";
|
|||||||
export interface KubeObjectListLayoutProps<K extends KubeObject> extends ItemListLayoutProps<K> {
|
export interface KubeObjectListLayoutProps<K extends KubeObject> extends ItemListLayoutProps<K> {
|
||||||
store: KubeObjectStore<K>;
|
store: KubeObjectStore<K>;
|
||||||
dependentStores?: KubeObjectStore<KubeObject>[];
|
dependentStores?: KubeObjectStore<KubeObject>[];
|
||||||
|
subscribeStores?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultProps: Partial<KubeObjectListLayoutProps<KubeObject>> = {
|
const defaultProps: Partial<KubeObjectListLayoutProps<KubeObject>> = {
|
||||||
onDetails: (item: KubeObject) => toggleDetails(item.selfLink),
|
onDetails: (item: KubeObject) => toggleDetails(item.selfLink),
|
||||||
|
subscribeStores: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -56,15 +58,17 @@ export class KubeObjectListLayout<K extends KubeObject> extends React.Component<
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { store, dependentStores = [] } = this.props;
|
const { store, dependentStores = [], subscribeStores } = this.props;
|
||||||
const stores = Array.from(new Set([store, ...dependentStores]));
|
const stores = Array.from(new Set([store, ...dependentStores]));
|
||||||
|
|
||||||
disposeOnUnmount(this, [
|
if (subscribeStores) {
|
||||||
kubeWatchApi.subscribeStores(stores, {
|
disposeOnUnmount(this, [
|
||||||
preload: true,
|
kubeWatchApi.subscribeStores(stores, {
|
||||||
namespaces: clusterContext.contextNamespaces,
|
preload: true,
|
||||||
}),
|
namespaces: clusterContext.contextNamespaces,
|
||||||
]);
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import styles from "./sidebar.module.css";
|
|||||||
import type { TabLayoutRoute } from "./tab-layout";
|
import type { TabLayoutRoute } from "./tab-layout";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { disposeOnUnmount, observer } from "mobx-react";
|
||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { Workloads } from "../+workloads";
|
import { Workloads } from "../+workloads";
|
||||||
@ -42,6 +42,7 @@ import * as routes from "../../../common/routes";
|
|||||||
import { Config } from "../+config";
|
import { Config } from "../+config";
|
||||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||||
import { SidebarCluster } from "./sidebar-cluster";
|
import { SidebarCluster } from "./sidebar-cluster";
|
||||||
|
import { kubeWatchApi } from "../../../common/k8s-api/kube-watch-api";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -51,8 +52,10 @@ interface Props {
|
|||||||
export class Sidebar extends React.Component<Props> {
|
export class Sidebar extends React.Component<Props> {
|
||||||
static displayName = "Sidebar";
|
static displayName = "Sidebar";
|
||||||
|
|
||||||
async componentDidMount() {
|
componentDidMount() {
|
||||||
crdStore.reloadAll();
|
disposeOnUnmount(this, [
|
||||||
|
kubeWatchApi.subscribeStores([crdStore]),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCustomResources() {
|
renderCustomResources() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user