mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-21 21:32:13 +01:00
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:
parent
23eda19ead
commit
f3e0ba8148
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<HTMLInputElement>();
|
||||
|
||||
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 (
|
||||
<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(() => {
|
||||
let timeout: ReturnType<typeof setTimeout>;
|
||||
if (countdown <= 0) {
|
||||
@ -113,6 +130,7 @@ const UserInputModal = (userInputRequest: UserInputRequest) => {
|
||||
<div className="userinput-body">
|
||||
{queryText}
|
||||
{inputBox}
|
||||
{optionalCheckbox}
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
|
@ -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;
|
||||
|
1
frontend/types/gotypes.d.ts
vendored
1
frontend/types/gotypes.d.ts
vendored
@ -471,6 +471,7 @@ declare global {
|
||||
"window:disablehardwareacceleration"?: boolean;
|
||||
"telemetry:*"?: boolean;
|
||||
"telemetry:enabled"?: boolean;
|
||||
askbeforewshinstall?: boolean;
|
||||
};
|
||||
|
||||
// waveobj.StickerClickOptsType
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -61,5 +61,7 @@ const (
|
||||
|
||||
ConfigKey_TelemetryClear = "telemetry:*"
|
||||
ConfigKey_TelemetryEnabled = "telemetry:enabled"
|
||||
|
||||
ConfigKey_AskBeforeWshInstall = "askbeforewshinstall"
|
||||
)
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user