mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Removing "filterItems" prop from ItemListLayout
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
5b3f71a5cb
commit
d06a2c6b4b
@ -34,6 +34,10 @@ export class HelmCharts extends Component<Props> {
|
||||
return helmChartStore.getByName(chartName, repo);
|
||||
}
|
||||
|
||||
get items() {
|
||||
return helmChartStore.items.filter(item => !item.deprecated);
|
||||
}
|
||||
|
||||
showDetails = (chart: HelmChart) => {
|
||||
if (!chart) {
|
||||
navigation.merge(helmChartsURL());
|
||||
@ -72,9 +76,7 @@ export class HelmCharts extends Component<Props> {
|
||||
(chart: HelmChart) => chart.getAppVersion(),
|
||||
(chart: HelmChart) => chart.getKeywords(),
|
||||
]}
|
||||
filterItems={[
|
||||
(items: HelmChart[]) => items.filter(item => !item.deprecated)
|
||||
]}
|
||||
items={this.items}
|
||||
customizeHeader={() => (
|
||||
<SearchInputUrl placeholder={`Search Helm Charts`} />
|
||||
)}
|
||||
|
||||
@ -33,6 +33,15 @@ export class CrdList extends React.Component {
|
||||
return crdGroupsUrlParam.get();
|
||||
}
|
||||
|
||||
get items() {
|
||||
const selectedGroups = this.groups;
|
||||
const storeItems = crdStore.items;
|
||||
|
||||
return selectedGroups.length ?
|
||||
storeItems.filter(item => selectedGroups.includes(item.getGroup())) :
|
||||
storeItems;
|
||||
}
|
||||
|
||||
onSelectGroup(group: string) {
|
||||
const groups = new Set(this.groups);
|
||||
|
||||
@ -62,11 +71,7 @@ export class CrdList extends React.Component {
|
||||
store={crdStore}
|
||||
sortingCallbacks={sortingCallbacks}
|
||||
searchFilters={Object.values(sortingCallbacks)}
|
||||
filterItems={[
|
||||
(items: CustomResourceDefinition[]) => {
|
||||
return selectedGroups.length ? items.filter(item => selectedGroups.includes(item.getGroup())) : items;
|
||||
}
|
||||
]}
|
||||
items={this.items}
|
||||
renderHeaderTitle="Custom Resources"
|
||||
customizeHeader={() => {
|
||||
let placeholder = <>All groups</>;
|
||||
|
||||
@ -45,7 +45,6 @@ export interface ItemListLayoutProps<T extends ItemObject = ItemObject> {
|
||||
isClusterScoped?: boolean;
|
||||
hideFilters?: boolean;
|
||||
searchFilters?: SearchFilter<T>[];
|
||||
filterItems?: ItemsFilter<T>[];
|
||||
|
||||
// header (title, filtering, searching, etc.)
|
||||
showHeader?: boolean;
|
||||
@ -86,7 +85,6 @@ const defaultProps: Partial<ItemListLayoutProps> = {
|
||||
copyClassNameFromHeadCells: true,
|
||||
preloadStores: true,
|
||||
dependentStores: [],
|
||||
filterItems: [],
|
||||
hasDetailsView: true,
|
||||
onDetails: noop,
|
||||
virtual: true
|
||||
@ -196,14 +194,8 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
||||
return filters.reduce((items, filter) => filter(items), items);
|
||||
}
|
||||
|
||||
@computed get allItems() {
|
||||
const { filterItems, store } = this.props;
|
||||
|
||||
return this.applyFilters(filterItems, store.items);
|
||||
}
|
||||
|
||||
@computed get items() {
|
||||
const { allItems, filters, filterCallbacks } = this;
|
||||
const { filters, filterCallbacks } = this;
|
||||
const filterItems: ItemsFilter[] = [];
|
||||
const filterGroups = groupBy<Filter>(filters, ({ type }) => type);
|
||||
|
||||
@ -215,9 +207,7 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
||||
}
|
||||
});
|
||||
|
||||
const items = this.props.items ?? allItems;
|
||||
|
||||
return this.applyFilters(filterItems, items);
|
||||
return this.applyFilters(filterItems, this.props.items);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user