mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
implement cmd:i, hook up telemetry switch, fix some settings types
This commit is contained in:
@@ -7,6 +7,7 @@ import { Toggle } from "@/app/element/toggle";
|
||||
import * as services from "@/store/services";
|
||||
import { FlexiModal } from "./modal";
|
||||
|
||||
import { WshServer } from "@/app/store/wshserver";
|
||||
import "./tos.less";
|
||||
|
||||
const TosModal = () => {
|
||||
@@ -14,6 +15,10 @@ const TosModal = () => {
|
||||
services.ClientService.AgreeTos();
|
||||
};
|
||||
|
||||
function setTelemetry(value: boolean) {
|
||||
WshServer.SetConfigCommand({ "telemetry:enabled": value });
|
||||
}
|
||||
|
||||
return (
|
||||
<FlexiModal className="tos-modal">
|
||||
<div className="modal-inner">
|
||||
@@ -76,7 +81,7 @@ const TosModal = () => {
|
||||
</a>
|
||||
to help us understand how people are using Wave.
|
||||
</div>
|
||||
<Toggle checked={true} onChange={() => {}} label="Telemetry enabled" />
|
||||
<Toggle checked={true} onChange={setTelemetry} label="Telemetry enabled" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2024, Command Line Inc.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { atoms, createBlock, getApi, getViewModel, globalStore, WOS } from "@/app/store/global";
|
||||
import { atoms, createBlock, getApi, getViewModel, globalStore, refocusNode, WOS } from "@/app/store/global";
|
||||
import * as services from "@/app/store/services";
|
||||
import {
|
||||
deleteLayoutModelForTab,
|
||||
@@ -112,6 +112,21 @@ function switchTab(offset: number) {
|
||||
services.ObjectService.SetActiveTab(newActiveTabId);
|
||||
}
|
||||
|
||||
function handleCmdI() {
|
||||
const layoutModel = getLayoutModelForActiveTab();
|
||||
const focusedNode = globalStore.get(layoutModel.focusedNode);
|
||||
if (focusedNode == null) {
|
||||
// focus a node
|
||||
layoutModel.focusFirstNode();
|
||||
return;
|
||||
}
|
||||
const blockId = focusedNode?.data?.blockId;
|
||||
if (blockId == null) {
|
||||
return;
|
||||
}
|
||||
refocusNode(blockId);
|
||||
}
|
||||
|
||||
async function handleCmdN() {
|
||||
const termBlockDef: BlockDef = {
|
||||
meta: {
|
||||
@@ -198,7 +213,7 @@ function registerGlobalKeys() {
|
||||
return true;
|
||||
});
|
||||
globalKeyMap.set("Cmd:i", () => {
|
||||
// TODO
|
||||
handleCmdI();
|
||||
return true;
|
||||
});
|
||||
globalKeyMap.set("Cmd:t", () => {
|
||||
|
||||
@@ -128,7 +128,7 @@ class WshServerType {
|
||||
}
|
||||
|
||||
// command "setconfig" [call]
|
||||
SetConfigCommand(data: MetaType, opts?: RpcOpts): Promise<void> {
|
||||
SetConfigCommand(data: SettingsType, opts?: RpcOpts): Promise<void> {
|
||||
return WOS.wshServerRpcHelper_call("setconfig", data, opts);
|
||||
}
|
||||
|
||||
|
||||
@@ -716,21 +716,6 @@ function CodeEditPreview({ parentRef, model }: SpecializedViewProps) {
|
||||
}
|
||||
});
|
||||
|
||||
if (false) {
|
||||
// bind Cmd:e
|
||||
editor.addCommand(simpleMod | monaco.KeyCode.KeyE, () => {
|
||||
model.setEditMode(false);
|
||||
});
|
||||
// bind Cmd:s
|
||||
editor.addCommand(simpleMod | monaco.KeyCode.KeyS, () => {
|
||||
model.handleFileSave();
|
||||
});
|
||||
// bind Cmd:o
|
||||
editor.addCommand(simpleMod | monaco.KeyCode.KeyO, () => {
|
||||
model.updateOpenFileModalAndError(true);
|
||||
});
|
||||
}
|
||||
|
||||
const isFocused = globalStore.get(model.nodeModel.isFocused);
|
||||
if (isFocused) {
|
||||
editor.focus();
|
||||
|
||||
@@ -10,6 +10,7 @@ import * as jotai from "jotai";
|
||||
import * as React from "react";
|
||||
import { CenteredDiv } from "../element/quickelems";
|
||||
|
||||
import { ErrorBoundary } from "@/app/element/errorboundary";
|
||||
import "./workspace.less";
|
||||
|
||||
const iconRegex = /^[a-z0-9-]+$/;
|
||||
@@ -107,15 +108,17 @@ const WorkspaceElem = React.memo(() => {
|
||||
<div className="workspace">
|
||||
<TabBar key={ws.oid} workspace={ws} />
|
||||
<div className="workspace-tabcontent">
|
||||
{activeTabId == "" ? (
|
||||
<CenteredDiv>No Active Tab</CenteredDiv>
|
||||
) : (
|
||||
<>
|
||||
<TabContent key={activeTabId} tabId={activeTabId} />
|
||||
<Widgets />
|
||||
<ModalsRenderer />
|
||||
</>
|
||||
)}
|
||||
<ErrorBoundary>
|
||||
{activeTabId == "" ? (
|
||||
<CenteredDiv>No Active Tab</CenteredDiv>
|
||||
) : (
|
||||
<>
|
||||
<TabContent key={activeTabId} tabId={activeTabId} />
|
||||
<Widgets />
|
||||
<ModalsRenderer />
|
||||
</>
|
||||
)}
|
||||
</ErrorBoundary>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -874,6 +874,11 @@ export class LayoutModel {
|
||||
*/
|
||||
focusNode(nodeId: string) {
|
||||
if (this.focusedNodeId === nodeId) return;
|
||||
const layoutNode = findNode(this.treeState?.rootNode, nodeId);
|
||||
if (!layoutNode) {
|
||||
console.error("unable to focus node, cannot find it in tree", nodeId);
|
||||
return;
|
||||
}
|
||||
const action: LayoutTreeFocusNodeAction = {
|
||||
type: LayoutTreeActionType.FocusNode,
|
||||
nodeId: nodeId,
|
||||
@@ -882,6 +887,13 @@ export class LayoutModel {
|
||||
this.treeReducer(action);
|
||||
}
|
||||
|
||||
focusFirstNode() {
|
||||
const leafOrder = this.getter(this.leafOrder);
|
||||
if (leafOrder.length > 0) {
|
||||
this.focusNode(leafOrder[0].nodeid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle magnification of a given node.
|
||||
* @param nodeId The id of the node that is being magnified.
|
||||
|
||||
Reference in New Issue
Block a user