1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

night insomnia clean-up

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-07-10 01:17:00 +03:00
parent 0e8187c2b0
commit e1acf7e3d0
7 changed files with 13 additions and 44 deletions

View File

@ -48,7 +48,7 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
});
}
@observable activeCluster: ClusterId;
@observable activeCluster: ClusterId; // todo: use active "context" from kube-config?
@observable removedClusters = observable.map<ClusterId, Cluster>();
@observable clusters = observable.map<ClusterId, Cluster>();

View File

@ -4,6 +4,9 @@ import windowStateKeeper from "electron-window-state"
import type { ClusterId } from "../common/cluster-store";
import { clusterStore } from "../common/cluster-store";
// todo: smooth switching btw clusters (e.g. wait ready-state before switching window)
// todo: devtools + manage main-window size btw views
export class WindowManager {
protected activeView: BrowserWindow;
protected views = new Map<ClusterId, BrowserWindow>();
@ -42,8 +45,6 @@ export class WindowManager {
this.splashWindow.hide();
}
// todo: smooth switching between windows/clusters
// todo: devtools + manage main-window size btw views
async showView(clusterId: ClusterId) {
const cluster = clusterStore.getById(clusterId);
if (!cluster) {

View File

@ -1,9 +0,0 @@
// App configuration api
import type { IConfigRoutePayload } from "../../../main/routes/config-route";
import { apiBase } from "../index";
export const configApi = {
getConfig() {
return apiBase.get<IConfigRoutePayload>("/config")
},
};

View File

@ -1,10 +1,7 @@
// Local express.js endpoints
export * from "./config.api"
export * from "./cluster.api"
export * from "./kubeconfig.api"
// Kubernetes endpoints
// Kubernetes apis
// Docs: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/
export * from "./cluster.api"
export * from "./namespaces.api"
export * from "./cluster-role.api"
export * from "./cluster-role-binding.api"

View File

@ -1,12 +0,0 @@
// Kubeconfig api
import { apiBase } from "../index";
export const kubeConfigApi = {
getUserConfig() {
return apiBase.get("/kubeconfig/user");
},
getServiceAccountConfig(account: string, namespace: string) {
return apiBase.get(`/kubeconfig/service-account/${namespace}/${account}`);
},
};

View File

@ -6,14 +6,15 @@ import { observer } from "mobx-react";
import jsYaml from "js-yaml";
import { Trans } from "@lingui/macro";
import { AceEditor } from "../ace-editor";
import { kubeConfigApi, ServiceAccount } from "../../api/endpoints";
import { copyToClipboard, downloadFile, cssNames } from "../../utils";
import { ServiceAccount } from "../../api/endpoints";
import { copyToClipboard, cssNames, downloadFile } from "../../utils";
import { Button } from "../button";
import { Dialog, DialogProps } from "../dialog";
import { Icon } from "../icon";
import { Notifications } from "../notifications";
import { Wizard, WizardStep } from "../wizard";
import { themeStore } from "../../theme.store";
import { apiBase } from "../../api";
interface IKubeconfigDialogData {
title?: React.ReactNode;
@ -111,19 +112,11 @@ export class KubeConfigDialog extends React.Component<Props> {
}
}
export function openUserKubeConfig() {
KubeConfigDialog.open({
loader: () => kubeConfigApi.getUserConfig()
})
}
export function openServiceAccountKubeConfig(account: ServiceAccount) {
const accountName = account.getName()
const namespace = account.getNs()
KubeConfigDialog.open({
title: <Trans>{accountName} kubeconfig</Trans>,
loader: () => {
return kubeConfigApi.getServiceAccountConfig(accountName, namespace)
}
loader: () => apiBase.get(`/kubeconfig/service-account/${namespace}/${account}`)
})
}

View File

@ -1,8 +1,7 @@
import type { IConfigRoutePayload } from "../main/routes/config-route";
import { observable, when } from "mobx";
import { autobind, interval } from "./utils";
import { configApi } from "./api/endpoints/config.api";
import { apiBase } from "./api";
@autobind()
export class ConfigStore {
@ -17,7 +16,7 @@ export class ConfigStore {
}
load() {
return configApi.getConfig().then((config: any) => {
return apiBase.get("/config").then((config: IConfigRoutePayload) => {
this.config = config;
this.isLoaded = true;
});