Check object instanceof on all detail panels (#4054)

* Check object instanceof on all detail panels

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix unit tests

- Remove prettier as snapShot testing is too tight of a bound

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-10-15 12:11:46 -04:00
1 parent dabfce3609
commit 052d12fc19
32 files changed
+392 -168

No files matched your search

@@ -26,13 +26,14 @@ import { disposeOnUnmount, observer } from "mobx-react";
import { DrawerItem, DrawerTitle } from "../drawer";
import { Badge } from "../badge";
import type { KubeObjectDetailsProps } from "../kube-object-details";
import type { Service } from "../../../common/k8s-api/endpoints";
import { Service } from "../../../common/k8s-api/endpoints";
import { KubeObjectMeta } from "../kube-object-meta";
import { ServicePortComponent } from "./service-port-component";
import { endpointStore } from "../+network-endpoints/endpoints.store";
import { ServiceDetailsEndpoint } from "./service-details-endpoint";
import { kubeWatchApi } from "../../../common/k8s-api/kube-watch-api";
import { portForwardStore } from "../../port-forward";
import logger from "../../../common/logger";
interface Props extends KubeObjectDetailsProps<Service> {
}
@@ -54,7 +55,16 @@ export class ServiceDetails extends React.Component<Props> {
render() {
const { object: service } = this.props;
if (!service) return null;
if (!service) {
return null;
}
if (!(service instanceof Service)) {
logger.error("[ServiceDetails]: passed object that is not an instanceof Service", service);
return null;
}
const { spec } = service;
const endpoint = endpointStore.getByName(service.getName(), service.getNs());