From f3e0ba814820894e4d452f4b17d6fe6de5ed3801 Mon Sep 17 00:00:00 2001 From: Sylvie Crowe <107814465+oneirocosm@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:50:46 -0700 Subject: [PATCH] Add Don't Ask Again Checkbox for Wsh Install (#1010) This provides a checkbox when installing wsh that will prevent the message from popping up in the future. It can also be disabled by adding `"askbeforewshinstall": false` to the config file. --- frontend/app/element/markdown.less | 6 +++--- frontend/app/modals/userinputmodal.less | 10 +++++++++ frontend/app/modals/userinputmodal.tsx | 24 ++++++++++++++++++--- frontend/app/view/preview/csvview.less | 2 +- frontend/types/gotypes.d.ts | 1 + pkg/remote/conncontroller/conncontroller.go | 21 ++++++++++++------ pkg/wconfig/defaultconfig/settings.json | 3 ++- pkg/wconfig/metaconsts.go | 2 ++ pkg/wconfig/settingsconfig.go | 2 ++ 9 files changed, 57 insertions(+), 14 deletions(-) diff --git a/frontend/app/element/markdown.less b/frontend/app/element/markdown.less index df7b1e36d..995e17395 100644 --- a/frontend/app/element/markdown.less +++ b/frontend/app/element/markdown.less @@ -13,7 +13,7 @@ width: 100%; overflow: scroll; line-height: 1.5; - color: var(--app-text-color); + color: var(--main-text-color); font-family: var(--markdown-font); font-size: 14px; overflow-wrap: break-word; @@ -26,13 +26,13 @@ &:first-of-type { margin-top: 0 !important; } - color: var(--app-text-color); + color: var(--main-text-color); margin-top: 16px; margin-bottom: 8px; } strong { - color: var(--app-text-color); + color: var(--main-text-color); } a { diff --git a/frontend/app/modals/userinputmodal.less b/frontend/app/modals/userinputmodal.less index 8cdb338c2..6cf2f5595 100644 --- a/frontend/app/modals/userinputmodal.less +++ b/frontend/app/modals/userinputmodal.less @@ -42,4 +42,14 @@ outline-color: var(--accent-color); } } + + .userinput-checkbox-container { + display: flex; + align-items: center; + gap: 6px; + + .userinput-checkbox { + accent-color: var(--accent-color); + } + } } diff --git a/frontend/app/modals/userinputmodal.tsx b/frontend/app/modals/userinputmodal.tsx index d3f40af2a..7d8ea9d15 100644 --- a/frontend/app/modals/userinputmodal.tsx +++ b/frontend/app/modals/userinputmodal.tsx @@ -13,7 +13,7 @@ import "./userinputmodal.less"; const UserInputModal = (userInputRequest: UserInputRequest) => { const [responseText, setResponseText] = useState(""); const [countdown, setCountdown] = useState(Math.floor(userInputRequest.timeoutms / 1000)); - const checkboxStatus = useRef(false); + const checkboxRef = useRef(); const handleSendCancel = useCallback(() => { UserInputService.SendUserInputResponse({ @@ -29,7 +29,7 @@ const UserInputModal = (userInputRequest: UserInputRequest) => { type: "userinputresp", requestid: userInputRequest.requestid, text: responseText, - checkboxstat: checkboxStatus.current, + checkboxstat: checkboxRef.current?.checked ?? false, }); modalsModel.popModal(); }, [responseText, userInputRequest]); @@ -39,7 +39,7 @@ const UserInputModal = (userInputRequest: UserInputRequest) => { type: "userinputresp", requestid: userInputRequest.requestid, confirm: true, - checkboxstat: checkboxStatus.current, + checkboxstat: checkboxRef.current?.checked ?? false, }); modalsModel.popModal(); }, [userInputRequest]); @@ -93,6 +93,23 @@ const UserInputModal = (userInputRequest: UserInputRequest) => { ); }, [userInputRequest.responsetype, userInputRequest.publictext, responseText, handleKeyDown, setResponseText]); + const optionalCheckbox = useMemo(() => { + if (userInputRequest.checkboxmsg == "") { + return <>; + } + return ( +
+ + +
+ ); + }, []); + useEffect(() => { let timeout: ReturnType; if (countdown <= 0) { @@ -113,6 +130,7 @@ const UserInputModal = (userInputRequest: UserInputRequest) => {
{queryText} {inputBox} + {optionalCheckbox}
); diff --git a/frontend/app/view/preview/csvview.less b/frontend/app/view/preview/csvview.less index 420a61c57..21631f585 100644 --- a/frontend/app/view/preview/csvview.less +++ b/frontend/app/view/preview/csvview.less @@ -39,7 +39,7 @@ border-bottom: 1px solid var(--scrollbar-thumb-hover-color); th { - color: var(--app-text-color); + color: var(--main-text-color); border-right: 1px solid var(--scrollbar-thumb-hover-color); border-bottom: none; padding: 2px 10px; diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 91d211cd9..e6378217c 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -471,6 +471,7 @@ declare global { "window:disablehardwareacceleration"?: boolean; "telemetry:*"?: boolean; "telemetry:enabled"?: boolean; + askbeforewshinstall?: boolean; }; // waveobj.StickerClickOptsType diff --git a/pkg/remote/conncontroller/conncontroller.go b/pkg/remote/conncontroller/conncontroller.go index c90db1fa3..0e8f986b1 100644 --- a/pkg/remote/conncontroller/conncontroller.go +++ b/pkg/remote/conncontroller/conncontroller.go @@ -25,6 +25,8 @@ import ( "github.com/wavetermdev/waveterm/pkg/util/shellutil" "github.com/wavetermdev/waveterm/pkg/util/utilfn" "github.com/wavetermdev/waveterm/pkg/wavebase" + "github.com/wavetermdev/waveterm/pkg/waveobj" + "github.com/wavetermdev/waveterm/pkg/wconfig" "github.com/wavetermdev/waveterm/pkg/wps" "github.com/wavetermdev/waveterm/pkg/wshrpc" "github.com/wavetermdev/waveterm/pkg/wshutil" @@ -296,11 +298,8 @@ func (conn *SSHConn) CheckAndInstallWsh(ctx context.Context, clientDisplayName s "Would you like to install them?", clientDisplayName) title = "Install Wave Shell Extensions" } else { - queryText = fmt.Sprintf("Wave requires the Wave Shell Extensions \n"+ - "installed on `%s` \n"+ - "to be updated from %s to %s. \n\n"+ - "Would you like to update?", clientDisplayName, clientVersion, expectedVersion) - title = "Update Wave Shell Extensions" + // don't ask for upgrading the version + opts.NoUserPrompt = true } if !opts.NoUserPrompt { request := &userinput.UserInputRequest{ @@ -314,6 +313,15 @@ func (conn *SSHConn) CheckAndInstallWsh(ctx context.Context, clientDisplayName s if err != nil || !response.Confirm { return err } + if response.CheckboxStat { + meta := waveobj.MetaMapType{ + wconfig.ConfigKey_AskBeforeWshInstall: false, + } + err := wconfig.SetBaseConfigValue(meta) + if err != nil { + return fmt.Errorf("error setting askbeforewshinstall value: %w", err) + } + } } log.Printf("attempting to install wsh to `%s`", clientDisplayName) clientOs, err := remote.GetClientOs(client) @@ -429,7 +437,8 @@ func (conn *SSHConn) connectInternal(ctx context.Context) error { log.Printf("error: unable to open domain socket listener for %s: %v\n", conn.GetName(), err) return err } - installErr := conn.CheckAndInstallWsh(ctx, clientDisplayName, nil) + config := wconfig.ReadFullConfig() + installErr := conn.CheckAndInstallWsh(ctx, clientDisplayName, &WshInstallOpts{NoUserPrompt: !config.Settings.AskBeforeWshInstall}) if installErr != nil { log.Printf("error: unable to install wsh shell extensions for %s: %v\n", conn.GetName(), err) return fmt.Errorf("conncontroller %s wsh install error: %v", conn.GetName(), installErr) diff --git a/pkg/wconfig/defaultconfig/settings.json b/pkg/wconfig/defaultconfig/settings.json index 3cc4ca932..71970e56b 100644 --- a/pkg/wconfig/defaultconfig/settings.json +++ b/pkg/wconfig/defaultconfig/settings.json @@ -9,5 +9,6 @@ "web:defaulturl": "https://github.com/wavetermdev/waveterm", "web:defaultsearch": "https://www.google.com/search?q={query}", "window:tilegapsize": 3, - "telemetry:enabled": true + "telemetry:enabled": true, + "askbeforewshinstall": true } diff --git a/pkg/wconfig/metaconsts.go b/pkg/wconfig/metaconsts.go index a2b469bd2..d3cdd9ee8 100644 --- a/pkg/wconfig/metaconsts.go +++ b/pkg/wconfig/metaconsts.go @@ -61,5 +61,7 @@ const ( ConfigKey_TelemetryClear = "telemetry:*" ConfigKey_TelemetryEnabled = "telemetry:enabled" + + ConfigKey_AskBeforeWshInstall = "askbeforewshinstall" ) diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index 7bf196eaa..dea03f718 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -95,6 +95,8 @@ type SettingsType struct { TelemetryClear bool `json:"telemetry:*,omitempty"` TelemetryEnabled bool `json:"telemetry:enabled,omitempty"` + + AskBeforeWshInstall bool `json:"askbeforewshinstall,omitempty"` } type ConfigError struct {