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

Add quick namespace filtering to Endpoints view

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-11-30 08:46:38 -05:00
parent 0659cf8e65
commit 665e3a5443
2 changed files with 32 additions and 4 deletions

View File

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

View File

@ -7,11 +7,16 @@ import "./endpoints.scss";
import React from "react"; import React from "react";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { endpointsStore } from "./legacy-store";
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 { 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 { prevDefault } from "../../utils";
import type { EndpointsStore } from "./store";
import type { FilterByNamespace } from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable";
import { withInjectables } from "@ogre-tools/injectable-react";
import endpointsStoreInjectable from "./store.injectable";
import filterByNamespaceInjectable from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable";
enum columnId { enum columnId {
name = "name", name = "name",
@ -20,8 +25,13 @@ enum columnId {
age = "age", age = "age",
} }
interface Dependencies {
endpointsStore: EndpointsStore;
filterByNamespace: FilterByNamespace;
}
@observer @observer
export class Endpoints extends React.Component { class NonInjectedEndpoints extends React.Component<Dependencies> {
render() { render() {
return ( return (
<SiblingsInTabLayout> <SiblingsInTabLayout>
@ -29,7 +39,7 @@ export class Endpoints extends React.Component {
isConfigurable isConfigurable
tableId="network_endpoints" tableId="network_endpoints"
className="Endpoints" className="Endpoints"
store={endpointsStore} store={this.props.endpointsStore}
sortingCallbacks={{ sortingCallbacks={{
[columnId.name]: endpoint => endpoint.getName(), [columnId.name]: endpoint => endpoint.getName(),
[columnId.namespace]: endpoint => endpoint.getNs(), [columnId.namespace]: endpoint => endpoint.getNs(),
@ -49,7 +59,13 @@ export class Endpoints extends React.Component {
renderTableContents={endpoint => [ renderTableContents={endpoint => [
endpoint.getName(), endpoint.getName(),
<KubeObjectStatusIcon key="icon" object={endpoint} />, <KubeObjectStatusIcon key="icon" object={endpoint} />,
endpoint.getNs(), <a
key="namespace"
className="filterNamespace"
onClick={prevDefault(() => this.props.filterByNamespace(endpoint.getNs()))}
>
{endpoint.getNs()}
</a>,
endpoint.toString(), endpoint.toString(),
<KubeObjectAge key="age" object={endpoint} />, <KubeObjectAge key="age" object={endpoint} />,
]} ]}
@ -65,3 +81,11 @@ export class Endpoints extends React.Component {
); );
} }
} }
export const Endpoints = withInjectables<Dependencies>(NonInjectedEndpoints, {
getProps: (di, props) => ({
...props,
endpointsStore: di.inject(endpointsStoreInjectable),
filterByNamespace: di.inject(filterByNamespaceInjectable),
}),
});