diff --git a/packages/core/src/renderer/components/+config-mutating-webhook-configurations/mutating-webhook-configuration-store.injectable.ts b/packages/core/src/renderer/components/+config-mutating-webhook-configurations/mutating-webhook-configuration-store.injectable.ts new file mode 100644 index 0000000000..6522360bd0 --- /dev/null +++ b/packages/core/src/renderer/components/+config-mutating-webhook-configurations/mutating-webhook-configuration-store.injectable.ts @@ -0,0 +1,26 @@ +/** + * 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 { kubeObjectStoreInjectionToken } from "../../../common/k8s-api/api-manager/kube-object-store-token"; +import { MutatingWebhookConfigurationStore } from "./mutating-webhook-configuration-store"; +import clusterFrameContextForNamespacedResourcesInjectable from "../../cluster-frame-context/for-namespaced-resources.injectable"; +import loggerInjectable from "../../../common/logger.injectable"; +import mutatingWebhookConfigurationApiInjectable + from "../../../common/k8s-api/endpoints/mutating-webhook-configuration-api.injectable"; + +const mutatingWebhookConfigurationStoreInjectable = getInjectable({ + id: "mutating-webhook-configuration-store", + instantiate: (di) => { + const api = di.inject(mutatingWebhookConfigurationApiInjectable); + + return new MutatingWebhookConfigurationStore({ + context: di.inject(clusterFrameContextForNamespacedResourcesInjectable), + logger: di.inject(loggerInjectable), + }, api); + }, + injectionToken: kubeObjectStoreInjectionToken, +}); + +export default mutatingWebhookConfigurationStoreInjectable; diff --git a/packages/core/src/renderer/components/+config-mutating-webhook-configurations/mutating-webhook-configuration-store.ts b/packages/core/src/renderer/components/+config-mutating-webhook-configurations/mutating-webhook-configuration-store.ts new file mode 100644 index 0000000000..fbd30b10e3 --- /dev/null +++ b/packages/core/src/renderer/components/+config-mutating-webhook-configurations/mutating-webhook-configuration-store.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import type { + MutatingWebhookConfiguration, + MutatingWebhookConfigurationApi, +} from "../../../common/k8s-api/endpoints"; +import type { + KubeObjectStoreDependencies, + KubeObjectStoreOptions, +} from "../../../common/k8s-api/kube-object.store"; +import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store"; + +export interface MutatingWebhookConfigurationStoreDependencies extends KubeObjectStoreDependencies { +} + +export class MutatingWebhookConfigurationStore extends KubeObjectStore { + constructor(protected readonly dependencies: MutatingWebhookConfigurationStoreDependencies, api: MutatingWebhookConfigurationApi, opts?: KubeObjectStoreOptions) { + super(dependencies, api, opts); + } +} diff --git a/packages/core/src/renderer/components/+config-mutating-webhook-configurations/mutating-webhook-configurations.tsx b/packages/core/src/renderer/components/+config-mutating-webhook-configurations/mutating-webhook-configurations.tsx new file mode 100644 index 0000000000..824743c8d0 --- /dev/null +++ b/packages/core/src/renderer/components/+config-mutating-webhook-configurations/mutating-webhook-configurations.tsx @@ -0,0 +1,86 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { observer } from "mobx-react"; +import { KubeObjectListLayout } from "../kube-object-list-layout"; +import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout"; +import type { MutatingWebhookConfigurationStore } from "./mutating-webhook-configuration-store"; +import { withInjectables } from "@ogre-tools/injectable-react"; +import mutatingWebhookConfigurationsStoreInjectable from "./mutating-webhook-configuration-store.injectable"; +import { NamespaceSelectBadge } from "../+namespaces/namespace-select-badge"; +import { Badge } from "../badge"; +import { KubeObjectAge } from "../kube-object/age"; + +enum columnId { + name = "name", + namespace = "namespace", + webhooks = "webhooks", + selector = "selector", + age = "age", +} + +interface Dependencies { + store: MutatingWebhookConfigurationStore; +} + +const NonInjectedMutatingWebhookConfigurations = observer((props: Dependencies) => { + return ( + + item.getName(), + [columnId.namespace]: item => item.getNs(), + [columnId.selector]: item => item.getLabels(), + [columnId.webhooks]: item => item.getWebhooks().length, + [columnId.age]: item => -item.getCreationTimestamp(), + }} + searchFilters={[ + item => item.getSearchFields(), + item => item.getLabels(), + ]} + renderHeaderTitle="Mutating Webhook Configurations" + renderTableHeader={[ + { title: "Name", className: "name", sortBy: columnId.name, id: columnId.name }, + { + title: "Namespace", + className: "namespace", + sortBy: columnId.namespace, + id: columnId.namespace, + }, + { + title: "Labels", + sortBy: columnId.selector, + id: columnId.selector, + }, + { + title: "Webhooks", + sortBy: columnId.webhooks, + id: columnId.webhooks, + }, + { title: "Age", className: "age", sortBy: columnId.age, id: columnId.age }, + ]} + renderTableContents={item => [ + item.getName(), + , + item.getLabels().map(label => ()), + item.getWebhooks().length, + , + ]} + /> + + ); +}); + +export const MutatingWebhookConfigurations = withInjectables(NonInjectedMutatingWebhookConfigurations, { + getProps: (di, props) => ({ + ...props, + store: di.inject(mutatingWebhookConfigurationsStoreInjectable), + }), +});