mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Display namespace defined in kubeconfig always in the namespace selector (#472)
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
a608918dce
commit
0661954a27
@ -34,7 +34,7 @@ export class NamespaceSelect extends React.Component<Props> {
|
|||||||
private unsubscribe = noop;
|
private unsubscribe = noop;
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
if (isAllowedResource("namespaces") && !namespaceStore.isLoaded) {
|
if (!namespaceStore.isLoaded) {
|
||||||
await namespaceStore.loadAll();
|
await namespaceStore.loadAll();
|
||||||
}
|
}
|
||||||
this.unsubscribe = namespaceStore.subscribe();
|
this.unsubscribe = namespaceStore.subscribe();
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { KubeObjectStore } from "../../kube-object.store";
|
|||||||
import { Namespace, namespacesApi } from "../../api/endpoints";
|
import { Namespace, namespacesApi } from "../../api/endpoints";
|
||||||
import { IQueryParams, navigation, setQueryParams } from "../../navigation";
|
import { IQueryParams, navigation, setQueryParams } from "../../navigation";
|
||||||
import { apiManager } from "../../api/api-manager";
|
import { apiManager } from "../../api/api-manager";
|
||||||
|
import { isAllowedResource } from "../..//api/rbac";
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
export class NamespaceStore extends KubeObjectStore<Namespace> {
|
export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||||
@ -43,6 +44,16 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected loadItems(namespaces?: string[]) {
|
protected loadItems(namespaces?: string[]) {
|
||||||
|
if (!isAllowedResource("namespaces")) {
|
||||||
|
if (namespaces) {
|
||||||
|
return Promise.all(namespaces.map(name => this.getDummyNamespace(name)))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new Promise<Namespace[]>(() => {
|
||||||
|
return []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
if (namespaces) {
|
if (namespaces) {
|
||||||
return Promise.all(namespaces.map(name => this.api.get({ name })))
|
return Promise.all(namespaces.map(name => this.api.get({ name })))
|
||||||
}
|
}
|
||||||
@ -51,6 +62,19 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected getDummyNamespace(name: string) {
|
||||||
|
return new Namespace({
|
||||||
|
kind: "Namespace",
|
||||||
|
apiVersion: "v1",
|
||||||
|
metadata: {
|
||||||
|
name: name,
|
||||||
|
uid: "",
|
||||||
|
resourceVersion: "",
|
||||||
|
selfLink: `/api/v1/namespaces/${name}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
setContext(namespaces: string[]) {
|
setContext(namespaces: string[]) {
|
||||||
this.contextNs.replace(namespaces);
|
this.contextNs.replace(namespaces);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user