mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
feat: New view for PriorityClasses under Config menu (#5816)
* feat: new view for PriorityClass under Config menu Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com> * Added priorityClassDetailItemInjectable Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com> * Removed uneccessary defensive code Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com>
This commit is contained in:
1 parent
70105a6ef2
commit
f4b7fea54a
24 files changed
+470
-2
No files matched your search
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
export * from "./priority-classes";
|
||||
export * from "./priority-classes-details";
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
.PriorityClassesDetails {}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import "./priority-classes.scss";
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { DrawerItem } from "../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import type { PriorityClass } from "../../../common/k8s-api/endpoints";
|
||||
import { KubeObjectMeta } from "../kube-object-meta";
|
||||
|
||||
export interface PriorityClassesDetailsProps extends KubeObjectDetailsProps<PriorityClass> {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class PriorityClassesDetails extends React.Component<PriorityClassesDetailsProps> {
|
||||
|
||||
render() {
|
||||
const { object: pc } = this.props;
|
||||
|
||||
return (
|
||||
<div className="PriorityClassesDetails">
|
||||
<KubeObjectMeta object={pc} />
|
||||
|
||||
<DrawerItem name="Description">
|
||||
{pc.getDescription()}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name="Value">
|
||||
{pc.getValue()}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name="Global Default">
|
||||
{pc.getGlobalDefault()}
|
||||
</DrawerItem>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
|
||||
import priorityClassesRouteInjectable from "../../../common/front-end-routing/routes/cluster/config/priority-classes/priority-classes-route.injectable";
|
||||
import { configSidebarItemId } from "../+config/config-sidebar-items.injectable";
|
||||
import { sidebarItemsInjectionToken } from "../layout/sidebar-items.injectable";
|
||||
import routeIsActiveInjectable from "../../routes/route-is-active.injectable";
|
||||
import navigateToPriorityClassesInjectable from "../../../common/front-end-routing/routes/cluster/config/priority-classes/navigate-to-priority-classes.injectable";
|
||||
|
||||
const priorityClassesSidebarItemsInjectable = getInjectable({
|
||||
id: "priority-classes-sidebar-items",
|
||||
|
||||
instantiate: (di) => {
|
||||
const route = di.inject(priorityClassesRouteInjectable);
|
||||
const navigateToPriorityClasses = di.inject(navigateToPriorityClassesInjectable);
|
||||
const routeIsActive = di.inject(routeIsActiveInjectable, route);
|
||||
|
||||
return computed(() => [
|
||||
{
|
||||
id: "priority-classes",
|
||||
parentId: configSidebarItemId,
|
||||
title: "Priority Classes",
|
||||
onClick: navigateToPriorityClasses,
|
||||
isActive: routeIsActive,
|
||||
isVisible: route.isEnabled,
|
||||
orderNumber: 60,
|
||||
},
|
||||
]);
|
||||
},
|
||||
|
||||
injectionToken: sidebarItemsInjectionToken,
|
||||
});
|
||||
|
||||
export default priorityClassesSidebarItemsInjectable;
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { PriorityClasses } from "./priority-classes";
|
||||
import priorityClassesRouteInjectable from "../../../common/front-end-routing/routes/cluster/config/priority-classes/priority-classes-route.injectable";
|
||||
import { routeSpecificComponentInjectionToken } from "../../routes/route-specific-component-injection-token";
|
||||
|
||||
const podDisruptionBudgetsRouteComponentInjectable = getInjectable({
|
||||
id: "priority-classes-route-component",
|
||||
|
||||
instantiate: (di) => ({
|
||||
route: di.inject(priorityClassesRouteInjectable),
|
||||
Component: PriorityClasses,
|
||||
}),
|
||||
|
||||
injectionToken: routeSpecificComponentInjectionToken,
|
||||
});
|
||||
|
||||
export default podDisruptionBudgetsRouteComponentInjectable;
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
.PriorityClasses {
|
||||
.TableCell {
|
||||
&.name {
|
||||
flex: 2;
|
||||
}
|
||||
|
||||
&.warning {
|
||||
@include table-cell-warning;
|
||||
}
|
||||
|
||||
&.keys {
|
||||
flex: 2.5;
|
||||
}
|
||||
|
||||
&.age {
|
||||
flex: .5;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import "./priority-classes.scss";
|
||||
|
||||
import * as React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { PriorityClass } from "../../../common/k8s-api/endpoints/priority-class.api";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
||||
import { KubeObjectAge } from "../kube-object/age";
|
||||
import { autoBind } from "../../../common/utils";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import priorityClassStoreInjectable from "./store.injectable";
|
||||
import type { PriorityClassStore } from "./store";
|
||||
|
||||
enum columnId {
|
||||
name = "name",
|
||||
value = "value",
|
||||
globalDefault = "global-default",
|
||||
age = "age",
|
||||
}
|
||||
|
||||
export interface PriorityClassesProps extends KubeObjectDetailsProps<PriorityClass> {
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
priorityClassStore: PriorityClassStore;
|
||||
}
|
||||
|
||||
@observer
|
||||
class NonInjectedPriorityClasses extends React.Component<PriorityClassesProps & Dependencies> {
|
||||
constructor(props: PriorityClassesProps & Dependencies) {
|
||||
super(props);
|
||||
autoBind(this);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { priorityClassStore } = this.props;
|
||||
|
||||
return (
|
||||
<SiblingsInTabLayout>
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="configuration_priority_classes"
|
||||
className="PriorityClasses"
|
||||
store={priorityClassStore}
|
||||
sortingCallbacks={{
|
||||
[columnId.name]: pc => pc.getName(),
|
||||
[columnId.value]: pc => pc.getValue(),
|
||||
[columnId.globalDefault]: pc => pc.getGlobalDefault(),
|
||||
[columnId.age]: pc => -pc.getCreationTimestamp(),
|
||||
}}
|
||||
searchFilters={[
|
||||
pc => pc.getSearchFields(),
|
||||
]}
|
||||
renderHeaderTitle="Priority Classes"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Value", className: "value", sortBy: columnId.value, id: columnId.value },
|
||||
{ title: "Global Default", className: "global-default", sortBy: columnId.globalDefault, id: columnId.globalDefault },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={pc => [
|
||||
pc.getName(),
|
||||
<KubeObjectStatusIcon key="icon" object={pc} />,
|
||||
pc.getValue(),
|
||||
pc.getGlobalDefault(),
|
||||
<KubeObjectAge key="age" object={pc} />,
|
||||
]}
|
||||
/>
|
||||
</SiblingsInTabLayout>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const PriorityClasses = withInjectables<Dependencies, PriorityClassesProps>(NonInjectedPriorityClasses, {
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
priorityClassStore: di.inject(priorityClassStoreInjectable),
|
||||
}),
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import assert from "assert";
|
||||
import { kubeObjectStoreInjectionToken } from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||
import priorityClassApiInjectable from "../../../common/k8s-api/endpoints/priority-class.api.injectable";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
import { PriorityClassStore } from "./store";
|
||||
|
||||
const priorityClassStoreInjectable = getInjectable({
|
||||
id: "priority-class-store",
|
||||
instantiate: (di) => {
|
||||
assert(di.inject(storesAndApisCanBeCreatedInjectable), "priorityClassStore is only available in certain environments");
|
||||
|
||||
const api = di.inject(priorityClassApiInjectable);
|
||||
|
||||
return new PriorityClassStore(api);
|
||||
},
|
||||
injectionToken: kubeObjectStoreInjectionToken,
|
||||
});
|
||||
|
||||
export default priorityClassStoreInjectable;
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { PriorityClass, PriorityClassApi } from "../../../common/k8s-api/endpoints/priority-class.api";
|
||||
|
||||
export class PriorityClassStore extends KubeObjectStore<PriorityClass, PriorityClassApi> {
|
||||
}
|
||||
Reference in new issue
Block a user