From eb94e171774367c5473e9cdbcc720ce5af19a14d Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Wed, 30 Nov 2022 08:33:56 -0500 Subject: [PATCH] Add quick namespace filtering to CustomResources view Signed-off-by: Sebastian Malton --- .../+custom-resources/crd-resources.scss | 4 +++- .../+custom-resources/crd-resources.tsx | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/+custom-resources/crd-resources.scss b/src/renderer/components/+custom-resources/crd-resources.scss index 1402036c53..3b217a77bf 100644 --- a/src/renderer/components/+custom-resources/crd-resources.scss +++ b/src/renderer/components/+custom-resources/crd-resources.scss @@ -4,5 +4,7 @@ */ .CrdResources { - + a.filterNamespace { + border-bottom: unset; + } } diff --git a/src/renderer/components/+custom-resources/crd-resources.tsx b/src/renderer/components/+custom-resources/crd-resources.tsx index ca8884bcd3..51ecd656ae 100644 --- a/src/renderer/components/+custom-resources/crd-resources.tsx +++ b/src/renderer/components/+custom-resources/crd-resources.tsx @@ -19,6 +19,9 @@ import { KubeObjectAge } from "../kube-object/age"; import type { CustomResourceDefinitionStore } from "./definition.store"; import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable"; import customResourceDefinitionStoreInjectable from "./definition.store.injectable"; +import { prevDefault } from "../../utils"; +import type { FilterByNamespace } from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable"; +import filterByNamespaceInjectable from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable"; enum columnId { name = "name", @@ -31,6 +34,7 @@ interface Dependencies { name: IComputedValue; apiManager: ApiManager; customResourceDefinitionStore: CustomResourceDefinitionStore; + filterByNamespace: FilterByNamespace; } @observer @@ -102,7 +106,15 @@ class NonInjectedCustomResources extends React.Component { ]} renderTableContents={customResource => [ customResource.getName(), - isNamespaced && customResource.getNs(), + isNamespaced && ( + this.props.filterByNamespace(customResource.getNs() as string))} + > + {customResource.getNs()} + + ), ...extraColumns.map((column) => safeJSONPathValue(customResource, column.jsonPath)), , ]} @@ -129,6 +141,7 @@ export const CustomResources = withInjectables(NonInjectedCustomRe ...di.inject(customResourcesRouteParametersInjectable), apiManager: di.inject(apiManagerInjectable), customResourceDefinitionStore: di.inject(customResourceDefinitionStoreInjectable), + filterByNamespace: di.inject(filterByNamespaceInjectable), }), });