1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

clean up / responding to comments

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2021-11-03 12:18:26 +02:00
parent 1f6560e190
commit a4914cd987
6 changed files with 53 additions and 34 deletions

View File

@ -377,10 +377,13 @@ utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => {
await kubeApiServerRow.click();
await frame.waitForSelector(".Drawer", { state: "visible" });
await frame.waitForSelector(".Drawer .drawer-title .Icon >> text=subject").then(button => button.click());
await frame.waitForSelector(".Dock.isOpen");
const showPodLogsIcon = await frame.waitForSelector(".Drawer .drawer-title .Icon >> text=subject");
showPodLogsIcon.click();
// Check if controls are available
await frame.waitForSelector(".Dock.isOpen");
await frame.waitForSelector(".LogList .VirtualList");
await frame.waitForSelector(".LogResourceSelector");

View File

@ -198,7 +198,6 @@
"electron-window-state": "^5.0.3",
"filehound": "^1.17.5",
"fs-extra": "^9.0.1",
"glob": "^7.2.0",
"glob-to-regexp": "^0.4.1",
"got": "^11.8.2",
"grapheme-splitter": "^1.0.4",

View File

@ -48,12 +48,14 @@ import { ThemeStore } from "./theme.store";
import { SentryInit } from "../common/sentry";
import { TerminalStore } from "./components/dock/terminal.store";
import { AppPaths } from "../common/app-paths";
import { registerCustomThemes } from "./components/monaco-editor";
if (process.isMainFrame) {
SentryInit();
}
configurePackages();
configurePackages(); // global packages
registerCustomThemes(); // monaco editor themes
/**
* If this is a development build, wait a second to attach

View File

@ -95,8 +95,14 @@ export interface DockTabChangeEvent {
}
export interface DockTabChangeEventOptions extends IReactionOptions {
tabKind?: TabKind; // filter: by dockStore.selectedTab.kind == tabKind
dockIsVisible?: boolean; // filter: dock and selected tab should be visible (default: true)
/**
* filter: by dockStore.selectedTab.kind == tabKind
*/
tabKind?: TabKind;
/**
* filter: dock and selected tab should be visible (default: true)
*/
dockIsVisible?: boolean;
}
export interface DockTabCloseEvent {

View File

@ -105,7 +105,7 @@ export class Dock extends React.Component<Props> {
if (!isOpen || !selectedTab) return null;
return (
<div className="tab-content" style={{ flexBasis: isOpen ? height : 0 }}>
<div className="tab-content" style={{ flexBasis: height }}>
{this.renderTab(selectedTab)}
</div>
);

View File

@ -21,17 +21,14 @@
import styles from "./monaco-editor.module.css";
import React from "react";
import { action, computed, makeObservable, observable, reaction } from "mobx";
import { observer } from "mobx-react";
import { action, computed, makeObservable, observable, reaction } from "mobx";
import { editor, Uri } from "monaco-editor";
import { MonacoTheme, registerCustomThemes } from "./monaco-themes";
import { MonacoValidator, monacoValidators } from "./monaco-validators";
import { cssNames, disposer, toJS } from "../../utils";
import { MonacoTheme, MonacoValidator, monacoValidators } from "./index";
import { debounce, merge } from "lodash";
import { cssNames, disposer } from "../../utils";
import { UserStore } from "../../../common/user-store";
import { ThemeStore } from "../../theme.store";
import debounce from "lodash/debounce";
registerCustomThemes(); // setup
export type MonacoEditorId = string;
@ -87,9 +84,13 @@ export class MonacoEditor extends React.Component<MonacoEditorProps> {
makeObservable(this);
}
@computed get id() {
return this.props.id ?? this.staticId;
}
@computed get model(): editor.ITextModel {
const uri = MonacoEditor.createUri(this.props.id ?? this.staticId);
const model = editor.getModels().find(model => model.uri.toString() == uri.toString());
const uri = MonacoEditor.createUri(this.id);
const model = editor.getModel(uri);
if (model) {
return model; // already exists
@ -101,10 +102,17 @@ export class MonacoEditor extends React.Component<MonacoEditorProps> {
}
@computed get options(): editor.IStandaloneEditorConstructionOptions {
return toJS({
...UserStore.getInstance().editorConfiguration,
...(this.props.options ?? {}),
});
return merge({},
UserStore.getInstance().editorConfiguration,
this.props.options
);
}
@computed get logMetadata() {
return {
editorId: this.id,
model: this.model,
};
}
/**
@ -128,9 +136,12 @@ export class MonacoEditor extends React.Component<MonacoEditorProps> {
}
onModelChange = (model: editor.ITextModel, oldModel?: editor.ITextModel) => {
this.logger?.info("[MONACO]: model change", { model, oldModel });
this.logger?.info("[MONACO]: model change", { model, oldModel }, this.logMetadata);
if (oldModel) {
this.saveViewState(oldModel);
}
this.saveViewState(oldModel);
this.editor.setModel(model);
this.restoreViewState(model);
this.editor.layout();
@ -144,32 +155,30 @@ export class MonacoEditor extends React.Component<MonacoEditorProps> {
* This will allow restore cursor position, selected text, etc.
* @param {editor.ITextModel} model
*/
saveViewState(model = this.model) {
if (!model) return;
private saveViewState(model: editor.ITextModel) {
MonacoEditor.viewStates.set(model.uri, this.editor.saveViewState());
}
restoreViewState(model = this.model) {
if (!model) return;
private restoreViewState(model: editor.ITextModel) {
const viewState = MonacoEditor.viewStates.get(model.uri);
this.editor.restoreViewState(viewState);
if (viewState) {
this.editor.restoreViewState(viewState);
}
}
componentDidMount() {
try {
this.createEditor();
this.logger?.info(`[MONACO]: editor did mount`);
this.logger?.info(`[MONACO]: editor did mount`, this.logMetadata);
} catch (error) {
this.logger?.error(`[MONACO]: mounting failed: ${error}`, this);
this.logger?.error(`[MONACO]: mounting failed: ${error}`, this.logMetadata);
}
}
componentWillUnmount() {
this.unmounting = true;
this.saveViewState();
this.saveViewState(this.model);
this.destroy();
}
@ -189,9 +198,9 @@ export class MonacoEditor extends React.Component<MonacoEditorProps> {
...this.options,
});
this.logger?.info(`[MONACO]: editor created for language=${language}, theme=${theme}`);
this.logger?.info(`[MONACO]: editor created for language=${language}, theme=${theme}`, this.logMetadata);
this.validateLazy(); // validate initial value
this.restoreViewState(); // restore previous state if any
this.restoreViewState(this.model); // restore previous state if any
if (this.props.autoFocus) {
this.editor.focus();