Cascade different refactorings to eliminate global shared state from app paths

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne SavolainenandMikko Aspiala committed 2022-01-05 13:26:49 +02:00
1 parent 908a40975e
commit 9d33fff906
336 files changed
+9105 -3307

No files matched your search

@@ -22,14 +22,20 @@
import React, { useState } from "react";
import { Input, InputValidators } from "../input";
import { SubTitle } from "../layout/sub-title";
import { getDefaultKubectlDownloadPath, UserStore } from "../../../common/user-store";
import { observer } from "mobx-react";
import { bundledKubectlPath } from "../../../main/kubectl";
import { UserStore } from "../../../common/user-store";
import { bundledKubectlPath } from "../../../main/kubectl/kubectl";
import { SelectOption, Select } from "../select";
import { FormSwitch, Switcher } 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";
export const KubectlBinaries = observer(() => {
interface Dependencies {
defaultPathForKubectlBinaries: string
}
const NonInjectedKubectlBinaries: React.FC<Dependencies> = (({ defaultPathForKubectlBinaries }) => {
const userStore = UserStore.getInstance();
const [downloadPath, setDownloadPath] = useState(userStore.downloadBinariesPath || "");
const [binariesPath, setBinariesPath] = useState(userStore.kubectlBinariesPath || "");
@@ -78,7 +84,7 @@ export const KubectlBinaries = observer(() => {
<Input
theme="round-black"
value={downloadPath}
placeholder={getDefaultKubectlDownloadPath()}
placeholder={defaultPathForKubectlBinaries}
validators={pathValidator}
onChange={setDownloadPath}
onBlur={save}
@@ -104,3 +110,9 @@ export const KubectlBinaries = observer(() => {
</>
);
});
export const KubectlBinaries = withInjectables<Dependencies>(NonInjectedKubectlBinaries, {
getProps: (di) => ({
defaultPathForKubectlBinaries: di.inject(directoryForBinariesInjectable),
}),
});