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.
This commit is contained in:
Sylvie Crowe 2024-10-10 15:50:46 -07:00 committed by GitHub
parent 23eda19ead
commit f3e0ba8148
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 57 additions and 14 deletions

View File

@ -13,7 +13,7 @@
width: 100%; width: 100%;
overflow: scroll; overflow: scroll;
line-height: 1.5; line-height: 1.5;
color: var(--app-text-color); color: var(--main-text-color);
font-family: var(--markdown-font); font-family: var(--markdown-font);
font-size: 14px; font-size: 14px;
overflow-wrap: break-word; overflow-wrap: break-word;
@ -26,13 +26,13 @@
&:first-of-type { &:first-of-type {
margin-top: 0 !important; margin-top: 0 !important;
} }
color: var(--app-text-color); color: var(--main-text-color);
margin-top: 16px; margin-top: 16px;
margin-bottom: 8px; margin-bottom: 8px;
} }
strong { strong {
color: var(--app-text-color); color: var(--main-text-color);
} }
a { a {

View File

@ -42,4 +42,14 @@
outline-color: var(--accent-color); outline-color: var(--accent-color);
} }
} }
.userinput-checkbox-container {
display: flex;
align-items: center;
gap: 6px;
.userinput-checkbox {
accent-color: var(--accent-color);
}
}
} }

View File

