diff --git a/src/common/cluster-store.ts b/src/common/cluster-store.ts index 8040db190e..e7e665b09d 100644 --- a/src/common/cluster-store.ts +++ b/src/common/cluster-store.ts @@ -48,7 +48,7 @@ export class ClusterStore extends BaseStore { }); } - @observable activeCluster: ClusterId; + @observable activeCluster: ClusterId; // todo: use active "context" from kube-config? @observable removedClusters = observable.map(); @observable clusters = observable.map(); diff --git a/src/main/window-manager.ts b/src/main/window-manager.ts index b2ab1d6ad0..8a7eb6cf7a 100644 --- a/src/main/window-manager.ts +++ b/src/main/window-manager.ts @@ -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(); @@ -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) { diff --git a/src/renderer/api/endpoints/config.api.ts b/src/renderer/api/endpoints/config.api.ts deleted file mode 100644 index bad571db6e..0000000000 --- a/src/renderer/api/endpoints/config.api.ts +++ /dev/null @@ -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("/config") - }, -}; diff --git a/src/renderer/api/endpoints/index.ts b/src/renderer/api/endpoints/index.ts index f175d6feb9..d723766f07 100644 --- a/src/renderer/api/endpoints/index.ts +++ b/src/renderer/api/endpoints/index.ts @@ -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" diff --git a/src/renderer/api/endpoints/kubeconfig.api.ts b/src/renderer/api/endpoints/kubeconfig.api.ts deleted file mode 100644 index c6476badf4..0000000000 --- a/src/renderer/api/endpoints/kubeconfig.api.ts +++ /dev/null @@ -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}`); - }, -}; diff --git a/src/renderer/components/kubeconfig-dialog/kubeconfig-dialog.tsx b/src/renderer/components/kubeconfig-dialog/kubeconfig-dialog.tsx index b5ce1ed6d2..68f0a93129 100644 --- a/src/renderer/components/kubeconfig-dialog/kubeconfig-dialog.tsx +++ b/src/renderer/components/kubeconfig-dialog/kubeconfig-dialog.tsx @@ -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 { } } -export function openUserKubeConfig() { - KubeConfigDialog.open({ - loader: () => kubeConfigApi.getUserConfig() - }) -} - export function openServiceAccountKubeConfig(account: ServiceAccount) { const accountName = account.getName() const namespace = account.getNs() KubeConfigDialog.open({ title: {accountName} kubeconfig, - loader: () => { - return kubeConfigApi.getServiceAccountConfig(accountName, namespace) - } + loader: () => apiBase.get(`/kubeconfig/service-account/${namespace}/${account}`) }) } \ No newline at end of file diff --git a/src/renderer/config.store.ts b/src/renderer/config.store.ts index 7de80807ac..f119754861 100755 --- a/src/renderer/config.store.ts +++ b/src/renderer/config.store.ts @@ -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; });