mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
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:
1 parent
dabfce3609
commit
052d12fc19
32 files changed
+392
-168
No files matched your search
@@ -28,6 +28,7 @@ import { LimitPart, LimitRange, LimitRangeItem, Resource } from "../../../common
|
||||
import { KubeObjectMeta } from "../kube-object-meta";
|
||||
import { DrawerItem } from "../drawer/drawer-item";
|
||||
import { Badge } from "../badge";
|
||||
import logger from "../../../common/logger";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<LimitRange> {
|
||||
}
|
||||
@@ -57,15 +58,13 @@ function renderResourceLimits(limit: LimitRangeItem, resource: Resource) {
|
||||
|
||||
function renderLimitDetails(limits: LimitRangeItem[], resources: Resource[]) {
|
||||
|
||||
return resources.map(resource =>
|
||||
return resources.map(resource => (
|
||||
<DrawerItem key={resource} name={resource}>
|
||||
{
|
||||
limits.map(limit =>
|
||||
renderResourceLimits(limit, resource)
|
||||
)
|
||||
limits.map(limit => renderResourceLimits(limit, resource))
|
||||
}
|
||||
</DrawerItem>
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@observer
|
||||
@@ -73,7 +72,16 @@ export class LimitRangeDetails extends React.Component<Props> {
|
||||
render() {
|
||||
const { object: limitRange } = this.props;
|
||||
|
||||
if (!limitRange) return null;
|
||||
if (!limitRange) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(limitRange instanceof LimitRange)) {
|
||||
logger.error("[LimitRangeDetails]: passed object that is not an instanceof LimitRange", limitRange);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const containerLimits = limitRange.getContainerLimits();
|
||||
const podLimits = limitRange.getPodLimits();
|
||||
const pvcLimits = limitRange.getPVCLimits();
|
||||
|
||||
Reference in new issue
Block a user