mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
cleanup Lens repo with tighter linting
Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
1 parent
e468105143
commit
b1ff34879a
470 files changed
+8447
-7443
No files matched your search
@@ -7,7 +7,7 @@ import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import { Badge } from "../badge";
|
||||
import { KubeObjectDetailsProps } from "../kube-object";
|
||||
import { cssNames } from "../../utils";
|
||||
import { HorizontalPodAutoscaler, hpaApi, HpaMetricType, IHpaMetric } from "../../api/endpoints/hpa.api";
|
||||
import { HorizontalPodAutoscaler, hpaApi, HpaMetricType, HpaMetric } from "../../api/endpoints/hpa.api";
|
||||
import { KubeEventDetails } from "../+events/kube-event-details";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||
@@ -21,10 +21,10 @@ interface Props extends KubeObjectDetailsProps<HorizontalPodAutoscaler> {
|
||||
|
||||
@observer
|
||||
export class HpaDetails extends React.Component<Props> {
|
||||
renderMetrics() {
|
||||
renderMetrics(): JSX.Element {
|
||||
const { object: hpa } = this.props;
|
||||
|
||||
const renderName = (metric: IHpaMetric) => {
|
||||
const renderName = (metric: HpaMetric): JSX.Element => {
|
||||
switch (metric.type) {
|
||||
case HpaMetricType.Resource:
|
||||
const addition = metric.resource.targetAverageUtilization ? <Trans>(as a percentage of request)</Trans> : "";
|
||||
@@ -51,7 +51,7 @@ export class HpaDetails extends React.Component<Props> {
|
||||
</Trans>
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Table>
|
||||
@@ -60,7 +60,7 @@ export class HpaDetails extends React.Component<Props> {
|
||||
<TableCell className="metrics"><Trans>Current / Target</Trans></TableCell>
|
||||
</TableHead>
|
||||
{
|
||||
hpa.getMetrics().map((metric, index) => {
|
||||
hpa.spec.metrics.map((metric, index) => {
|
||||
const name = renderName(metric);
|
||||
const values = hpa.getMetricValues(metric);
|
||||
return (
|
||||
@@ -68,16 +68,18 @@ export class HpaDetails extends React.Component<Props> {
|
||||
<TableCell className="name">{name}</TableCell>
|
||||
<TableCell className="metrics">{values}</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
render(): JSX.Element {
|
||||
const { object: hpa } = this.props;
|
||||
if (!hpa) return;
|
||||
if (!hpa) {
|
||||
return;
|
||||
}
|
||||
const { scaleTargetRef } = hpa.spec;
|
||||
return (
|
||||
<div className="HpaDetails">
|
||||
@@ -92,20 +94,22 @@ export class HpaDetails extends React.Component<Props> {
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name={<Trans>Min Pods</Trans>}>
|
||||
{hpa.getMinPods()}
|
||||
{hpa.spec.minReplicas}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name={<Trans>Max Pods</Trans>}>
|
||||
{hpa.getMaxPods()}
|
||||
{hpa.spec.maxReplicas}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name={<Trans>Replicas</Trans>}>
|
||||
{hpa.getReplicas()}
|
||||
{hpa.status.currentReplicas}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name={<Trans>Status</Trans>} labelsOnly>
|
||||
{hpa.getConditions().map(({ type, tooltip, isReady }) => {
|
||||
if (!isReady) return null;
|
||||
if (!isReady) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Badge
|
||||
key={type}
|
||||
@@ -113,7 +117,7 @@ export class HpaDetails extends React.Component<Props> {
|
||||
tooltip={tooltip}
|
||||
className={cssNames({ [type.toLowerCase()]: isReady })}
|
||||
/>
|
||||
)
|
||||
);
|
||||
})}
|
||||
</DrawerItem>
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import { buildURL } from "../../navigation";
|
||||
|
||||
export const hpaRoute: RouteProps = {
|
||||
path: "/hpa"
|
||||
};
|
||||
|
||||
export interface HpaRouteParams {
|
||||
}
|
||||
|
||||
export interface IHpaRouteParams {
|
||||
}
|
||||
|
||||
export const hpaURL = buildURL<IHpaRouteParams>(hpaRoute.path)
|
||||
export const hpaURL = buildURL<HpaRouteParams>(hpaRoute.path);
|
||||
@@ -1,4 +1,4 @@
|
||||
import "./hpa.scss"
|
||||
import "./hpa.scss";
|
||||
|
||||
import * as React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
@@ -6,7 +6,7 @@ import { RouteComponentProps } from "react-router";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { KubeObjectMenu, KubeObjectMenuProps } from "../kube-object/kube-object-menu";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { IHpaRouteParams } from "./hpa.route";
|
||||
import { HpaRouteParams } from "./hpa.route";
|
||||
import { HorizontalPodAutoscaler, hpaApi } from "../../api/endpoints/hpa.api";
|
||||
import { hpaStore } from "./hpa.store";
|
||||
import { Badge } from "../badge";
|
||||
@@ -22,32 +22,32 @@ enum sortBy {
|
||||
age = "age",
|
||||
}
|
||||
|
||||
interface Props extends RouteComponentProps<IHpaRouteParams> {
|
||||
interface Props extends RouteComponentProps<HpaRouteParams> {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class HorizontalPodAutoscalers extends React.Component<Props> {
|
||||
getTargets(hpa: HorizontalPodAutoscaler) {
|
||||
const metrics = hpa.getMetrics();
|
||||
getTargets(hpa: HorizontalPodAutoscaler): JSX.Element {
|
||||
const { metrics } = hpa.spec;
|
||||
const metricsRemainCount = metrics.length - 1;
|
||||
const metricsRemain = metrics.length > 1 ? <Trans>{metricsRemainCount} more...</Trans> : null;
|
||||
const metricValues = hpa.getMetricValues(metrics[0]);
|
||||
return <p>{metricValues} {metricsRemain && "+"}{metricsRemain}</p>;
|
||||
}
|
||||
|
||||
render() {
|
||||
render(): JSX.Element {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
className="HorizontalPodAutoscalers" store={hpaStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (item: HorizontalPodAutoscaler) => item.getName(),
|
||||
[sortBy.namespace]: (item: HorizontalPodAutoscaler) => item.getNs(),
|
||||
[sortBy.minPods]: (item: HorizontalPodAutoscaler) => item.getMinPods(),
|
||||
[sortBy.maxPods]: (item: HorizontalPodAutoscaler) => item.getMaxPods(),
|
||||
[sortBy.replicas]: (item: HorizontalPodAutoscaler) => item.getReplicas()
|
||||
[sortBy.name]: (item: HorizontalPodAutoscaler): string => item.getName(),
|
||||
[sortBy.namespace]: (item: HorizontalPodAutoscaler): string => item.getNs(),
|
||||
[sortBy.minPods]: (item: HorizontalPodAutoscaler): number => item.spec.minReplicas,
|
||||
[sortBy.maxPods]: (item: HorizontalPodAutoscaler): number => item.spec.maxReplicas,
|
||||
[sortBy.replicas]: (item: HorizontalPodAutoscaler): number => item.status.currentReplicas
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: HorizontalPodAutoscaler) => item.getSearchFields()
|
||||
(item: HorizontalPodAutoscaler): string[] => item.getSearchFields()
|
||||
]}
|
||||
renderHeaderTitle={<Trans>Horizontal Pod Autoscalers</Trans>}
|
||||
renderTableHeader={[
|
||||
@@ -60,16 +60,18 @@ export class HorizontalPodAutoscalers extends React.Component<Props> {
|
||||
{ title: <Trans>Age</Trans>, className: "age", sortBy: sortBy.age },
|
||||
{ title: <Trans>Status</Trans>, className: "status" },
|
||||
]}
|
||||
renderTableContents={(hpa: HorizontalPodAutoscaler) => [
|
||||
renderTableContents={(hpa: HorizontalPodAutoscaler): (string | number | React.ReactNode)[] => [
|
||||
hpa.getName(),
|
||||
hpa.getNs(),
|
||||
this.getTargets(hpa),
|
||||
hpa.getMinPods(),
|
||||
hpa.getMaxPods(),
|
||||
hpa.getReplicas(),
|
||||
hpa.spec.minReplicas,
|
||||
hpa.spec.maxReplicas,
|
||||
hpa.status.currentReplicas,
|
||||
hpa.getAge(),
|
||||
hpa.getConditions().map(({ type, tooltip, isReady }) => {
|
||||
if (!isReady) return null;
|
||||
if (!isReady) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Badge
|
||||
key={type}
|
||||
@@ -77,23 +79,23 @@ export class HorizontalPodAutoscalers extends React.Component<Props> {
|
||||
tooltip={tooltip}
|
||||
className={cssNames(type.toLowerCase())}
|
||||
/>
|
||||
)
|
||||
);
|
||||
})
|
||||
]}
|
||||
renderItemMenu={(item: HorizontalPodAutoscaler) => {
|
||||
return <HpaMenu object={item}/>
|
||||
renderItemMenu={(item: HorizontalPodAutoscaler): JSX.Element => {
|
||||
return <HpaMenu object={item}/>;
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function HpaMenu(props: KubeObjectMenuProps<HorizontalPodAutoscaler>) {
|
||||
export function HpaMenu(props: KubeObjectMenuProps<HorizontalPodAutoscaler>): JSX.Element {
|
||||
return (
|
||||
<KubeObjectMenu {...props}/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
apiManager.registerViews(hpaApi, {
|
||||
Menu: HpaMenu,
|
||||
})
|
||||
});
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from "./hpa"
|
||||
export * from "./hpa-details"
|
||||
export * from "./hpa.route"
|
||||
export * from "./hpa";
|
||||
export * from "./hpa-details";
|
||||
export * from "./hpa.route";
|
||||
Reference in new issue
Block a user