diff --git a/src/renderer/components/+namespaces/namespace-select-filter.tsx b/src/renderer/components/+namespaces/namespace-select-filter.tsx index 25b14ae9e6..8ae2e97958 100644 --- a/src/renderer/components/+namespaces/namespace-select-filter.tsx +++ b/src/renderer/components/+namespaces/namespace-select-filter.tsx @@ -26,8 +26,6 @@ import { observer } from "mobx-react"; import { components, PlaceholderProps } from "react-select"; import { Icon } from "../icon"; -import { FilterIcon } from "../item-object-list/filter-icon"; -import { FilterType } from "../item-object-list/page-filters.store"; import { NamespaceSelect } from "./namespace-select"; import { namespaceStore } from "./namespace.store"; @@ -63,7 +61,7 @@ export class NamespaceSelectFilter extends React.Component { return (
- + {namespace} {isSelected && }
diff --git a/src/renderer/components/item-object-list/filter-icon.tsx b/src/renderer/components/item-object-list/filter-icon.tsx index f5534b2f71..87f41c524f 100644 --- a/src/renderer/components/item-object-list/filter-icon.tsx +++ b/src/renderer/components/item-object-list/filter-icon.tsx @@ -31,9 +31,6 @@ export function FilterIcon(props: Props) { const { type, ...iconProps } = props; switch (type) { - case FilterType.NAMESPACE: - return ; - case FilterType.SEARCH: return ; diff --git a/src/renderer/components/item-object-list/item-list-layout.tsx b/src/renderer/components/item-object-list/item-list-layout.tsx index f894f90a4a..647cbcaec9 100644 --- a/src/renderer/components/item-object-list/item-list-layout.tsx +++ b/src/renderer/components/item-object-list/item-list-layout.tsx @@ -35,7 +35,6 @@ import type { ItemObject, ItemStore } from "../../item.store"; import { SearchInputUrl } from "../input"; import { Filter, FilterType, pageFilters } from "./page-filters.store"; import { PageFiltersList } from "./page-filters-list"; -import { PageFiltersSelect } from "./page-filters-select"; import { ThemeStore } from "../../theme.store"; import { MenuActions } from "../menu/menu-actions"; import { MenuItem } from "../menu"; @@ -179,16 +178,6 @@ export class ItemListLayout extends React.Component { return items; }, - - [FilterType.NAMESPACE]: items => { - const filterValues = pageFilters.getValues(FilterType.NAMESPACE); - - if (filterValues.length > 0) { - return items.filter(item => filterValues.includes(item.getNs())); - } - - return items; - }, }; @computed get isReady() { @@ -401,14 +390,7 @@ export class ItemListLayout extends React.Component { const placeholders: IHeaderPlaceholders = { title:
{title}
, info: this.renderInfo(), - filters: ( - <> - {showNamespaceSelectFilter && } - - - ), + filters: showNamespaceSelectFilter && , search: , }; let header = this.renderHeaderContent(placeholders); diff --git a/src/renderer/components/item-object-list/page-filters-select.tsx b/src/renderer/components/item-object-list/page-filters-select.tsx deleted file mode 100644 index 418c82045b..0000000000 --- a/src/renderer/components/item-object-list/page-filters-select.tsx +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright (c) 2021 OpenLens Authors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import React from "react"; -import { observer } from "mobx-react"; -import { computed, makeObservable } from "mobx"; -import { GroupSelectOption, Select, SelectOption, SelectProps } from "../select"; -import { FilterType, pageFilters } from "./page-filters.store"; -import { namespaceStore } from "../+namespaces/namespace.store"; -import { Icon } from "../icon"; -import { FilterIcon } from "./filter-icon"; - -export interface SelectOptionFilter extends SelectOption { - type: FilterType; - selected?: boolean; -} - -interface Props extends SelectProps { - allowEmpty?: boolean; - disableFilters?: { - [filterType: string]: boolean; - }; -} - -@observer -export class PageFiltersSelect extends React.Component { - static defaultProps: Props = { - allowEmpty: true, - disableFilters: {}, - }; - - constructor(props: Props) { - super(props); - makeObservable(this); - } - - @computed get groupedOptions() { - const options: GroupSelectOption[] = []; - const { disableFilters } = this.props; - - if (!disableFilters[FilterType.NAMESPACE]) { - const selectedValues = pageFilters.getValues(FilterType.NAMESPACE); - - options.push({ - label: "Namespace", - options: namespaceStore.items.map(ns => { - const name = ns.getName(); - - return { - type: FilterType.NAMESPACE, - value: name, - icon: , - selected: selectedValues.includes(name), - }; - }) - }); - } - - return options; - } - - @computed get options(): SelectOptionFilter[] { - return this.groupedOptions.reduce((options, optGroup) => { - options.push(...optGroup.options); - - return options; - }, []); - } - - private formatLabel = (option: SelectOptionFilter) => { - const { label, value, type, selected } = option; - - return ( -
- - {label || String(value)} - {selected && } -
- ); - }; - - private onSelect = (option: SelectOptionFilter) => { - const { type, value, selected } = option; - const { addFilter, removeFilter } = pageFilters; - const filter = { type, value }; - - if (!selected) { - addFilter(filter); - } - else { - removeFilter(filter); - } - }; - - render() { - const { groupedOptions, formatLabel, onSelect, options } = this; - - if (!options.length && this.props.allowEmpty) { - return null; - } - const { allowEmpty, disableFilters, ...selectProps } = this.props; - const selectedOptions = options.filter(opt => opt.selected); - - return ( -