mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
Persist line "minimized" status to DB (#306)
* backend implementation * integrate minize linesate in UI * remove debugging code * change prompt:min key to wave:min
This commit is contained in:
parent
8bcb99fa35
commit
743d6d8622
@ -113,9 +113,6 @@ class LineCmd extends React.Component<
|
||||
isOverflow: OV<boolean> = mobx.observable.box(false, {
|
||||
name: "line-overflow",
|
||||
});
|
||||
isMinimized: OV<boolean> = mobx.observable.box(false, {
|
||||
name: "line-minimised",
|
||||
});
|
||||
isCmdExpanded: OV<boolean> = mobx.observable.box(false, {
|
||||
name: "cmd-expanded",
|
||||
});
|
||||
@ -351,9 +348,9 @@ class LineCmd extends React.Component<
|
||||
|
||||
@boundMethod
|
||||
clickMinimize() {
|
||||
mobx.action(() => {
|
||||
this.isMinimized.set(!this.isMinimized.get());
|
||||
})();
|
||||
const { line } = this.props;
|
||||
const isMinimized = line.linestate["wave:min"];
|
||||
GlobalCommandRunner.lineMinimize(line.lineid, !isMinimized, true);
|
||||
}
|
||||
|
||||
@boundMethod
|
||||
@ -566,6 +563,7 @@ class LineCmd extends React.Component<
|
||||
|
||||
render() {
|
||||
const { screen, line, width, staticRender, visible } = this.props;
|
||||
const isMinimized = line.linestate["wave:min"];
|
||||
const isVisible = visible.get();
|
||||
if (staticRender || !isVisible) {
|
||||
return this.renderSimple();
|
||||
@ -678,19 +676,19 @@ class LineCmd extends React.Component<
|
||||
<If condition={containerType == appconst.LineContainer_Main}>
|
||||
<div
|
||||
key="minimize"
|
||||
title={`${this.isMinimized.get() ? "Maximise" : "Minimize"}`}
|
||||
title={`${isMinimized ? "Maximise" : "Minimize"}`}
|
||||
className={cn(
|
||||
"line-icon",
|
||||
"line-minimize",
|
||||
"hoverEffect",
|
||||
this.isMinimized.get() ? "line-icon-show" : ""
|
||||
isMinimized ? "line-icon-show" : ""
|
||||
)}
|
||||
onClick={this.clickMinimize}
|
||||
>
|
||||
<If condition={this.isMinimized.get()}>
|
||||
<If condition={isMinimized}>
|
||||
<i className="fa-sharp fa-regular fa-circle-plus" />
|
||||
</If>
|
||||
<If condition={!this.isMinimized.get()}>
|
||||
<If condition={!isMinimized}>
|
||||
<i className="fa-sharp fa-regular fa-circle-minus" />
|
||||
</If>
|
||||
</div>
|
||||
@ -717,7 +715,7 @@ class LineCmd extends React.Component<
|
||||
showing in sidebar =>
|
||||
</div>
|
||||
</If>
|
||||
<If condition={!this.isMinimized.get() && !isInSidebar}>
|
||||
<If condition={!isMinimized && !isInSidebar}>
|
||||
<ErrorBoundary plugin={rendererPlugin?.name} lineContext={lineutil.getRendererContext(line)}>
|
||||
<If condition={rendererPlugin == null && !isNoneRenderer}>
|
||||
<TerminalRenderer
|
||||
|
@ -6,7 +6,7 @@ import * as mobxReact from "mobx-react";
|
||||
import * as mobx from "mobx";
|
||||
|
||||
import { debounce } from "throttle-debounce";
|
||||
import * as util from "@/util";
|
||||
import * as util from "@/util/util";
|
||||
import { GlobalModel } from "@/models";
|
||||
|
||||
class SimpleBlobRendererModel {
|
||||
|
@ -77,6 +77,11 @@ class CommandRunner {
|
||||
return GlobalModel.submitCommand("line", "delete", [lineArg], { nohist: "1" }, interactive);
|
||||
}
|
||||
|
||||
lineMinimize(lineId: string, minimize: boolean, interactive: boolean): Promise<CommandRtnType> {
|
||||
let minimizeStr = minimize ? "1" : "0";
|
||||
return GlobalModel.submitCommand("line", "minimize", [lineId, minimizeStr], { nohist: "1" }, interactive);
|
||||
}
|
||||
|
||||
lineRestart(lineArg: string, interactive: boolean): Promise<CommandRtnType> {
|
||||
return GlobalModel.submitCommand("line", "restart", [lineArg], { nohist: "1" }, interactive);
|
||||
}
|
||||
|
@ -217,6 +217,7 @@ func init() {
|
||||
registerCmdFn("line:view", LineViewCommand)
|
||||
registerCmdFn("line:set", LineSetCommand)
|
||||
registerCmdFn("line:restart", LineRestartCommand)
|
||||
registerCmdFn("line:minimize", LineMinimizeCommand)
|
||||
|
||||
registerCmdFn("client", ClientCommand)
|
||||
registerCmdFn("client:show", ClientShowCommand)
|
||||
@ -4325,6 +4326,51 @@ func LineArchiveCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (
|
||||
return update, nil
|
||||
}
|
||||
|
||||
func LineMinimizeCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.UpdatePacket, error) {
|
||||
ids, err := resolveUiIds(ctx, pk, R_Session|R_Screen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(pk.Args) == 0 {
|
||||
return nil, fmt.Errorf("/line:minimize requires arguments (line number or id and min value)")
|
||||
}
|
||||
if len(pk.Args) > 2 {
|
||||
return nil, fmt.Errorf("/line:minimize only takes up to 2 argument (line number or id and min value)")
|
||||
}
|
||||
lineArg1 := pk.Args[0]
|
||||
lineId, err := sstore.FindLineIdByArg(ctx, ids.ScreenId, lineArg1)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error looking up lineid: %v", err)
|
||||
}
|
||||
if lineId == "" {
|
||||
return nil, fmt.Errorf("line %q not found", lineArg1)
|
||||
}
|
||||
lineArg2 := pk.Args[1]
|
||||
minVal := resolveBool(lineArg2, true)
|
||||
lineState := make(map[string]any)
|
||||
if minVal {
|
||||
lineState[sstore.LineState_Min] = minVal
|
||||
} else {
|
||||
// Remove sstore.LineState_Min from lineState if it exists
|
||||
delete(lineState, sstore.LineState_Min)
|
||||
}
|
||||
err = sstore.UpdateLineState(ctx, ids.ScreenId, lineId, lineState)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot update linestate: %v", err)
|
||||
}
|
||||
lineObj, err := sstore.GetLineById(ctx, ids.ScreenId, lineId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("/line:minimize cannot retrieve updated line: %v", err)
|
||||
}
|
||||
if lineObj == nil {
|
||||
// no line (which is strange given we checked for it above). just return a nop.
|
||||
return nil, nil
|
||||
}
|
||||
update := scbus.MakeUpdatePacket()
|
||||
sstore.AddLineUpdate(update, lineObj, nil)
|
||||
return update, nil
|
||||
}
|
||||
|
||||
func LineDeleteCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.UpdatePacket, error) {
|
||||
ids, err := resolveUiIds(ctx, pk, R_Session|R_Screen)
|
||||
if err != nil {
|
||||
|
@ -63,6 +63,7 @@ const (
|
||||
const (
|
||||
LineState_Source = "prompt:source"
|
||||
LineState_File = "prompt:file"
|
||||
LineState_Min = "wave:min"
|
||||
LineState_Template = "template"
|
||||
LineState_Mode = "mode"
|
||||
LineState_Lang = "lang"
|
||||
|
Loading…
Reference in New Issue
Block a user