mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move to settings object
Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box>
This commit is contained in:
parent
0cfb8f0c75
commit
5375c79611
@ -10,7 +10,7 @@ import { getAppVersion, ObservableToggleSet } from "../utils";
|
||||
import type { editor } from "monaco-editor";
|
||||
import merge from "lodash/merge";
|
||||
import { SemVer } from "semver";
|
||||
import { defaultTheme, defaultEditorFontFamily, defaultFontSize } from "../vars";
|
||||
import { defaultTheme, defaultEditorFontFamily, defaultFontSize, defaultTerminalFontFamily } from "../vars";
|
||||
|
||||
export interface KubeconfigSyncEntry extends KubeconfigSyncValue {
|
||||
filePath: string;
|
||||
@ -18,6 +18,15 @@ export interface KubeconfigSyncEntry extends KubeconfigSyncValue {
|
||||
|
||||
export interface KubeconfigSyncValue {
|
||||
}
|
||||
export interface TerminalConfig {
|
||||
fontSize: number;
|
||||
fontFamily: string;
|
||||
}
|
||||
|
||||
export const defaultTerminalConfig: TerminalConfig = {
|
||||
fontSize: defaultFontSize,
|
||||
fontFamily: defaultTerminalFontFamily,
|
||||
};
|
||||
|
||||
export type EditorConfiguration = Pick<editor.IStandaloneEditorConstructionOptions,
|
||||
"minimap" | "tabSize" | "lineNumbers" | "fontSize" | "fontFamily">;
|
||||
@ -188,32 +197,6 @@ const downloadBinariesPath: PreferenceDescription<string | undefined> = {
|
||||
},
|
||||
};
|
||||
|
||||
const terminalFontSize: PreferenceDescription<number | undefined> = {
|
||||
fromStore(val) {
|
||||
return val;
|
||||
},
|
||||
toStore(val) {
|
||||
if (!val) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return val;
|
||||
},
|
||||
};
|
||||
|
||||
const terminalFontFamily: PreferenceDescription<string | undefined> = {
|
||||
fromStore(val) {
|
||||
return val;
|
||||
},
|
||||
toStore(val) {
|
||||
if (!val) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return val;
|
||||
},
|
||||
};
|
||||
|
||||
const kubectlBinariesPath: PreferenceDescription<string | undefined> = {
|
||||
fromStore(val) {
|
||||
return val;
|
||||
@ -300,6 +283,15 @@ const editorConfiguration: PreferenceDescription<EditorConfiguration, EditorConf
|
||||
},
|
||||
};
|
||||
|
||||
const terminalConfig: PreferenceDescription<TerminalConfig, TerminalConfig> = {
|
||||
fromStore(val) {
|
||||
return merge(defaultTerminalConfig, val);
|
||||
},
|
||||
toStore(val) {
|
||||
return val;
|
||||
},
|
||||
};
|
||||
|
||||
const updateChannels = new Map([
|
||||
["latest", {
|
||||
label: "Stable",
|
||||
@ -385,8 +377,7 @@ export const DESCRIPTORS = {
|
||||
syncKubeconfigEntries,
|
||||
editorConfiguration,
|
||||
terminalCopyOnSelect,
|
||||
terminalFontSize,
|
||||
terminalFontFamily,
|
||||
terminalConfig,
|
||||
updateChannel,
|
||||
extensionRegistryUrl,
|
||||
};
|
||||
|
||||
@ -12,7 +12,7 @@ import { getAppVersion } from "../utils/app-version";
|
||||
import { kubeConfigDefaultPath } from "../kube-helpers";
|
||||
import { appEventBus } from "../app-event-bus/event-bus";
|
||||
import { ObservableToggleSet, toJS } from "../../renderer/utils";
|
||||
import { DESCRIPTORS, EditorConfiguration, ExtensionRegistry, KubeconfigSyncValue, UserPreferencesModel } from "./preferences-helpers";
|
||||
import { DESCRIPTORS, EditorConfiguration, ExtensionRegistry, KubeconfigSyncValue, UserPreferencesModel, TerminalConfig } from "./preferences-helpers";
|
||||
import logger from "../../main/logger";
|
||||
|
||||
export interface UserStoreModel {
|
||||
@ -57,6 +57,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
@observable downloadBinariesPath?: string;
|
||||
@observable kubectlBinariesPath?: string;
|
||||
@observable terminalCopyOnSelect: boolean;
|
||||
@observable terminalConfig: TerminalConfig;
|
||||
@observable terminalFontSize?: number;
|
||||
@observable terminalFontFamily?: string;
|
||||
@observable updateChannel?: string;
|
||||
@ -187,8 +188,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
this.syncKubeconfigEntries.replace(DESCRIPTORS.syncKubeconfigEntries.fromStore(preferences?.syncKubeconfigEntries));
|
||||
this.editorConfiguration = DESCRIPTORS.editorConfiguration.fromStore(preferences?.editorConfiguration);
|
||||
this.terminalCopyOnSelect = DESCRIPTORS.terminalCopyOnSelect.fromStore(preferences?.terminalCopyOnSelect);
|
||||
this.terminalFontSize = DESCRIPTORS.terminalFontSize.fromStore(preferences?.terminalFontSize);
|
||||
this.terminalFontFamily = DESCRIPTORS.terminalFontFamily.fromStore(preferences?.terminalFontFamily);
|
||||
this.terminalConfig = DESCRIPTORS.terminalConfig.fromStore(preferences?.terminalConfig);
|
||||
this.updateChannel = DESCRIPTORS.updateChannel.fromStore(preferences?.updateChannel);
|
||||
this.extensionRegistryUrl = DESCRIPTORS.extensionRegistryUrl.fromStore(preferences?.extensionRegistryUrl);
|
||||
}
|
||||
@ -214,8 +214,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
syncKubeconfigEntries: DESCRIPTORS.syncKubeconfigEntries.toStore(this.syncKubeconfigEntries),
|
||||
editorConfiguration: DESCRIPTORS.editorConfiguration.toStore(this.editorConfiguration),
|
||||
terminalCopyOnSelect: DESCRIPTORS.terminalCopyOnSelect.toStore(this.terminalCopyOnSelect),
|
||||
terminalFontFamily: DESCRIPTORS.terminalFontFamily.toStore(this.terminalFontFamily),
|
||||
terminalFontSize: DESCRIPTORS.terminalFontSize.toStore(this.terminalFontSize),
|
||||
terminalConfig: DESCRIPTORS.terminalConfig.toStore(this.terminalConfig),
|
||||
updateChannel: DESCRIPTORS.updateChannel.toStore(this.updateChannel),
|
||||
extensionRegistryUrl: DESCRIPTORS.extensionRegistryUrl.toStore(this.extensionRegistryUrl),
|
||||
},
|
||||
|
||||
@ -30,8 +30,8 @@ export const Terminal = observer(() => {
|
||||
const userStore = UserStore.getInstance();
|
||||
const [terminalSettings, setTerminalSettings] = React.useState({
|
||||
shell: userStore.shell || "",
|
||||
terminalFontSize: userStore.terminalFontSize,
|
||||
terminalFontFamily: userStore.terminalFontFamily,
|
||||
terminalFontSize: userStore.terminalConfig.fontSize,
|
||||
terminalFontFamily: userStore.terminalConfig.fontFamily,
|
||||
});
|
||||
const defaultShell = process.env.SHELL
|
||||
|| process.env.PTYSHELL
|
||||
@ -77,7 +77,7 @@ export const Terminal = observer(() => {
|
||||
...terminalSettings,
|
||||
terminalFontSize: Number(value),
|
||||
})}
|
||||
onBlur={() => userStore.terminalFontSize = terminalSettings.terminalFontSize}
|
||||
onBlur={() => userStore.terminalConfig.fontSize = terminalSettings.terminalFontSize}
|
||||
/>
|
||||
</section>
|
||||
<section>
|
||||
@ -90,7 +90,7 @@ export const Terminal = observer(() => {
|
||||
...terminalSettings,
|
||||
terminalFontFamily: value.toString(),
|
||||
})}
|
||||
onBlur={() => userStore.terminalFontFamily = terminalSettings.terminalFontFamily}
|
||||
onBlur={() => userStore.terminalConfig.fontFamily = terminalSettings.terminalFontFamily}
|
||||
/>
|
||||
</section>
|
||||
</div>);
|
||||
|
||||
@ -11,24 +11,28 @@ import type { DockStore, TabId } from "../dock-store/dock.store";
|
||||
import { TerminalApi, TerminalChannels } from "../../../api/terminal-api";
|
||||
import { ThemeStore } from "../../../theme.store";
|
||||
import { disposer } from "../../../utils";
|
||||
import { isMac, defaultTerminalFontFamily, defaultFontSize} from "../../../../common/vars";
|
||||
import { isMac, defaultTerminalFontFamily } from "../../../../common/vars";
|
||||
import { once } from "lodash";
|
||||
import { UserStore } from "../../../../common/user-store";
|
||||
import { clipboard } from "electron";
|
||||
import logger from "../../../../common/logger";
|
||||
import type { TerminalConfig } from "../../../common/user-store/preferences-helpers";
|
||||
|
||||
interface Dependencies {
|
||||
dockStore: DockStore
|
||||
}
|
||||
|
||||
export class Terminal {
|
||||
|
||||
private terminalConfig: TerminalConfig = UserStore.getInstance().terminalConfig;
|
||||
|
||||
public static get spawningPool() {
|
||||
return document.getElementById("terminal-init");
|
||||
}
|
||||
|
||||
static async preloadFonts() {
|
||||
const fontPath = require("../../fonts/roboto-mono-nerd.ttf").default; // eslint-disable-line @typescript-eslint/no-var-requires
|
||||
const fontFace = new FontFace(defaultFontFamily, `url(${fontPath})`);
|
||||
const fontPath = require("../fonts/roboto-mono-nerd.ttf").default; // eslint-disable-line @typescript-eslint/no-var-requires
|
||||
const fontFace = new FontFace(defaultTerminalFontFamily, `url(${fontPath})`);
|
||||
|
||||
await fontFace.load();
|
||||
document.fonts.add(fontFace);
|
||||
@ -37,8 +41,8 @@ export class Terminal {
|
||||
private xterm: XTerm | null = new XTerm({
|
||||
cursorBlink: true,
|
||||
cursorStyle: "bar",
|
||||
fontSize: UserStore.getInstance().terminalFontSize || defaultFontSize,
|
||||
fontFamily: UserStore.getInstance().terminalFontFamily || defaultTerminalFontFamily,
|
||||
fontSize: this.terminalConfig.fontSize,
|
||||
fontFamily: this.terminalConfig.fontFamily,
|
||||
});
|
||||
private readonly fitAddon = new FitAddon();
|
||||
private scrollPos = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user