@ -13,7 +13,7 @@ import "./userinputmodal.less";
const UserInputModal = (userInputRequest: UserInputRequest) => { const UserInputModal = (userInputRequest: UserInputRequest) => {
const [responseText, setResponseText] = useState(""); const [responseText, setResponseText] = useState("");
const [countdown, setCountdown] = useState(Math.floor(userInputRequest.timeoutms / 1000)); const [countdown, setCountdown] = useState(Math.floor(userInputRequest.timeoutms / 1000));
const checkboxStatus = useRef(false); const checkboxRef = useRef<HTMLInputElement>();
const handleSendCancel = useCallback(() => { const handleSendCancel = useCallback(() => {
UserInputService.SendUserInputResponse({ UserInputService.SendUserInputResponse({
@ -29,7 +29,7 @@ const UserInputModal = (userInputRequest: UserInputRequest) => {
type: "userinputresp", type: "userinputresp",
requestid: userInputRequest.requestid, requestid: userInputRequest.requestid,
text: responseText, text: responseText,
checkboxstat: checkboxStatus.current, checkboxstat: checkboxRef.current?.checked ?? false,
}); });
modalsModel.popModal(); modalsModel.popModal();
}, [responseText, userInputRequest]); }, [responseText, userInputRequest]);
@ -39,7 +39,7 @@ const UserInputModal = (userInputRequest: UserInputRequest) => {
type: "userinputresp", type: "userinputresp",
requestid: userInputRequest.requestid, requestid: userInputRequest.requestid,
confirm: true, confirm: true,
checkboxstat: checkboxStatus.current, checkboxstat: checkboxRef.current?.checked ?? false,
}); });
modalsModel.popModal(); modalsModel.popModal();
}, [userInputRequest]); }, [userInputRequest]);
@ -93,6 +93,23 @@ const UserInputModal = (userInputRequest: UserInputRequest) => {
); );
}, [userInputRequest.responsetype, userInputRequest.publictext, responseText, handleKeyDown, setResponseText]); }, [userInputRequest.responsetype, userInputRequest.publictext, responseText, handleKeyDown, setResponseText]);
const optionalCheckbox = useMemo(() => {
if (userInputRequest.checkboxmsg == "") {
return <></>;
}
return (
<div className="userinput-checkbox-container">
<input
type="checkbox"
id={`uicheckbox-${userInputRequest.requestid}`}
className="userinput-checkbox"
ref={checkboxRef}
/>
<label htmlFor={`uicheckbox-${userInputRequest.requestid}}`}>{userInputRequest.checkboxmsg}</label>
</div>
);
}, []);
useEffect(() => { useEffect(() => {
let timeout: ReturnType<typeof setTimeout>; let timeout: ReturnType<typeof setTimeout>;
if (countdown <= 0) { if (countdown <= 0) {
@ -113,6 +130,7 @@ const UserInputModal = (userInputRequest: UserInputRequest) => {
<div className="userinput-body"> <div className="userinput-body">
{queryText} {queryText}
{inputBox} {inputBox}
{optionalCheckbox}
</div> </div>
</Modal> </Modal>
); );

View File

@ -39,7 +39,7 @@
border-bottom: 1px solid var(--scrollbar-thumb-hover-color); border-bottom: 1px solid var(--scrollbar-thumb-hover-color);
th { th {
color: var(--app-text-color); color: var(--main-text-color);
border-right: 1px solid var(--scrollbar-thumb-hover-color); border-right: 1px solid var(--scrollbar-thumb-hover-color);
border-bottom: none; border-bottom: none;
padding: 2px 10px; padding: 2px 10px;

View File

@ -471,6 +471,7 @@ declare global {
"window:disablehardwareacceleration"?: boolean; "window:disablehardwareacceleration"?: boolean;
"telemetry:*"?: boolean; "telemetry:*"?: boolean;
"telemetry:enabled"?: boolean; "telemetry:enabled"?: boolean;
askbeforewshinstall?: boolean;
}; };
// waveobj.StickerClickOptsType // waveobj.StickerClickOptsType

View File

@ -25,6 +25,8 @@ import (
"github.com/wavetermdev/waveterm/pkg/util/shellutil" "github.com/wavetermdev/waveterm/pkg/util/shellutil"
"github.com/wavetermdev/waveterm/pkg/util/utilfn" "github.com/wavetermdev/waveterm/pkg/util/utilfn"
"github.com/wavetermdev/waveterm/pkg/wavebase" "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/wps"
"github.com/wavetermdev/waveterm/pkg/wshrpc" "github.com/wavetermdev/waveterm/pkg/wshrpc"
"github.com/wavetermdev/waveterm/pkg/wshutil" "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) "Would you like to install them?", clientDisplayName)
title = "Install Wave Shell Extensions" title = "Install Wave Shell Extensions"
} else { } else {
queryText = fmt.Sprintf("Wave requires the Wave Shell Extensions \n"+ // don't ask for upgrading the version
"installed on `%s` \n"+ opts.NoUserPrompt = true
"to be updated from %s to %s. \n\n"+
"Would you like to update?", clientDisplayName, clientVersion, expectedVersion)
title = "Update Wave Shell Extensions"
} }
if !opts.NoUserPrompt { if !opts.NoUserPrompt {
request := &userinput.UserInputRequest{ request := &userinput.UserInputRequest{
@ -314,6 +313,15 @@ func (conn *SSHConn) CheckAndInstallWsh(ctx context.Context, clientDisplayName s
if err != nil || !response.Confirm { if err != nil || !response.Confirm {
return err 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) log.Printf("attempting to install wsh to `%s`", clientDisplayName)
clientOs, err := remote.GetClientOs(client) 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) log.Printf("error: unable to open domain socket listener for %s: %v\n", conn.GetName(), err)
return 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 { if installErr != nil {
log.Printf("error: unable to install wsh shell extensions for %s: %v\n", conn.GetName(), err) 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) return fmt.Errorf("conncontroller %s wsh install error: %v", conn.GetName(), installErr)

View File

@ -9,5 +9,6 @@
"web:defaulturl": "https://github.com/wavetermdev/waveterm", "web:defaulturl": "https://github.com/wavetermdev/waveterm",
"web:defaultsearch": "https://www.google.com/search?q={query}", "web:defaultsearch": "https://www.google.com/search?q={query}",
"window:tilegapsize": 3, "window:tilegapsize": 3,
"telemetry:enabled": true "telemetry:enabled": true,
"askbeforewshinstall": true
} }

View File

@ -61,5 +61,7 @@ const (
ConfigKey_TelemetryClear = "telemetry:*" ConfigKey_TelemetryClear = "telemetry:*"
ConfigKey_TelemetryEnabled = "telemetry:enabled" ConfigKey_TelemetryEnabled = "telemetry:enabled"
ConfigKey_AskBeforeWshInstall = "askbeforewshinstall"
) )

View File

@ -95,6 +95,8 @@ type SettingsType struct {
TelemetryClear bool `json:"telemetry:*,omitempty"` TelemetryClear bool `json:"telemetry:*,omitempty"`
TelemetryEnabled bool `json:"telemetry:enabled,omitempty"` TelemetryEnabled bool `json:"telemetry:enabled,omitempty"`
AskBeforeWshInstall bool `json:"askbeforewshinstall,omitempty"`
} }
type ConfigError struct { type ConfigError struct {