mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Improve Table typing and remove annotations on callbacks (#2981)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
c6a4d55d86
commit
64ac04186b
59 files changed
+487
-482
No files matched your search
@@ -30,9 +30,7 @@ import type { KubeObject } from "../../api/kube-object";
|
||||
import { Spinner } from "../spinner";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { crdStore } from "../+custom-resources/crd.store";
|
||||
import { CrdResourceDetails } from "../+custom-resources";
|
||||
import { KubeObjectMenu } from "./kube-object-menu";
|
||||
import type { CustomResourceDefinition } from "../../api/endpoints";
|
||||
import { KubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
||||
import logger from "../../../main/logger";
|
||||
|
||||
@@ -108,6 +106,8 @@ export class KubeObjectDetails extends React.Component {
|
||||
?.getByPath(this.path);
|
||||
} catch (error) {
|
||||
logger.error(`[KUBE-OBJECT-DETAILS]: failed to get store or object: ${error}`, { path: this.path });
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ export class KubeObjectDetails extends React.Component {
|
||||
});
|
||||
|
||||
render() {
|
||||
const { object, isLoading, loadingError, isCrdInstance } = this;
|
||||
const { object, isLoading, loadingError } = this;
|
||||
const isOpen = !!(object || isLoading || loadingError);
|
||||
|
||||
if (!object) {
|
||||
@@ -169,10 +169,6 @@ export class KubeObjectDetails extends React.Component {
|
||||
<item.components.Details object={object} key={`object-details-${index}`} />
|
||||
));
|
||||
|
||||
if (isCrdInstance && details.length === 0) {
|
||||
details.push(<CrdResourceDetails object={object as CustomResourceDefinition}/>);
|
||||
}
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
className="KubeObjectDetails flex column"
|
||||
|
||||
@@ -33,20 +33,20 @@ import { clusterContext } from "../context";
|
||||
import { NamespaceSelectFilter } from "../+namespaces/namespace-select-filter";
|
||||
import { ResourceKindMap, ResourceNames } from "../../utils/rbac";
|
||||
|
||||
export interface KubeObjectListLayoutProps extends ItemListLayoutProps {
|
||||
store: KubeObjectStore;
|
||||
dependentStores?: KubeObjectStore[];
|
||||
export interface KubeObjectListLayoutProps<K extends KubeObject> extends ItemListLayoutProps<K> {
|
||||
store: KubeObjectStore<K>;
|
||||
dependentStores?: KubeObjectStore<KubeObject>[];
|
||||
}
|
||||
|
||||
const defaultProps: Partial<KubeObjectListLayoutProps> = {
|
||||
const defaultProps: Partial<KubeObjectListLayoutProps<KubeObject>> = {
|
||||
onDetails: (item: KubeObject) => showDetails(item.selfLink),
|
||||
};
|
||||
|
||||
@observer
|
||||
export class KubeObjectListLayout extends React.Component<KubeObjectListLayoutProps> {
|
||||
export class KubeObjectListLayout<K extends KubeObject> extends React.Component<KubeObjectListLayoutProps<K>> {
|
||||
static defaultProps = defaultProps as object;
|
||||
|
||||
constructor(props: KubeObjectListLayoutProps) {
|
||||
constructor(props: KubeObjectListLayoutProps<K>) {
|
||||
super(props);
|
||||
makeObservable(this);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ export class KubeObjectListLayout extends React.Component<KubeObjectListLayoutPr
|
||||
}),
|
||||
...[customizeHeader].flat(),
|
||||
]}
|
||||
renderItemMenu={(item: KubeObject) => <KubeObjectMenu object={item} />} // safe because we are dealing with KubeObjects here
|
||||
renderItemMenu={item => <KubeObjectMenu object={item} />}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import type { IKubeMetaField, KubeObject } from "../../api/kube-object";
|
||||
import type { KubeMetaField, KubeObject } from "../../api/kube-object";
|
||||
import { DrawerItem, DrawerItemLabels } from "../drawer";
|
||||
import { lookupApiLink } from "../../api/kube-api";
|
||||
import { Link } from "react-router-dom";
|
||||
@@ -30,15 +30,15 @@ import { getDetailsUrl } from "./kube-object-details";
|
||||
|
||||
export interface KubeObjectMetaProps {
|
||||
object: KubeObject;
|
||||
hideFields?: IKubeMetaField[];
|
||||
hideFields?: KubeMetaField[];
|
||||
}
|
||||
|
||||
export class KubeObjectMeta extends React.Component<KubeObjectMetaProps> {
|
||||
static defaultHiddenFields: IKubeMetaField[] = [
|
||||
static defaultHiddenFields: KubeMetaField[] = [
|
||||
"uid", "resourceVersion", "selfLink"
|
||||
];
|
||||
|
||||
isHidden(field: IKubeMetaField): boolean {
|
||||
isHidden(field: KubeMetaField): boolean {
|
||||
const { hideFields = KubeObjectMeta.defaultHiddenFields } = this.props;
|
||||
|
||||
return hideFields.includes(field);
|
||||
|
||||
Reference in new issue
Block a user