diff --git a/package.json b/package.json index b5fdd16e23..224c0df837 100644 --- a/package.json +++ b/package.json @@ -172,7 +172,6 @@ "@hapi/call": "^8.0.0", "@hapi/subtext": "^7.0.3", "@kubernetes/client-node": "^0.12.0", - "@material-ui/icons": "^4.11.2", "abort-controller": "^3.0.0", "array-move": "^3.0.0", "await-lock": "^2.1.0", @@ -234,6 +233,7 @@ "devDependencies": { "@emeraldpay/hashicon-react": "^0.4.0", "@material-ui/core": "^4.10.1", + "@material-ui/icons": "^4.11.2", "@material-ui/lab": "^4.0.0-alpha.57", "@pmmmwh/react-refresh-webpack-plugin": "^0.4.3", "@testing-library/jest-dom": "^5.11.10", @@ -341,7 +341,7 @@ "sharp": "^0.26.1", "spectron": "11.0.0", "style-loader": "^1.2.1", - "ts-jest": "^26.1.0", + "ts-jest": "26.3.0", "ts-loader": "^7.0.5", "ts-node": "^8.10.2", "type-fest": "^1.0.2", diff --git a/src/common/kube-helpers.ts b/src/common/kube-helpers.ts index 0b001ebf18..f8a75624f4 100644 --- a/src/common/kube-helpers.ts +++ b/src/common/kube-helpers.ts @@ -29,15 +29,15 @@ function readResolvedPathSync(filePath: string): string { } function checkRawCluster(rawCluster: any): boolean { - return rawCluster?.name && rawCluster?.cluster?.server; + return Boolean(rawCluster?.name && rawCluster?.cluster?.server); } function checkRawUser(rawUser: any): boolean { - return rawUser?.name; + return Boolean(rawUser?.name); } function checkRawContext(rawContext: any): boolean { - return rawContext.name && rawContext.context?.cluster && rawContext.context?.user; + return Boolean(rawContext.name && rawContext.context?.cluster && rawContext.context?.user); } export interface KubeConfigOptions { @@ -206,6 +206,8 @@ export function getNodeWarningConditions(node: V1Node) { /** * Checks if `config` has valid `Context`, `User`, `Cluster`, and `exec` fields (if present when required) + * + * Note: This function returns an error instead of throwing it, returning `undefined` if the validation passes */ export function validateKubeConfig(config: KubeConfig, contextName: string, validationOpts: KubeConfigValidationOpts = {}): Error | undefined { // we only receive a single context, cluster & user object here so lets validate them as this diff --git a/src/main/catalog-sources/__test__/kubeconfig-sync.source.test.ts b/src/main/catalog-sources/__test__/kubeconfig-sync.test.ts similarity index 98% rename from src/main/catalog-sources/__test__/kubeconfig-sync.source.test.ts rename to src/main/catalog-sources/__test__/kubeconfig-sync.test.ts index 0d0159a579..beda3ca890 100644 --- a/src/main/catalog-sources/__test__/kubeconfig-sync.source.test.ts +++ b/src/main/catalog-sources/__test__/kubeconfig-sync.test.ts @@ -2,7 +2,7 @@ import { ObservableMap } from "mobx"; import { CatalogEntity } from "../../../common/catalog"; import { loadFromOptions } from "../../../common/kube-helpers"; import { Cluster } from "../../cluster"; -import { computeDiff, configToModels } from "../kubeconfig-sync.source"; +import { computeDiff, configToModels } from "../kubeconfig-sync"; import mockFs from "mock-fs"; import fs from "fs"; diff --git a/src/main/catalog-sources/index.ts b/src/main/catalog-sources/index.ts index c519f37161..5824760082 100644 --- a/src/main/catalog-sources/index.ts +++ b/src/main/catalog-sources/index.ts @@ -1 +1 @@ -export { KubeconfigSyncManager } from "./kubeconfig-sync.source"; +export { KubeconfigSyncManager } from "./kubeconfig-sync"; diff --git a/src/main/catalog-sources/kubeconfig-sync.source.ts b/src/main/catalog-sources/kubeconfig-sync.ts similarity index 100% rename from src/main/catalog-sources/kubeconfig-sync.source.ts rename to src/main/catalog-sources/kubeconfig-sync.ts diff --git a/src/renderer/bootstrap.tsx b/src/renderer/bootstrap.tsx index c1851db704..43b1c170eb 100644 --- a/src/renderer/bootstrap.tsx +++ b/src/renderer/bootstrap.tsx @@ -21,7 +21,7 @@ import { LensApp } from "./lens-app"; import { ThemeStore } from "./theme.store"; import { HelmRepoManager } from "../main/helm/helm-repo-manager"; import { ExtensionInstallationStateStore } from "./components/+extensions/extension-install.store"; -import { createMuiTheme, ThemeProvider } from "@material-ui/core"; +import { DefaultProps } from "./mui-base-theme"; /** * If this is a development buid, wait a second to attach @@ -97,37 +97,5 @@ export async function bootstrap(App: AppComponent) { , rootElem); } -const defaultTheme = createMuiTheme({ - props: { - MuiIconButton: { - color: "inherit", - }, - MuiSvgIcon: { - fontSize: "inherit", - }, - MuiTooltip: { - placement: "top", - } - }, - overrides: { - MuiIconButton: { - root: { - "&:hover": { - color: "var(--iconActiveColor)", - backgroundColor: "var(--iconActiveBackground)", - } - } - } - }, -}); - -function DefaultProps(App: AppComponent) { - return ( - - - - ); -} - // run bootstrap(process.isMainFrame ? LensApp : App); diff --git a/src/renderer/mui-base-theme.tsx b/src/renderer/mui-base-theme.tsx new file mode 100644 index 0000000000..284e2ca40a --- /dev/null +++ b/src/renderer/mui-base-theme.tsx @@ -0,0 +1,34 @@ +import React from "react"; +import { createMuiTheme, ThemeProvider } from "@material-ui/core"; + +const defaultTheme = createMuiTheme({ + props: { + MuiIconButton: { + color: "inherit", + }, + MuiSvgIcon: { + fontSize: "inherit", + }, + MuiTooltip: { + placement: "top", + } + }, + overrides: { + MuiIconButton: { + root: { + "&:hover": { + color: "var(--iconActiveColor)", + backgroundColor: "var(--iconActiveBackground)", + } + } + } + }, +}); + +export function DefaultProps(App: React.ComponentType) { + return ( + + + + ); +} diff --git a/yarn.lock b/yarn.lock index 8550442574..c563f09836 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13657,7 +13657,7 @@ ts-essentials@^4.0.0: resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-4.0.0.tgz#506c42b270bbd0465574b90416533175b09205ab" integrity sha512-uQJX+SRY9mtbKU+g9kl5Fi7AEMofPCvHfJkQlaygpPmHPZrtgaBqbWFOYyiA47RhnSwwnXdepUJrgqUYxoUyhQ== -ts-jest@^26.1.0: +ts-jest@26.3.0: version "26.3.0" resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.3.0.tgz#6b2845045347dce394f069bb59358253bc1338a9" integrity sha512-Jq2uKfx6bPd9+JDpZNMBJMdMQUC3sJ08acISj8NXlVgR2d5OqslEHOR2KHMgwymu8h50+lKIm0m0xj/ioYdW2Q==