mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Revert 2844 (#2980)
* Revert "review comments" This reverts commit97f2ecd88d. * Revert "Switch to I, remove type parameter default" This reverts commita3073cc99b. * Revert "Improve Table typing and remove annotations on callbacks" This reverts commitdefb0ea0dd.
This commit is contained in:
1 parent
97f2ecd88d
commit
60a19143b4
55 files changed
+471
-479
No files matched your search
@@ -33,7 +33,6 @@ import { crdStore } from "../+custom-resources/crd.store";
|
||||
import { CrdResourceDetails } from "../+custom-resources";
|
||||
import { KubeObjectMenu } from "./kube-object-menu";
|
||||
import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
||||
import { CustomResourceDefinition } from "../../api/endpoints";
|
||||
|
||||
/**
|
||||
* Used to store `object.selfLink` to show more info about resource in the details panel.
|
||||
@@ -100,7 +99,15 @@ export class KubeObjectDetails extends React.Component {
|
||||
}
|
||||
|
||||
@computed get object() {
|
||||
return apiManager.getStore(this.path)?.getByPath(this.path);
|
||||
const store = apiManager.getStore(this.path);
|
||||
|
||||
if (store) {
|
||||
return store.getByPath(this.path);
|
||||
}
|
||||
}
|
||||
|
||||
@computed get isCrdInstance() {
|
||||
return !!crdStore.getByObject(this.object);
|
||||
}
|
||||
|
||||
@disposeOnUnmount
|
||||
@@ -130,7 +137,7 @@ export class KubeObjectDetails extends React.Component {
|
||||
});
|
||||
|
||||
render() {
|
||||
const { object, isLoading, loadingError } = this;
|
||||
const { object, isLoading, loadingError, isCrdInstance } = this;
|
||||
const isOpen = !!(object || isLoading || loadingError);
|
||||
let title = "";
|
||||
let details: React.ReactNode[];
|
||||
@@ -143,7 +150,7 @@ export class KubeObjectDetails extends React.Component {
|
||||
return <item.components.Details object={object} key={`object-details-${index}`}/>;
|
||||
});
|
||||
|
||||
if (object instanceof CustomResourceDefinition && details.length === 0) {
|
||||
if (isCrdInstance && details.length === 0) {
|
||||
details.push(<CrdResourceDetails object={object}/>);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,22 +30,21 @@ import { KubeObjectMenu } from "./kube-object-menu";
|
||||
import { kubeSelectedUrlParam, showDetails } from "./kube-object-details";
|
||||
import { kubeWatchApi } from "../../api/kube-watch-api";
|
||||
import { clusterContext } from "../context";
|
||||
import { FilterType, pageFilters } from "../item-object-list/page-filters.store";
|
||||
|
||||
export interface KubeObjectListLayoutProps<K extends KubeObject> extends ItemListLayoutProps<K> {
|
||||
store: KubeObjectStore<K>;
|
||||
dependentStores?: KubeObjectStore<KubeObject>[];
|
||||
export interface KubeObjectListLayoutProps extends ItemListLayoutProps {
|
||||
store: KubeObjectStore;
|
||||
dependentStores?: KubeObjectStore[];
|
||||
}
|
||||
|
||||
const defaultProps: Partial<KubeObjectListLayoutProps<KubeObject>> = {
|
||||
const defaultProps: Partial<KubeObjectListLayoutProps> = {
|
||||
onDetails: (item: KubeObject) => showDetails(item.selfLink),
|
||||
};
|
||||
|
||||
@observer
|
||||
export class KubeObjectListLayout<K extends KubeObject> extends React.Component<KubeObjectListLayoutProps<K>> {
|
||||
export class KubeObjectListLayout extends React.Component<KubeObjectListLayoutProps> {
|
||||
static defaultProps = defaultProps as object;
|
||||
|
||||
constructor(props: KubeObjectListLayoutProps<K>) {
|
||||
constructor(props: KubeObjectListLayoutProps) {
|
||||
super(props);
|
||||
makeObservable(this);
|
||||
}
|
||||
@@ -77,18 +76,7 @@ export class KubeObjectListLayout<K extends KubeObject> extends React.Component<
|
||||
items={items}
|
||||
preloadStores={false} // loading handled in kubeWatchApi.subscribeStores()
|
||||
detailsItem={this.selectedItem}
|
||||
renderItemMenu={(item: K) => <KubeObjectMenu object={item} />} // safe because we are dealing with KubeObjects here
|
||||
filterCallbacks={{
|
||||
[FilterType.NAMESPACE]: items => {
|
||||
const filterValues = pageFilters.getValues(FilterType.NAMESPACE);
|
||||
|
||||
if (filterValues.length > 0) {
|
||||
return items.filter(item => filterValues.includes(item.getNs()));
|
||||
}
|
||||
|
||||
return items;
|
||||
},
|
||||
}}
|
||||
renderItemMenu={(item: KubeObject) => <KubeObjectMenu object={item} />} // safe because we are dealing with KubeObjects here
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user