From 4997c3de20a381eac30224a7a550afa66174f07d Mon Sep 17 00:00:00 2001
From: Joanne <zehan_ding@brown.edu>
Date: Mon, 12 May 2025 20:53:12 -0400
Subject: added tutorial tool, still need to integrate with metadatatool

---
 .../collectionFreeForm/CollectionFreeFormView.tsx  | 43 +++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

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

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 89aa53c35..0ce72add5 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -72,6 +72,7 @@ import { SettingsManager } from '../../../util/SettingsManager';
 import { Slider } from '@mui/material';
 import { AiOutlineSend } from 'react-icons/ai';
 import { DrawingFillHandler } from '../../smartdraw/DrawingFillHandler';
+import { CollectionFreeFormInfoUI } from './CollectionFreeFormInfoUI';
 
 @observer
 class CollectionFreeFormOverlayView extends React.Component<{ elements: () => ViewDefResult[] }> {
@@ -94,6 +95,8 @@ export interface collectionFreeformViewProps {
 
 @observer
 export class CollectionFreeFormView extends CollectionSubView<Partial<collectionFreeformViewProps>>() {
+    private static _infoUIInstance: CollectionFreeFormInfoUI | null = null;
+    
     public get displayName() {
         return 'CollectionFreeFormView(' + (this.Document.title?.toString() ?? '') + ')';
     } // this makes mobx trace() statements more descriptive
@@ -1758,11 +1761,49 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
     static SetInfoUICreator(func: (doc: Doc, layout: Doc, childDocs: () => Doc[], close: () => void) => JSX.Element) {
         CollectionFreeFormView._infoUI = func;
     }
-    infoUI = () =>
+    /**
+   * Called from TutorialTool in Agent system
+   */
+  public static showTutorial(kind: 'links' | 'pins' | 'presentation') {
+        const ui = CollectionFreeFormView._infoUIInstance;
+        if (!ui) return;
+        switch (kind) {
+          case 'links':
+            ui.skipToState((ui).tutorialStates.multipleDocs);
+            ui._nextState
+            break;
+          case 'pins':
+            ui.skipToState((ui).tutorialStates.presentDocs);
+            ui._nextState
+            break;
+          case 'presentation':
+            ui.skipToState((ui).tutorialStates.makePresentation);
+            ui._nextState
+            break;
+        }
+      }
+
+    infoUI = () => {
         Doc.IsInfoUIDisabled || this.Document.annotationOn || this._props.renderDepth
             ? null //
             : CollectionFreeFormView._infoUI?.(this.Document, this.layoutDoc, this.childDocsFunc, this.closeInfo) || null;
 
+      if (Doc.IsInfoUIDisabled || this.Document.annotationOn || this._props.renderDepth) {
+        return null;
+      }
+      const creator = CollectionFreeFormView._infoUI;
+      if (!creator) return null;
+      const element = creator(this.Document, this.layoutDoc, this.childDocsFunc, this.closeInfo);
+      // attach ref so we can call skipToState(...) later
+      return React.isValidElement(element)
+        ? React.cloneElement(element, {
+            ref: (r: CollectionFreeFormInfoUI) => {
+              CollectionFreeFormView._infoUIInstance = r;
+            }
+          })
+        : element;
+        
+    };
     componentDidMount() {
         this._props.setContentViewBox?.(this);
         super.componentDidMount?.();
-- 
cgit v1.2.3-70-g09d2

