1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/+config-vertical-pod-autoscalers/vpa.tsx
Jim Ehrismann 38ca67c6a4 introducing vpa resources (as hpa resources to start)
vpa spec (WIP)

adding real vpa fields

scss files, and updates after rebase on master

scss update

tweaks to vpa api definition

putting more fields into the vpa list

adding vpa details, fixing vpa spec implementation (WIP)

vpa details page done

merge conflicts

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
2023-01-26 16:48:59 -05:00

101 lines
3.8 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import "./vpa.scss";
import React from "react";
import { observer } from "mobx-react";
import { KubeObjectListLayout } from "../kube-object-list-layout";
// import type { VerticalPodAutoscaler } from "../../../common/k8s-api/endpoints/vertical-pod-autoscaler.api";
import { Badge } from "../badge";
import { cssNames, prevDefault } from "../../utils";
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
import { KubeObjectAge } from "../kube-object/age";
import type { VerticalPodAutoscalerStore } from "./store";
import type { FilterByNamespace } from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable";
import { withInjectables } from "@ogre-tools/injectable-react";
import filterByNamespaceInjectable from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable";
import verticalPodAutoscalerStoreInjectable from "./store.injectable";
enum columnId {
name = "name",
namespace = "namespace",
mode = "mode",
age = "age",
status = "status",
}
interface Dependencies {
verticalPodAutoscalerStore: VerticalPodAutoscalerStore;
filterByNamespace: FilterByNamespace;
}
@observer
class NonInjectedVerticalPodAutoscalers extends React.Component<Dependencies> {
render() {
return (
<SiblingsInTabLayout>
<KubeObjectListLayout
isConfigurable
tableId="configuration_vpa"
className="VerticalPodAutoscalers"
store={this.props.verticalPodAutoscalerStore}
sortingCallbacks={{
[columnId.name]: vpa => vpa.getName(),
[columnId.namespace]: vpa => vpa.getNs(),
[columnId.age]: vpa => -vpa.getCreationTimestamp(),
}}
searchFilters={[
vpa => vpa.getSearchFields(),
]}
renderHeaderTitle="Vertical Pod Autoscalers"
renderTableHeader={[
{ title: "Name", className: "name", sortBy: columnId.name },
{ className: "warning", showWithColumn: columnId.name },
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
{ title: "Mode", className: "mode", sortBy: columnId.mode, id: columnId.mode },
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
{ title: "Status", className: "status scrollable", id: columnId.status },
]}
renderTableContents={vpa => [
vpa.getName(),
<KubeObjectStatusIcon key="icon" object={vpa} />,
<a
key="namespace"
className="filterNamespace"
onClick={prevDefault(() => this.props.filterByNamespace(vpa.getNs()))}
>
{vpa.getNs()}
</a>,
vpa.getMode(),
<KubeObjectAge key="age" object={vpa} />,
vpa.getConditions()
.filter(({ isReady }) => isReady)
.map(({ type, tooltip }) => (
<Badge
key={type}
label={type}
tooltip={tooltip}
className={cssNames(type.toLowerCase())}
expandable={false}
scrollable={true}
/>
)),
]}
/>
</SiblingsInTabLayout>
);
}
}
export const VerticalPodAutoscalers = withInjectables<Dependencies>(NonInjectedVerticalPodAutoscalers, {
getProps: (di, props) => ({
...props,
filterByNamespace: di.inject(filterByNamespaceInjectable),
verticalPodAutoscalerStore: di.inject(verticalPodAutoscalerStoreInjectable),
}),
});