@@ -12,6 +12,7 @@ import '../../../style/NotebookFooter.css';
1212import LoadingCircle from "../../components/LoadingCircle" ;
1313import CodeIcon from "../../icons/NotebookFooter/CodeIcon" ;
1414import TextIcon from "../../icons/NotebookFooter/TextIcon" ;
15+ import SpreadsheetIcon from "../../icons/NotebookFooter/SpreadsheetIcon" ;
1516import { userSignupEvents } from '../../utils/userSignupEvents' ;
1617import { useUserSignup } from '../AiChat/hooks/useUserSignup' ;
1718
@@ -25,12 +26,18 @@ const NotebookFooter: React.FC<NotebookFooterProps> = ({ notebookTracker, app })
2526
2627 const [ inputValue , setInputValue ] = useState ( '' ) ;
2728 const [ isGenerating , setIsGenerating ] = useState ( false ) ;
29+ const [ hasMitosheet , setHasMitosheet ] = useState ( false ) ;
2830 const { isSignedUp, refreshUserSignupState } = useUserSignup ( ) ;
2931
3032 useEffect ( ( ) => {
3133 void refreshUserSignupState ( ) ;
3234 } , [ ] ) ;
3335
36+ // Check if mitosheet command exists
37+ useEffect ( ( ) => {
38+ setHasMitosheet ( app . commands . hasCommand ( 'mitosheet:create-empty-mitosheet' ) ) ;
39+ } , [ app ] ) ;
40+
3441 // Listen for signup success events from other components
3542 useEffect ( ( ) => {
3643 const handleSignupSuccess = ( ) : void => {
@@ -60,13 +67,15 @@ const NotebookFooter: React.FC<NotebookFooterProps> = ({ notebookTracker, app })
6067 }
6168 } ;
6269
63- const addCell = ( cellType : 'code' | 'markdown' = 'code' ) : void => {
70+ const addCell = ( cellType : 'code' | 'markdown' | 'spreadsheet' = 'code' ) : void => {
6471 if ( notebook . widgets . length && notebook . widgets . length > 0 ) {
6572 notebook . activeCellIndex = notebook . widgets . length - 1 ;
6673 }
6774
6875 if ( cellType === 'code' ) {
6976 NotebookActions . insertBelow ( notebook ) ;
77+ } else if ( cellType === 'spreadsheet' ) {
78+ void app . commands . execute ( 'mitosheet:create-empty-mitosheet' ) ;
7079 } else {
7180 NotebookActions . insertBelow ( notebook ) ;
7281 // Change the cell type after insertion
@@ -190,6 +199,22 @@ const NotebookFooter: React.FC<NotebookFooterProps> = ({ notebookTracker, app })
190199 < span className = "button-label" > Text</ span >
191200 </ div >
192201 </ button >
202+
203+ { /* Spreadsheet button */ }
204+ { hasMitosheet && (
205+ < button
206+ onClick = { ( ) => addCell ( 'spreadsheet' ) }
207+ className = "footer-button"
208+ onMouseDown = { ( e ) => e . stopPropagation ( ) }
209+ >
210+ < div className = "button-content" >
211+ < div className = "button-icon" >
212+ < SpreadsheetIcon />
213+ </ div >
214+ < span className = "button-label" > Spreadsheet</ span >
215+ </ div >
216+ </ button >
217+ ) }
193218 </ div >
194219 </ div >
195220 ) ;
0 commit comments