1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add quick namespace filtering to RoleBindings view

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-11-30 09:20:10 -05:00
parent f7a40c8da4
commit b4dd6873cb
4 changed files with 54 additions and 9 deletions

View File

@ -7,7 +7,7 @@ import assert from "assert";
import { storesAndApisCanBeCreatedInjectionToken } from "../../../../common/k8s-api/stores-apis-can-be-created.token"; import { storesAndApisCanBeCreatedInjectionToken } from "../../../../common/k8s-api/stores-apis-can-be-created.token";
import clusterRoleApiInjectable from "../../../../common/k8s-api/endpoints/cluster-role.api.injectable"; import clusterRoleApiInjectable from "../../../../common/k8s-api/endpoints/cluster-role.api.injectable";
import { kubeObjectStoreInjectionToken } from "../../../../common/k8s-api/api-manager/manager.injectable"; import { kubeObjectStoreInjectionToken } from "../../../../common/k8s-api/api-manager/manager.injectable";
import { ClusterRolesStore } from "./store"; import { ClusterRoleStore } from "./store";
const clusterRoleStoreInjectable = getInjectable({ const clusterRoleStoreInjectable = getInjectable({
id: "cluster-role-store", id: "cluster-role-store",
@ -16,7 +16,7 @@ const clusterRoleStoreInjectable = getInjectable({
const api = di.inject(clusterRoleApiInjectable); const api = di.inject(clusterRoleApiInjectable);
return new ClusterRolesStore(api); return new ClusterRoleStore(api);
}, },
injectionToken: kubeObjectStoreInjectionToken, injectionToken: kubeObjectStoreInjectionToken,
}); });

View File

@ -5,7 +5,7 @@
import type { ClusterRole, ClusterRoleApi, ClusterRoleData } from "../../../../common/k8s-api/endpoints"; import type { ClusterRole, ClusterRoleApi, ClusterRoleData } from "../../../../common/k8s-api/endpoints";
import { KubeObjectStore } from "../../../../common/k8s-api/kube-object.store"; import { KubeObjectStore } from "../../../../common/k8s-api/kube-object.store";
export class ClusterRolesStore extends KubeObjectStore<ClusterRole, ClusterRoleApi, ClusterRoleData> { export class ClusterRoleStore extends KubeObjectStore<ClusterRole, ClusterRoleApi, ClusterRoleData> {
protected sortItems(items: ClusterRole[]) { protected sortItems(items: ClusterRole[]) {
return super.sortItems(items, [ return super.sortItems(items, [
clusterRole => clusterRole.kind, clusterRole => clusterRole.kind,

View File

@ -12,5 +12,9 @@
&.warning { &.warning {
@include table-cell-warning; @include table-cell-warning;
} }
a.filterNamespace {
border-bottom: unset;
}
} }
} }

View File

@ -9,12 +9,20 @@ import React from "react";
import { KubeObjectListLayout } from "../../kube-object-list-layout"; import { KubeObjectListLayout } from "../../kube-object-list-layout";
import { KubeObjectStatusIcon } from "../../kube-object-status-icon"; import { KubeObjectStatusIcon } from "../../kube-object-status-icon";
import { RoleBindingDialog } from "./dialog"; import { RoleBindingDialog } from "./dialog";
import { roleBindingStore } from "./legacy-store";
import { roleStore } from "../+roles/legacy-store";
import { clusterRoleStore } from "../+cluster-roles/legacy-store";
import { serviceAccountStore } from "../+service-accounts/legacy-store";
import { SiblingsInTabLayout } from "../../layout/siblings-in-tab-layout"; import { SiblingsInTabLayout } from "../../layout/siblings-in-tab-layout";
import { KubeObjectAge } from "../../kube-object/age"; import { KubeObjectAge } from "../../kube-object/age";
import type { RoleStore } from "../+roles/store";
import type { ServiceAccountStore } from "../+service-accounts/store";
import type { RoleBindingStore } from "./store";
import { prevDefault } from "../../../utils";
import type { ClusterRoleStore } from "../+cluster-roles/store";
import type { FilterByNamespace } from "../../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable";
import { withInjectables } from "@ogre-tools/injectable-react";
import clusterRoleStoreInjectable from "../+cluster-roles/store.injectable";
import filterByNamespaceInjectable from "../../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable";
import roleBindingStoreInjectable from "./store.injectable";
import roleStoreInjectable from "../+roles/store.injectable";
import serviceAccountStoreInjectable from "../+service-accounts/store.injectable";
enum columnId { enum columnId {
name = "name", name = "name",
@ -23,9 +31,25 @@ enum columnId {
age = "age", age = "age",
} }
interface Dependencies {
roleBindingStore: RoleBindingStore;
roleStore: RoleStore;
clusterRoleStore: ClusterRoleStore;
serviceAccountStore: ServiceAccountStore;
filterByNamespace: FilterByNamespace;
}
@observer @observer
export class RoleBindings extends React.Component { class NonInjectedRoleBindings extends React.Component<Dependencies> {
render() { render() {
const {
clusterRoleStore,
roleBindingStore,
roleStore,
serviceAccountStore,
filterByNamespace,
} = this.props;
return ( return (
<SiblingsInTabLayout> <SiblingsInTabLayout>
<KubeObjectListLayout <KubeObjectListLayout
@ -55,7 +79,13 @@ export class RoleBindings extends React.Component {
renderTableContents={binding => [ renderTableContents={binding => [
binding.getName(), binding.getName(),
<KubeObjectStatusIcon key="icon" object={binding} />, <KubeObjectStatusIcon key="icon" object={binding} />,
binding.getNs(), <a
key="namespace"
className="filterNamespace"
onClick={prevDefault(() => filterByNamespace(binding.getNs()))}
>
{binding.getNs()}
</a>,
binding.getSubjectNames(), binding.getSubjectNames(),
<KubeObjectAge key="age" object={binding} />, <KubeObjectAge key="age" object={binding} />,
]} ]}
@ -69,3 +99,14 @@ export class RoleBindings extends React.Component {
); );
} }
} }
export const RoleBindings = withInjectables<Dependencies>(NonInjectedRoleBindings, {
getProps: (di, props) => ({
...props,
clusterRoleStore: di.inject(clusterRoleStoreInjectable),
filterByNamespace: di.inject(filterByNamespaceInjectable),
roleBindingStore: di.inject(roleBindingStoreInjectable),
roleStore: di.inject(roleStoreInjectable),
serviceAccountStore: di.inject(serviceAccountStoreInjectable),
}),
});