From 4ece667aaa99d6f2c7f9630f30f239c1a12c85e1 Mon Sep 17 00:00:00 2001 From: MrStashley Date: Wed, 13 Mar 2024 13:42:36 -0700 Subject: [PATCH] added mainview slashcommand --- assets/default-keybindings.json | 5 +++-- src/models/model.ts | 11 +++++++---- wavesrv/pkg/cmdrunner/cmdrunner.go | 24 ++++++++++++++++++++++++ wavesrv/pkg/sstore/sstore.go | 8 +++++--- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/assets/default-keybindings.json b/assets/default-keybindings.json index 98306e0ad..86a31d96b 100644 --- a/assets/default-keybindings.json +++ b/assets/default-keybindings.json @@ -42,11 +42,12 @@ { "command": "app:openConnectionsView", "keys": [], - "commandStr": "/remote:show" + "commandStr": "/mainview connections" }, { "command": "app:openSettingsView", - "keys": [] + "keys": [], + "commandStr": "/mainview clientsettings" }, { "command": "app:newTab", diff --git a/src/models/model.ts b/src/models/model.ts index 1da481ba3..ee7fa3539 100644 --- a/src/models/model.ts +++ b/src/models/model.ts @@ -240,10 +240,7 @@ class Model { return true; }); this.keybindManager.registerKeybinding("app", "model", "app:openConnectionsView", null); - this.keybindManager.registerKeybinding("app", "model", "app:openSettingsView", (waveEvent) => { - this.onOpenSettingsViewPressed(); - return true; - }); + this.keybindManager.registerKeybinding("app", "model", "app:openSettingsView", null); } static getInstance(): Model { @@ -1005,6 +1002,12 @@ class Model { console.warn("invalid bookmarksview in update:", update.mainview); } break; + case "clientsettings": + this.activeMainView.set("clientsettings"); + break; + case "connections": + this.activeMainView.set("connections"); + break; case "plugins": this.pluginsModel.showPluginsView(); break; diff --git a/wavesrv/pkg/cmdrunner/cmdrunner.go b/wavesrv/pkg/cmdrunner/cmdrunner.go index 5d4bd4711..fe5ff37fb 100644 --- a/wavesrv/pkg/cmdrunner/cmdrunner.go +++ b/wavesrv/pkg/cmdrunner/cmdrunner.go @@ -172,6 +172,8 @@ func init() { registerCmdFn("signal", SignalCommand) registerCmdFn("sync", SyncCommand) + registerCmdFn("mainview", MainViewCommand) + registerCmdFn("session", SessionCommand) registerCmdFn("session:open", SessionOpenCommand) registerCmdAlias("session:new", SessionOpenCommand) @@ -3560,6 +3562,28 @@ func SessionSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (s return update, nil } +func MainViewCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.UpdatePacket, error) { + if len(pk.Args) < 1 { + return nil, fmt.Errorf("no argument found - usage: /mainview [view]") + } + update := scbus.MakeUpdatePacket() + mainViewArg := pk.Args[0] + if mainViewArg == sstore.MainViewSession { + update.AddUpdate(&sstore.MainViewUpdate{MainView: sstore.MainViewSession}) + } else if mainViewArg == sstore.MainViewConnections { + update.AddUpdate(&sstore.MainViewUpdate{MainView: sstore.MainViewConnections}) + } else if mainViewArg == sstore.MainViewSettings { + update.AddUpdate(&sstore.MainViewUpdate{MainView: sstore.MainViewSettings}) + } else if mainViewArg == sstore.MainViewHistory { + return nil, fmt.Errorf("use /history instead") + } else if mainViewArg == sstore.MainViewBookmarks { + return nil, fmt.Errorf("use /bookmarks instead") + } else { + return nil, fmt.Errorf("unrecognized main view") + } + return update, nil +} + func SessionCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.UpdatePacket, error) { ids, err := resolveUiIds(ctx, pk, 0) if err != nil { diff --git a/wavesrv/pkg/sstore/sstore.go b/wavesrv/pkg/sstore/sstore.go index ba07baa44..294594357 100644 --- a/wavesrv/pkg/sstore/sstore.go +++ b/wavesrv/pkg/sstore/sstore.go @@ -71,9 +71,11 @@ const ( ) const ( - MainViewSession = "session" - MainViewBookmarks = "bookmarks" - MainViewHistory = "history" + MainViewSession = "session" + MainViewBookmarks = "bookmarks" + MainViewHistory = "history" + MainViewConnections = "connections" + MainViewSettings = "clientsettings" ) const (