mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix namespaces not being shown
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
5f58196529
commit
ff30f8ace7
@ -208,7 +208,11 @@ export abstract class KubeObjectStore<
|
||||
}
|
||||
}
|
||||
|
||||
return await res ?? [];
|
||||
const items = await res ?? [];
|
||||
|
||||
console.trace("loadItems", this.api, [...items]);
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
this.loadedNamespaces.set(namespaces);
|
||||
@ -249,6 +253,8 @@ export abstract class KubeObjectStore<
|
||||
try {
|
||||
const items = await this.loadItems({ namespaces, reqInit, onLoadFailure });
|
||||
|
||||
console.log("loadAll", this.api, [...items]);
|
||||
|
||||
this.mergeItems(items, { merge, namespaces });
|
||||
|
||||
this.isLoaded = true;
|
||||
@ -281,6 +287,8 @@ export abstract class KubeObjectStore<
|
||||
protected mergeItems(partialItems: K[], { merge = true, updateStore = true, sort = true, filter = true, namespaces }: MergeItemsOptions): K[] {
|
||||
let items = partialItems;
|
||||
|
||||
console.log("mergeItems", this.api, [...partialItems]);
|
||||
|
||||
// update existing items
|
||||
if (merge && this.api.isNamespaced) {
|
||||
const ns = new Set(namespaces);
|
||||
|
||||
18
src/renderer/cluster/accessible-namespaces.injectable.ts
Normal file
18
src/renderer/cluster/accessible-namespaces.injectable.ts
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import hostedClusterInjectable from "../cluster-frame-context/hosted-cluster.injectable";
|
||||
|
||||
const clusterConfiguredAccessibleNamespacesInjectable = getInjectable({
|
||||
id: "cluster-configured-accessible-namespaces",
|
||||
instantiate: (di) => {
|
||||
const hostedCluster = di.inject(hostedClusterInjectable);
|
||||
|
||||
return computed(() => [...hostedCluster?.accessibleNamespaces ?? []]);
|
||||
},
|
||||
});
|
||||
|
||||
export default clusterConfiguredAccessibleNamespacesInjectable;
|
||||
@ -10,6 +10,7 @@ import namespaceApiInjectable from "../../../common/k8s-api/endpoints/namespace.
|
||||
import assert from "assert";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
import clusterFrameContextForClusterScopedResourcesInjectable from "../../cluster-frame-context/for-cluster-scoped-resources.injectable";
|
||||
import clusterConfiguredAccessibleNamespacesInjectable from "../../cluster/accessible-namespaces.injectable";
|
||||
|
||||
const namespaceStoreInjectable = getInjectable({
|
||||
id: "namespace-store",
|
||||
@ -23,6 +24,7 @@ const namespaceStoreInjectable = getInjectable({
|
||||
return new NamespaceStore({
|
||||
context: di.inject(clusterFrameContextForClusterScopedResourcesInjectable),
|
||||
storage: createStorage<string[] | undefined>("selected_namespaces", undefined),
|
||||
clusterConfiguredAccessibleNamespaces: di.inject(clusterConfiguredAccessibleNamespacesInjectable),
|
||||
}, api);
|
||||
},
|
||||
injectionToken: kubeObjectStoreInjectionToken,
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { IReactionDisposer } from "mobx";
|
||||
import type { IComputedValue, IReactionDisposer } from "mobx";
|
||||
import { action, comparer, computed, makeObservable, reaction } from "mobx";
|
||||
import type { StorageLayer } from "../../utils";
|
||||
import { autoBind, noop, toggle } from "../../utils";
|
||||
@ -14,6 +14,7 @@ import { Namespace } from "../../../common/k8s-api/endpoints/namespace.api";
|
||||
|
||||
interface Dependencies extends KubeObjectStoreDependencies {
|
||||
readonly storage: StorageLayer<string[] | undefined>;
|
||||
readonly clusterConfiguredAccessibleNamespaces: IComputedValue<string[]>;
|
||||
}
|
||||
|
||||
export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
|
||||
@ -118,17 +119,13 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
|
||||
}
|
||||
|
||||
protected async loadItems(params: KubeObjectStoreLoadingParams): Promise<Namespace[]> {
|
||||
const { allowedNamespaces } = this;
|
||||
const clusterConfiguredAccessibleNamespaces = this.dependencies.clusterConfiguredAccessibleNamespaces.get();
|
||||
|
||||
let namespaces = await super.loadItems(params).catch(() => []);
|
||||
|
||||
namespaces = namespaces.filter(namespace => allowedNamespaces.includes(namespace.getName()));
|
||||
|
||||
if (!namespaces.length && allowedNamespaces.length > 0) {
|
||||
return allowedNamespaces.map(getDummyNamespace);
|
||||
if (clusterConfiguredAccessibleNamespaces.length > 0) {
|
||||
return clusterConfiguredAccessibleNamespaces.map(getDummyNamespace);
|
||||
}
|
||||
|
||||
return namespaces;
|
||||
return super.loadItems(params);
|
||||
}
|
||||
|
||||
@action selectNamespaces = (namespace: string | string[]) => {
|
||||
|
||||
@ -76,7 +76,7 @@ class NonInjectedSearchInput extends React.Component<SearchInputProps & Dependen
|
||||
}
|
||||
|
||||
render() {
|
||||
const { className, compact, onClear, showClearIcon, bindGlobalFocusHotkey, value, ...inputProps } = this.props;
|
||||
const { className, compact, onClear, showClearIcon, bindGlobalFocusHotkey, value, isMac, ...inputProps } = this.props;
|
||||
let rightIcon = <Icon small material="search"/>;
|
||||
|
||||
if (showClearIcon && value) {
|
||||
|
||||
@ -15,7 +15,7 @@ import { ClusterFrame } from "./cluster-frame";
|
||||
import historyInjectable from "../../navigation/history.injectable";
|
||||
import { computed } from "mobx";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import createClusterInjectable from "../../create-cluster/create-cluster.injectable";
|
||||
import createClusterInjectable from "../../cluster/create-cluster.injectable";
|
||||
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
||||
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user