confirm websharing. minor bug fixes, etc (hotkeys, menu edits, etc.)

This commit is contained in:
sawka
2023-04-04 23:26:34 -07:00
parent 1f2967c145
commit f492645530
6 changed files with 73 additions and 15 deletions
+3
View File
@@ -143,6 +143,9 @@ class BookmarksView extends React.Component<{}, {}> {
render() {
let isHidden = (GlobalModel.activeMainView.get() != "bookmarks");
if (isHidden) {
return null;
}
let bookmarks = GlobalModel.bookmarksModel.bookmarks;
let idx : number = 0;
let bookmark : BookmarkType = null;
+4 -8
View File
@@ -15,6 +15,7 @@ import {GlobalModel, GlobalCommandRunner, Session, Cmd, ScreenLines, Screen, riT
import {windowWidthToCols, windowHeightToRows, termHeightFromRows, termWidthFromCols, getMonoFontSize} from "./textmeasure";
import {isModKeyPress, boundInt, sortAndFilterRemotes, makeExternLink, isBlank} from "./util";
import {BookmarksView} from "./bookmarks";
import {WebShareView} from "./webshare-client-view";
import {HistoryView} from "./history";
import {Line, Prompt} from "./linecomps";
import {ScreenSettingsModal, SessionSettingsModal, LineSettingsModal, ClientSettingsModal} from "./settings";
@@ -1496,7 +1497,7 @@ class MainSideBar extends React.Component<{}, {}> {
</div>
<div className="menu">
<p className="menu-label">
Private Sessions
Sessions
</p>
<ul className="menu-list session-menu-list">
<If condition={!model.sessionListLoaded.get()}>
@@ -1506,7 +1507,7 @@ class MainSideBar extends React.Component<{}, {}> {
<For each="session" index="idx" of={sessionList}>
<li key={session.sessionId}><a className={cn({"is-active": mainView == "session" && activeSessionId == session.sessionId})} onClick={() => this.handleSessionClick(session.sessionId)}>
<If condition={!session.archived.get()}>
<div className="session-num">{idx+1}</div>
<div className="session-num"><span className="hotkey">^</span>{idx+1}</div>
</If>
<If condition={session.archived.get()}>
<div className="session-num"><i title="archived" className="fa-sharp fa-solid fa-box-archive"/></div>
@@ -1523,12 +1524,6 @@ class MainSideBar extends React.Component<{}, {}> {
<li className="new-session"><a onClick={() => this.handleNewSession()}><i className="fa-sharp fa-solid fa-plus"/> New Session</a></li>
</If>
</ul>
<p className="menu-label">
Shared Sessions
</p>
<ul className="menu-list">
<li className="new-session"><a onClick={() => this.handleNewSharedSession()}><i className="fa-sharp fa-solid fa-plus"/> New Session</a></li>
</ul>
<ul className="menu-list" style={{marginTop: 20}}>
<li className="menu-history"><a onClick={this.handleHistoryClick} className={cn({"is-active": (mainView == "history")})}><i className="fa-sharp fa-solid fa-clock"/> HISTORY <span className="hotkey">&#x2318;H</span></a></li>
</ul>
@@ -1967,6 +1962,7 @@ class Main extends React.Component<{}, {}> {
<SessionView/>
<HistoryView/>
<BookmarksView/>
<WebShareView/>
</div>
<AlertModal/>
<If condition={GlobalModel.needsTos()}>
+13 -2
View File
@@ -1958,6 +1958,12 @@ class HistoryViewModel {
this.selectedItems.clear();
})();
}
showWebShareView() : void {
mobx.action(() => {
GlobalModel.activeMainView.set("webshare");
})();
}
}
class BookmarksModel {
@@ -2399,7 +2405,7 @@ class Model {
localServerRunning : OV<boolean>;
authKey : string;
isDev : boolean;
activeMainView : OV<"session" | "history" | "bookmarks"> = mobx.observable.box("session", {name: "activeMainView"});
activeMainView : OV<"session" | "history" | "bookmarks" | "webshare"> = mobx.observable.box("session", {name: "activeMainView"});
termFontSize : CV<number>;
alertMessage : OV<AlertMessageType> = mobx.observable.box(null, {name: "alertMessage"});
alertPromiseResolver : (result : boolean) => void;
@@ -2409,6 +2415,7 @@ class Model {
clientSettingsModal : OV<boolean> = mobx.observable.box(false, {name: "clientSettingsModal"});
lineSettingsModal : OV<LineType> = mobx.observable.box(null, {name: "lineSettingsModal"});
remotesModalModel : RemotesModalModel;
inputModel : InputModel;
bookmarksModel : BookmarksModel;
@@ -2589,6 +2596,10 @@ class Model {
}
if (e.code == "Escape") {
e.preventDefault();
if (this.activeMainView.get() == "webshare") {
this.showSessionView();
return;
}
if (this.clearModals()) {
return;
}
@@ -3121,7 +3132,7 @@ class Model {
})();
return {success: true};
}).catch((err) => {
this.errorHandler("calling run-command", err, true);
this.errorHandler("calling run-command", err, interactive);
let errMessage = "error running command";
if (err != null && !isBlank(err.message)) {
errMessage = err.message;
+13 -4
View File
@@ -24,12 +24,14 @@ const VERSION = __PROMPT_VERSION__;
// @ts-ignore
const BUILD = __PROMPT_BUILD__;
const WebShareMarkdown = `
const WebShareConfirmMarkdown = `
You are about to share a terminal tab on the web. Please make sure that you do
NOT share any private information, keys, passwords, or other sensitive information.
You are responsible for what you are sharing, be smart.
`.trim();
See [Terms of Service](https://www.getprompt.dev/tos.html) for more details.
const WebStopShareConfirmMarkdown = `
Are you sure you want to stop web-sharing this screen?
`.trim();
function commandRtnHandler(prtn : Promise<CommandRtnType>, errorMessage : OV<string>) {
@@ -102,8 +104,15 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId
if (screen.isWebShared() == val) {
return;
}
let prtn = GlobalCommandRunner.screenWebShare(screen.screenId, val);
commandRtnHandler(prtn, this.errorMessage);
let message = (val ? WebShareConfirmMarkdown : WebStopShareConfirmMarkdown);
let alertRtn = GlobalModel.showAlert({message: message, confirm: true, markdown: true});
alertRtn.then((result) => {
if (!result) {
return;
}
let prtn = GlobalCommandRunner.screenWebShare(screen.screenId, val);
commandRtnHandler(prtn, this.errorMessage);
});
}
@boundMethod
+8 -1
View File
@@ -51,7 +51,9 @@
html, body, #app, #main {
background-color: #000;
height: 100vh;
}
.content {
a:hover {
color: #485fc7;
}
@@ -981,6 +983,10 @@ body::-webkit-scrollbar {
.bottom-spacer {
height: 10px;
}
a:hover {
color: white;
}
}
.menu-label {
@@ -1041,7 +1047,8 @@ body::-webkit-scrollbar {
align-items: center;
.session-num {
width: 14px;
width: 24px;
margin-left: -12px;
}
.session-gear {
+32
View File
@@ -0,0 +1,32 @@
import * as React from "react";
import * as mobxReact from "mobx-react";
import * as mobx from "mobx";
import {sprintf} from "sprintf-js";
import {boundMethod} from "autobind-decorator";
import {v4 as uuidv4} from "uuid";
import dayjs from "dayjs";
import {If, For, When, Otherwise, Choose} from "tsx-control-statements/components";
import cn from "classnames";
import {GlobalModel, GlobalCommandRunner} from "./model";
@mobxReact.observer
class WebShareView extends React.Component<{}, {}> {
@boundMethod
closeView() : void {
GlobalModel.showSessionView();
}
render() {
let isHidden = (GlobalModel.activeMainView.get() != "bookmarks");
if (isHidden) {
return null;
}
return (
<div className={cn("webshare-view", "alt-view")}>
</div>
);
}
}
export {WebShareView};