From 4a0686ca3db91cf6e2c984c53f1ad4f2fea8de8b Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 17 Nov 2022 16:28:01 -0500
Subject: more cleanup to addDocTab.  fixed pile views to show proper icons
 instead of loading document label icons

---
 src/client/views/collections/TabDocView.tsx | 37 ++++++++++-------------------
 1 file changed, 13 insertions(+), 24 deletions(-)

(limited to 'src/client/views/collections/TabDocView.tsx')

diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx
index 2cc588b78..7696777fd 100644
--- a/src/client/views/collections/TabDocView.tsx
+++ b/src/client/views/collections/TabDocView.tsx
@@ -345,30 +345,19 @@ export class TabDocView extends React.Component<TabDocViewProps> {
     //  inPlace - will add the document to any collection along the path from the document to the docking view that has a field isInPlaceContainer. if none is found, inPlace adds a tab to current stack
     addDocTab = (doc: Doc, location: OpenWhere) => {
         SelectionManager.DeselectAll();
-        const locationFields = doc._viewType === CollectionViewType.Docking ? [OpenWhere.dashboard] : location.split(':');
-        const locationParams: OpenWhereMod = locationFields.length > 1 ? (locationFields[1] as OpenWhereMod) : OpenWhereMod.none;
-        switch (locationFields[0]) {
-            case OpenWhere.dashboard:
-                return DashboardView.openDashboard(doc);
-            case OpenWhere.close:
-                return CollectionDockingView.CloseSplit(doc, locationParams);
-            case OpenWhere.fullScreen:
-                return CollectionDockingView.OpenFullScreen(doc);
-            case OpenWhere.replace:
-                return CollectionDockingView.ReplaceTab(doc, locationParams, this.stack);
-            case OpenWhere.inPlace:
-                const inPlaceView = DocCast(doc.context) ? DocumentManager.Instance.getFirstDocumentView(DocCast(doc.context)) : undefined;
-                if (inPlaceView) {
-                    inPlaceView.dataDoc[Doc.LayoutFieldKey(inPlaceView.rootDoc)] = new List<Doc>([doc]);
-                    return true;
-                } // fall through to lightbox
-            case OpenWhere.lightbox:
-                return LightboxView.AddDocTab(doc, location, undefined, this.addDocTab);
-            case OpenWhere.toggle:
-                return CollectionDockingView.ToggleSplit(doc, locationParams, this.stack);
-            case OpenWhere.add:
-            default:
-                return CollectionDockingView.AddSplit(doc, locationParams, this.stack);
+        const whereFields = doc._viewType === CollectionViewType.Docking ? [OpenWhere.dashboard] : location.split(':');
+        const whereMods: OpenWhereMod = whereFields.length > 1 ? (whereFields[1] as OpenWhereMod) : OpenWhereMod.none;
+        if (doc.dockingConfig) return DashboardView.openDashboard(doc);
+        // prettier-ignore
+        switch (whereFields[0]) {
+            case OpenWhere.inPlace:  // fall through to lightbox
+            case OpenWhere.lightbox:   return LightboxView.AddDocTab(doc, location, undefined, this.addDocTab);
+            case OpenWhere.dashboard:  return DashboardView.openDashboard(doc);
+            case OpenWhere.fullScreen: return CollectionDockingView.OpenFullScreen(doc);
+            case OpenWhere.close:      return CollectionDockingView.CloseSplit(doc, whereMods);
+            case OpenWhere.replace:    return CollectionDockingView.ReplaceTab(doc, whereMods, this.stack);
+            case OpenWhere.toggle:     return CollectionDockingView.ToggleSplit(doc, whereMods, this.stack);
+            case OpenWhere.add:default:return CollectionDockingView.AddSplit(doc, whereMods, this.stack);
         }
     };
     remDocTab = (doc: Doc | Doc[]) => {
-- 
cgit v1.2.3-70-g09d2

