mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
Declare types as global (#282)
* declare types as global * remove mobx types aliases * put back model_old.ts * remove types.ts
This commit is contained in:
@@ -7,7 +7,6 @@ import * as mobx from "mobx";
|
||||
import { boundMethod } from "autobind-decorator";
|
||||
import { If } from "tsx-control-statements/components";
|
||||
import dayjs from "dayjs";
|
||||
import type { ContextMenuOpts } from "../types/types";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import { GlobalModel } from "../models";
|
||||
import { isBlank } from "../util/util";
|
||||
@@ -25,8 +24,6 @@ import "./app.less";
|
||||
|
||||
dayjs.extend(localizedFormat);
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
|
||||
@mobxReact.observer
|
||||
class App extends React.Component<{}, {}> {
|
||||
dcWait: OV<boolean> = mobx.observable.box(false, { name: "dcWait" });
|
||||
|
||||
@@ -47,3 +47,13 @@ export const TabIcons = [
|
||||
export const VERSION = __WAVETERM_VERSION__;
|
||||
// @ts-ignore
|
||||
export const BUILD = __WAVETERM_BUILD__;
|
||||
|
||||
/**
|
||||
* Levels for the screen status indicator
|
||||
*/
|
||||
export enum StatusIndicatorLevel {
|
||||
None = 0,
|
||||
Output = 1,
|
||||
Success = 2,
|
||||
Error = 3,
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as mobx from "mobx";
|
||||
import { boundMethod } from "autobind-decorator";
|
||||
import { If, For } from "tsx-control-statements/components";
|
||||
import cn from "classnames";
|
||||
import type { BookmarkType } from "../../types/types";
|
||||
import { GlobalModel } from "../../models";
|
||||
import { CmdStrCode, Markdown } from "../common/elements";
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import { boundMethod } from "autobind-decorator";
|
||||
import cn from "classnames";
|
||||
import { GlobalModel, GlobalCommandRunner, RemotesModel } from "../../models";
|
||||
import { Toggle, InlineSettingsTextEdit, SettingsError, Dropdown } from "../common/elements";
|
||||
import * as types from "../../types/types";
|
||||
import { commandRtnHandler, isBlank } from "../../util/util";
|
||||
import * as appconst from "../appconst";
|
||||
|
||||
@@ -16,10 +15,10 @@ import "./clientsettings.less";
|
||||
|
||||
@mobxReact.observer
|
||||
class ClientSettingsView extends React.Component<{ model: RemotesModel }, { hoveredItemId: string }> {
|
||||
fontSizeDropdownActive: types.OV<boolean> = mobx.observable.box(false, {
|
||||
fontSizeDropdownActive: OV<boolean> = mobx.observable.box(false, {
|
||||
name: "clientSettings-fontSizeDropdownActive",
|
||||
});
|
||||
errorMessage: types.OV<string> = mobx.observable.box(null, { name: "ClientSettings-errorMessage" });
|
||||
errorMessage: OV<string> = mobx.observable.box(null, { name: "ClientSettings-errorMessage" });
|
||||
|
||||
@boundMethod
|
||||
dismissError(): void {
|
||||
@@ -48,7 +47,7 @@ class ClientSettingsView extends React.Component<{ model: RemotesModel }, { hove
|
||||
|
||||
@boundMethod
|
||||
handleChangeTelemetry(val: boolean): void {
|
||||
let prtn: Promise<types.CommandRtnType> = null;
|
||||
let prtn: Promise<CommandRtnType> = null;
|
||||
if (val) {
|
||||
prtn = GlobalCommandRunner.telemetryOn(false);
|
||||
} else {
|
||||
@@ -59,7 +58,7 @@ class ClientSettingsView extends React.Component<{ model: RemotesModel }, { hove
|
||||
|
||||
@boundMethod
|
||||
handleChangeReleaseCheck(val: boolean): void {
|
||||
let prtn: Promise<types.CommandRtnType> = null;
|
||||
let prtn: Promise<CommandRtnType> = null;
|
||||
if (val) {
|
||||
prtn = GlobalCommandRunner.releaseCheckAutoOn(false);
|
||||
} else {
|
||||
@@ -112,7 +111,7 @@ class ClientSettingsView extends React.Component<{ model: RemotesModel }, { hove
|
||||
return null;
|
||||
}
|
||||
|
||||
let cdata: types.ClientDataType = GlobalModel.clientData.get();
|
||||
let cdata: ClientDataType = GlobalModel.clientData.get();
|
||||
let openAIOpts = cdata.openaiopts ?? {};
|
||||
let apiTokenStr = isBlank(openAIOpts.apitoken) ? "(not set)" : "********";
|
||||
let maxTokensStr = String(
|
||||
|
||||
@@ -11,8 +11,6 @@ import { checkKeyPressed, adaptFromReactOrNativeKeyEvent } from "../../../util/k
|
||||
|
||||
import "./inlinesettingstextedit.less";
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
|
||||
@mobxReact.observer
|
||||
class InlineSettingsTextEdit extends React.Component<
|
||||
{
|
||||
|
||||
@@ -10,8 +10,6 @@ import { IconButton } from "./iconbutton";
|
||||
|
||||
import "./modal.less";
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
|
||||
interface ModalHeaderProps {
|
||||
onClose?: () => void;
|
||||
title: string;
|
||||
|
||||
@@ -11,8 +11,6 @@ import { MagicLayout } from "../../magiclayout";
|
||||
|
||||
import "./resizablesidebar.less";
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
|
||||
interface ResizableSidebarProps {
|
||||
parentRef: React.RefObject<HTMLElement>;
|
||||
position: "left" | "right";
|
||||
|
||||
@@ -6,8 +6,6 @@ import * as mobxReact from "mobx-react";
|
||||
import * as mobx from "mobx";
|
||||
import { boundMethod } from "autobind-decorator";
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
|
||||
@mobxReact.observer
|
||||
class SettingsError extends React.Component<{ errorMessage: OV<string> }, {}> {
|
||||
@boundMethod
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { Component, ReactNode } from "react";
|
||||
import { RendererContext } from "../../../types/types";
|
||||
import cn from "classnames";
|
||||
|
||||
interface ErrorBoundaryState {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React from "react";
|
||||
import { StatusIndicatorLevel } from "../../../types/types";
|
||||
import cn from "classnames";
|
||||
import { ReactComponent as SpinnerIndicator } from "../../assets/icons/spinner-indicator.svg";
|
||||
import { boundMethod } from "autobind-decorator";
|
||||
import * as mobx from "mobx";
|
||||
import * as mobxReact from "mobx-react";
|
||||
import * as appconst from "../../appconst";
|
||||
|
||||
import { ReactComponent as RotateIconSvg } from "../../assets/icons/line/rotate.svg";
|
||||
|
||||
@@ -131,7 +131,7 @@ interface StatusIndicatorProps {
|
||||
/**
|
||||
* The level of the status indicator. This will determine the color of the status indicator.
|
||||
*/
|
||||
level: StatusIndicatorLevel;
|
||||
level: appconst.StatusIndicatorLevel;
|
||||
className?: string;
|
||||
/**
|
||||
* If true, a spinner will be shown around the status indicator.
|
||||
@@ -191,16 +191,16 @@ export class StatusIndicator extends React.Component<StatusIndicatorProps> {
|
||||
const { level, className, runningCommands } = this.props;
|
||||
const spinnerVisible = this.spinnerVisible.get();
|
||||
let statusIndicator = null;
|
||||
if (level != StatusIndicatorLevel.None || spinnerVisible) {
|
||||
if (level != appconst.StatusIndicatorLevel.None || spinnerVisible) {
|
||||
let indicatorLevelClass = null;
|
||||
switch (level) {
|
||||
case StatusIndicatorLevel.Output:
|
||||
case appconst.StatusIndicatorLevel.Output:
|
||||
indicatorLevelClass = "output";
|
||||
break;
|
||||
case StatusIndicatorLevel.Success:
|
||||
case appconst.StatusIndicatorLevel.Success:
|
||||
indicatorLevelClass = "success";
|
||||
break;
|
||||
case StatusIndicatorLevel.Error:
|
||||
case appconst.StatusIndicatorLevel.Error:
|
||||
indicatorLevelClass = "error";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as mobx from "mobx";
|
||||
import { boundMethod } from "autobind-decorator";
|
||||
import { If } from "tsx-control-statements/components";
|
||||
import { GlobalModel, GlobalCommandRunner, RemotesModel } from "../../../models";
|
||||
import * as T from "../../../types/types";
|
||||
import {
|
||||
Modal,
|
||||
TextField,
|
||||
@@ -22,8 +21,6 @@ import * as util from "../../../util/util";
|
||||
|
||||
import "./createremoteconn.less";
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
|
||||
@mobxReact.observer
|
||||
class CreateRemoteConnModal extends React.Component<{}, {}> {
|
||||
tempAlias: OV<string>;
|
||||
@@ -35,7 +32,7 @@ class CreateRemoteConnModal extends React.Component<{}, {}> {
|
||||
tempKeyFile: OV<string>;
|
||||
tempShellPref: OV<string>;
|
||||
errorStr: OV<string>;
|
||||
remoteEdit: T.RemoteEditType;
|
||||
remoteEdit: RemoteEditType;
|
||||
model: RemotesModel;
|
||||
|
||||
constructor(props: { remotesModel?: RemotesModel }) {
|
||||
|
||||
@@ -7,14 +7,11 @@ import * as mobx from "mobx";
|
||||
import { If } from "tsx-control-statements/components";
|
||||
import { boundMethod } from "autobind-decorator";
|
||||
import { GlobalModel, GlobalCommandRunner, RemotesModel } from "../../../models";
|
||||
import * as T from "../../../types/types";
|
||||
import { Modal, TextField, InputDecoration, Dropdown, PasswordField, Tooltip } from "../elements";
|
||||
import * as util from "../../../util/util";
|
||||
|
||||
import "./editremoteconn.less";
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
|
||||
const PasswordUnchangedSentinel = "--unchanged--";
|
||||
|
||||
@mobxReact.observer
|
||||
@@ -42,11 +39,11 @@ class EditRemoteConnModal extends React.Component<{}, {}> {
|
||||
return this.model.selectedRemoteId.get();
|
||||
}
|
||||
|
||||
get selectedRemote(): T.RemoteType {
|
||||
get selectedRemote(): RemoteType {
|
||||
return GlobalModel.getRemote(this.selectedRemoteId);
|
||||
}
|
||||
|
||||
get remoteEdit(): T.RemoteEditType {
|
||||
get remoteEdit(): RemoteEditType {
|
||||
return this.model.remoteEdit.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,11 @@ import * as mobx from "mobx";
|
||||
import { boundMethod } from "autobind-decorator";
|
||||
import { GlobalModel, GlobalCommandRunner } from "../../../models";
|
||||
import { SettingsError, Modal, Dropdown } from "../elements";
|
||||
import { LineType, RendererPluginType } from "../../../types/types";
|
||||
import { PluginModel } from "../../../plugins/plugins";
|
||||
import { commandRtnHandler } from "../../../util/util";
|
||||
|
||||
import "./linesettings.less";
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
|
||||
@mobxReact.observer
|
||||
class LineSettingsModal extends React.Component<{}, {}> {
|
||||
rendererDropdownActive: OV<boolean> = mobx.observable.box(false, { name: "lineSettings-rendererDropdownActive" });
|
||||
|
||||
@@ -9,7 +9,6 @@ import { If, For } from "tsx-control-statements/components";
|
||||
import cn from "classnames";
|
||||
import { GlobalModel, GlobalCommandRunner, Screen } from "../../../models";
|
||||
import { Toggle, InlineSettingsTextEdit, SettingsError, Modal, Dropdown, Tooltip } from "../elements";
|
||||
import { RemoteType } from "../../../types/types";
|
||||
import * as util from "../../../util/util";
|
||||
import { commandRtnHandler } from "../../../util/util";
|
||||
import { ReactComponent as SquareIcon } from "../../assets/icons/tab/square.svg";
|
||||
@@ -19,8 +18,6 @@ import * as appconst from "../../appconst";
|
||||
|
||||
import "./screensettings.less";
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
|
||||
const ScreenDeleteMessage = `
|
||||
Are you sure you want to delete this tab?
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ import { commandRtnHandler } from "../../../util/util";
|
||||
|
||||
import "./sessionsettings.less";
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
|
||||
const SessionDeleteMessage = `
|
||||
Are you sure you want to delete this workspace?
|
||||
|
||||
|
||||
@@ -15,9 +15,6 @@ import { ReactComponent as SquareIcon } from "../../assets/icons/tab/square.svg"
|
||||
|
||||
import "./tabswitcher.less";
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
type OArr<V> = mobx.IObservableArray<V>;
|
||||
|
||||
type SwitcherDataType = {
|
||||
sessionId: string;
|
||||
sessionName: string;
|
||||
|
||||
@@ -7,7 +7,6 @@ import { boundMethod } from "autobind-decorator";
|
||||
import { GlobalModel, GlobalCommandRunner } from "../../../models";
|
||||
import { Toggle, Modal, Button } from "../elements";
|
||||
import * as util from "../../../util/util";
|
||||
import { ClientDataType } from "../../../types/types";
|
||||
|
||||
import shield from "../../assets/icons/shield_check.svg";
|
||||
import help from "../../assets/icons/help_filled.svg";
|
||||
|
||||
@@ -2,7 +2,6 @@ import * as React from "react";
|
||||
import { GlobalModel } from "../../../models";
|
||||
import { Choose, When, If } from "tsx-control-statements/components";
|
||||
import { Modal, PasswordField, Markdown } from "../elements";
|
||||
import { UserInputRequest } from "../../../types/types";
|
||||
|
||||
import "./userinput.less";
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import { boundMethod } from "autobind-decorator";
|
||||
import { If, For } from "tsx-control-statements/components";
|
||||
import cn from "classnames";
|
||||
import { GlobalModel, GlobalCommandRunner, RemotesModel } from "../../../models";
|
||||
import * as T from "../../../types/types";
|
||||
import { Modal, Tooltip, Button, Status } from "../elements";
|
||||
import * as util from "../../../util/util";
|
||||
import * as textmeasure from "../../../util/textmeasure";
|
||||
@@ -27,7 +26,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
|
||||
}
|
||||
|
||||
@mobx.computed
|
||||
getSelectedRemote(): T.RemoteType {
|
||||
getSelectedRemote(): RemoteType {
|
||||
const selectedRemoteId = this.model.selectedRemoteId.get();
|
||||
return GlobalModel.getRemote(selectedRemoteId);
|
||||
}
|
||||
@@ -58,7 +57,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
|
||||
}
|
||||
}
|
||||
|
||||
getRemoteTypeStr(remote: T.RemoteType): string {
|
||||
getRemoteTypeStr(remote: RemoteType): string {
|
||||
if (!util.isBlank(remote.uname)) {
|
||||
let unameStr = remote.uname;
|
||||
unameStr = unameStr.replace("|", ", ");
|
||||
@@ -136,7 +135,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
|
||||
this.model.setRecentConnAdded(false);
|
||||
}
|
||||
|
||||
renderInstallStatus(remote: T.RemoteType): any {
|
||||
renderInstallStatus(remote: RemoteType): any {
|
||||
let statusStr: string = null;
|
||||
if (remote.installstatus == "disconnected") {
|
||||
if (remote.needsmshellupgrade) {
|
||||
@@ -160,7 +159,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
|
||||
);
|
||||
}
|
||||
|
||||
renderHeaderBtns(remote: T.RemoteType): React.ReactNode {
|
||||
renderHeaderBtns(remote: RemoteType): React.ReactNode {
|
||||
let buttons: React.ReactNode[] = [];
|
||||
const disconnectButton = (
|
||||
<Button theme="secondary" onClick={() => this.disconnectRemote(remote.remoteid)}>
|
||||
@@ -254,7 +253,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
|
||||
);
|
||||
}
|
||||
|
||||
getMessage(remote: T.RemoteType): string {
|
||||
getMessage(remote: RemoteType): string {
|
||||
let message = "";
|
||||
if (remote.status == "connected") {
|
||||
message = "Connected and ready to run commands.";
|
||||
@@ -393,7 +392,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
|
||||
}
|
||||
}
|
||||
|
||||
function getImportTooltip(remote: T.RemoteType): React.ReactElement<any, any> {
|
||||
function getImportTooltip(remote: RemoteType): React.ReactElement<any, any> {
|
||||
if (remote.sshconfigsrc == "sshconfig-import") {
|
||||
return (
|
||||
<Tooltip
|
||||
|
||||
@@ -3,17 +3,9 @@
|
||||
|
||||
import * as React from "react";
|
||||
import * as mobxReact from "mobx-react";
|
||||
import * as mobx from "mobx";
|
||||
import dayjs from "dayjs";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import { GlobalModel } from "../../../models";
|
||||
import type {
|
||||
LineType,
|
||||
RemoteType,
|
||||
RemotePtrType,
|
||||
LineHeightChangeCallbackType,
|
||||
LineContainerType,
|
||||
} from "../../../types/types";
|
||||
import cn from "classnames";
|
||||
import { isBlank } from "../../../util/util";
|
||||
import { ReactComponent as FolderIcon } from "../../assets/icons/folder.svg";
|
||||
@@ -22,23 +14,6 @@ import "./prompt.less";
|
||||
|
||||
dayjs.extend(localizedFormat);
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
type OArr<V> = mobx.IObservableArray<V>;
|
||||
type OMap<K, V> = mobx.ObservableMap<K, V>;
|
||||
|
||||
type RendererComponentProps = {
|
||||
screen: LineContainerType;
|
||||
line: LineType;
|
||||
width: number;
|
||||
staticRender: boolean;
|
||||
visible: OV<boolean>;
|
||||
onHeightChange: LineHeightChangeCallbackType;
|
||||
collapsed: boolean;
|
||||
};
|
||||
type RendererComponentType = {
|
||||
new (props: RendererComponentProps): React.Component<RendererComponentProps, {}>;
|
||||
};
|
||||
|
||||
function makeFullRemoteRef(ownerName: string, remoteRef: string, name: string): string {
|
||||
if (isBlank(ownerName) && isBlank(name)) {
|
||||
return remoteRef;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user