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

Move <NamespaceSelectFilter> to KubeObjectListLayout

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-06-03 14:47:21 -04:00
parent 9ec6466ea7
commit e048cf9062
2 changed files with 12 additions and 20 deletions

View File

@ -36,14 +36,12 @@ import { SearchInputUrl } from "../input";
import { Filter, FilterType, pageFilters } from "./page-filters.store"; import { Filter, FilterType, pageFilters } from "./page-filters.store";
import { PageFiltersList } from "./page-filters-list"; import { PageFiltersList } from "./page-filters-list";
import { PageFiltersSelect } from "./page-filters-select"; import { PageFiltersSelect } from "./page-filters-select";
import { NamespaceSelectFilter } from "../+namespaces/namespace-select-filter";
import { ThemeStore } from "../../theme.store"; import { ThemeStore } from "../../theme.store";
import { MenuActions } from "../menu/menu-actions"; import { MenuActions } from "../menu/menu-actions";
import { MenuItem } from "../menu"; import { MenuItem } from "../menu";
import { Checkbox } from "../checkbox"; import { Checkbox } from "../checkbox";
import { UserStore } from "../../../common/user-store"; import { UserStore } from "../../../common/user-store";
import { namespaceStore } from "../+namespaces/namespace.store"; import { namespaceStore } from "../+namespaces/namespace.store";
import { KubeObjectStore } from "../../kube-object.store";
// todo: refactor, split to small re-usable components // todo: refactor, split to small re-usable components
@ -191,21 +189,6 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
}, },
}; };
@computed get isNamespaced(): boolean {
const { store, dependentStores = [] } = this.props;
const stores = new Set([store, ...dependentStores]);
for (const store of stores) {
if (store instanceof KubeObjectStore) {
if (store.api.isNamespaced) {
return true;
}
}
}
return false;
}
@computed get isReady() { @computed get isReady() {
return this.props.isReady ?? this.props.store.isLoaded; return this.props.isReady ?? this.props.store.isLoaded;
} }
@ -412,12 +395,11 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
const placeholders: IHeaderPlaceholders = { const placeholders: IHeaderPlaceholders = {
title: <h5 className="title">{title}</h5>, title: <h5 className="title">{title}</h5>,
info: this.renderInfo(), info: this.renderInfo(),
filters: <> filters: (
{this.isNamespaced && <NamespaceSelectFilter />}
<PageFiltersSelect allowEmpty disableFilters={{ <PageFiltersSelect allowEmpty disableFilters={{
[FilterType.NAMESPACE]: true, // namespace-select used instead [FilterType.NAMESPACE]: true, // namespace-select used instead
}} /> }} />
</>, ),
search: <SearchInputUrl />, search: <SearchInputUrl />,
}; };
let header = this.renderHeaderContent(placeholders); let header = this.renderHeaderContent(placeholders);

View File

@ -30,6 +30,7 @@ import { KubeObjectMenu } from "./kube-object-menu";
import { kubeSelectedUrlParam, showDetails } from "./kube-object-details"; import { kubeSelectedUrlParam, showDetails } from "./kube-object-details";
import { kubeWatchApi } from "../../api/kube-watch-api"; import { kubeWatchApi } from "../../api/kube-watch-api";
import { clusterContext } from "../context"; import { clusterContext } from "../context";
import { NamespaceSelectFilter } from "../+namespaces/namespace-select-filter";
export interface KubeObjectListLayoutProps extends ItemListLayoutProps { export interface KubeObjectListLayoutProps extends ItemListLayoutProps {
store: KubeObjectStore; store: KubeObjectStore;
@ -76,6 +77,15 @@ export class KubeObjectListLayout extends React.Component<KubeObjectListLayoutPr
items={items} items={items}
preloadStores={false} // loading handled in kubeWatchApi.subscribeStores() preloadStores={false} // loading handled in kubeWatchApi.subscribeStores()
detailsItem={this.selectedItem} detailsItem={this.selectedItem}
customizeHeader={({ filters, ...placeholders }) => ({
filters: (
<>
{store.api.isNamespaced && <NamespaceSelectFilter />}
{filters}
</>
),
...placeholders,
})}
renderItemMenu={(item: KubeObject) => <KubeObjectMenu object={item} />} // safe because we are dealing with KubeObjects here renderItemMenu={(item: KubeObject) => <KubeObjectMenu object={item} />} // safe because we are dealing with KubeObjects here
/> />
); );