Skip to content

Commit 965c75d

Browse files
committed
Enhance App.js with notebook reference and improved Spark app ID handling
- Added useRef for notebook reference to facilitate direct interaction with the Notebook component. - Updated Spark app ID handling to ensure it is set correctly when an active Spark application is detected. - Minor refactoring for improved clarity and maintainability of the code.
1 parent 1ae461f commit 965c75d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

webapp/src/App.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, { useState, useEffect, useRef } from 'react';
22
import LoginForm from './components/auth/LoginForm';
33
import Sidebar from './components/sidebar/Sidebar';
44
import Notebook from './components/notebook/Notebook';
@@ -60,6 +60,8 @@ const App = () => {
6060
const [workspaceFiles, setWorkspaceFiles] = useState([]);
6161
const [refreshKey, setRefreshKey] = useState(0);
6262

63+
const notebookRef = useRef(null);
64+
6365
// Auth
6466
useEffect(() => {
6567
const storedUsername = localStorage.getItem('username');
@@ -147,8 +149,8 @@ const App = () => {
147149
setNotebook(notebookData);
148150

149151
// Update Spark badge if there's an active Spark app
150-
if (sparkApp) {
151-
setSparkAppId(sparkApp.spark_app_id);
152+
if (sparkApp && sparkApp.spark_app_id) {
153+
notebookRef.current?.setSparkAppId(sparkApp.spark_app_id);
152154
}
153155

154156
setShowHistoryServer(false);
@@ -224,6 +226,7 @@ const App = () => {
224226
username={username}
225227
useremail={useremail}/>
226228
<Notebook
229+
ref={notebookRef}
227230
showNotebook={showNotebook}
228231
notebook={notebook}
229232
notebookState={notebookState}

0 commit comments

Comments
 (0)