From 13fe90cdb597b5c3876b55a394e722ab60615c60 Mon Sep 17 00:00:00 2001 From: sawka Date: Fri, 15 Sep 2023 13:01:04 -0700 Subject: [PATCH 1/3] implement codeedit focus with the help of a shouldFocus prop from the Line component. also update line status, and remove websharing in left nav --- src/linecomps.tsx | 21 ++++++++++++++++----- src/lines.less | 22 +++++++++++++++++++++- src/main.tsx | 10 ---------- src/simplerenderer.tsx | 31 +++++++++++++++++++------------ src/types.ts | 1 + src/view/code.tsx | 15 ++++++++++++++- 6 files changed, 71 insertions(+), 29 deletions(-) diff --git a/src/linecomps.tsx b/src/linecomps.tsx index 9681ef00..2bfb18f0 100644 --- a/src/linecomps.tsx +++ b/src/linecomps.tsx @@ -152,21 +152,22 @@ class SmallLineAvatar extends React.Component<{ line: LineType; cmd: Cmd; onRigh let isComment = line.linetype == "text"; let icon: string = null; let iconTitle = null; - let iconColor = "auto"; + let iconColor = null; if (isComment) { icon = "fa-comment"; iconTitle = "comment"; } else if (status == "done") { icon = exitcode === 0 ? "fa-check" : "fa-xmark"; iconTitle = exitcode === 0 ? "success" : "fail"; - iconColor = exitcode === 0 ? "auto" : "red"; + iconColor = exitcode === 0 ? "color-green" : "color-red"; } else if (status == "hangup" || status == "error") { icon = "fa-triangle-exclamation"; iconTitle = status; - iconColor = "yellow"; + iconColor = "color-yellow"; } else if (status == "running" || "detached") { - icon = "fa-rotate"; + icon = "fa-rotate fa-spin"; iconTitle = "running"; + iconColor = "color-green"; } else { icon = "fa-square-question"; iconTitle = "unknown"; @@ -177,7 +178,7 @@ class SmallLineAvatar extends React.Component<{ line: LineType; cmd: Cmd; onRigh className={cn("simple-line-status", "status-" + status, rtnstate ? "has-rtnstate" : null)} > {lineNumStr} - + ); } @@ -676,6 +677,15 @@ class LineCmd extends React.Component< { name: "computed-isFocused" } ) .get(); + let shouldCmdFocus = mobx + .computed( + () => { + let screenFocusType = screen.getFocusType(); + return isSelected && screenFocusType == "cmd"; + }, + { name: "computed-shouldCmdFocus" } + ) + .get(); let isStatic = staticRender; let isRunning = cmd.isRunning(); let isExpanded = this.isCmdExpanded.get(); @@ -768,6 +778,7 @@ class LineCmd extends React.Component< initParams={this.makeRendererModelInitializeParams()} scrollToBringIntoViewport={this.scrollToBringIntoViewport} isSelected={isSelected} + shouldFocus={shouldCmdFocus} /> diff --git a/src/lines.less b/src/lines.less index b6639c22..a537d4d5 100644 --- a/src/lines.less +++ b/src/lines.less @@ -22,7 +22,15 @@ } .line .load-error-text { - color: #cc0000; + .mono-font(); + color: @term-red; + padding-top: 5px; +} + +.line .renderer-loading { + .mono-font(); + color: @term-white; + padding-top: 5px; } .line.line-cmd { @@ -221,6 +229,18 @@ font-weight: bold; } } + + .color-red { + color: @term-red; + } + + .color-green { + color: @term-bright-green; + } + + .color-yellow { + color: @term-bright-yellow; + } } &.top-border { diff --git a/src/main.tsx b/src/main.tsx index 32b7d6f4..59ae2f09 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1793,16 +1793,6 @@ class MainSideBar extends React.Component<{}, {}> { -

Playbooks

  • diff --git a/src/simplerenderer.tsx b/src/simplerenderer.tsx index 7a0b80ea..9353c942 100644 --- a/src/simplerenderer.tsx +++ b/src/simplerenderer.tsx @@ -20,6 +20,7 @@ import type { TermContextUnion, RendererContainerType, } from "./types"; +import * as T from "./types"; import { PacketDataBuffer } from "./ptydata"; import { debounce, throttle } from "throttle-debounce"; import * as util from "./util"; @@ -177,6 +178,7 @@ class SimpleBlobRenderer extends React.Component< initParams: RendererModelInitializeParams; scrollToBringIntoViewport: () => void; isSelected: boolean; + shouldFocus: boolean; }, {} > { @@ -243,18 +245,23 @@ class SimpleBlobRenderer extends React.Component< let { plugin } = this.props; let model = this.model; if (model.loadError.get() != null) { + let errorText = model.loadError.get(); let height = this.model.savedHeight; return ( -
    -
    ERROR: {model.loadError.get()}
    +
    +
    ERROR: {errorText}
    ); } if (model.loading.get()) { let height = this.model.savedHeight; return ( -
    - ... +
    + loading content
    ); } @@ -262,7 +269,6 @@ class SimpleBlobRenderer extends React.Component< if (Comp == null) {
    (no component found in plugin)
    ; } - let simpleModel = model as SimpleBlobRendererModel; let { festate, cmdstr, exitcode } = this.props.initParams.rawCmd; return (
    @@ -270,15 +276,16 @@ class SimpleBlobRenderer extends React.Component< cwd={festate.cwd} cmdstr={cmdstr} exitcode={exitcode} - data={simpleModel.dataBlob} - readOnly={simpleModel.readOnly} - notFound={simpleModel.notFound} - lineState={simpleModel.lineState} - context={simpleModel.context} - opts={simpleModel.opts} - savedHeight={simpleModel.savedHeight} + data={model.dataBlob} + readOnly={model.readOnly} + notFound={model.notFound} + lineState={model.lineState} + context={model.context} + opts={model.opts} + savedHeight={model.savedHeight} scrollToBringIntoViewport={this.props.scrollToBringIntoViewport} isSelected={this.props.isSelected} + shouldFocus={this.props.shouldFocus} />
    ); diff --git a/src/types.ts b/src/types.ts index 3571ff30..dd914848 100644 --- a/src/types.ts +++ b/src/types.ts @@ -413,6 +413,7 @@ type SimpleBlobRendererComponent = React.ComponentType<{ readOnly?: boolean; notFound?: boolean; isSelected?: boolean; + shouldFocus?: boolean; cmdstr?: string; cwd?: string; exitcode?: number; diff --git a/src/view/code.tsx b/src/view/code.tsx index 6ee57f64..a00d381f 100644 --- a/src/view/code.tsx +++ b/src/view/code.tsx @@ -26,6 +26,7 @@ class SourceCodeRenderer extends React.Component< scrollToBringIntoViewport: () => void; lineState: LineStateType; isSelected: boolean; + shouldFocus: boolean; }, { code: string; @@ -70,12 +71,21 @@ class SourceCodeRenderer extends React.Component< const code = SourceCodeRenderer.codeCache.get(this.cacheKey); if (code) { this.setState({ code, isClosed: this.props.lineState["prompt:closed"] }); - } else + } else { this.props.data.text().then((code) => { this.originalData = code; this.setState({ code, isClosed: this.props.lineState["prompt:closed"] }); SourceCodeRenderer.codeCache.set(this.cacheKey, code); }); + } + } + + componentDidUpdate(prevProps: any): void { + if (!prevProps.shouldFocus && this.props.shouldFocus) { + if (this.monacoEditor) { + this.monacoEditor.focus(); + } + } } setInitialLanguage = (editor) => { @@ -125,6 +135,9 @@ class SourceCodeRenderer extends React.Component< this.doClose(); } }); + if (this.props.shouldFocus) { + this.monacoEditor.focus(); + } }; handleLanguageChange = (event) => { From 17fef0341da7c7948e25b853f8ba2cb1bd9aceed Mon Sep 17 00:00:00 2001 From: sawka Date: Fri, 15 Sep 2023 15:46:17 -0700 Subject: [PATCH 2/3] remove webshare from screen settings --- src/settings.tsx | 49 ------------------------------------------------ 1 file changed, 49 deletions(-) diff --git a/src/settings.tsx b/src/settings.tsx index 56707d7c..0c33b99f 100644 --- a/src/settings.tsx +++ b/src/settings.tsx @@ -277,55 +277,6 @@ class ScreenSettingsModal extends React.Component<{ sessionId: string; screenId:
    -
    -
    Web Sharing
    -
    - -
    -
    - -
    -
    Share Link
    -
    - - open in browser - - - - -
    - copy link - - - -
    -
    -
    -
    -
    Share Name
    -
    -
    - -
    -
    -
    -
    Actions
    From b9ff6bd20ffbad9fc75b9ce9ec42e30e9c07a77e Mon Sep 17 00:00:00 2001 From: sawka Date: Fri, 15 Sep 2023 17:24:38 -0700 Subject: [PATCH 3/3] codeedit: on close, if we're focused, give focus back to the input box --- src/view/code.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/view/code.tsx b/src/view/code.tsx index a00d381f..d1c4823b 100644 --- a/src/view/code.tsx +++ b/src/view/code.tsx @@ -203,6 +203,9 @@ class SourceCodeRenderer extends React.Component< this.setState({ message: null }); }, 3000); }); + if (this.props.shouldFocus) { + GlobalCommandRunner.screenSetFocus("input"); + } }; handleEditorChange = (code) => {