mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Consolidate way of passing items to ItemListLayout (#4850)
This commit is contained in:
parent
e626cc91d4
commit
668ac58cb3
@ -73,6 +73,7 @@ export class HelmCharts extends Component<Props> {
|
|||||||
tableId="helm_charts"
|
tableId="helm_charts"
|
||||||
className="HelmCharts"
|
className="HelmCharts"
|
||||||
store={helmChartStore}
|
store={helmChartStore}
|
||||||
|
getItems={() => helmChartStore.items}
|
||||||
isSelectable={false}
|
isSelectable={false}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
[columnId.name]: chart => chart.getName(),
|
[columnId.name]: chart => chart.getName(),
|
||||||
|
|||||||
@ -147,6 +147,7 @@ class NonInjectedHelmReleases extends Component<Dependencies & Props> {
|
|||||||
<>
|
<>
|
||||||
<ItemListLayout
|
<ItemListLayout
|
||||||
store={legacyReleaseStore}
|
store={legacyReleaseStore}
|
||||||
|
getItems={() => legacyReleaseStore.items}
|
||||||
preloadStores={false}
|
preloadStores={false}
|
||||||
isConfigurable
|
isConfigurable
|
||||||
tableId="helm_releases"
|
tableId="helm_releases"
|
||||||
|
|||||||
@ -86,7 +86,9 @@ class NonInjectedPortForwards extends React.Component<Props & Dependencies> {
|
|||||||
<ItemListLayout
|
<ItemListLayout
|
||||||
isConfigurable
|
isConfigurable
|
||||||
tableId="port_forwards"
|
tableId="port_forwards"
|
||||||
className="PortForwards" store={this.props.portForwardStore}
|
className="PortForwards"
|
||||||
|
store={this.props.portForwardStore}
|
||||||
|
getItems={() => this.props.portForwardStore.items}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
[columnId.name]: item => item.getName(),
|
[columnId.name]: item => item.getName(),
|
||||||
[columnId.namespace]: item => item.getNs(),
|
[columnId.namespace]: item => item.getNs(),
|
||||||
|
|||||||
@ -41,8 +41,7 @@ export type HeaderCustomizer = (placeholders: HeaderPlaceholders) => HeaderPlace
|
|||||||
export interface ItemListLayoutProps<I extends ItemObject> {
|
export interface ItemListLayoutProps<I extends ItemObject> {
|
||||||
tableId?: string;
|
tableId?: string;
|
||||||
className: IClassName;
|
className: IClassName;
|
||||||
items?: I[];
|
getItems: () => I[];
|
||||||
getItems?: () => I[];
|
|
||||||
store: ItemStore<I>;
|
store: ItemStore<I>;
|
||||||
dependentStores?: ItemStore<ItemObject>[];
|
dependentStores?: ItemStore<ItemObject>[];
|
||||||
preloadStores?: boolean;
|
preloadStores?: boolean;
|
||||||
@ -213,7 +212,7 @@ class NonInjectedItemListLayout<I extends ItemObject> extends React.Component<It
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const items = this.props.getItems?.() ?? this.props.items ?? this.props.store.items;
|
const items = this.props.getItems();
|
||||||
|
|
||||||
return applyFilters(filterItems.concat(this.props.filterItems), items);
|
return applyFilters(filterItems.concat(this.props.filterItems), items);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,11 +21,14 @@ import { TooltipPosition } from "../tooltip";
|
|||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import type { ClusterFrameContext } from "../../cluster-frame-context/cluster-frame-context";
|
import type { ClusterFrameContext } from "../../cluster-frame-context/cluster-frame-context";
|
||||||
import clusterFrameContextInjectable from "../../cluster-frame-context/cluster-frame-context.injectable";
|
import clusterFrameContextInjectable from "../../cluster-frame-context/cluster-frame-context.injectable";
|
||||||
import kubeWatchApiInjectable
|
import kubeWatchApiInjectable from "../../kube-watch-api/kube-watch-api.injectable";
|
||||||
from "../../kube-watch-api/kube-watch-api.injectable";
|
|
||||||
import type { KubeWatchSubscribeStoreOptions } from "../../kube-watch-api/kube-watch-api";
|
import type { KubeWatchSubscribeStoreOptions } from "../../kube-watch-api/kube-watch-api";
|
||||||
|
|
||||||
export interface KubeObjectListLayoutProps<K extends KubeObject> extends ItemListLayoutProps<K> {
|
type ItemListLayoutPropsWithoutGetItems<K extends KubeObject> = Omit<ItemListLayoutProps<K>, "getItems">;
|
||||||
|
|
||||||
|
export interface KubeObjectListLayoutProps<K extends KubeObject> extends ItemListLayoutPropsWithoutGetItems<K> {
|
||||||
|
items?: K[];
|
||||||
|
getItems?: () => K[];
|
||||||
store: KubeObjectStore<K>;
|
store: KubeObjectStore<K>;
|
||||||
dependentStores?: KubeObjectStore<KubeObject>[];
|
dependentStores?: KubeObjectStore<KubeObject>[];
|
||||||
subscribeStores?: boolean;
|
subscribeStores?: boolean;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user