diff --git a/src/Main.tsx b/src/Main.tsx index af3d462a7..c90f016ac 100644 --- a/src/Main.tsx +++ b/src/Main.tsx @@ -105,9 +105,12 @@ const App = (): JSX.Element => { // Scenario-based health tracking: start ApplicationLoad and complete phases. const { startScenario, completePhase } = useMetricScenario(); React.useEffect(() => { - startScenario(MetricScenario.ApplicationLoad); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + // Only start scenario after config is initialized to avoid race conditions + // with message handlers that depend on configContext.platform + if (config) { + startScenario(MetricScenario.ApplicationLoad); + } + }, [config, startScenario]); React.useEffect(() => { if (explorer) { diff --git a/src/NotebookViewer/NotebookViewer.tsx b/src/NotebookViewer/NotebookViewer.tsx deleted file mode 100644 index 2bb1441b2..000000000 --- a/src/NotebookViewer/NotebookViewer.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import { initializeIcons } from "@fluentui/react"; -import "bootstrap/dist/css/bootstrap.css"; -import React from "react"; -import * as ReactDOM from "react-dom"; -import { configContext, initializeConfiguration } from "../ConfigContext"; -import { GalleryHeaderComponent } from "../Explorer/Controls/Header/GalleryHeaderComponent"; -import { GalleryTab } from "../Explorer/Controls/NotebookGallery/GalleryViewerComponent"; -import { - NotebookViewerComponent, - NotebookViewerComponentProps, -} from "../Explorer/Controls/NotebookViewer/NotebookViewerComponent"; -import * as FileSystemUtil from "../Explorer/Notebook/FileSystemUtil"; -import { IGalleryItem, JunoClient } from "../Juno/JunoClient"; -import * as GalleryUtils from "../Utils/GalleryUtils"; - -const onInit = async () => { - initializeIcons(); - await initializeConfiguration(); - const galleryViewerProps = GalleryUtils.getGalleryViewerProps(window.location.search); - const notebookViewerProps = GalleryUtils.getNotebookViewerProps(window.location.search); - let backNavigationText: string; - let onBackClick: () => void; - if (galleryViewerProps.selectedTab !== undefined) { - backNavigationText = GalleryUtils.getTabTitle(galleryViewerProps.selectedTab); - onBackClick = () => - (window.location.href = `${configContext.hostedExplorerURL}gallery.html?tab=${ - GalleryTab[galleryViewerProps.selectedTab] - }`); - } - const hideInputs = notebookViewerProps.hideInputs; - - const notebookUrl = decodeURIComponent(notebookViewerProps.notebookUrl); - - const galleryItemId = notebookViewerProps.galleryItemId; - let galleryItem: IGalleryItem; - - if (galleryItemId) { - const junoClient = new JunoClient(); - const galleryItemJunoResponse = await junoClient.getNotebookInfo(galleryItemId); - galleryItem = galleryItemJunoResponse.data; - } - - // The main purpose of hiding the prompt is to hide everything when hiding inputs. - // It is generally not very useful to just hide the prompt. - const hidePrompts = hideInputs; - - render(notebookUrl, backNavigationText, hideInputs, hidePrompts, galleryItem, onBackClick); -}; - -const render = ( - notebookUrl: string, - backNavigationText: string, - hideInputs?: boolean, - hidePrompts?: boolean, - galleryItem?: IGalleryItem, - onBackClick?: () => void, -) => { - const props: NotebookViewerComponentProps = { - junoClient: galleryItem ? new JunoClient() : undefined, - notebookUrl, - galleryItem, - backNavigationText, - hideInputs, - hidePrompts, - onBackClick: onBackClick, - onTagClick: undefined, - }; - - if (galleryItem) { - document.title = FileSystemUtil.stripExtension(galleryItem.name, "ipynb"); - } - - const element = ( - <> -
- -
-
- -
- - ); - - ReactDOM.render(element, document.getElementById("notebookContent")); -}; - -// Entry point -window.addEventListener("load", onInit); diff --git a/src/Platform/Hosted/extractFeatures.ts b/src/Platform/Hosted/extractFeatures.ts index 2eecd5033..e9c4fc6b1 100644 --- a/src/Platform/Hosted/extractFeatures.ts +++ b/src/Platform/Hosted/extractFeatures.ts @@ -94,7 +94,7 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear notebookBasePath: get("notebookbasepath"), notebookServerToken: get("notebookservertoken"), notebookServerUrl: get("notebookserverurl"), - sandboxNotebookOutputs: "true" === get("sandboxnotebookoutputs", "true"), + sandboxNotebookOutputs: true, selfServeType: get("selfservetype"), showMinRUSurvey: "true" === get("showminrusurvey"), ttl90Days: "true" === get("ttl90days"), diff --git a/src/Utils/AuthorizationUtils.test.ts b/src/Utils/AuthorizationUtils.test.ts index 781edec60..305b1cc9d 100644 --- a/src/Utils/AuthorizationUtils.test.ts +++ b/src/Utils/AuthorizationUtils.test.ts @@ -27,7 +27,7 @@ describe("AuthorizationUtils", () => { enableKoResourceTree: false, enableThroughputBuckets: false, hostedDataExplorer: false, - sandboxNotebookOutputs: false, + sandboxNotebookOutputs: true, showMinRUSurvey: false, ttl90Days: false, enableThroughputCap: false,