Skip to content

Commit 5148511

Browse files
committed
add an "add" button when there are no secrets, also add wsh secret ui cli command
1 parent 27b3df8 commit 5148511

3 files changed

Lines changed: 59 additions & 3 deletions

File tree

cmd/wsh/cmd/wshcmd-secret.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010

1111
"github.com/spf13/cobra"
12+
"github.com/wavetermdev/waveterm/pkg/waveobj"
1213
"github.com/wavetermdev/waveterm/pkg/wshrpc"
1314
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient"
1415
)
@@ -54,12 +55,21 @@ var secretDeleteCmd = &cobra.Command{
5455
PreRunE: preRunSetupRpcClient,
5556
}
5657

58+
var secretUiCmd = &cobra.Command{
59+
Use: "ui",
60+
Short: "open secrets UI",
61+
Args: cobra.NoArgs,
62+
RunE: secretUiRun,
63+
PreRunE: preRunSetupRpcClient,
64+
}
65+
5766
func init() {
5867
rootCmd.AddCommand(secretCmd)
5968
secretCmd.AddCommand(secretGetCmd)
6069
secretCmd.AddCommand(secretSetCmd)
6170
secretCmd.AddCommand(secretListCmd)
6271
secretCmd.AddCommand(secretDeleteCmd)
72+
secretCmd.AddCommand(secretUiCmd)
6373
}
6474

6575
func secretGetRun(cmd *cobra.Command, args []string) (rtnErr error) {
@@ -156,4 +166,26 @@ func secretDeleteRun(cmd *cobra.Command, args []string) (rtnErr error) {
156166

157167
WriteStdout("secret deleted: %s\n", name)
158168
return nil
169+
}
170+
171+
func secretUiRun(cmd *cobra.Command, args []string) (rtnErr error) {
172+
defer func() {
173+
sendActivity("secret", rtnErr == nil)
174+
}()
175+
176+
wshCmd := &wshrpc.CommandCreateBlockData{
177+
BlockDef: &waveobj.BlockDef{
178+
Meta: map[string]interface{}{
179+
waveobj.MetaKey_View: "secretstore",
180+
},
181+
},
182+
Magnified: false,
183+
Focused: true,
184+
}
185+
186+
_, err := RpcClient.SendRpcRequest(wshrpc.Command_CreateBlock, wshCmd, &wshrpc.RpcOpts{Timeout: 2000})
187+
if err != nil {
188+
return fmt.Errorf("opening secrets UI: %w", err)
189+
}
190+
return nil
159191
}

docs/docs/wsh-reference.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,23 @@ wsh secret delete old_api_key
978978
wsh secret delete temp_token
979979
```
980980
981+
### ui
982+
983+
```sh
984+
wsh secret ui
985+
```
986+
987+
Open the secrets management interface in a new block. This provides a graphical interface for viewing and managing all your secrets.
988+
989+
Example:
990+
991+
```sh
992+
# Open the secrets UI
993+
wsh secret ui
994+
```
995+
996+
The secrets UI provides a convenient visual way to browse, add, edit, and delete secrets without needing to use the command-line interface.
997+
981998
:::tip
982999
Use secrets in your scripts to avoid hardcoding sensitive values. Secrets work across remote machines - store an API key locally with `wsh secret set`, then access it from any SSH or WSL connection with `wsh secret get`. The secret is securely retrieved from your local machine without needing to duplicate it on remote systems.
9831000
:::

frontend/app/view/secretstore/secretstore.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,19 @@ const LoadingSpinner = memo(({ message }: { message: string }) => {
3838
});
3939
LoadingSpinner.displayName = "LoadingSpinner";
4040

41-
const EmptyState = memo(() => {
41+
const EmptyState = memo(({ onAddSecret }: { onAddSecret: () => void }) => {
4242
return (
43-
<div className="flex flex-col items-center justify-center gap-3 py-12">
43+
<div className="flex flex-col items-center justify-center gap-4 py-12">
4444
<i className="fa-sharp fa-solid fa-key text-4xl text-gray-600" />
4545
<h3 className="text-lg font-semibold text-gray-400">No Secrets</h3>
4646
<p className="text-gray-500">Add a secret to get started</p>
47+
<button
48+
className="flex items-center gap-2 px-4 py-2 bg-accent-600 hover:bg-accent-500 rounded cursor-pointer transition-colors"
49+
onClick={onAddSecret}
50+
>
51+
<i className="fa-sharp fa-solid fa-plus" />
52+
<span className="font-medium">Add New Secret</span>
53+
</button>
4754
</div>
4855
);
4956
});
@@ -352,7 +359,7 @@ export const SecretStoreView = memo(({ model }: { blockId: string; model: Secret
352359
}
353360

354361
if (secretNames.length === 0) {
355-
return <EmptyState />;
362+
return <EmptyState onAddSecret={() => model.startAddingSecret()} />;
356363
}
357364

358365
return (

0 commit comments

Comments
 (0)