/** * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ import React, { useState } from "react"; import { observer } from "mobx-react"; import { Input, InputValidators } from "../input"; import { SubTitle } from "../layout/sub-title"; import { UserStore } from "../../../common/user-store"; import { bundledKubectlPath } from "../../../main/kubectl/kubectl"; import { SelectOption, Select } from "../select"; import { Switch } from "../switch"; import { packageMirrors } from "../../../common/user-store/preferences-helpers"; import directoryForBinariesInjectable from "../../../common/app-paths/directory-for-binaries/directory-for-binaries.injectable"; import { withInjectables } from "@ogre-tools/injectable-react"; interface Dependencies { defaultPathForKubectlBinaries: string; } const NonInjectedKubectlBinaries: React.FC = observer(({ defaultPathForKubectlBinaries }) => { const userStore = UserStore.getInstance(); const [downloadPath, setDownloadPath] = useState(userStore.downloadBinariesPath || ""); const [binariesPath, setBinariesPath] = useState(userStore.kubectlBinariesPath || ""); const pathValidator = downloadPath ? InputValidators.isPath : undefined; const downloadMirrorOptions: SelectOption[] = Array.from( packageMirrors.entries(), ([value, { label, platforms }]) => ({ value, label, platforms }), ); const save = () => { userStore.downloadBinariesPath = downloadPath; userStore.kubectlBinariesPath = binariesPath; }; return ( <>
userStore.downloadKubectlBinaries = !userStore.downloadKubectlBinaries} > Download kubectl binaries matching the Kubernetes cluster version
The directory to download binaries into.
); }); export const KubectlBinaries = withInjectables(NonInjectedKubectlBinaries, { getProps: (di) => ({ defaultPathForKubectlBinaries: di.inject(directoryForBinariesInjectable), }), });