Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/plugins/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (r *pluginResource) Commands() []resource.Command {
Key: command.Key,
Description: command.Description,
Default: command.Default,
StatusLabel: command.StatusLabel,
})
}

Expand Down Expand Up @@ -92,6 +93,7 @@ func (r *pluginResource) Execute(command resource.Command, row resource.Row) tea
Key: command.Key,
Description: command.Description,
Default: command.Default,
StatusLabel: command.StatusLabel,
}, pluginsdk.Row{
ID: row.ID,
Fields: row.Fields,
Expand Down
2 changes: 2 additions & 0 deletions internal/resource/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ type NavigateScopedMsg struct {
type ErrorMsg struct {
Err error
}

type CommandCompletedMsg struct{}
1 change: 1 addition & 0 deletions internal/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Command struct {
Key string
Description string
Default bool
StatusLabel string
}

type Resource interface {
Expand Down
5 changes: 5 additions & 0 deletions internal/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,11 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

return m, nil

case resource.CommandCompletedMsg:
m.showLoading = false
m.loadingLabel = ""
return m, nil

}

var cmd tea.Cmd
Expand Down
18 changes: 13 additions & 5 deletions internal/ui/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,26 @@ func (m *Model) executeResourceCommand(key string) tea.Cmd {
if command.Key == key {
row := m.resourceRows[cursor]

m.showLoading = true
m.loadingLabel = command.StatusLabel
if m.loadingLabel == "" {
m.loadingLabel = "Loading..."
}

if m.resource.Kind() == "contexts" && key == "a" {
m.activatingContext = true
m.showLoading = true
m.loadingLabel = "Connecting to " + row.ID + "..."
}

if key == "s" {
m.showLoading = true
m.loadingLabel = "Loading..."
}
cmd := m.resource.Execute(command, row)

return m.resource.Execute(command, row)
return tea.Sequence(
cmd,
func() tea.Msg {
return resource.CommandCompletedMsg{}
},
)
}
}

Expand Down
2 changes: 2 additions & 0 deletions pluginsdk/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (r *grpcResource) Commands() []Command {
Key: command.Key,
Description: command.Description,
Default: command.Default,
StatusLabel: command.StatusLabel,
})
}

Expand Down Expand Up @@ -119,6 +120,7 @@ func (r *grpcResource) Execute(ctx context.Context, command Command, row Row) (R
Key: command.Key,
Description: command.Description,
Default: command.Default,
StatusLabel: command.StatusLabel,
},
Row: &pb.Row{
Id: row.ID,
Expand Down
2 changes: 2 additions & 0 deletions pluginsdk/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (s *grpcServer) GetResources(context.Context, *pb.Empty) (*pb.Resources, er
Key: command.Key,
Description: command.Description,
Default: command.Default,
StatusLabel: command.StatusLabel,
})
}

Expand Down Expand Up @@ -124,6 +125,7 @@ func (s *grpcServer) Execute(ctx context.Context, request *pb.ExecuteRequest) (*
Key: request.Command.Key,
Description: request.Command.Description,
Default: request.Command.Default,
StatusLabel: request.Command.StatusLabel,
}, Row{
ID: request.Row.Id,
Fields: request.Row.Fields,
Expand Down
1 change: 1 addition & 0 deletions pluginsdk/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Command struct {
Key string
Description string
Default bool
StatusLabel string
}

type Resource interface {
Expand Down
13 changes: 11 additions & 2 deletions pluginsdk/proto/plugin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pluginsdk/proto/plugin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ message Command {
string key = 1;
string description = 2;
bool default = 3;
string status_label = 4;
}

message Row {
Expand Down
Loading