From 51ee7bef6195a89cdcfa3cc7a736189c0165ce5f Mon Sep 17 00:00:00 2001
From: Sylvie Crowe <107814465+oneirocosm@users.noreply.github.com>
Date: Wed, 31 Jan 2024 14:11:12 -0800
Subject: [PATCH] Shellpref for sshconfig import (#270)
---
src/app/common/modals/editremoteconn.less | 6 ++++
src/app/common/modals/editremoteconn.tsx | 33 +++++++++++++++++--
src/app/common/modals/modals.tsx | 11 -------
.../common/modals/viewremoteconndetail.tsx | 11 -------
wavesrv/pkg/cmdrunner/cmdrunner.go | 16 ++++++---
5 files changed, 48 insertions(+), 29 deletions(-)
diff --git a/src/app/common/modals/editremoteconn.less b/src/app/common/modals/editremoteconn.less
index ad954ff39..bb98eb3d6 100644
--- a/src/app/common/modals/editremoteconn.less
+++ b/src/app/common/modals/editremoteconn.less
@@ -20,6 +20,12 @@
width: 100%;
}
+ .import-edit-warning {
+ display: flex;
+ flex-direction: row;
+ align-items: flex-start;
+ }
+
.name-actions-section {
margin-bottom: 10px;
display: flex;
diff --git a/src/app/common/modals/editremoteconn.tsx b/src/app/common/modals/editremoteconn.tsx
index 6502aa191..930a306ad 100644
--- a/src/app/common/modals/editremoteconn.tsx
+++ b/src/app/common/modals/editremoteconn.tsx
@@ -58,6 +58,10 @@ class EditRemoteConnModal extends React.Component<{}, {}> {
return this.selectedRemote?.local;
}
+ isImportedRemote(): boolean {
+ return this.selectedRemote?.sshconfigsrc == "sshconfig-import";
+ }
+
componentDidMount(): void {
mobx.action(() => {
this.tempAlias.set(this.selectedRemote?.remotealias);
@@ -259,6 +263,27 @@ class EditRemoteConnModal extends React.Component<{}, {}> {
);
}
+ renderImportedRemoteEditWarning() {
+ return (
+
+
+ Most options for connections imported from an ssh config file cannot be edited. For these
+ changes, you must edit the config file and import it again. The shell preference can be
+ edited, but will return to the default if you import again. It will stay changed if you
+ follow this procedure .
+
+ }
+ icon={ }
+ >
+
+
+ SSH Config Import Behavior
+
+ );
+ }
+
renderAuthMode() {
let authMode = this.tempAuthMode.get();
return (
@@ -344,6 +369,7 @@ class EditRemoteConnModal extends React.Component<{}, {}> {
return null;
}
let isLocal = this.isLocalRemote();
+ let isImported = this.isImportedRemote();
return (
@@ -351,9 +377,10 @@ class EditRemoteConnModal extends React.Component<{}, {}> {
{util.getRemoteName(this.selectedRemote)}
- {this.renderAlias()}
- {this.renderAuthMode()}
- {this.renderConnectMode()}
+ {this.renderAlias()}
+ {this.renderAuthMode()}
+ {this.renderConnectMode()}
+ {this.renderImportedRemoteEditWarning()}
{this.renderShellPref()}
Error: {this.remoteEdit?.errorstr}
diff --git a/src/app/common/modals/modals.tsx b/src/app/common/modals/modals.tsx
index fb3010e6b..e154296bf 100644
--- a/src/app/common/modals/modals.tsx
+++ b/src/app/common/modals/modals.tsx
@@ -1026,17 +1026,6 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
cancelInstallButton = <>>;
}
if (remote.sshconfigsrc == "sshconfig-import") {
- updateAuthButton = (
-
- Edit
- }
- >
-
-
-
- );
archiveButton = (
this.clickArchive()}>
Delete
diff --git a/src/app/common/modals/viewremoteconndetail.tsx b/src/app/common/modals/viewremoteconndetail.tsx
index 5fa461fb4..c10b20987 100644
--- a/src/app/common/modals/viewremoteconndetail.tsx
+++ b/src/app/common/modals/viewremoteconndetail.tsx
@@ -209,17 +209,6 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
cancelInstallButton = <>>;
}
if (remote.sshconfigsrc == "sshconfig-import") {
- updateAuthButton = (
-
- Edit
- }
- >
-
-
-
- );
archiveButton = (
this.clickArchive()}>
Delete
diff --git a/wavesrv/pkg/cmdrunner/cmdrunner.go b/wavesrv/pkg/cmdrunner/cmdrunner.go
index 6f681177f..718c83fdc 100644
--- a/wavesrv/pkg/cmdrunner/cmdrunner.go
+++ b/wavesrv/pkg/cmdrunner/cmdrunner.go
@@ -1420,9 +1420,6 @@ func RemoteSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (ss
if err != nil {
return nil, err
}
- if ids.Remote.RState.SSHConfigSrc == sstore.SSHConfigSrcTypeImport {
- return nil, fmt.Errorf("/remote:new cannot update imported remote")
- }
visualEdit := resolveBool(pk.Kwargs["visual"], false)
isSubmitted := resolveBool(pk.Kwargs["submit"], false)
editArgs, err := parseRemoteEditArgs(false, pk, ids.Remote.MShell.IsLocal())
@@ -1542,6 +1539,7 @@ type HostInfoType struct {
SshKeyFile string
ConnectMode string
Ignore bool
+ ShellPref string
}
func createSshImportSummary(changeList map[string][]string) string {
@@ -1637,6 +1635,13 @@ func NewHostInfo(hostName string) (*HostInfoType, error) {
connectMode = sstore.ConnectModeManual
}
+ shellPref := sstore.ShellTypePref_Detect
+ if cfgWaveOptions["shellpref"] == "bash" {
+ shellPref = "bash"
+ } else if cfgWaveOptions["shellpref"] == "zsh" {
+ shellPref = "zsh"
+ }
+
outHostInfo := new(HostInfoType)
outHostInfo.Host = hostName
outHostInfo.User = userName
@@ -1645,6 +1650,7 @@ func NewHostInfo(hostName string) (*HostInfoType, error) {
outHostInfo.SshKeyFile = sshKeyFile
outHostInfo.ConnectMode = connectMode
outHostInfo.Ignore = shouldIgnore
+ outHostInfo.ShellPref = shellPref
return outHostInfo, nil
}
@@ -1709,6 +1715,7 @@ func RemoteConfigParseCommand(ctx context.Context, pk *scpacket.FeCommandPacketT
if hostInfo.SshKeyFile != "" {
editMap[sstore.RemoteField_SSHKey] = hostInfo.SshKeyFile
}
+ editMap[sstore.RemoteField_ShellPref] = hostInfo.ShellPref
msh := remote.GetRemoteById(previouslyImportedRemote.RemoteId)
if msh == nil {
remoteChangeList["updateErr"] = append(remoteChangeList["updateErr"], hostInfo.CanonicalName)
@@ -1716,7 +1723,7 @@ func RemoteConfigParseCommand(ctx context.Context, pk *scpacket.FeCommandPacketT
continue
}
- if msh.Remote.ConnectMode == hostInfo.ConnectMode && msh.Remote.SSHOpts.SSHIdentity == hostInfo.SshKeyFile && msh.Remote.RemoteAlias == hostInfo.Host {
+ if msh.Remote.ConnectMode == hostInfo.ConnectMode && msh.Remote.SSHOpts.SSHIdentity == hostInfo.SshKeyFile && msh.Remote.RemoteAlias == hostInfo.Host && msh.Remote.ShellPref == hostInfo.ShellPref {
// silently skip this one. it didn't fail, but no changes were needed
continue
}
@@ -1753,6 +1760,7 @@ func RemoteConfigParseCommand(ctx context.Context, pk *scpacket.FeCommandPacketT
AutoInstall: true,
SSHOpts: sshOpts,
SSHConfigSrc: sstore.SSHConfigSrcTypeImport,
+ ShellPref: sstore.ShellTypePref_Detect,
}
err := remote.AddRemote(ctx, r, false)
if err != nil {