From 4d21b79bfb87bb5fe81950a432a031f42b99f707 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 6 Oct 2022 10:19:31 -0400
Subject: don't allow golden layout to be created if there's no dockingConfig.

---
 .../views/collections/CollectionDockingView.tsx    | 57 ++++++++++++----------
 1 file changed, 30 insertions(+), 27 deletions(-)

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

diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 40a5876e0..37a2d5e5d 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -282,35 +282,38 @@ export class CollectionDockingView extends CollectionSubView() {
         return true;
     }
     setupGoldenLayout = async () => {
-        const config = StrCast(this.props.Document.dockingConfig, JSON.stringify(DashboardView.resetDashboard(this.props.Document)));
-        const matches = config.match(/\"documentId\":\"[a-z0-9-]+\"/g);
-        const docids = matches?.map(m => m.replace('"documentId":"', '').replace('"', '')) ?? [];
-
-        await Promise.all(docids.map(id => DocServer.GetRefField(id)));
-
-        if (this._goldenLayout) {
-            if (config === JSON.stringify(this._goldenLayout.toConfig())) {
-                return;
-            } else {
-                try {
-                    this._goldenLayout.unbind('tabCreated', this.tabCreated);
-                    this._goldenLayout.unbind('tabDestroyed', this.tabDestroyed);
-                    this._goldenLayout.unbind('stackCreated', this.stackCreated);
-                } catch (e) {}
+        //const config = StrCast(this.props.Document.dockingConfig, JSON.stringify(DashboardView.resetDashboard(this.props.Document)));
+        const config = StrCast(this.props.Document.dockingConfig);
+        if (config) {
+            const matches = config.match(/\"documentId\":\"[a-z0-9-]+\"/g);
+            const docids = matches?.map(m => m.replace('"documentId":"', '').replace('"', '')) ?? [];
+
+            await Promise.all(docids.map(id => DocServer.GetRefField(id)));
+
+            if (this._goldenLayout) {
+                if (config === JSON.stringify(this._goldenLayout.toConfig())) {
+                    return;
+                } else {
+                    try {
+                        this._goldenLayout.unbind('tabCreated', this.tabCreated);
+                        this._goldenLayout.unbind('tabDestroyed', this.tabDestroyed);
+                        this._goldenLayout.unbind('stackCreated', this.stackCreated);
+                    } catch (e) {}
+                }
+                this.tabMap.clear();
+                this._goldenLayout.destroy();
             }
-            this.tabMap.clear();
-            this._goldenLayout.destroy();
+            const glay = (this._goldenLayout = new GoldenLayout(JSON.parse(config)));
+            glay.on('tabCreated', this.tabCreated);
+            glay.on('tabDestroyed', this.tabDestroyed);
+            glay.on('stackCreated', this.stackCreated);
+            glay.registerComponent('DocumentFrameRenderer', TabDocView);
+            glay.container = this._containerRef.current;
+            glay.init();
+            glay.root.layoutManager.on('itemDropped', this.tabItemDropped);
+            glay.root.layoutManager.on('dragStart', this.tabDragStart);
+            glay.root.layoutManager.on('activeContentItemChanged', this.stateChanged);
         }
-        const glay = (this._goldenLayout = new GoldenLayout(JSON.parse(config)));
-        glay.on('tabCreated', this.tabCreated);
-        glay.on('tabDestroyed', this.tabDestroyed);
-        glay.on('stackCreated', this.stackCreated);
-        glay.registerComponent('DocumentFrameRenderer', TabDocView);
-        glay.container = this._containerRef.current;
-        glay.init();
-        glay.root.layoutManager.on('itemDropped', this.tabItemDropped);
-        glay.root.layoutManager.on('dragStart', this.tabDragStart);
-        glay.root.layoutManager.on('activeContentItemChanged', this.stateChanged);
     };
 
     componentDidMount: () => void = () => {
-- 
cgit v1.2.3-70-g09d2


From 161e0f1bdaec29516c9398c740a585e22595bf74 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 6 Oct 2022 11:18:42 -0400
Subject: fixed warnings with scriptingbox keys

---
 src/client/views/LightboxView.tsx                      | 2 +-
 src/client/views/collections/CollectionDockingView.tsx | 2 ++
 src/client/views/nodes/ScriptingBox.tsx                | 9 ++++-----
 3 files changed, 7 insertions(+), 6 deletions(-)

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

diff --git a/src/client/views/LightboxView.tsx b/src/client/views/LightboxView.tsx
index e8b8a3eaa..bd6cea28a 100644
--- a/src/client/views/LightboxView.tsx
+++ b/src/client/views/LightboxView.tsx
@@ -281,7 +281,7 @@ export class LightboxView extends React.Component<LightboxViewProps> {
                                         action(() => {
                                             const target = LightboxView._docTarget;
                                             const doc = LightboxView._doc;
-                                            const targetView = target && DocumentManager.Instance.getLightboxDocumentView(target);
+                                            //const targetView = target && DocumentManager.Instance.getLightboxDocumentView(target);
                                             if (doc === r.props.Document && (!target || target === doc)) r.ComponentView?.shrinkWrap?.();
                                             //else target?.focus(target, { willZoom: true, scale: 0.9, instant: true }); // bcz: why was this here?  it breaks smooth navigation in lightbox using 'next' button
                                         })
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 37a2d5e5d..e9b41de25 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -313,6 +313,8 @@ export class CollectionDockingView extends CollectionSubView() {
             glay.root.layoutManager.on('itemDropped', this.tabItemDropped);
             glay.root.layoutManager.on('dragStart', this.tabDragStart);
             glay.root.layoutManager.on('activeContentItemChanged', this.stateChanged);
+        } else {
+            console.log('ERROR: no config for dashboard!!');
         }
     };
 
diff --git a/src/client/views/nodes/ScriptingBox.tsx b/src/client/views/nodes/ScriptingBox.tsx
index 1c9b0bc0e..4883ad538 100644
--- a/src/client/views/nodes/ScriptingBox.tsx
+++ b/src/client/views/nodes/ScriptingBox.tsx
@@ -397,8 +397,8 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatable
                             onPointerDown={e => e.stopPropagation()}
                             onChange={e => this.viewChanged(e, parameter)}
                             value={typeof this.rootDoc[parameter] === 'string' ? 'S' + StrCast(this.rootDoc[parameter]) : typeof this.rootDoc[parameter] === 'number' ? 'N' + NumCast(this.rootDoc[parameter]) : 'B' + BoolCast(this.rootDoc[parameter])}>
-                            {types.map(type => (
-                                <option className="scriptingBox-viewOption" value={(typeof type === 'string' ? 'S' : typeof type === 'number' ? 'N' : 'B') + type}>
+                            {types.map((type, i) => (
+                                <option key={i} className="scriptingBox-viewOption" value={(typeof type === 'string' ? 'S' : typeof type === 'number' ? 'N' : 'B') + type}>
                                     {' '}
                                     {type.toString()}{' '}
                                 </option>
@@ -666,7 +666,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatable
         const definedParameters = !this.compileParams.length ? null : (
             <div className="scriptingBox-plist" style={{ width: '30%' }}>
                 {this.compileParams.map((parameter, i) => (
-                    <div className="scriptingBox-pborder" onKeyPress={e => e.key === 'Enter' && this._overlayDisposer?.()}>
+                    <div key={i} className="scriptingBox-pborder" onKeyPress={e => e.key === 'Enter' && this._overlayDisposer?.()}>
                         <EditableView
                             display={'block'}
                             maxHeight={72}
@@ -745,7 +745,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatable
                 {!this.compileParams.length || !this.paramsNames ? null : (
                     <div className="scriptingBox-plist">
                         {this.paramsNames.map((parameter: string, i: number) => (
-                            <div className="scriptingBox-pborder" onKeyPress={e => e.key === 'Enter' && this._overlayDisposer?.()}>
+                            <div key={i} className="scriptingBox-pborder" onKeyPress={e => e.key === 'Enter' && this._overlayDisposer?.()}>
                                 <div className="scriptingBox-wrapper" style={{ maxHeight: '40px' }}>
                                     <div className="scriptingBox-paramNames"> {`${parameter}:${this.paramsTypes[i]} = `} </div>
                                     {this.paramsTypes[i] === 'boolean' ? this.renderEnum(parameter, [true, false]) : null}
@@ -805,7 +805,6 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatable
 
     // renders script UI if _applied = false and params UI if _applied = true
     render() {
-        console.log(ReactTextareaAutocomplete);
         TraceMobx();
         return (
             <div className={`scriptingBox`} onContextMenu={this.specificContextMenu} onPointerUp={!this._function ? this.suggestionPos : undefined}>
-- 
cgit v1.2.3-70-g09d2

