@@ -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 ) {
@@ -419,10 +405,10 @@ func (ls Ls) ShowOrgWorkspaces(org *entity.Organization, workspaces []entity.Wor
419405 displayLsResetBreadCrumb (ls .terminal , workspaces )
420406}
421407
422- func (ls Ls ) displayWorkspacesAndHelp (org * entity.Organization , otherOrgs []entity.Organization , userWorkspaces []entity.Workspace , allWorkspaces []entity.Workspace , gpuLookup map [string ]string ) {
423- if len (userWorkspaces ) == 0 {
408+ func (ls Ls ) displayWorkspacesAndHelp (org * entity.Organization , otherOrgs []entity.Organization , workspacesToDisplay []entity.Workspace , allWorkspaces []entity.Workspace , showAll bool , gpuLookup map [string ]string ) {
409+ if len (workspacesToDisplay ) == 0 {
424410 ls .terminal .Vprint (ls .terminal .Yellow ("No instances in org %s\n " , org .Name ))
425- if len (allWorkspaces ) > 0 {
411+ if ! showAll && len (allWorkspaces ) > 0 {
426412 ls .terminal .Vprintf ("%s" , ls .terminal .Green ("See teammates' instances:\n " ))
427413 ls .terminal .Vprintf ("%s" , ls .terminal .Yellow ("\t brev ls --all\n " ))
428414 } else {
@@ -434,13 +420,17 @@ func (ls Ls) displayWorkspacesAndHelp(org *entity.Organization, otherOrgs []enti
434420 ls .terminal .Vprintf ("%s" , ls .terminal .Yellow (fmt .Sprintf ("\t brev set %s\n " , getOtherOrg (otherOrgs , * org ).Name )))
435421 }
436422 } else {
437- ls .terminal .Vprintf ("You have %d instances in Org %s\n " , len (userWorkspaces ), ls .terminal .Yellow (org .Name ))
438- displayWorkspacesTable (ls .terminal , userWorkspaces , gpuLookup )
423+ if showAll {
424+ ls .terminal .Vprintf ("%d instances in Org %s\n " , len (workspacesToDisplay ), ls .terminal .Yellow (org .Name ))
425+ } else {
426+ ls .terminal .Vprintf ("You have %d instances in Org %s\n " , len (workspacesToDisplay ), ls .terminal .Yellow (org .Name ))
427+ }
428+ displayWorkspacesTable (ls .terminal , workspacesToDisplay , gpuLookup )
439429
440430 fmt .Print ("\n " )
441431
442- displayLsResetBreadCrumb (ls .terminal , userWorkspaces )
443- // displayLsConnectBreadCrumb(ls.terminal, userWorkspaces )
432+ displayLsResetBreadCrumb (ls .terminal , workspacesToDisplay )
433+ // displayLsConnectBreadCrumb(ls.terminal, workspacesToDisplay )
444434 }
445435}
446436
@@ -548,7 +538,7 @@ func (ls Ls) RunWorkspaces(cliAuth auth.CLIAuth, org *entity.Organization, showA
548538 return breverrors .WrapAndTrace (err )
549539 }
550540 if showAll {
551- ls .ShowAllWorkspaces (org , orgs , user , allWorkspaces , gpuLookup )
541+ ls .ShowAllWorkspaces (org , orgs , workspacesToShow , gpuLookup )
552542 if len (nodes ) > 0 {
553543 ls .terminal .Vprintf ("\n You have %d external node(s) in Org %s\n " , len (nodes ), ls .terminal .Yellow (org .Name ))
554544 displayNodesTable (ls .terminal , nodes , ls .piped )
@@ -680,23 +670,6 @@ func (ls Ls) RunHosts(org *entity.Organization) error {
680670 return nil
681671}
682672
683- func displayProjects (t * terminal.Terminal , orgName string , projects []virtualproject.VirtualProject ) {
684- if len (projects ) > 0 {
685- fmt .Print ("\n " )
686- t .Vprintf ("%d other projects in Org %s\n " , len (projects ), t .Yellow (orgName ))
687- displayProjectsTable (projects )
688-
689- fmt .Print ("\n " )
690- t .Vprintf ("%s" , t .Green ("Join a project:\n " )+
691- t .Yellow (fmt .Sprintf ("\t brev start %s\n " , projects [0 ].Name )))
692- } else {
693- t .Vprintf ("no other projects in Org %s\n " , t .Yellow (orgName ))
694- fmt .Print ("\n " )
695- t .Vprintf ("%s" , t .Green ("Invite a teamate:\n " )+
696- t .Yellow ("\t brev invite" ))
697- }
698- }
699-
700673func getBrevTableOptions () table.Options {
701674 options := table .OptionsDefault
702675 options .DrawBorder = false
@@ -793,19 +766,6 @@ func displayOrgTable(t *terminal.Terminal, orgs []entity.Organization, currentOr
793766 ta .Render ()
794767}
795768
796- func displayProjectsTable (projects []virtualproject.VirtualProject ) {
797- ta := table .NewWriter ()
798- ta .SetOutputMirror (os .Stdout )
799- ta .Style ().Options = getBrevTableOptions ()
800- header := table.Row {"NAME" , "MEMBERS" }
801- ta .AppendHeader (header )
802- for _ , p := range projects {
803- workspaceRow := []table.Row {{p .Name , p .GetUniqueUserCount ()}}
804- ta .AppendRows (workspaceRow )
805- }
806- ta .Render ()
807- }
808-
809769func getStatusColoredText (t * terminal.Terminal , status string ) string {
810770 switch status {
811771 case entity .Running , entity .Ready , string (entity .Completed ):
0 commit comments