From 9884e69da08678557ffef41e0e5a304922df7cf2 Mon Sep 17 00:00:00 2001 From: sawka Date: Fri, 14 Apr 2023 15:32:21 -0700 Subject: [PATCH] update session settings (include archive/delete). add delete to screen settings. --- src/model.ts | 16 +++++- src/settings.tsx | 135 +++++++++++++++++++++++++++++++++++++++++------ src/sh2.less | 6 +++ 3 files changed, 140 insertions(+), 17 deletions(-) diff --git a/src/model.ts b/src/model.ts index 105799e8..76f06829 100644 --- a/src/model.ts +++ b/src/model.ts @@ -3420,6 +3420,10 @@ class CommandRunner { return GlobalModel.submitCommand("screen", "archive", [screenId, (shouldArchive ? "1" : "0")], {"nohist": "1"}, false); } + screenPurge(screenId : string) : Promise { + return GlobalModel.submitCommand("screen", "purge", [screenId], {"nohist": "1"}, false); + } + screenWebShare(screenId : string, shouldShare : boolean) : Promise { let kwargs : Record = {"nohist": "1"}; kwargs["screen"] = screenId; @@ -3515,11 +3519,19 @@ class CommandRunner { return GlobalModel.submitCommand("screen", "set", null, kwargs, interactive); } - sessionSetSettings(sessionId : string, settings : {name? : string}) : void { + sessionArchive(sessionId : string, shouldArchive : boolean) : Promise { + return GlobalModel.submitCommand("session", "archive", [sessionId, (shouldArchive ? "1" : "0")], {"nohist": "1"}, false); + } + + sessionPurge(sessionId : string) : Promise { + return GlobalModel.submitCommand("session", "purge", [sessionId], {"nohist": "1"}, false); + } + + sessionSetSettings(sessionId : string, settings : {name? : string}, interactive : boolean) : Promise { let kwargs = Object.assign({}, settings); kwargs["nohist"] = "1"; kwargs["session"] = sessionId; - GlobalModel.submitCommand("session", "set", null, kwargs, true); + return GlobalModel.submitCommand("session", "set", null, kwargs, interactive); } lineStar(lineId : string, starVal : number) { diff --git a/src/settings.tsx b/src/settings.tsx index 828d6a38..6c135a8d 100644 --- a/src/settings.tsx +++ b/src/settings.tsx @@ -6,7 +6,7 @@ import {boundMethod} from "autobind-decorator"; import {If, For, When, Otherwise, Choose} from "tsx-control-statements/components"; import cn from "classnames"; import {GlobalModel, GlobalCommandRunner, TabColors} from "./model"; -import {Toggle, RemoteStatusLight, InlineSettingsTextEdit, SettingsError} from "./elements"; +import {Toggle, RemoteStatusLight, InlineSettingsTextEdit, SettingsError, InfoMessage} from "./elements"; import {LineType, RendererPluginType, ClientDataType, CommandRtnType} from "./types"; import {PluginModel} from "./plugins"; import * as util from "./util"; @@ -24,6 +24,19 @@ const VERSION = __PROMPT_VERSION__; // @ts-ignore const BUILD = __PROMPT_BUILD__; + +const ScreenDeleteMessage = ` +Are you sure you want to delete this screen/tab? + +All commands and output will be deleted, and removed from history. To hide the screen, and retain the commands in history, use 'archive'. +`.trim(); + +const SessionDeleteMessage = ` +Are you sure you want to delete this session? + +All commands and output will be deleted, and removed from history. To hide the session, and retain the commands in history, use 'archive'. +`.trim(); + 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. @@ -179,6 +192,24 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId })(); } + @boundMethod + handleDeleteScreen() : void { + let {sessionId, screenId} = this.props; + let screen = GlobalModel.getScreenById(sessionId, screenId); + if (screen == null) { + return; + } + let message = ScreenDeleteMessage; + let alertRtn = GlobalModel.showAlert({message: message, confirm: true, markdown: true}); + alertRtn.then((result) => { + if (!result) { + return; + } + let prtn = GlobalCommandRunner.screenPurge(screenId); + commandRtnHandler(prtn, this.errorMessage); + }); + } + render() { let {sessionId, screenId} = this.props; let screen = GlobalModel.getScreenById(sessionId, screenId); @@ -241,7 +272,10 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId
- Archived +
Archived
+ + Archive will hide the screen tab. Commands and output will be retained in history. +
@@ -289,6 +323,17 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId
+
+
+
Actions
+ + Delete will remove the screen, removing all commands and output from history. + +
+
+
Delete Screen
+
+