@@ -24,7 +24,6 @@ import (
2424 "github.com/brevdev/brev-cli/pkg/cmdcontext"
2525 "github.com/brevdev/brev-cli/pkg/config"
2626 "github.com/brevdev/brev-cli/pkg/entity"
27- "github.com/brevdev/brev-cli/pkg/entity/virtualproject"
2827 breverrors "github.com/brevdev/brev-cli/pkg/errors"
2928 "github.com/brevdev/brev-cli/pkg/featureflag"
3029 "github.com/brevdev/brev-cli/pkg/store"
@@ -383,27 +382,14 @@ func (ls Ls) RunUser(_ bool) error {
383382 return nil
384383}
385384
386- func (ls Ls ) ShowAllWorkspaces (org * entity.Organization , otherOrgs []entity.Organization , user * entity.User , allWorkspaces []entity.Workspace , gpuLookup map [string ]string ) {
387- userWorkspaces := store .FilterForUserWorkspaces (allWorkspaces , user .ID )
388- ls .displayWorkspacesAndHelp (org , otherOrgs , userWorkspaces , allWorkspaces , gpuLookup )
389-
390- projects := virtualproject .NewVirtualProjects (allWorkspaces )
391-
392- var unjoinedProjects []virtualproject.VirtualProject
393- for _ , p := range projects {
394- wks := p .GetUserWorkspaces (user .ID )
395- if len (wks ) == 0 {
396- unjoinedProjects = append (unjoinedProjects , p )
397- }
398- }
399-
400- displayProjects (ls .terminal , org .Name , unjoinedProjects )
385+ func (ls Ls ) ShowAllWorkspaces (org * entity.Organization , otherOrgs []entity.Organization , workspacesToShow []entity.Workspace , gpuLookup map [string ]string ) {
386+ ls .displayWorkspacesAndHelp (org , otherOrgs , workspacesToShow , workspacesToShow , true , gpuLookup )
401387}
402388
403389func (ls Ls ) ShowUserWorkspaces (org * entity.Organization , otherOrgs []entity.Organization , user * entity.User , allWorkspaces []entity.Workspace , gpuLookup map [string ]string ) {
404390 userWorkspaces := store .FilterForUserWorkspaces (allWorkspaces , user .ID )
405391
406- ls .displayWorkspacesAndHelp (org , otherOrgs , userWorkspaces , allWorkspaces , gpuLookup )
392+ ls .displayWorkspacesAndHelp (org , otherOrgs , userWorkspaces , allWorkspaces , false , gpuLookup )
407393}
408394
409395func (ls Ls ) ShowOrgWorkspaces (org * entity.Organization , workspaces []entity.Workspace , gpuLookup map [string ]string ) {
@@ -417,10 +403,10 @@ func (ls Ls) ShowOrgWorkspaces(org *entity.Organization, workspaces []entity.Wor
417403 fmt .Print ("\n " )
418404}
419405
420- func (ls Ls ) displayWorkspacesAndHelp (org * entity.Organization , otherOrgs []entity.Organization , userWorkspaces []entity.Workspace , allWorkspaces []entity.Workspace , gpuLookup map [string ]string ) {
421- if len (userWorkspaces ) == 0 {
406+ func (ls Ls ) displayWorkspacesAndHelp (org * entity.Organization , otherOrgs []entity.Organization , workspacesToDisplay []entity.Workspace , allWorkspaces []entity.Workspace , showAll bool , gpuLookup map [string ]string ) {
407+ if len (workspacesToDisplay ) == 0 {
422408 ls .terminal .Vprint (ls .terminal .Yellow ("No instances in org %s\n " , org .Name ))
423- if len (allWorkspaces ) > 0 {
409+ if ! showAll && len (allWorkspaces ) > 0 {
424410 ls .terminal .Vprintf ("%s" , ls .terminal .Green ("See teammates' instances:\n " ))
425411 ls .terminal .Vprintf ("%s" , ls .terminal .Yellow ("\t brev ls --all\n " ))
426412 } else {
@@ -432,8 +418,12 @@ func (ls Ls) displayWorkspacesAndHelp(org *entity.Organization, otherOrgs []enti
432418 ls .terminal .Vprintf ("%s" , ls .terminal .Yellow (fmt .Sprintf ("\t brev set %s\n " , getOtherOrg (otherOrgs , * org ).Name )))
433419 }
434420 } else {
435- ls .terminal .Vprintf ("You have %d instances in Org %s\n " , len (userWorkspaces ), ls .terminal .Yellow (org .Name ))
436- displayWorkspacesTable (ls .terminal , userWorkspaces , gpuLookup )
421+ if showAll {
422+ ls .terminal .Vprintf ("%d instances in Org %s\n " , len (workspacesToDisplay ), ls .terminal .Yellow (org .Name ))
423+ } else {
424+ ls .terminal .Vprintf ("You have %d instances in Org %s\n " , len (workspacesToDisplay ), ls .terminal .Yellow (org .Name ))
425+ }
426+ displayWorkspacesTable (ls .terminal , workspacesToDisplay , gpuLookup )
437427
438428 fmt .Print ("\n " )
439429 }
@@ -530,7 +520,7 @@ func (ls Ls) RunWorkspaces(cliAuth auth.CLIAuth, org *entity.Organization, showA
530520 return breverrors .WrapAndTrace (err )
531521 }
532522 if showAll {
533- ls .ShowAllWorkspaces (org , orgs , user , allWorkspaces , gpuLookup )
523+ ls .ShowAllWorkspaces (org , orgs , workspacesToShow , gpuLookup )
534524 if len (nodes ) > 0 {
535525 ls .terminal .Vprintf ("\n You have %d external node(s) in Org %s\n " , len (nodes ), ls .terminal .Yellow (org .Name ))
536526 displayNodesTable (ls .terminal , nodes , ls .piped )
@@ -662,23 +652,6 @@ func (ls Ls) RunHosts(org *entity.Organization) error {
662652 return nil
663653}
664654
665- func displayProjects (t * terminal.Terminal , orgName string , projects []virtualproject.VirtualProject ) {
666- if len (projects ) > 0 {
667- fmt .Print ("\n " )
668- t .Vprintf ("%d other projects in Org %s\n " , len (projects ), t .Yellow (orgName ))
669- displayProjectsTable (projects )
670-
671- fmt .Print ("\n " )
672- t .Vprintf ("%s" , t .Green ("Join a project:\n " )+
673- t .Yellow (fmt .Sprintf ("\t brev start %s\n " , projects [0 ].Name )))
674- } else {
675- t .Vprintf ("no other projects in Org %s\n " , t .Yellow (orgName ))
676- fmt .Print ("\n " )
677- t .Vprintf ("%s" , t .Green ("Invite a teamate:\n " )+
678- t .Yellow ("\t brev invite" ))
679- }
680- }
681-
682655func getBrevTableOptions () table.Options {
683656 options := table .OptionsDefault
684657 options .DrawBorder = false
@@ -775,19 +748,6 @@ func displayOrgTable(t *terminal.Terminal, orgs []entity.Organization, currentOr
775748 ta .Render ()
776749}
777750
778- func displayProjectsTable (projects []virtualproject.VirtualProject ) {
779- ta := table .NewWriter ()
780- ta .SetOutputMirror (os .Stdout )
781- ta .Style ().Options = getBrevTableOptions ()
782- header := table.Row {"NAME" , "MEMBERS" }
783- ta .AppendHeader (header )
784- for _ , p := range projects {
785- workspaceRow := []table.Row {{p .Name , p .GetUniqueUserCount ()}}
786- ta .AppendRows (workspaceRow )
787- }
788- ta .Render ()
789- }
790-
791751func getStatusColoredText (t * terminal.Terminal , status string ) string {
792752 switch status {
793753 case entity .Running , entity .Ready , string (entity .Completed ):
0 commit comments