feat(cli): show workspace favorite status in list output (#11878)

This commit is contained in:
Cian Johnston
2024-01-29 14:14:12 +00:00
committed by GitHub
parent 9abf6ec170
commit eeef56a655
3 changed files with 12 additions and 5 deletions

View File

@ -22,6 +22,7 @@ type workspaceListRow struct {
codersdk.Workspace `table:"-"`
// For table format:
Favorite bool `json:"-" table:"favorite"`
WorkspaceName string `json:"-" table:"workspace,default_sort"`
Template string `json:"-" table:"template"`
Status string `json:"-" table:"status"`
@ -46,9 +47,15 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace)
if status == "Starting" || status == "Started" {
healthy = strconv.FormatBool(workspace.Health.Healthy)
}
favIco := " "
if workspace.Favorite {
favIco = "★"
}
workspaceName := favIco + " " + workspace.OwnerName + "/" + workspace.Name
return workspaceListRow{
Favorite: workspace.Favorite,
Workspace: workspace,
WorkspaceName: workspace.OwnerName + "/" + workspace.Name,
WorkspaceName: workspaceName,
Template: workspace.TemplateName,
Status: status,
Healthy: healthy,