Remove BaseStore<T> and replace with composition of dependencies (#7002)

* Rename ExtensionStore -> BaseExtensionStore
- The name was too close to ExtensionsStore

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Move ExtensionsStore to new format

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Move ClusterStore to new format

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Move UserStore to new format

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Cleanup types to remove multiple cast locations

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Move HotbarStore to new format

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Move WeblinkStore to new format

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Move FileSystemProvisionerStore to new format

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Update snapshots

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Clean up impl and rename to better describe intent

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix remaining type errors

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fully split apart the enabled extensions storage

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fully split apart the clusters storage

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fully split apart the hotbar storage

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fully split apart the weblinks storage

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fully split apart the user preferences storage

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix crashing

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix tests and snapshots

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix integration test failures

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Improve typing to prevent errors in the future.

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Cleanup @k8slens/messaging and friends

- To fix type errors

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix lint issue

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix type errors

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix global override not being complete enough causing tests to fail

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Bump memory for unit tests on CI

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Attempt to fix memory issue on CI again

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fixup test because of new injectables

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Upgrade Jest

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix unit tests falling over

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Back out jest config change

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Remove console log

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Update snapshot

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix tests by matching equality instead of snapshots

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix tests by forcing specific snapshot style

- Ubuntu CI seems to format arrays in snapshots differently than macOS locally

Signed-off-by: Sebastian Malton <sebastian@malton.name>

---------

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2023-03-28 17:54:25 +03:00
1 parent ba4a283af9
commit 49f0a1af9c
365 files changed
+6733 -3972

No files matched your search

@@ -709,7 +709,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1057,7 +1057,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1263,7 +1263,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1469,7 +1469,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -2231,7 +2231,7 @@ exports[`preferences - closing-preferences given already in a page and then navi
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -2579,7 +2579,7 @@ exports[`preferences - closing-preferences given already in a page and then navi
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -2785,7 +2785,7 @@ exports[`preferences - closing-preferences given already in a page and then navi
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -2991,7 +2991,7 @@ exports[`preferences - closing-preferences given already in a page and then navi
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -722,7 +722,7 @@ exports[`preferences: extension adding preference tabs given in preferences, whe
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -697,7 +697,7 @@ exports[`preferences - hiding-of-empty-branches, given in preferences page given
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1475,7 +1475,7 @@ exports[`preferences - hiding-of-empty-branches, given in preferences page given
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -2265,7 +2265,7 @@ exports[`preferences - hiding-of-empty-branches, given in preferences page given
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -697,7 +697,7 @@ exports[`preferences - navigation to application preferences given in preference
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1478,7 +1478,7 @@ exports[`preferences - navigation to application preferences given in preference
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1884,7 +1884,7 @@ exports[`preferences - navigation to application preferences given in some child
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -2634,7 +2634,7 @@ exports[`preferences - navigation to application preferences given in some child
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -3385,7 +3385,7 @@ exports[`preferences - navigation to application preferences given in some child
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -697,7 +697,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1336,7 +1336,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -710,7 +710,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1090,7 +1090,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1481,7 +1481,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1872,7 +1872,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -2289,7 +2289,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -3039,7 +3039,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -3827,7 +3827,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -4232,7 +4232,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -4568,7 +4568,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -697,7 +697,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1374,7 +1374,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -697,7 +697,7 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1103,7 +1103,7 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -337,7 +337,7 @@ exports[`preferences - navigation to telemetry preferences given URL for Sentry
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1087,7 +1087,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1849,7 +1849,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -2228,7 +2228,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -2567,7 +2567,7 @@ exports[`preferences - navigation to telemetry preferences given no URL for Sent
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -697,7 +697,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1310,7 +1310,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -230,7 +230,7 @@ exports[`preferences - navigation using application menu renders 1`] = `
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -980,7 +980,7 @@ exports[`preferences - navigation using application menu when navigating to pref
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -231,7 +231,7 @@ exports[`show-about-using-tray renders 1`] = `
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -983,7 +983,7 @@ exports[`show-about-using-tray when navigating using tray renders 1`] = `
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -375,7 +375,7 @@ exports[`preferences: URLs of legacy extensions given extension with both custom
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -804,7 +804,7 @@ exports[`preferences: URLs of legacy extensions given extension with both custom
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1195,7 +1195,7 @@ exports[`preferences: URLs of legacy extensions given extension with custom pref
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1560,7 +1560,7 @@ exports[`preferences: URLs of legacy extensions given extension with custom pref
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -1965,7 +1965,7 @@ exports[`preferences: URLs of legacy extensions given extension with custom pref
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
class="Icon material interactive focusable"
tabindex="0"
>
<span
@@ -6,16 +6,16 @@ import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { Select } from "../../../../../../renderer/components/select";
import { withInjectables } from "@ogre-tools/injectable-react";
import { defaultExtensionRegistryUrl, defaultExtensionRegistryUrlLocation } from "../../../../../../common/user-store/preferences-helpers";
import { Input } from "../../../../../../renderer/components/input";
import { isUrl } from "../../../../../../renderer/components/input/input_validators";
import type { UserStore } from "../../../../../../common/user-store";
import { runInAction } from "mobx";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
import { defaultExtensionRegistryUrlLocation, defaultExtensionRegistryUrl } from "../../../../../user-preferences/common/preferences-helpers";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const extensionInstallRegistryOptions = [
@@ -33,8 +33,8 @@ const extensionInstallRegistryOptions = [
},
] as const;
const NonInjectedExtensionInstallRegistry = observer(({ userStore }: Dependencies) => {
const [customUrl, setCustomUrl] = React.useState(userStore.extensionRegistryUrl.customUrl || "");
const NonInjectedExtensionInstallRegistry = observer(({ state }: Dependencies) => {
const [customUrl, setCustomUrl] = React.useState(state.extensionRegistryUrl.customUrl || "");
return (
<section id="extensionRegistryUrl">
@@ -42,14 +42,14 @@ const NonInjectedExtensionInstallRegistry = observer(({ userStore }: Dependencie
<Select
id="extension-install-registry-input"
options={extensionInstallRegistryOptions}
value={userStore.extensionRegistryUrl.location}
value={state.extensionRegistryUrl.location}
onChange={(value) =>
runInAction(() => {
userStore.extensionRegistryUrl.location =
state.extensionRegistryUrl.location =
value?.value ?? defaultExtensionRegistryUrlLocation;
if (userStore.extensionRegistryUrl.location === "custom") {
userStore.extensionRegistryUrl.customUrl = "";
if (state.extensionRegistryUrl.location === "custom") {
state.extensionRegistryUrl.customUrl = "";
}
})
}
@@ -69,20 +69,16 @@ const NonInjectedExtensionInstallRegistry = observer(({ userStore }: Dependencie
validators={isUrl}
value={customUrl}
onChange={setCustomUrl}
onBlur={() => (userStore.extensionRegistryUrl.customUrl = customUrl)}
onBlur={() => (state.extensionRegistryUrl.customUrl = customUrl)}
placeholder="Custom Extension Registry URL..."
disabled={userStore.extensionRegistryUrl.location !== "custom"}
disabled={state.extensionRegistryUrl.location !== "custom"}
/>
</section>
);
});
export const ExtensionInstallRegistry = withInjectables<Dependencies>(
NonInjectedExtensionInstallRegistry,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const ExtensionInstallRegistry = withInjectables<Dependencies>(NonInjectedExtensionInstallRegistry, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,33 +5,29 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { Switch } from "../../../../../../renderer/components/switch";
import { observer } from "mobx-react";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const NonInjectedStartUp = observer(({ userStore }: Dependencies) => (
const NonInjectedStartUp = observer(({ state }: Dependencies) => (
<section id="other">
<SubTitle title="Start-up" />
<Switch
checked={userStore.openAtLogin}
onChange={() => (userStore.openAtLogin = !userStore.openAtLogin)}
checked={state.openAtLogin}
onChange={() => (state.openAtLogin = !state.openAtLogin)}
>
Automatically start Lens on login
</Switch>
</section>
));
export const StartUp = withInjectables<Dependencies>(
NonInjectedStartUp,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const StartUp = withInjectables<Dependencies>(NonInjectedStartUp, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -7,26 +7,26 @@ import { SubTitle } from "../../../../../../renderer/components/layout/sub-title
import { Select } from "../../../../../../renderer/components/select";
import { withInjectables } from "@ogre-tools/injectable-react";
import { observer } from "mobx-react";
import type { UserStore } from "../../../../../../common/user-store";
import type { LensTheme } from "../../../../../../renderer/themes/lens-theme";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import defaultLensThemeInjectable from "../../../../../../renderer/themes/default-theme.injectable";
import { lensThemeDeclarationInjectionToken } from "../../../../../../renderer/themes/declaration";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
defaultTheme: LensTheme;
themes: LensTheme[];
}
const NonInjectedTheme = observer(({
userStore,
state,
themes,
defaultTheme,
}: Dependencies) => {
const themeOptions = [
{
value: "system", // TODO: replace with a sentinal value that isn't string (and serialize it differently)
value: "system", // TODO: replace with a sentinel value that isn't string (and serialize it differently)
label: "Sync with computer",
},
...themes.map(theme => ({
@@ -41,9 +41,9 @@ const NonInjectedTheme = observer(({
<Select
id="theme-input"
options={themeOptions}
value={userStore.colorTheme}
value={state.colorTheme}
onChange={(value) =>
(userStore.colorTheme = value?.value ?? defaultTheme.name)
(state.colorTheme = value?.value ?? defaultTheme.name)
}
themeName="lens"
/>
@@ -53,7 +53,7 @@ const NonInjectedTheme = observer(({
export const Theme = withInjectables<Dependencies>(NonInjectedTheme, {
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
state: di.inject(userPreferencesStateInjectable),
defaultTheme: di.inject(defaultLensThemeInjectable),
themes: di.injectMany(lensThemeDeclarationInjectionToken),
}),
@@ -5,15 +5,15 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { Select } from "../../../../../../renderer/components/select";
import moment from "moment-timezone";
import { observer } from "mobx-react";
import currentTimezoneInjectable from "../../../../../../common/user-store/current-timezone.injectable";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import currentTimezoneInjectable from "../../../../../../common/vars/current-timezone.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
currentTimezone: string;
}
@@ -23,9 +23,8 @@ const timezoneOptions = moment.tz.names()
label: timezone.replace("_", " "),
}));
const NonInjectedTimezone = observer(({
userStore,
state,
currentTimezone,
}: Dependencies) => (
<section id="locale">
@@ -33,17 +32,16 @@ const NonInjectedTimezone = observer(({
<Select
id="timezone-input"
options={timezoneOptions}
value={userStore.localeTimezone}
onChange={value => userStore.localeTimezone = value?.value ?? currentTimezone}
value={state.localeTimezone}
onChange={value => state.localeTimezone = value?.value ?? currentTimezone}
themeName="lens"
/>
</section>
));
export const Timezone = withInjectables<Dependencies>(NonInjectedTimezone, {
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
state: di.inject(userPreferencesStateInjectable),
currentTimezone: di.inject(currentTimezoneInjectable),
}),
});
@@ -5,16 +5,16 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { Input } from "../../../../../../renderer/components/input";
import { observer } from "mobx-react";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const NonInjectedEditorFontFamily = observer(({ userStore: { editorConfiguration }}: Dependencies) => (
const NonInjectedEditorFontFamily = observer(({ state: { editorConfiguration }}: Dependencies) => (
<section>
<SubTitle title="Font family" />
<Input
@@ -26,12 +26,8 @@ const NonInjectedEditorFontFamily = observer(({ userStore: { editorConfiguration
</section>
));
export const EditorFontFamily = withInjectables<Dependencies>(
NonInjectedEditorFontFamily,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const EditorFontFamily = withInjectables<Dependencies>(NonInjectedEditorFontFamily, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,16 +5,16 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { Input, InputValidators } from "../../../../../../renderer/components/input";
import { observer } from "mobx-react";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const NonInjectedEditorFontSize = observer(({ userStore: { editorConfiguration }}: Dependencies) => (
const NonInjectedEditorFontSize = observer(({ state: { editorConfiguration }}: Dependencies) => (
<section>
<SubTitle title="Font size" />
<Input
@@ -28,12 +28,8 @@ const NonInjectedEditorFontSize = observer(({ userStore: { editorConfiguration }
</section>
));
export const EditorFontSize = withInjectables<Dependencies>(
NonInjectedEditorFontSize,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const EditorFontSize = withInjectables<Dependencies>(NonInjectedEditorFontSize, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,15 +5,15 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { Select } from "../../../../../../renderer/components/select";
import { defaultEditorConfig } from "../../../../../../common/user-store/preferences-helpers";
import { capitalize } from "lodash/fp";
import { observer } from "mobx-react";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import { defaultEditorConfig } from "../../../../../user-preferences/common/preferences-helpers";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const lineNumberOptions = ([
@@ -26,7 +26,7 @@ const lineNumberOptions = ([
label: capitalize(lineNumbers),
}));
const NonInjectedLineNumbers = observer(({ userStore: { editorConfiguration }}: Dependencies) => (
const NonInjectedLineNumbers = observer(({ state: { editorConfiguration }}: Dependencies) => (
<section>
<SubTitle title="Line numbers"/>
<Select
@@ -37,15 +37,10 @@ const NonInjectedLineNumbers = observer(({ userStore: { editorConfiguration }}:
themeName="lens"
/>
</section>
));
export const LineNumbers = withInjectables<Dependencies>(
NonInjectedLineNumbers,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const LineNumbers = withInjectables<Dependencies>(NonInjectedLineNumbers, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,15 +5,15 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { Switch } from "../../../../../../renderer/components/switch";
import { SubHeader } from "../../../../../../renderer/components/layout/sub-header";
import { Select } from "../../../../../../renderer/components/select";
import { observer } from "mobx-react";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const minimapPositionOptions = (["left", "right"] as const)
@@ -23,7 +23,7 @@ const minimapPositionOptions = (["left", "right"] as const)
}));
const NonInjectedMinimap = observer(({ userStore: { editorConfiguration }}: Dependencies) => (
const NonInjectedMinimap = observer(({ state: { editorConfiguration }}: Dependencies) => (
<section>
<SubTitle title="Minimap"/>
@@ -50,12 +50,8 @@ const NonInjectedMinimap = observer(({ userStore: { editorConfiguration }}: Depe
</section>
));
export const Minimap = withInjectables<Dependencies>(
NonInjectedMinimap,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const Minimap = withInjectables<Dependencies>(NonInjectedMinimap, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,16 +5,16 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { Input, InputValidators } from "../../../../../../renderer/components/input";
import { observer } from "mobx-react";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const NonInjectedTabSize = observer(({ userStore: { editorConfiguration }}: Dependencies) => (
const NonInjectedTabSize = observer(({ state: { editorConfiguration }}: Dependencies) => (
<section>
<SubTitle title="Tab size" />
<Input
@@ -28,12 +28,8 @@ const NonInjectedTabSize = observer(({ userStore: { editorConfiguration }}: Depe
</section>
));
export const TabSize = withInjectables<Dependencies>(
NonInjectedTabSize,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const TabSize = withInjectables<Dependencies>(NonInjectedTabSize, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -7,13 +7,11 @@ import { computed, makeObservable, observable, reaction } from "mobx";
import { disposeOnUnmount, observer } from "mobx-react";
import React from "react";
import { Notice } from "../../../../../../renderer/components/+extensions/notice";
import type { UserStore } from "../../../../../../common/user-store";
import { iter, tuple } from "@k8slens/utilities";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { PathPicker } from "../../../../../../renderer/components/path-picker/path-picker";
import { Spinner } from "../../../../../../renderer/components/spinner";
import { RemovableItem } from "../../../removable-item/removable-item";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import isWindowsInjectable from "../../../../../../common/vars/is-windows.injectable";
import loggerInjectable from "../../../../../../common/logger.injectable";
import type { Logger } from "../../../../../../common/logger";
@@ -21,13 +19,15 @@ import type { DiscoverAllKubeconfigSyncKinds } from "./discover-all-sync-kinds.i
import type { DiscoverKubeconfigSyncKind, SyncKind } from "./discover-sync-kind.injectable";
import discoverKubeconfigSyncKindInjectable from "./discover-sync-kind.injectable";
import discoverAllKubeconfigSyncKindsInjectable from "./discover-all-sync-kinds.injectable";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Entry extends SyncKind {
filePath: string;
}
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
isWindows: boolean;
logger: Logger;
discoverAllKubeconfigSyncKinds: DiscoverAllKubeconfigSyncKinds;
@@ -47,7 +47,7 @@ class NonInjectedKubeconfigSync extends React.Component<Dependencies> {
async componentDidMount() {
const mapEntries = await Promise.all(
iter.map(
this.props.userStore.syncKubeconfigEntries,
this.props.state.syncKubeconfigEntries,
([filePath]) => this.props.discoverKubeconfigSyncKind(filePath),
),
);
@@ -59,7 +59,7 @@ class NonInjectedKubeconfigSync extends React.Component<Dependencies> {
reaction(
() => Array.from(this.syncs.entries(), ([filePath, kind]) => tuple.from(filePath, kind)),
syncs => {
this.props.userStore.syncKubeconfigEntries.replace(syncs);
this.props.state.syncKubeconfigEntries.replace(syncs);
},
),
]);
@@ -177,7 +177,7 @@ class NonInjectedKubeconfigSync extends React.Component<Dependencies> {
export const KubeconfigSync = withInjectables<Dependencies>(NonInjectedKubeconfigSync, {
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
state: di.inject(userPreferencesStateInjectable),
isWindows: di.inject(isWindowsInjectable),
logger: di.inject(loggerInjectable),
discoverAllKubeconfigSyncKinds: di.inject(discoverAllKubeconfigSyncKindsInjectable),
@@ -5,34 +5,29 @@
import React from "react";
import { SubTitle } from "../../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import { Switch } from "../../../../../../../renderer/components/switch";
import type { UserPreferencesState } from "../../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const NonInjectedKubectlBinaryDownload = observer(({ userStore }: Dependencies) => (
const NonInjectedKubectlBinaryDownload = observer(({ state }: Dependencies) => (
<section>
<SubTitle title="Kubectl binary download" />
<Switch
checked={userStore.downloadKubectlBinaries}
onChange={() => userStore.downloadKubectlBinaries = !userStore.downloadKubectlBinaries}
checked={state.downloadKubectlBinaries}
onChange={() => state.downloadKubectlBinaries = !state.downloadKubectlBinaries}
>
Download kubectl binaries matching the Kubernetes cluster version
</Switch>
</section>
));
export const KubectlBinaryDownload = withInjectables<Dependencies>(
NonInjectedKubectlBinaryDownload,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const KubectlBinaryDownload = withInjectables<Dependencies>(NonInjectedKubectlBinaryDownload, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,24 +5,24 @@
import React, { useState } from "react";
import { SubTitle } from "../../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import { Input, InputValidators } from "../../../../../../../renderer/components/input";
import directoryForBinariesInjectable from "../../../../../../../common/app-paths/directory-for-binaries/directory-for-binaries.injectable";
import type { UserPreferencesState } from "../../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
defaultPathForGeneralBinaries: string;
}
const NonInjectedKubectlDirectoryForBinaries = observer(
({ userStore, defaultPathForGeneralBinaries }: Dependencies) => {
const [downloadPath, setDownloadPath] = useState(userStore.downloadBinariesPath || "");
({ state, defaultPathForGeneralBinaries }: Dependencies) => {
const [downloadPath, setDownloadPath] = useState(state.downloadBinariesPath || "");
const pathValidator = downloadPath ? InputValidators.isPath : undefined;
const save = () => {
userStore.downloadBinariesPath = downloadPath;
state.downloadBinariesPath = downloadPath;
};
return (
@@ -35,7 +35,7 @@ const NonInjectedKubectlDirectoryForBinaries = observer(
validators={pathValidator}
onChange={setDownloadPath}
onBlur={save}
disabled={!userStore.downloadKubectlBinaries}
disabled={!state.downloadKubectlBinaries}
/>
<div className="hint">The directory to download binaries into.</div>
</section>
@@ -43,13 +43,9 @@ const NonInjectedKubectlDirectoryForBinaries = observer(
},
);
export const KubectlDirectoryForBinaries = withInjectables<Dependencies>(
NonInjectedKubectlDirectoryForBinaries,
{
getProps: (di) => ({
defaultPathForGeneralBinaries: di.inject(directoryForBinariesInjectable),
userStore: di.inject(userStoreInjectable),
}),
},
);
export const KubectlDirectoryForBinaries = withInjectables<Dependencies>(NonInjectedKubectlDirectoryForBinaries, {
getProps: (di) => ({
defaultPathForGeneralBinaries: di.inject(directoryForBinariesInjectable),
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,14 +5,14 @@
import React from "react";
import { SubTitle } from "../../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import { Select } from "../../../../../../../renderer/components/select";
import { defaultPackageMirror, packageMirrors } from "../../../../../../../common/user-store/preferences-helpers";
import { defaultPackageMirror, packageMirrors } from "../../../../../../user-preferences/common/preferences-helpers";
import type { UserPreferencesState } from "../../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const downloadMirrorOptions = Array.from(packageMirrors, ([name, mirror]) => ({
@@ -24,27 +24,23 @@ const downloadMirrorOptions = Array.from(packageMirrors, ([name, mirror]) => ({
}));
const NonInjectedKubectlDownloadMirror = observer(({ userStore }: Dependencies) => (
const NonInjectedKubectlDownloadMirror = observer(({ state }: Dependencies) => (
<section>
<SubTitle title="Download mirror" />
<Select
id="download-mirror-input"
placeholder="Download mirror for kubectl"
options={downloadMirrorOptions}
value={userStore.downloadMirror}
onChange={option => userStore.downloadMirror = option?.value ?? defaultPackageMirror}
isDisabled={!userStore.downloadKubectlBinaries}
value={state.downloadMirror}
onChange={option => state.downloadMirror = option?.value ?? defaultPackageMirror}
isDisabled={!state.downloadKubectlBinaries}
themeName="lens"
/>
</section>
));
export const KubectlDownloadMirror = withInjectables<Dependencies>(
NonInjectedKubectlDownloadMirror,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const KubectlDownloadMirror = withInjectables<Dependencies>(NonInjectedKubectlDownloadMirror, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,50 +5,48 @@
import React, { useState } from "react";
import { SubTitle } from "../../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import { Input, InputValidators } from "../../../../../../../renderer/components/input";
import directoryForKubectlBinariesInjectable from "../../../../../../../common/app-paths/directory-for-kubectl-binaries/directory-for-kubectl-binaries.injectable";
import type { UserPreferencesState } from "../../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
defaultPathForKubectlBinaries: string;
}
const NonInjectedKubectlPathToBinary = observer(
({ userStore, defaultPathForKubectlBinaries }: Dependencies) => {
const [binariesPath, setBinariesPath] = useState(userStore.kubectlBinariesPath || "");
const pathValidator = binariesPath ? InputValidators.isPath : undefined;
const NonInjectedKubectlPathToBinary = observer(({
state,
defaultPathForKubectlBinaries,
}: Dependencies) => {
const [binariesPath, setBinariesPath] = useState(state.kubectlBinariesPath || "");
const pathValidator = binariesPath ? InputValidators.isPath : undefined;
const save = () => {
userStore.kubectlBinariesPath = binariesPath;
};
const save = () => {
state.kubectlBinariesPath = binariesPath;
};
return (
<section>
<SubTitle title="Path to kubectl binary" />
<Input
theme="round-black"
placeholder={defaultPathForKubectlBinaries}
value={binariesPath}
validators={pathValidator}
onChange={setBinariesPath}
onBlur={save}
disabled={userStore.downloadKubectlBinaries}
/>
</section>
);
},
return (
<section>
<SubTitle title="Path to kubectl binary" />
<Input
theme="round-black"
placeholder={defaultPathForKubectlBinaries}
value={binariesPath}
validators={pathValidator}
onChange={setBinariesPath}
onBlur={save}
disabled={state.downloadKubectlBinaries}
/>
</section>
);
},
);
export const KubectlPathToBinary = withInjectables<Dependencies>(
NonInjectedKubectlPathToBinary,
{
getProps: (di) => ({
defaultPathForKubectlBinaries: di.inject(directoryForKubectlBinariesInjectable),
userStore: di.inject(userStoreInjectable),
}),
},
);
export const KubectlPathToBinary = withInjectables<Dependencies>(NonInjectedKubectlPathToBinary, {
getProps: (di) => ({
defaultPathForKubectlBinaries: di.inject(directoryForKubectlBinariesInjectable),
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,23 +5,21 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import { Switch } from "../../../../../../renderer/components/switch";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const NonInjectedAllowUntrustedCertificates = observer(({ userStore }: Dependencies) => (
const NonInjectedAllowUntrustedCertificates = observer(({ state }: Dependencies) => (
<section className="small">
<SubTitle title="Certificate Trust" />
<Switch
checked={userStore.allowUntrustedCAs}
onChange={() =>
(userStore.allowUntrustedCAs = !userStore.allowUntrustedCAs)
}
checked={state.allowUntrustedCAs}
onChange={() => state.allowUntrustedCAs = !state.allowUntrustedCAs}
>
Allow untrusted Certificate Authorities
</Switch>
@@ -33,12 +31,8 @@ const NonInjectedAllowUntrustedCertificates = observer(({ userStore }: Dependenc
</section>
));
export const AllowUntrustedCertificates = withInjectables<Dependencies>(
NonInjectedAllowUntrustedCertificates,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const AllowUntrustedCertificates = withInjectables<Dependencies>(NonInjectedAllowUntrustedCertificates, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,43 +5,39 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import { Input } from "../../../../../../renderer/components/input";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const NonInjectedHttpProxyUrl = observer(
({ userStore }: Dependencies) => {
const [proxy, setProxy] = React.useState(userStore.httpsProxy || "");
const NonInjectedHttpProxyUrl = observer(({
state,
}: Dependencies) => {
const [proxy, setProxy] = React.useState(state.httpsProxy || "");
return (
<section>
<SubTitle title="HTTP Proxy" />
<Input
theme="round-black"
placeholder="Type HTTP proxy url (example: http://proxy.acme.org:8080)"
value={proxy}
onChange={(v) => setProxy(v)}
onBlur={() => (userStore.httpsProxy = proxy)}
/>
<small className="hint">
Proxy is used only for non-cluster communication.
</small>
</section>
);
},
);
return (
<section>
<SubTitle title="HTTP Proxy" />
<Input
theme="round-black"
placeholder="Type HTTP proxy url (example: http://proxy.acme.org:8080)"
value={proxy}
onChange={(v) => setProxy(v)}
onBlur={() => (state.httpsProxy = proxy)}
/>
<small className="hint">
Proxy is used only for non-cluster communication.
</small>
</section>
);
});
export const HttpProxyUrl = withInjectables<Dependencies>(
NonInjectedHttpProxyUrl,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const HttpProxyUrl = withInjectables<Dependencies>(NonInjectedHttpProxyUrl, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,16 +5,16 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import { Checkbox } from "../../../../../../renderer/components/checkbox";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const NonInjectedAutomaticErrorReporting = observer(({ userStore }: Dependencies) => (
const NonInjectedAutomaticErrorReporting = observer(({ state }: Dependencies) => (
<div
id="sentry"
className="small"
@@ -23,8 +23,8 @@ const NonInjectedAutomaticErrorReporting = observer(({ userStore }: Dependencies
<SubTitle title="Automatic Error Reporting" />
<Checkbox
label="Allow automatic error reporting"
value={userStore.allowErrorReporting}
onChange={(value) => (userStore.allowErrorReporting = value)}
value={state.allowErrorReporting}
onChange={(value) => (state.allowErrorReporting = value)}
/>
<div className="hint">
<span>
@@ -36,12 +36,8 @@ const NonInjectedAutomaticErrorReporting = observer(({ userStore }: Dependencies
</div>
));
export const AutomaticErrorReporting = withInjectables<Dependencies>(
NonInjectedAutomaticErrorReporting,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const AutomaticErrorReporting = withInjectables<Dependencies>(NonInjectedAutomaticErrorReporting, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,38 +5,31 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import { Switch } from "../../../../../../renderer/components/switch";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const NonInjectedCopyPasteFromTerminal = observer(
({ userStore }: Dependencies) => {
const NonInjectedCopyPasteFromTerminal = observer(({
state,
}: Dependencies) => (
<section id="terminalSelection">
<SubTitle title="Terminal copy & paste" />
<Switch
checked={state.terminalCopyOnSelect}
onChange={() => state.terminalCopyOnSelect = !state.terminalCopyOnSelect}
>
Copy on select and paste on right-click
</Switch>
</section>
));
return (
<section id="terminalSelection">
<SubTitle title="Terminal copy & paste" />
<Switch
checked={userStore.terminalCopyOnSelect}
onChange={() => userStore.terminalCopyOnSelect = !userStore.terminalCopyOnSelect}
>
Copy on select and paste on right-click
</Switch>
</section>
);
},
);
export const CopyPasteFromTerminal = withInjectables<Dependencies>(
NonInjectedCopyPasteFromTerminal,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const CopyPasteFromTerminal = withInjectables<Dependencies>(NonInjectedCopyPasteFromTerminal, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -7,10 +7,10 @@ import type { IComputedValue } from "mobx";
import { action, computed } from "mobx";
import React from "react";
import type { SingleValue } from "react-select";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { defaultTerminalFontFamily } from "../../../../../../common/vars";
import type { SelectOption } from "../../../../../../renderer/components/select";
import { terminalFontInjectionToken } from "../../../../../terminal/renderer/fonts/token";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
export interface TerminalFontPreferencePresenter {
readonly options: IComputedValue<SelectOption<string>[]>;
@@ -21,7 +21,7 @@ export interface TerminalFontPreferencePresenter {
const terminalFontPreferencePresenterInjectable = getInjectable({
id: "terminal-font-preference-presenter",
instantiate: (di): TerminalFontPreferencePresenter => {
const userStore = di.inject(userStoreInjectable);
const state = di.inject(userPreferencesStateInjectable);
const terminalFonts = di.injectMany(terminalFontInjectionToken);
return {
@@ -30,18 +30,18 @@ const terminalFontPreferencePresenterInjectable = getInjectable({
<span
style={{
fontFamily: `${font.name}, var(--font-terminal)`,
fontSize: userStore.terminalConfig.fontSize,
fontSize: state.terminalConfig.fontSize,
}}
>
{font.name}
</span>
),
value: font.name,
isSelected: userStore.terminalConfig.fontFamily === font.name,
isSelected: state.terminalConfig.fontFamily === font.name,
}))),
current: computed(() => userStore.terminalConfig.fontFamily),
current: computed(() => state.terminalConfig.fontFamily),
onSelection: action(selection => {
userStore.terminalConfig.fontFamily = selection?.value ?? defaultTerminalFontFamily;
state.terminalConfig.fontFamily = selection?.value ?? defaultTerminalFontFamily;
}),
};
},
@@ -5,40 +5,32 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import { Input } from "../../../../../../renderer/components/input";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
}
const NonInjectedTerminalFontSize = observer(
({ userStore }: Dependencies) => {
const NonInjectedTerminalFontSize = observer(({
state,
}: Dependencies) => (
<section>
<SubTitle title="Font size" />
<Input
theme="round-black"
type="number"
min={10}
max={50}
defaultValue={state.terminalConfig.fontSize.toString()}
onChange={(value) => state.terminalConfig.fontSize = Number(value)} />
</section>
));
return (
<section>
<SubTitle title="Font size" />
<Input
theme="round-black"
type="number"
min={10}
max={50}
defaultValue={userStore.terminalConfig.fontSize.toString()}
onChange={(value) => userStore.terminalConfig.fontSize = Number(value)}
/>
</section>
);
},
);
export const TerminalFontSize = withInjectables<Dependencies>(
NonInjectedTerminalFontSize,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
}),
},
);
export const TerminalFontSize = withInjectables<Dependencies>(NonInjectedTerminalFontSize, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
}),
});
@@ -5,42 +5,35 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import { Input } from "../../../../../../renderer/components/input";
import defaultShellInjectable from "./default-shell/default-shell.injectable";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
defaultShell: string;
}
const NonInjectedTerminalShellPath = observer(
({ userStore, defaultShell }: Dependencies) => {
const NonInjectedTerminalShellPath = observer(({
state,
defaultShell,
}: Dependencies) => (
<section id="shell">
<SubTitle title="Terminal Shell Path" />
<Input
theme="round-black"
placeholder={defaultShell}
value={state.shell ?? ""}
onChange={(value) => state.shell = value}
/>
</section>
));
return (
<section id="shell">
<SubTitle title="Terminal Shell Path" />
<Input
theme="round-black"
placeholder={defaultShell}
value={userStore.shell ?? ""}
onChange={(value) => userStore.shell = value}
/>
</section>
);
},
);
export const TerminalShellPath = withInjectables<Dependencies>(
NonInjectedTerminalShellPath,
{
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
defaultShell: di.inject(defaultShellInjectable),
}),
},
);
export const TerminalShellPath = withInjectables<Dependencies>(NonInjectedTerminalShellPath, {
getProps: (di) => ({
state: di.inject(userPreferencesStateInjectable),
defaultShell: di.inject(defaultShellInjectable),
}),
});
@@ -5,26 +5,25 @@
import React from "react";
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { UserStore } from "../../../../../../common/user-store";
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
import { observer } from "mobx-react";
import { Select } from "../../../../../../renderer/components/select";
import type { LensTheme } from "../../../../../../renderer/themes/lens-theme";
import { lensThemeDeclarationInjectionToken } from "../../../../../../renderer/themes/declaration";
import type { UserPreferencesState } from "../../../../../user-preferences/common/state.injectable";
import userPreferencesStateInjectable from "../../../../../user-preferences/common/state.injectable";
interface Dependencies {
userStore: UserStore;
state: UserPreferencesState;
themes: LensTheme[];
}
const NonInjectedTerminalTheme = observer(({
userStore,
state,
themes,
}: Dependencies) => {
const themeOptions = [
{
value: "", // TODO: replace with a sentinal value that isn't string (and serialize it differently)
value: "", // TODO: replace with a sentinel value that isn't string (and serialize it differently)
label: "Match Lens Theme",
},
...themes.map(theme => ({
@@ -40,8 +39,8 @@ const NonInjectedTerminalTheme = observer(({
id="terminal-theme-input"
themeName="lens"
options={themeOptions}
value={userStore.terminalTheme}
onChange={option => userStore.terminalTheme = option?.value ?? ""}
value={state.terminalTheme}
onChange={option => state.terminalTheme = option?.value ?? ""}
/>
</section>
);
@@ -50,7 +49,7 @@ const NonInjectedTerminalTheme = observer(({
export const TerminalTheme = withInjectables<Dependencies>(NonInjectedTerminalTheme, {
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
state: di.inject(userPreferencesStateInjectable),
themes: di.injectMany(lensThemeDeclarationInjectionToken),
}),
});