@@ -50,18 +50,17 @@ var WorkspaceIcons = [...]string{
5050
5151func CreateWorkspace (ctx context.Context , name string , icon string , color string , applyDefaults bool , isInitialLaunch bool ) (* waveobj.Workspace , error ) {
5252 ws := & waveobj.Workspace {
53- OID : uuid .NewString (),
54- TabIds : []string {},
55- PinnedTabIds : []string {},
56- Name : "" ,
57- Icon : "" ,
58- Color : "" ,
53+ OID : uuid .NewString (),
54+ TabIds : []string {},
55+ Name : "" ,
56+ Icon : "" ,
57+ Color : "" ,
5958 }
6059 err := wstore .DBInsert (ctx , ws )
6160 if err != nil {
6261 return nil , fmt .Errorf ("error inserting workspace: %w" , err )
6362 }
64- _ , err = CreateTab (ctx , ws .OID , "" , true , false , isInitialLaunch )
63+ _ , err = CreateTab (ctx , ws .OID , "" , true , isInitialLaunch )
6564 if err != nil {
6665 return nil , fmt .Errorf ("error creating tab: %w" , err )
6766 }
@@ -128,13 +127,12 @@ func DeleteWorkspace(ctx context.Context, workspaceId string, force bool) (bool,
128127 return false , "" , fmt .Errorf ("error retrieving workspaceList: %w" , err )
129128 }
130129
131- if workspace .Name != "" && workspace .Icon != "" && ! force && ( len (workspace .TabIds ) > 0 || len ( workspace . PinnedTabIds ) > 0 ) {
130+ if workspace .Name != "" && workspace .Icon != "" && ! force && len (workspace .TabIds ) > 0 {
132131 log .Printf ("Ignoring DeleteWorkspace for workspace %s as it is named\n " , workspaceId )
133132 return false , "" , nil
134133 }
135134
136- // delete all pinned and unpinned tabs
137- for _ , tabId := range append (workspace .TabIds , workspace .PinnedTabIds ... ) {
135+ for _ , tabId := range workspace .TabIds {
138136 log .Printf ("deleting tab %s\n " , tabId )
139137 _ , err := DeleteTab (ctx , workspaceId , tabId , false )
140138 if err != nil {
@@ -198,17 +196,16 @@ func getTabPresetMeta() (waveobj.MetaMapType, error) {
198196}
199197
200198// returns tabid
201- func CreateTab (ctx context.Context , workspaceId string , tabName string , activateTab bool , pinned bool , isInitialLaunch bool ) (string , error ) {
199+ func CreateTab (ctx context.Context , workspaceId string , tabName string , activateTab bool , isInitialLaunch bool ) (string , error ) {
202200 if tabName == "" {
203201 ws , err := GetWorkspace (ctx , workspaceId )
204202 if err != nil {
205203 return "" , fmt .Errorf ("workspace %s not found: %w" , workspaceId , err )
206204 }
207- tabName = "T" + fmt .Sprint (len (ws .TabIds )+ len ( ws . PinnedTabIds ) + 1 )
205+ tabName = "T" + fmt .Sprint (len (ws .TabIds )+ 1 )
208206 }
209207
210- // The initial tab for the initial launch should be pinned
211- tab , err := createTabObj (ctx , workspaceId , tabName , pinned || isInitialLaunch , nil )
208+ tab , err := createTabObj (ctx , workspaceId , tabName , nil )
212209 if err != nil {
213210 return "" , fmt .Errorf ("error creating tab: %w" , err )
214211 }
@@ -240,7 +237,7 @@ func CreateTab(ctx context.Context, workspaceId string, tabName string, activate
240237 return tab .OID , nil
241238}
242239
243- func createTabObj (ctx context.Context , workspaceId string , name string , pinned bool , meta waveobj.MetaMapType ) (* waveobj.Tab , error ) {
240+ func createTabObj (ctx context.Context , workspaceId string , name string , meta waveobj.MetaMapType ) (* waveobj.Tab , error ) {
244241 ws , err := GetWorkspace (ctx , workspaceId )
245242 if err != nil {
246243 return nil , fmt .Errorf ("workspace %s not found: %w" , workspaceId , err )
@@ -256,11 +253,7 @@ func createTabObj(ctx context.Context, workspaceId string, name string, pinned b
256253 layoutState := & waveobj.LayoutState {
257254 OID : layoutStateId ,
258255 }
259- if pinned {
260- ws .PinnedTabIds = append (ws .PinnedTabIds , tab .OID )
261- } else {
262- ws .TabIds = append (ws .TabIds , tab .OID )
263- }
256+ ws .TabIds = append (ws .TabIds , tab .OID )
264257 wstore .DBInsert (ctx , tab )
265258 wstore .DBInsert (ctx , layoutState )
266259 wstore .DBUpdate (ctx , ws )
@@ -279,14 +272,10 @@ func DeleteTab(ctx context.Context, workspaceId string, tabId string, recursive
279272
280273 // ensure tab is in workspace
281274 tabIdx := utilfn .FindStringInSlice (ws .TabIds , tabId )
282- tabIdxPinned := utilfn .FindStringInSlice (ws .PinnedTabIds , tabId )
283- if tabIdx != - 1 {
284- ws .TabIds = append (ws .TabIds [:tabIdx ], ws .TabIds [tabIdx + 1 :]... )
285- } else if tabIdxPinned != - 1 {
286- ws .PinnedTabIds = append (ws .PinnedTabIds [:tabIdxPinned ], ws .PinnedTabIds [tabIdxPinned + 1 :]... )
287- } else {
275+ if tabIdx == - 1 {
288276 return "" , fmt .Errorf ("tab %s not found in workspace %s" , tabId , workspaceId )
289277 }
278+ ws .TabIds = append (ws .TabIds [:tabIdx ], ws .TabIds [tabIdx + 1 :]... )
290279
291280 // close blocks (sends events + stops block controllers)
292281 tab , _ := wstore .DBGet [* waveobj.Tab ](ctx , tabId )
@@ -303,13 +292,7 @@ func DeleteTab(ctx context.Context, workspaceId string, tabId string, recursive
303292 newActiveTabId := ws .ActiveTabId
304293 if ws .ActiveTabId == tabId {
305294 if len (ws .TabIds ) > 0 {
306- if tabIdx != - 1 {
307- newActiveTabId = ws .TabIds [max (0 , min (tabIdx - 1 , len (ws .TabIds )- 1 ))]
308- } else {
309- newActiveTabId = ws .TabIds [0 ]
310- }
311- } else if len (ws .PinnedTabIds ) > 0 {
312- newActiveTabId = ws .PinnedTabIds [0 ]
295+ newActiveTabId = ws .TabIds [max (0 , min (tabIdx - 1 , len (ws .TabIds )- 1 ))]
313296 } else {
314297 newActiveTabId = ""
315298 }
@@ -353,44 +336,19 @@ func SetActiveTab(ctx context.Context, workspaceId string, tabId string) error {
353336 return nil
354337}
355338
356- func ChangeTabPinning (ctx context.Context , workspaceId string , tabId string , pinned bool ) error {
357- if tabId != "" && workspaceId != "" {
358- workspace , err := GetWorkspace (ctx , workspaceId )
359- if err != nil {
360- return fmt .Errorf ("workspace %s not found: %w" , workspaceId , err )
361- }
362- if pinned && utilfn .FindStringInSlice (workspace .PinnedTabIds , tabId ) == - 1 {
363- if utilfn .FindStringInSlice (workspace .TabIds , tabId ) == - 1 {
364- return fmt .Errorf ("tab %s not found in workspace %s" , tabId , workspaceId )
365- }
366- workspace .TabIds = utilfn .RemoveElemFromSlice (workspace .TabIds , tabId )
367- workspace .PinnedTabIds = append (workspace .PinnedTabIds , tabId )
368- } else if ! pinned && utilfn .FindStringInSlice (workspace .PinnedTabIds , tabId ) != - 1 {
369- if utilfn .FindStringInSlice (workspace .PinnedTabIds , tabId ) == - 1 {
370- return fmt .Errorf ("tab %s not found in workspace %s" , tabId , workspaceId )
371- }
372- workspace .PinnedTabIds = utilfn .RemoveElemFromSlice (workspace .PinnedTabIds , tabId )
373- workspace .TabIds = append ([]string {tabId }, workspace .TabIds ... )
374- }
375- wstore .DBUpdate (ctx , workspace )
376- }
377- return nil
378- }
379-
380339func SendActiveTabUpdate (ctx context.Context , workspaceId string , newActiveTabId string ) {
381340 eventbus .SendEventToElectron (eventbus.WSEventType {
382341 EventType : eventbus .WSEvent_ElectronUpdateActiveTab ,
383342 Data : & waveobj.ActiveTabUpdate {WorkspaceId : workspaceId , NewActiveTabId : newActiveTabId },
384343 })
385344}
386345
387- func UpdateWorkspaceTabIds (ctx context.Context , workspaceId string , tabIds []string , pinnedTabIds [] string ) error {
346+ func UpdateWorkspaceTabIds (ctx context.Context , workspaceId string , tabIds []string ) error {
388347 ws , _ := wstore .DBGet [* waveobj.Workspace ](ctx , workspaceId )
389348 if ws == nil {
390349 return fmt .Errorf ("workspace not found: %q" , workspaceId )
391350 }
392351 ws .TabIds = tabIds
393- ws .PinnedTabIds = pinnedTabIds
394352 wstore .DBUpdate (ctx , ws )
395353 return nil
396354}
0 commit comments