mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
feat: Add removing subNamespaces to Namespace route
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
c5572257bd
commit
aa950026a3
@ -17,6 +17,8 @@ import namespaceStoreInjectable from "./store.injectable";
|
|||||||
import { KubeObjectAge } from "../kube-object/age";
|
import { KubeObjectAge } from "../kube-object/age";
|
||||||
import openAddNamespaceDialogInjectable from "./add-dialog/open.injectable";
|
import openAddNamespaceDialogInjectable from "./add-dialog/open.injectable";
|
||||||
import { SubnamespaceBadge } from "./subnamespace-badge";
|
import { SubnamespaceBadge } from "./subnamespace-badge";
|
||||||
|
import type { RequestDeleteNamespace } from "./request-delete-namespace.injectable";
|
||||||
|
import requestDeleteNamespaceInjectable from "./request-delete-namespace.injectable";
|
||||||
|
|
||||||
enum columnId {
|
enum columnId {
|
||||||
name = "name",
|
name = "name",
|
||||||
@ -28,15 +30,45 @@ enum columnId {
|
|||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
namespaceStore: NamespaceStore;
|
namespaceStore: NamespaceStore;
|
||||||
openAddNamespaceDialog: () => void;
|
openAddNamespaceDialog: () => void;
|
||||||
|
requestDeleteNamespace: RequestDeleteNamespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NonInjectedNamespacesRoute = ({ namespaceStore, openAddNamespaceDialog }: Dependencies) => (
|
const NonInjectedNamespacesRoute = ({
|
||||||
|
namespaceStore,
|
||||||
|
openAddNamespaceDialog,
|
||||||
|
requestDeleteNamespace,
|
||||||
|
}: Dependencies) => (
|
||||||
<TabLayout>
|
<TabLayout>
|
||||||
<KubeObjectListLayout
|
<KubeObjectListLayout
|
||||||
isConfigurable
|
isConfigurable
|
||||||
tableId="namespaces"
|
tableId="namespaces"
|
||||||
className="Namespaces"
|
className="Namespaces"
|
||||||
store={namespaceStore}
|
store={{
|
||||||
|
api: namespaceStore.api,
|
||||||
|
get contextItems() {
|
||||||
|
return namespaceStore.contextItems;
|
||||||
|
},
|
||||||
|
get failedLoading() {
|
||||||
|
return namespaceStore.failedLoading;
|
||||||
|
},
|
||||||
|
get isLoaded() {
|
||||||
|
return namespaceStore.isLoaded;
|
||||||
|
},
|
||||||
|
get selectedItems() {
|
||||||
|
return namespaceStore.selectedItems;
|
||||||
|
},
|
||||||
|
getByPath: (...params) => namespaceStore.getByPath(...params),
|
||||||
|
getTotalCount: (...params) => namespaceStore.getTotalCount(...params),
|
||||||
|
isSelected: (...params) => namespaceStore.isSelected(...params),
|
||||||
|
isSelectedAll: (...params) => namespaceStore.isSelectedAll(...params),
|
||||||
|
loadAll: (...params) => namespaceStore.loadAll(...params),
|
||||||
|
subscribe: () => namespaceStore.subscribe(),
|
||||||
|
toggleSelection: (...params) => namespaceStore.toggleSelection(...params),
|
||||||
|
toggleSelectionAll: (...params) => namespaceStore.toggleSelectionAll(...params),
|
||||||
|
pickOnlySelected: (...params) => namespaceStore.pickOnlySelected(...params),
|
||||||
|
removeItems: async (items) => { await Promise.all(items.map(requestDeleteNamespace)); },
|
||||||
|
removeSelectedItems: async () => { await Promise.all(namespaceStore.selectedItems.map(requestDeleteNamespace)); },
|
||||||
|
}}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
[columnId.name]: namespace => namespace.getName(),
|
[columnId.name]: namespace => namespace.getName(),
|
||||||
[columnId.labels]: namespace => namespace.getLabels(),
|
[columnId.labels]: namespace => namespace.getLabels(),
|
||||||
@ -87,5 +119,6 @@ export const NamespacesRoute = withInjectables<Dependencies>(NonInjectedNamespac
|
|||||||
getProps: (di) => ({
|
getProps: (di) => ({
|
||||||
namespaceStore: di.inject(namespaceStoreInjectable),
|
namespaceStore: di.inject(namespaceStoreInjectable),
|
||||||
openAddNamespaceDialog: di.inject(openAddNamespaceDialogInjectable),
|
openAddNamespaceDialog: di.inject(openAddNamespaceDialogInjectable),
|
||||||
|
requestDeleteNamespace: di.inject(requestDeleteNamespaceInjectable),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,9 +11,8 @@ import { disposeOnUnmount, observer } from "mobx-react";
|
|||||||
import type { Disposer } from "@k8slens/utilities";
|
import type { Disposer } from "@k8slens/utilities";
|
||||||
import { hasTypedProperty, isObject, isString, cssNames, isDefined } from "@k8slens/utilities";
|
import { hasTypedProperty, isObject, isString, cssNames, isDefined } from "@k8slens/utilities";
|
||||||
import type { KubeJsonApiDataFor, KubeObject } from "../../../common/k8s-api/kube-object";
|
import type { KubeJsonApiDataFor, KubeObject } from "../../../common/k8s-api/kube-object";
|
||||||
import type { ItemListLayoutProps } from "../item-object-list/list-layout";
|
import type { ItemListLayoutProps, ItemListStore } from "../item-object-list/list-layout";
|
||||||
import { ItemListLayout } from "../item-object-list/list-layout";
|
import { ItemListLayout } from "../item-object-list/list-layout";
|
||||||
import type { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
|
||||||
import { KubeObjectMenu } from "../kube-object-menu";
|
import { KubeObjectMenu } from "../kube-object-menu";
|
||||||
import { NamespaceSelectFilter } from "../+namespaces/namespace-select-filter";
|
import { NamespaceSelectFilter } from "../+namespaces/namespace-select-filter";
|
||||||
import { ResourceKindMap, ResourceNames } from "../../utils/rbac";
|
import { ResourceKindMap, ResourceNames } from "../../utils/rbac";
|
||||||
@ -33,14 +32,20 @@ import type { KubeObjectListLayoutColumn, ItemObject } from "@k8slens/list-layou
|
|||||||
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
|
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
|
||||||
import { sortBy } from "lodash";
|
import { sortBy } from "lodash";
|
||||||
|
|
||||||
|
export type KubeItemListStore<K extends KubeObject> = ItemListStore<K, false> & SubscribableStore & {
|
||||||
|
getByPath: (path: string) => K | undefined;
|
||||||
|
readonly contextItems: K[];
|
||||||
|
};
|
||||||
|
|
||||||
export interface KubeObjectListLayoutProps<
|
export interface KubeObjectListLayoutProps<
|
||||||
K extends KubeObject,
|
K extends KubeObject,
|
||||||
|
// eslint-disable-next-line unused-imports/no-unused-vars-ts
|
||||||
A extends KubeApi<K, D>,
|
A extends KubeApi<K, D>,
|
||||||
D extends KubeJsonApiDataFor<K>,
|
D extends KubeJsonApiDataFor<K>,
|
||||||
> extends Omit<ItemListLayoutProps<K, false>, "getItems" | "dependentStores" | "preloadStores"> {
|
> extends Omit<ItemListLayoutProps<K, false>, "getItems" | "dependentStores" | "preloadStores"> {
|
||||||
items?: K[];
|
items?: K[];
|
||||||
getItems?: () => K[];
|
getItems?: () => K[];
|
||||||
store: KubeObjectStore<K, A, D>;
|
store: KubeItemListStore<K>;
|
||||||
dependentStores?: SubscribableStore[];
|
dependentStores?: SubscribableStore[];
|
||||||
subscribeStores?: boolean;
|
subscribeStores?: boolean;
|
||||||
|
|
||||||
|
|||||||
@ -82,6 +82,7 @@ export interface SubscribableStore {
|
|||||||
readonly isNamespaced: boolean;
|
readonly isNamespaced: boolean;
|
||||||
readonly apiBase: string;
|
readonly apiBase: string;
|
||||||
readonly kind: string;
|
readonly kind: string;
|
||||||
|
readonly apiVersionWithGroup?: string;
|
||||||
};
|
};
|
||||||
loadAll(opts?: KubeObjectStoreLoadAllParams): Promise<unknown>;
|
loadAll(opts?: KubeObjectStoreLoadAllParams): Promise<unknown>;
|
||||||
subscribe(opts?: KubeObjectStoreSubscribeParams): Disposer;
|
subscribe(opts?: KubeObjectStoreSubscribeParams): Disposer;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user