mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove dead code
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
258bfc98e8
commit
f2de81cf81
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { computed } from "mobx";
|
|
||||||
import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token";
|
|
||||||
|
|
||||||
const appPreferencesRouteInjectable = getInjectable({
|
|
||||||
id: "app-preferences-route",
|
|
||||||
|
|
||||||
instantiate: () => ({
|
|
||||||
path: "/preferences/app",
|
|
||||||
clusterFrame: false,
|
|
||||||
isEnabled: computed(() => true),
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: frontEndRouteInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default appPreferencesRouteInjectable;
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { computed } from "mobx";
|
|
||||||
import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token";
|
|
||||||
|
|
||||||
const editorPreferencesRouteInjectable = getInjectable({
|
|
||||||
id: "editor-preferences-route",
|
|
||||||
|
|
||||||
instantiate: () => ({
|
|
||||||
path: "/preferences/editor",
|
|
||||||
clusterFrame: false,
|
|
||||||
isEnabled: computed(() => true),
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: frontEndRouteInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default editorPreferencesRouteInjectable;
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { computed } from "mobx";
|
|
||||||
import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token";
|
|
||||||
|
|
||||||
const kubernetesPreferencesRouteInjectable = getInjectable({
|
|
||||||
id: "kubernetes-preferences-route",
|
|
||||||
|
|
||||||
instantiate: () => ({
|
|
||||||
path: "/preferences/kubernetes",
|
|
||||||
clusterFrame: false,
|
|
||||||
isEnabled: computed(() => true),
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: frontEndRouteInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default kubernetesPreferencesRouteInjectable;
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { computed } from "mobx";
|
|
||||||
import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token";
|
|
||||||
|
|
||||||
const proxyPreferencesRouteInjectable = getInjectable({
|
|
||||||
id: "proxy-preferences-route",
|
|
||||||
|
|
||||||
instantiate: () => ({
|
|
||||||
path: "/preferences/proxy",
|
|
||||||
clusterFrame: false,
|
|
||||||
isEnabled: computed(() => true),
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: frontEndRouteInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default proxyPreferencesRouteInjectable;
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { computed } from "mobx";
|
|
||||||
import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token";
|
|
||||||
|
|
||||||
const telemetryPreferencesRouteInjectable = getInjectable({
|
|
||||||
id: "telemetry-preferences-route",
|
|
||||||
|
|
||||||
instantiate: () => ({
|
|
||||||
path: "/preferences/telemetry",
|
|
||||||
clusterFrame: false,
|
|
||||||
isEnabled: computed(() => true),
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: frontEndRouteInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default telemetryPreferencesRouteInjectable;
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { computed } from "mobx";
|
|
||||||
import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token";
|
|
||||||
|
|
||||||
const terminalPreferencesRouteInjectable = getInjectable({
|
|
||||||
id: "terminal-preferences-route",
|
|
||||||
|
|
||||||
instantiate: () => ({
|
|
||||||
path: "/preferences/terminal",
|
|
||||||
clusterFrame: false,
|
|
||||||
isEnabled: computed(() => true),
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: frontEndRouteInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default terminalPreferencesRouteInjectable;
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { routeSpecificComponentInjectionToken } from "../../routes/route-specific-component-injection-token";
|
|
||||||
import appPreferencesRouteInjectable from "../../../common/front-end-routing/routes/preferences/app/app-preferences-route.injectable";
|
|
||||||
import { Application } from "./application";
|
|
||||||
|
|
||||||
const appPreferencesRouteComponentInjectable = getInjectable({
|
|
||||||
id: "app-preferences-route-component",
|
|
||||||
|
|
||||||
instantiate: (di) => ({
|
|
||||||
route: di.inject(appPreferencesRouteInjectable),
|
|
||||||
Component: Application,
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: routeSpecificComponentInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default appPreferencesRouteComponentInjectable;
|
|
||||||
@ -1,193 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import { observer } from "mobx-react";
|
|
||||||
import { SubTitle } from "../layout/sub-title";
|
|
||||||
import { Select } from "../select";
|
|
||||||
import type { ThemeStore } from "../../themes/store";
|
|
||||||
import type { UserStore } from "../../../common/user-store";
|
|
||||||
import { Input } from "../input";
|
|
||||||
import { Switch } from "../switch";
|
|
||||||
import moment from "moment-timezone";
|
|
||||||
import { defaultExtensionRegistryUrl, defaultLocaleTimezone, defaultExtensionRegistryUrlLocation } from "../../../common/user-store/preferences-helpers";
|
|
||||||
import type { IComputedValue } from "mobx";
|
|
||||||
import { runInAction } from "mobx";
|
|
||||||
import { isUrl } from "../input/input_validators";
|
|
||||||
import { ExtensionSettings } from "./extension-settings";
|
|
||||||
import type { RegisteredAppPreference } from "./app-preferences/app-preference-registration";
|
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
|
||||||
import appPreferencesInjectable from "./app-preferences/app-preferences.injectable";
|
|
||||||
import { Preferences } from "./preferences";
|
|
||||||
import userStoreInjectable from "../../../common/user-store/user-store.injectable";
|
|
||||||
import themeStoreInjectable from "../../themes/store.injectable";
|
|
||||||
import { defaultThemeId } from "../../../common/vars";
|
|
||||||
import { updateChannels } from "../../../features/application-update/common/update-channels";
|
|
||||||
import { map, toPairs } from "lodash/fp";
|
|
||||||
import { pipeline } from "@ogre-tools/fp";
|
|
||||||
import type { SelectedUpdateChannel } from "../../../features/application-update/common/selected-update-channel/selected-update-channel.injectable";
|
|
||||||
import selectedUpdateChannelInjectable from "../../../features/application-update/common/selected-update-channel/selected-update-channel.injectable";
|
|
||||||
|
|
||||||
interface Dependencies {
|
|
||||||
appPreferenceItems: IComputedValue<RegisteredAppPreference[]>;
|
|
||||||
userStore: UserStore;
|
|
||||||
themeStore: ThemeStore;
|
|
||||||
selectedUpdateChannel: SelectedUpdateChannel;
|
|
||||||
}
|
|
||||||
|
|
||||||
const timezoneOptions = moment.tz.names()
|
|
||||||
.map(timezone => ({
|
|
||||||
value: timezone,
|
|
||||||
label: timezone.replace("_", " "),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const updateChannelOptions = pipeline(
|
|
||||||
toPairs(updateChannels),
|
|
||||||
|
|
||||||
map(([, channel]) => ({
|
|
||||||
value: channel.id,
|
|
||||||
label: channel.label,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
|
|
||||||
const extensionInstallRegistryOptions = [
|
|
||||||
{
|
|
||||||
value: "default",
|
|
||||||
label: "Default Url",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "npmrc",
|
|
||||||
label: "Global .npmrc file's Url",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "custom",
|
|
||||||
label: "Custom Url",
|
|
||||||
},
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
const NonInjectedApplication: React.FC<Dependencies> = ({ appPreferenceItems, userStore, themeStore, selectedUpdateChannel }) => {
|
|
||||||
const [customUrl, setCustomUrl] = React.useState(userStore.extensionRegistryUrl.customUrl || "");
|
|
||||||
const themeOptions = [
|
|
||||||
{
|
|
||||||
value: "system", // TODO: replace with a sentinal value that isn't string (and serialize it differently)
|
|
||||||
label: "Sync with computer",
|
|
||||||
},
|
|
||||||
...Array.from(themeStore.themes, ([themeId, { name }]) => ({
|
|
||||||
value: themeId,
|
|
||||||
label: name,
|
|
||||||
})),
|
|
||||||
];
|
|
||||||
const extensionSettings = appPreferenceItems.get()
|
|
||||||
.filter((preference) => preference.showInPreferencesTab === "application");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Preferences data-testid="application-preferences-page">
|
|
||||||
<section id="application">
|
|
||||||
<h2 data-testid="application-header">Application</h2>
|
|
||||||
<section id="appearance">
|
|
||||||
<SubTitle title="Theme" />
|
|
||||||
<Select
|
|
||||||
id="theme-input"
|
|
||||||
options={themeOptions}
|
|
||||||
value={userStore.colorTheme}
|
|
||||||
onChange={value => userStore.colorTheme = value?.value ?? defaultThemeId}
|
|
||||||
themeName="lens"
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<section id="extensionRegistryUrl">
|
|
||||||
<SubTitle title="Extension Install Registry" />
|
|
||||||
<Select
|
|
||||||
id="extension-install-registry-input"
|
|
||||||
options={extensionInstallRegistryOptions}
|
|
||||||
value={userStore.extensionRegistryUrl.location}
|
|
||||||
onChange={value => runInAction(() => {
|
|
||||||
userStore.extensionRegistryUrl.location = value?.value ?? defaultExtensionRegistryUrlLocation;
|
|
||||||
|
|
||||||
if (userStore.extensionRegistryUrl.location === "custom") {
|
|
||||||
userStore.extensionRegistryUrl.customUrl = "";
|
|
||||||
}
|
|
||||||
})}
|
|
||||||
themeName="lens"
|
|
||||||
/>
|
|
||||||
<p className="mt-4 mb-5 leading-relaxed">
|
|
||||||
{"This setting is to change the registry URL for installing extensions by name. "}
|
|
||||||
{`If you are unable to access the default registry (${defaultExtensionRegistryUrl}) you can change it in your `}
|
|
||||||
<b>.npmrc</b>
|
|
||||||
{" file or in the input below."}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<Input
|
|
||||||
theme="round-black"
|
|
||||||
validators={isUrl}
|
|
||||||
value={customUrl}
|
|
||||||
onChange={setCustomUrl}
|
|
||||||
onBlur={() => userStore.extensionRegistryUrl.customUrl = customUrl}
|
|
||||||
placeholder="Custom Extension Registry URL..."
|
|
||||||
disabled={userStore.extensionRegistryUrl.location !== "custom"}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<section id="other">
|
|
||||||
<SubTitle title="Start-up" />
|
|
||||||
<Switch checked={userStore.openAtLogin} onChange={() => userStore.openAtLogin = !userStore.openAtLogin}>
|
|
||||||
Automatically start Lens on login
|
|
||||||
</Switch>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
{extensionSettings.map(setting => (
|
|
||||||
<ExtensionSettings
|
|
||||||
key={setting.id}
|
|
||||||
setting={setting}
|
|
||||||
size="normal"
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<section id="update-channel">
|
|
||||||
<SubTitle title="Update Channel" />
|
|
||||||
<Select
|
|
||||||
id="update-channel-input"
|
|
||||||
options={updateChannelOptions}
|
|
||||||
value={selectedUpdateChannel.value.get().id}
|
|
||||||
onChange={(selected) => selectedUpdateChannel.setValue(selected?.value) }
|
|
||||||
themeName="lens"
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<section id="locale">
|
|
||||||
<SubTitle title="Locale Timezone" />
|
|
||||||
<Select
|
|
||||||
id="timezone-input"
|
|
||||||
options={timezoneOptions}
|
|
||||||
value={userStore.localeTimezone}
|
|
||||||
onChange={value => userStore.localeTimezone = value?.value ?? defaultLocaleTimezone}
|
|
||||||
themeName="lens"
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
</Preferences>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Application = withInjectables<Dependencies>(
|
|
||||||
observer(NonInjectedApplication),
|
|
||||||
|
|
||||||
{
|
|
||||||
getProps: (di) => ({
|
|
||||||
appPreferenceItems: di.inject(appPreferencesInjectable),
|
|
||||||
userStore: di.inject(userStoreInjectable),
|
|
||||||
themeStore: di.inject(themeStoreInjectable),
|
|
||||||
selectedUpdateChannel: di.inject(selectedUpdateChannelInjectable),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { routeSpecificComponentInjectionToken } from "../../routes/route-specific-component-injection-token";
|
|
||||||
import { Editor } from "./editor";
|
|
||||||
import editorPreferencesRouteInjectable from "../../../common/front-end-routing/routes/preferences/editor/editor-preferences-route.injectable";
|
|
||||||
|
|
||||||
const editorPreferencesRouteComponentInjectable = getInjectable({
|
|
||||||
id: "editor-preferences-route-component",
|
|
||||||
|
|
||||||
instantiate: (di) => ({
|
|
||||||
route: di.inject(editorPreferencesRouteInjectable),
|
|
||||||
Component: Editor,
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: routeSpecificComponentInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default editorPreferencesRouteComponentInjectable;
|
|
||||||
@ -1,127 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { observer } from "mobx-react";
|
|
||||||
import React from "react";
|
|
||||||
import type { UserStore } from "../../../common/user-store";
|
|
||||||
import { Switch } from "../switch";
|
|
||||||
import { Select } from "../select";
|
|
||||||
import { SubTitle } from "../layout/sub-title";
|
|
||||||
import { SubHeader } from "../layout/sub-header";
|
|
||||||
import { Input, InputValidators } from "../input";
|
|
||||||
import { Preferences } from "./preferences";
|
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
|
||||||
import userStoreInjectable from "../../../common/user-store/user-store.injectable";
|
|
||||||
import { defaultEditorConfig } from "../../../common/user-store/preferences-helpers";
|
|
||||||
import { capitalize } from "lodash";
|
|
||||||
|
|
||||||
interface Dependencies {
|
|
||||||
userStore: UserStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
const minimapPositionOptions = (["left", "right"] as const)
|
|
||||||
.map(side => ({
|
|
||||||
value: side,
|
|
||||||
label: side,
|
|
||||||
}));
|
|
||||||
const lineNumberOptions = ([
|
|
||||||
"on",
|
|
||||||
"off",
|
|
||||||
"relative",
|
|
||||||
"interval",
|
|
||||||
] as const).map(lineNumbers => ({
|
|
||||||
value: lineNumbers,
|
|
||||||
label: capitalize(lineNumbers),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const NonInjectedEditor = observer(({ userStore }: Dependencies) => {
|
|
||||||
const editorConfiguration = userStore.editorConfiguration;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Preferences data-testid="editor-preferences-page">
|
|
||||||
<section id="editor">
|
|
||||||
<h2 data-testid="editor-configuration-header">Editor configuration</h2>
|
|
||||||
|
|
||||||
<SubTitle title="Minimap"/>
|
|
||||||
<section>
|
|
||||||
<div className="flex gaps justify-space-between">
|
|
||||||
<div className="flex gaps align-center">
|
|
||||||
<Switch
|
|
||||||
checked={editorConfiguration.minimap.enabled}
|
|
||||||
onChange={() => editorConfiguration.minimap.enabled = !editorConfiguration.minimap.enabled}
|
|
||||||
>
|
|
||||||
Show minimap
|
|
||||||
</Switch>
|
|
||||||
</div>
|
|
||||||
<div className="flex gaps align-center">
|
|
||||||
<SubHeader compact>Position</SubHeader>
|
|
||||||
<Select
|
|
||||||
id="minimap-input"
|
|
||||||
themeName="lens"
|
|
||||||
options={minimapPositionOptions}
|
|
||||||
value={editorConfiguration.minimap.side}
|
|
||||||
onChange={option => editorConfiguration.minimap.side = option?.value}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<SubTitle title="Line numbers"/>
|
|
||||||
<Select
|
|
||||||
id="editor-line-numbers-input"
|
|
||||||
options={lineNumberOptions}
|
|
||||||
value={editorConfiguration.lineNumbers}
|
|
||||||
onChange={option => editorConfiguration.lineNumbers = option?.value ?? defaultEditorConfig.lineNumbers}
|
|
||||||
themeName="lens"
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<SubTitle title="Tab size" />
|
|
||||||
<Input
|
|
||||||
theme="round-black"
|
|
||||||
type="number"
|
|
||||||
min={1}
|
|
||||||
validators={InputValidators.isNumber}
|
|
||||||
value={editorConfiguration.tabSize.toString()}
|
|
||||||
onChange={value => editorConfiguration.tabSize = Number(value)}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<SubTitle title="Font size" />
|
|
||||||
<Input
|
|
||||||
theme="round-black"
|
|
||||||
type="number"
|
|
||||||
min={10}
|
|
||||||
validators={InputValidators.isNumber}
|
|
||||||
value={editorConfiguration.fontSize.toString()}
|
|
||||||
onChange={value => editorConfiguration.fontSize = Number(value)}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<SubTitle title="Font family" />
|
|
||||||
<Input
|
|
||||||
theme="round-black"
|
|
||||||
type="text"
|
|
||||||
value={editorConfiguration.fontFamily}
|
|
||||||
onChange={value => editorConfiguration.fontFamily = value}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
</Preferences>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
export const Editor = withInjectables<Dependencies>(
|
|
||||||
NonInjectedEditor,
|
|
||||||
|
|
||||||
{
|
|
||||||
getProps: (di) => ({
|
|
||||||
userStore: di.inject(userStoreInjectable),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { routeSpecificComponentInjectionToken } from "../../routes/route-specific-component-injection-token";
|
|
||||||
import kubernetesPreferencesRouteInjectable from "../../../common/front-end-routing/routes/preferences/kubernetes/kubernetes-preferences-route.injectable";
|
|
||||||
import { Kubernetes } from "./kubernetes";
|
|
||||||
|
|
||||||
const kubernetesPreferencesRouteComponentInjectable = getInjectable({
|
|
||||||
id: "kubernetes-preferences-route-component",
|
|
||||||
|
|
||||||
instantiate: (di) => ({
|
|
||||||
route: di.inject(kubernetesPreferencesRouteInjectable),
|
|
||||||
Component: Kubernetes,
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: routeSpecificComponentInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default kubernetesPreferencesRouteComponentInjectable;
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { observer } from "mobx-react";
|
|
||||||
import React from "react";
|
|
||||||
import { HelmCharts } from "../../../features/helm-charts/child-features/preferences/renderer/helm-charts";
|
|
||||||
import { KubeconfigSync } from "../../../features/preferences/renderer/preference-items/kubernetes/kubeconfig-sync/kubeconfig-sync";
|
|
||||||
import { KubectlBinaries } from "./kubectl-binaries";
|
|
||||||
import { Preferences } from "./preferences";
|
|
||||||
|
|
||||||
export const Kubernetes = observer(() => (
|
|
||||||
<Preferences data-testid="kubernetes-preferences-page">
|
|
||||||
<section id="kubernetes">
|
|
||||||
<section id="kubectl">
|
|
||||||
<h2 data-testid="kubernetes-header">Kubernetes</h2>
|
|
||||||
<KubectlBinaries />
|
|
||||||
</section>
|
|
||||||
<hr />
|
|
||||||
<KubeconfigSync />
|
|
||||||
<hr />
|
|
||||||
<HelmCharts />
|
|
||||||
</section>
|
|
||||||
</Preferences>
|
|
||||||
));
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { routeSpecificComponentInjectionToken } from "../../routes/route-specific-component-injection-token";
|
|
||||||
import proxyPreferencesRouteInjectable from "../../../common/front-end-routing/routes/preferences/proxy/proxy-preferences-route.injectable";
|
|
||||||
import { LensProxy } from "./proxy";
|
|
||||||
|
|
||||||
const proxyPreferencesRouteComponentInjectable = getInjectable({
|
|
||||||
id: "proxy-preferences-route-component",
|
|
||||||
|
|
||||||
instantiate: (di) => ({
|
|
||||||
route: di.inject(proxyPreferencesRouteInjectable),
|
|
||||||
Component: LensProxy,
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: routeSpecificComponentInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default proxyPreferencesRouteComponentInjectable;
|
|
||||||
@ -1,71 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
|
||||||
import { observer } from "mobx-react";
|
|
||||||
import React from "react";
|
|
||||||
import type { UserStore } from "../../../common/user-store";
|
|
||||||
import { Input } from "../input";
|
|
||||||
import { SubTitle } from "../layout/sub-title";
|
|
||||||
import { Switch } from "../switch";
|
|
||||||
import { Preferences } from "./preferences";
|
|
||||||
import userStoreInjectable from "../../../common/user-store/user-store.injectable";
|
|
||||||
|
|
||||||
interface Dependencies {
|
|
||||||
userStore: UserStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NonInjectedLensProxy = observer(({ userStore }: Dependencies) => {
|
|
||||||
const [proxy, setProxy] = React.useState(userStore.httpsProxy || "");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Preferences data-testid="proxy-preferences-page">
|
|
||||||
<section id="proxy">
|
|
||||||
<section>
|
|
||||||
<h2 data-testid="proxy-header">Proxy</h2>
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<hr className="small" />
|
|
||||||
|
|
||||||
<section className="small">
|
|
||||||
<SubTitle title="Certificate Trust" />
|
|
||||||
<Switch
|
|
||||||
checked={userStore.allowUntrustedCAs}
|
|
||||||
onChange={() => userStore.allowUntrustedCAs = !userStore.allowUntrustedCAs}
|
|
||||||
>
|
|
||||||
Allow untrusted Certificate Authorities
|
|
||||||
</Switch>
|
|
||||||
<small className="hint">
|
|
||||||
This will make Lens to trust ANY certificate authority without any validations.
|
|
||||||
{" "}
|
|
||||||
Needed with some corporate proxies that do certificate re-writing.
|
|
||||||
{" "}
|
|
||||||
Does not affect cluster communications!
|
|
||||||
</small>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
</Preferences>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
export const LensProxy = withInjectables<Dependencies>(
|
|
||||||
NonInjectedLensProxy,
|
|
||||||
|
|
||||||
{
|
|
||||||
getProps: (di) => ({
|
|
||||||
userStore: di.inject(userStoreInjectable),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { routeSpecificComponentInjectionToken } from "../../routes/route-specific-component-injection-token";
|
|
||||||
import telemetryPreferencesRouteInjectable from "../../../common/front-end-routing/routes/preferences/telemetry/telemetry-preferences-route.injectable";
|
|
||||||
import { Telemetry } from "./telemetry";
|
|
||||||
|
|
||||||
const telemetryPreferencesRouteComponentInjectable = getInjectable({
|
|
||||||
id: "telemetry-preferences-route-component",
|
|
||||||
|
|
||||||
instantiate: (di) => ({
|
|
||||||
route: di.inject(telemetryPreferencesRouteInjectable),
|
|
||||||
Component: Telemetry,
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: routeSpecificComponentInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default telemetryPreferencesRouteComponentInjectable;
|
|
||||||
@ -1,81 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { observer } from "mobx-react";
|
|
||||||
import React from "react";
|
|
||||||
import type { UserStore } from "../../../common/user-store";
|
|
||||||
import { Checkbox } from "../checkbox";
|
|
||||||
import { SubTitle } from "../layout/sub-title";
|
|
||||||
import { ExtensionSettings } from "./extension-settings";
|
|
||||||
import type { IComputedValue } from "mobx";
|
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
|
||||||
import { Preferences } from "./preferences";
|
|
||||||
import telemetryPreferenceItemsInjectable from "./telemetry-preference-items.injectable";
|
|
||||||
import sentryDataSourceNameInjectable from "../../../common/vars/sentry-dsn-url.injectable";
|
|
||||||
import userStoreInjectable from "../../../common/user-store/user-store.injectable";
|
|
||||||
import type { AppPreferenceRegistration } from "./app-preferences/app-preference-registration";
|
|
||||||
|
|
||||||
interface Dependencies {
|
|
||||||
telemetryPreferenceItems: IComputedValue<AppPreferenceRegistration[]>;
|
|
||||||
sentryDnsUrl: string;
|
|
||||||
userStore: UserStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NonInjectedTelemetry: React.FC<Dependencies> = ({
|
|
||||||
telemetryPreferenceItems,
|
|
||||||
sentryDnsUrl,
|
|
||||||
userStore,
|
|
||||||
}) => (
|
|
||||||
<Preferences data-testid="telemetry-preferences-page">
|
|
||||||
<section id="telemetry">
|
|
||||||
<h2 data-testid="telemetry-header">Telemetry</h2>
|
|
||||||
{telemetryPreferenceItems.get().map((item) => (
|
|
||||||
<ExtensionSettings
|
|
||||||
key={item.id}
|
|
||||||
setting={item}
|
|
||||||
size="small"
|
|
||||||
data-testid={`telemetry-preference-item-for-${item.id}`}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
{sentryDnsUrl ? (
|
|
||||||
<React.Fragment key="sentry">
|
|
||||||
<section
|
|
||||||
id="sentry"
|
|
||||||
className="small"
|
|
||||||
data-testid="telemetry-preferences-for-automatic-error-reporting"
|
|
||||||
>
|
|
||||||
<SubTitle title="Automatic Error Reporting" />
|
|
||||||
<Checkbox
|
|
||||||
label="Allow automatic error reporting"
|
|
||||||
value={userStore.allowErrorReporting}
|
|
||||||
onChange={(value) => userStore.allowErrorReporting = value}
|
|
||||||
/>
|
|
||||||
<div className="hint">
|
|
||||||
<span>
|
|
||||||
Automatic error reports provide vital information about issues
|
|
||||||
and application crashes. It is highly recommended to keep this
|
|
||||||
feature enabled to ensure fast turnaround for issues you might
|
|
||||||
encounter.
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<hr className="small" />
|
|
||||||
</React.Fragment>
|
|
||||||
) : // we don't need to shows the checkbox at all if Sentry dsn is not a valid url
|
|
||||||
null}
|
|
||||||
</section>
|
|
||||||
</Preferences>
|
|
||||||
);
|
|
||||||
|
|
||||||
export const Telemetry = withInjectables<Dependencies>(
|
|
||||||
observer(NonInjectedTelemetry),
|
|
||||||
|
|
||||||
{
|
|
||||||
getProps: (di) => ({
|
|
||||||
telemetryPreferenceItems: di.inject(telemetryPreferenceItemsInjectable),
|
|
||||||
sentryDnsUrl: di.inject(sentryDataSourceNameInjectable),
|
|
||||||
userStore: di.inject(userStoreInjectable),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { routeSpecificComponentInjectionToken } from "../../routes/route-specific-component-injection-token";
|
|
||||||
import terminalPreferencesRouteInjectable from "../../../common/front-end-routing/routes/preferences/terminal/terminal-preferences-route.injectable";
|
|
||||||
import { Terminal } from "./terminal";
|
|
||||||
|
|
||||||
const terminalPreferencesRouteComponentInjectable = getInjectable({
|
|
||||||
id: "terminal-preferences-route-component",
|
|
||||||
|
|
||||||
instantiate: (di) => ({
|
|
||||||
route: di.inject(terminalPreferencesRouteInjectable),
|
|
||||||
Component: Terminal,
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: routeSpecificComponentInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default terminalPreferencesRouteComponentInjectable;
|
|
||||||
@ -1,138 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import { action } from "mobx";
|
|
||||||
import { observer } from "mobx-react";
|
|
||||||
import type { UserStore } from "../../../common/user-store";
|
|
||||||
import { SubTitle } from "../layout/sub-title";
|
|
||||||
import { Input } from "../input";
|
|
||||||
import { Switch } from "../switch";
|
|
||||||
import { Select, type SelectOption } from "../select";
|
|
||||||
import type { ThemeStore } from "../../themes/store";
|
|
||||||
import { Preferences } from "./preferences";
|
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
|
||||||
import userStoreInjectable from "../../../common/user-store/user-store.injectable";
|
|
||||||
import themeStoreInjectable from "../../themes/store.injectable";
|
|
||||||
import defaultShellInjectable from "./default-shell.injectable";
|
|
||||||
import logger from "../../../common/logger";
|
|
||||||
|
|
||||||
interface Dependencies {
|
|
||||||
userStore: UserStore;
|
|
||||||
themeStore: ThemeStore;
|
|
||||||
defaultShell: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NonInjectedTerminal = observer((
|
|
||||||
{
|
|
||||||
userStore,
|
|
||||||
themeStore,
|
|
||||||
defaultShell,
|
|
||||||
}: Dependencies) => {
|
|
||||||
const themeOptions = [
|
|
||||||
{
|
|
||||||
value: "", // TODO: replace with a sentinal value that isn't string (and serialize it differently)
|
|
||||||
label: "Match Lens Theme",
|
|
||||||
},
|
|
||||||
...Array.from(themeStore.themes, ([themeId, { name }]) => ({
|
|
||||||
value: themeId,
|
|
||||||
label: name,
|
|
||||||
})),
|
|
||||||
];
|
|
||||||
|
|
||||||
// fonts must be declared in `fonts.scss` and at `template.html` (if early-preloading required)
|
|
||||||
const supportedCustomFonts: SelectOption<string>[] = [
|
|
||||||
"RobotoMono", "Anonymous Pro", "IBM Plex Mono", "JetBrains Mono", "Red Hat Mono",
|
|
||||||
"Source Code Pro", "Space Mono", "Ubuntu Mono",
|
|
||||||
].map(customFont => {
|
|
||||||
const { fontFamily, fontSize } = userStore.terminalConfig;
|
|
||||||
|
|
||||||
return {
|
|
||||||
label: <span style={{ fontFamily: customFont, fontSize }}>{customFont}</span>,
|
|
||||||
value: customFont,
|
|
||||||
isSelected: fontFamily === customFont,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const onFontFamilyChange = action(({ value: fontFamily }: SelectOption<string>) => {
|
|
||||||
logger.info(`setting terminal font to ${fontFamily}`);
|
|
||||||
|
|
||||||
userStore.terminalConfig.fontFamily = fontFamily; // save to external storage
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Preferences data-testid="terminal-preferences-page">
|
|
||||||
<section>
|
|
||||||
<h2>Terminal</h2>
|
|
||||||
|
|
||||||
<section id="shell">
|
|
||||||
<SubTitle title="Terminal Shell Path" />
|
|
||||||
<Input
|
|
||||||
theme="round-black"
|
|
||||||
placeholder={defaultShell}
|
|
||||||
value={userStore.shell ?? ""}
|
|
||||||
onChange={(value) => userStore.shell = value}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<section id="terminalTheme">
|
|
||||||
<SubTitle title="Terminal theme" />
|
|
||||||
<Select
|
|
||||||
id="terminal-theme-input"
|
|
||||||
themeName="lens"
|
|
||||||
options={themeOptions}
|
|
||||||
value={userStore.terminalTheme}
|
|
||||||
onChange={option => userStore.terminalTheme = option?.value ?? ""}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
<section>
|
|
||||||
<SubTitle title="Font family" />
|
|
||||||
<Select
|
|
||||||
themeName="lens"
|
|
||||||
controlShouldRenderValue
|
|
||||||
value={userStore.terminalConfig.fontFamily}
|
|
||||||
options={supportedCustomFonts}
|
|
||||||
onChange={onFontFamilyChange as any}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
</Preferences>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
export const Terminal = withInjectables<Dependencies>(
|
|
||||||
NonInjectedTerminal,
|
|
||||||
|
|
||||||
{
|
|
||||||
getProps: (di) => ({
|
|
||||||
userStore: di.inject(userStoreInjectable),
|
|
||||||
themeStore: di.inject(themeStoreInjectable),
|
|
||||||
defaultShell: di.inject(defaultShellInjectable),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user