mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adding webhook list and store
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
1d96760a3a
commit
18ea6c2a4f
@ -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;
|
||||
@ -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<MutatingWebhookConfiguration, MutatingWebhookConfigurationApi> {
|
||||
constructor(protected readonly dependencies: MutatingWebhookConfigurationStoreDependencies, api: MutatingWebhookConfigurationApi, opts?: KubeObjectStoreOptions) {
|
||||
super(dependencies, api, opts);
|
||||
}
|
||||
}
|
||||
@ -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 (
|
||||
<SiblingsInTabLayout>
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="config_mutating_webhook_configurations"
|
||||
className={"MutatingWebhookConfigurations"}
|
||||
store={props.store}
|
||||
sortingCallbacks={{
|
||||
[columnId.name]: item => 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(),
|
||||
<NamespaceSelectBadge key="namespace" namespace={item.getNs()} />,
|
||||
item.getLabels().map(label => (<Badge key={label} label={label} />)),
|
||||
item.getWebhooks().length,
|
||||
<KubeObjectAge key="age" object={item} />,
|
||||
]}
|
||||
/>
|
||||
</SiblingsInTabLayout>
|
||||
);
|
||||
});
|
||||
|
||||
export const MutatingWebhookConfigurations = withInjectables<Dependencies>(NonInjectedMutatingWebhookConfigurations, {
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
store: di.inject(mutatingWebhookConfigurationsStoreInjectable),
|
||||
}),
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user