From 267b035fc86b4442a602ca693f20a69fbff1aa4c Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 25 Oct 2023 22:07:00 -0700 Subject: [PATCH] remove autoinstall options from GUI, always set autoinstall flag, db migration to set autoinstall for all remotes (#48) --- src/app/connections/connections.tsx | 51 ------------------- .../db/migrations/000023_autoinstall.down.sql | 1 + .../db/migrations/000023_autoinstall.up.sql | 1 + wavesrv/pkg/cmdrunner/cmdrunner.go | 6 +-- wavesrv/pkg/sstore/dbops.go | 11 ++-- wavesrv/pkg/sstore/migrate.go | 4 +- 6 files changed, 8 insertions(+), 66 deletions(-) create mode 100644 wavesrv/db/migrations/000023_autoinstall.down.sql create mode 100644 wavesrv/db/migrations/000023_autoinstall.up.sql diff --git a/src/app/connections/connections.tsx b/src/app/connections/connections.tsx index 50aa3cad..6b0c5510 100644 --- a/src/app/connections/connections.tsx +++ b/src/app/connections/connections.tsx @@ -153,7 +153,6 @@ class CreateRemote extends React.Component<{ model: RemotesModalModel; remoteEdi tempManualMode: OV; tempPassword: OV; tempKeyFile: OV; - tempAutoInstall: OV; errorStr: OV; constructor(props: any) { @@ -166,7 +165,6 @@ class CreateRemote extends React.Component<{ model: RemotesModalModel; remoteEdi this.tempConnectMode = mobx.observable.box("auto", { name: "CreateRemote-connectMode" }); this.tempKeyFile = mobx.observable.box("", { name: "CreateRemote-keystr" }); this.tempPassword = mobx.observable.box("", { name: "CreateRemote-password" }); - this.tempAutoInstall = mobx.observable.box(true, { name: "CreateRemote-autoinstall" }); this.errorStr = mobx.observable.box(remoteEdit.errorstr, { name: "CreateRemote-errorStr" }); } @@ -223,7 +221,6 @@ class CreateRemote extends React.Component<{ model: RemotesModalModel; remoteEdi kwargs["password"] = ""; } kwargs["connectmode"] = this.tempConnectMode.get(); - kwargs["autoinstall"] = this.tempAutoInstall.get() ? "1" : "0"; kwargs["visual"] = "1"; kwargs["submit"] = "1"; let model = this.props.model; @@ -286,13 +283,6 @@ class CreateRemote extends React.Component<{ model: RemotesModalModel; remoteEdi })(); } - @boundMethod - handleChangeAutoInstall(val: boolean): void { - mobx.action(() => { - this.tempAutoInstall.set(val); - })(); - } - render() { let { model, remoteEdit } = this.props; let authMode = this.tempAuthMode.get(); @@ -438,19 +428,6 @@ class CreateRemote extends React.Component<{ model: RemotesModalModel; remoteEdi -
-
-
Auto Install
-
- - If selected, will try to auto-install the mshell client if it is not installed or out of - date. - -
-
- -
-
Error: {this.getErrorStr()}
@@ -484,7 +461,6 @@ class EditRemoteSettings extends React.Component< tempManualMode: OV; tempPassword: OV; tempKeyFile: OV; - tempAutoInstall: OV; constructor(props: any) { super(props); @@ -496,7 +472,6 @@ class EditRemoteSettings extends React.Component< this.tempPassword = mobx.observable.box(remoteEdit.haspassword ? PasswordUnchangedSentinel : "", { name: "EditRemoteSettings-password", }); - this.tempAutoInstall = mobx.observable.box(!!remote.autoinstall, { name: "EditRemoteSettings-autoinstall" }); } componentDidUpdate() { @@ -552,13 +527,6 @@ class EditRemoteSettings extends React.Component< })(); } - @boundMethod - handleChangeAutoInstall(val: boolean): void { - mobx.action(() => { - this.tempAutoInstall.set(val); - })(); - } - @boundMethod canResetPw(): boolean { let { remoteEdit } = this.props; @@ -609,9 +577,6 @@ class EditRemoteSettings extends React.Component< if (!util.isStrEq(this.tempConnectMode.get(), remote.connectmode)) { kwargs["connectmode"] = this.tempConnectMode.get(); } - if (!util.isBoolEq(this.tempAutoInstall.get(), remote.autoinstall)) { - kwargs["autoinstall"] = this.tempAutoInstall.get() ? "1" : "0"; - } if (Object.keys(kwargs).length == 0) { return; } @@ -758,19 +723,6 @@ class EditRemoteSettings extends React.Component<
-
-
-
Auto Install
-
- - If selected, will try to auto-install the mshell client if it is not installed or out of - date. - -
-
- -
-
Actions
@@ -891,9 +843,6 @@ class RemoteDetailView extends React.Component<{ model: RemotesModalModel; remot if (statusStr == null) { return null; } - if (remote.autoinstall) { - statusStr = statusStr + " (autoinstall)"; - } return (
Install Status
diff --git a/wavesrv/db/migrations/000023_autoinstall.down.sql b/wavesrv/db/migrations/000023_autoinstall.down.sql new file mode 100644 index 00000000..b4eaa212 --- /dev/null +++ b/wavesrv/db/migrations/000023_autoinstall.down.sql @@ -0,0 +1 @@ +-- no down migration diff --git a/wavesrv/db/migrations/000023_autoinstall.up.sql b/wavesrv/db/migrations/000023_autoinstall.up.sql new file mode 100644 index 00000000..d9eacd9e --- /dev/null +++ b/wavesrv/db/migrations/000023_autoinstall.up.sql @@ -0,0 +1 @@ +UPDATE remote SET autoinstall = 1; diff --git a/wavesrv/pkg/cmdrunner/cmdrunner.go b/wavesrv/pkg/cmdrunner/cmdrunner.go index a340675c..e3ea8861 100644 --- a/wavesrv/pkg/cmdrunner/cmdrunner.go +++ b/wavesrv/pkg/cmdrunner/cmdrunner.go @@ -1047,7 +1047,6 @@ func parseRemoteEditArgs(isNew bool, pk *scpacket.FeCommandPacketType, isLocal b err := fmt.Errorf("invalid connectmode %q: valid modes are %s", connectMode, formatStrs([]string{sstore.ConnectModeStartup, sstore.ConnectModeAuto, sstore.ConnectModeManual}, "or", false)) return nil, err } - autoInstall := resolveBool(pk.Kwargs["autoinstall"], true) keyFile, err := resolveFile(pk.Kwargs["key"]) if err != nil { return nil, fmt.Errorf("invalid ssh keyfile %q: %v", pk.Kwargs["key"], err) @@ -1076,9 +1075,6 @@ func parseRemoteEditArgs(isNew bool, pk *scpacket.FeCommandPacketType, isLocal b } editMap[sstore.RemoteField_ConnectMode] = connectMode } - if _, found := pk.Kwargs[sstore.RemoteField_AutoInstall]; found { - editMap[sstore.RemoteField_AutoInstall] = autoInstall - } if _, found := pk.Kwargs["key"]; found { if isLocal { return nil, fmt.Errorf("Cannot edit ssh key file for 'local' remote") @@ -1099,7 +1095,7 @@ func parseRemoteEditArgs(isNew bool, pk *scpacket.FeCommandPacketType, isLocal b SSHOpts: sshOpts, ConnectMode: connectMode, Alias: alias, - AutoInstall: autoInstall, + AutoInstall: true, CanonicalName: canonicalName, SSHKeyFile: keyFile, SSHPassword: sshPassword, diff --git a/wavesrv/pkg/sstore/dbops.go b/wavesrv/pkg/sstore/dbops.go index 593ef3e4..361d74a4 100644 --- a/wavesrv/pkg/sstore/dbops.go +++ b/wavesrv/pkg/sstore/dbops.go @@ -13,14 +13,14 @@ import ( "sync" "time" + "github.com/google/uuid" + "github.com/jmoiron/sqlx" + "github.com/sawka/txwrap" "github.com/wavetermdev/waveterm/waveshell/pkg/base" "github.com/wavetermdev/waveterm/waveshell/pkg/packet" "github.com/wavetermdev/waveterm/waveshell/pkg/shexec" "github.com/wavetermdev/waveterm/wavesrv/pkg/dbutil" "github.com/wavetermdev/waveterm/wavesrv/pkg/scbase" - "github.com/google/uuid" - "github.com/jmoiron/sqlx" - "github.com/sawka/txwrap" ) const HistoryCols = "h.historyid, h.ts, h.userid, h.sessionid, h.screenid, h.lineid, h.haderror, h.cmdstr, h.remoteownerid, h.remoteid, h.remotename, h.ismetacmd, h.incognito, h.linenum" @@ -1644,7 +1644,6 @@ func GetSessionStats(ctx context.Context, sessionId string) (*SessionStatsType, const ( RemoteField_Alias = "alias" // string RemoteField_ConnectMode = "connectmode" // string - RemoteField_AutoInstall = "autoinstall" // bool RemoteField_SSHKey = "sshkey" // string RemoteField_SSHPassword = "sshpassword" // string RemoteField_Color = "color" // string @@ -1670,10 +1669,6 @@ func UpdateRemote(ctx context.Context, remoteId string, editMap map[string]inter query = `UPDATE remote SET connectmode = ? WHERE remoteid = ?` tx.Exec(query, mode, remoteId) } - if autoInstall, found := editMap[RemoteField_AutoInstall]; found { - query = `UPDATE remote SET autoinstall = ? WHERE remoteid = ?` - tx.Exec(query, autoInstall, remoteId) - } if sshKey, found := editMap[RemoteField_SSHKey]; found { query = `UPDATE remote SET sshopts = json_set(sshopts, '$.sshidentity', ?) WHERE remoteid = ?` tx.Exec(query, sshKey, remoteId) diff --git a/wavesrv/pkg/sstore/migrate.go b/wavesrv/pkg/sstore/migrate.go index 566c30b0..eefce745 100644 --- a/wavesrv/pkg/sstore/migrate.go +++ b/wavesrv/pkg/sstore/migrate.go @@ -11,16 +11,16 @@ import ( "strconv" "time" - sh2db "github.com/wavetermdev/waveterm/wavesrv/db" _ "github.com/golang-migrate/migrate/v4/database/sqlite3" _ "github.com/golang-migrate/migrate/v4/source/file" "github.com/golang-migrate/migrate/v4/source/iofs" _ "github.com/mattn/go-sqlite3" + sh2db "github.com/wavetermdev/waveterm/wavesrv/db" "github.com/golang-migrate/migrate/v4" ) -const MaxMigration = 22 +const MaxMigration = 23 const MigratePrimaryScreenVersion = 9 const CmdScreenSpecialMigration = 13 const CmdLineSpecialMigration = 20