cosmos-explorer/src/Main.tsx

133 lines
5.4 KiB
TypeScript
Raw Normal View History

// Import this first, to ensure that the dev tools hook is copied before React is loaded.
import "./ReactDevTools";
2021-01-20 09:15:01 -06:00
// CSS Dependencies
Initial Fabric support (#1607) * Add Platform.Fabric to run in context of Fabric * Use separate StyleConstants We want to have more flexibility with Styles at runtime but Constants depend on ConfigContext and therefore get loaded very early at startup. * Add Fabric specific styles and Fluent theme documentDBFabric.less contains all styles for Fabric. We use React.lazy to import them conditionally at runtime preventing webpack from preprocessing them into main.css. * Restyle CommandBar for Fabric with more roundness and native colors. * Disable Notebooks when running in Fabric * Disable Synapse and Scripts commands for Fabric * Fix code formatting issues * Fetch encrypted token from sessionStorage for fabric platform * Fix Tabs style * Dark refresh icons for Fabric * Use new ResourceTree2 for Fabric * Fluent tree should have a fixed width otherwise the action buttons jump around on hover. * Disable remaining Script actions in Fabric * Revert accidentally committed change which broke a test * Fix cross-origin error second try * Adjust @FabrixBoxMargin css * Hide Database Scale node on Fabric * Remove all Collection child nodes on Fabric * Add a comment about why we need FabricPlatform.tsx * Fix equality checks * Fix more Colors for Fabric * Switch resource tree to "medium" size * Fix formatting again * Fix formatting again * Disable no-var-requires error on some intended var import. * Increase memory limit for build * Use standard Segoe UI font for Fabric * Improve Tabs design for Fabric * Fix active Tab style bug in Portal introduced with 39a7765aef807de5c1e7c82b094765072a10924c --------- Co-authored-by: Laurent Nguyen <laurent.nguyen@microsoft.com>
2023-09-15 17:33:27 +02:00
import { initializeIcons, loadTheme } from "@fluentui/react";
2022-09-14 14:42:09 -07:00
import { QuickstartCarousel } from "Explorer/Quickstart/QuickstartCarousel";
import { MongoQuickstartTutorial } from "Explorer/Quickstart/Tutorials/MongoQuickstartTutorial";
import { SQLQuickstartTutorial } from "Explorer/Quickstart/Tutorials/SQLQuickstartTutorial";
2024-08-15 13:29:57 -07:00
import "allotment/dist/style.css";
import "bootstrap/dist/css/bootstrap.css";
import { useCarousel } from "hooks/useCarousel";
import React from "react";
2021-03-14 22:53:16 -05:00
import ReactDOM from "react-dom";
import "../externals/jquery-ui.min.css";
import "../externals/jquery-ui.min.js";
import "../externals/jquery-ui.structure.min.css";
import "../externals/jquery-ui.theme.min.css";
import "../externals/jquery.dataTables.min.css";
import "../externals/jquery.typeahead.min.css";
import "../externals/jquery.typeahead.min.js";
// Image Dependencies
import { Platform } from "ConfigContext";
2023-06-06 11:43:53 -07:00
import { QueryCopilotCarousel } from "Explorer/QueryCopilot/CopilotCarousel";
import { SidebarContainer } from "Explorer/Sidebar";
import { KeyboardShortcutRoot } from "KeyboardShortcuts";
import "allotment/dist/style.css";
2021-03-14 22:53:16 -05:00
import "../images/CosmosDB_rgb_ui_lighttheme.ico";
import hdeConnectImage from "../images/HdeConnectCosmosDB.svg";
import "../images/favicon.ico";
import "../less/TableStyles/CustomizeColumns.less";
import "../less/TableStyles/EntityEditor.less";
import "../less/TableStyles/fulldatatables.less";
import "../less/TableStyles/queryBuilder.less";
2021-01-20 09:15:01 -06:00
import "../less/documentDB.less";
import "../less/forms.less";
import "../less/infobox.less";
2021-03-14 22:53:16 -05:00
import "../less/menus.less";
2021-01-20 09:15:01 -06:00
import "../less/messagebox.less";
2021-03-14 22:53:16 -05:00
import "../less/resourceTree.less";
import "../less/tree.less";
import * as StyleConstants from "./Common/StyleConstants";
2021-03-14 22:53:16 -05:00
import "./Explorer/Controls/Accordion/AccordionComponent.less";
2021-01-20 09:15:01 -06:00
import "./Explorer/Controls/CollapsiblePanel/CollapsiblePanelComponent.less";
2021-05-20 09:54:26 -05:00
import { Dialog } from "./Explorer/Controls/Dialog";
2021-03-14 22:53:16 -05:00
import "./Explorer/Controls/ErrorDisplayComponent/ErrorDisplayComponent.less";
2021-01-20 09:15:01 -06:00
import "./Explorer/Controls/JsonEditor/JsonEditorComponent.less";
2021-03-14 22:53:16 -05:00
import "./Explorer/Controls/Notebook/NotebookTerminalComponent.less";
import "./Explorer/Controls/TreeComponent/treeComponent.less";
2021-01-20 09:15:01 -06:00
import "./Explorer/Graph/GraphExplorerComponent/graphExplorer.less";
2021-03-14 22:53:16 -05:00
import "./Explorer/Menus/CommandBar/CommandBarComponent.less";
2021-05-28 15:20:59 -05:00
import { CommandBar } from "./Explorer/Menus/CommandBar/CommandBarComponentAdapter";
import "./Explorer/Menus/CommandBar/ConnectionStatusComponent.less";
2021-03-14 22:53:16 -05:00
import "./Explorer/Menus/CommandBar/MemoryTrackerComponent.less";
import "./Explorer/Menus/NotificationConsole/NotificationConsole.less";
import { NotificationConsole } from "./Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
2021-03-14 22:53:16 -05:00
import "./Explorer/Panes/PanelComponent.less";
import { SidePanel } from "./Explorer/Panes/PanelContainerComponent";
import "./Explorer/SplashScreen/SplashScreen.less";
import "./Libs/jquery";
Initial Fabric support (#1607) * Add Platform.Fabric to run in context of Fabric * Use separate StyleConstants We want to have more flexibility with Styles at runtime but Constants depend on ConfigContext and therefore get loaded very early at startup. * Add Fabric specific styles and Fluent theme documentDBFabric.less contains all styles for Fabric. We use React.lazy to import them conditionally at runtime preventing webpack from preprocessing them into main.css. * Restyle CommandBar for Fabric with more roundness and native colors. * Disable Notebooks when running in Fabric * Disable Synapse and Scripts commands for Fabric * Fix code formatting issues * Fetch encrypted token from sessionStorage for fabric platform * Fix Tabs style * Dark refresh icons for Fabric * Use new ResourceTree2 for Fabric * Fluent tree should have a fixed width otherwise the action buttons jump around on hover. * Disable remaining Script actions in Fabric * Revert accidentally committed change which broke a test * Fix cross-origin error second try * Adjust @FabrixBoxMargin css * Hide Database Scale node on Fabric * Remove all Collection child nodes on Fabric * Add a comment about why we need FabricPlatform.tsx * Fix equality checks * Fix more Colors for Fabric * Switch resource tree to "medium" size * Fix formatting again * Fix formatting again * Disable no-var-requires error on some intended var import. * Increase memory limit for build * Use standard Segoe UI font for Fabric * Improve Tabs design for Fabric * Fix active Tab style bug in Portal introduced with 39a7765aef807de5c1e7c82b094765072a10924c --------- Co-authored-by: Laurent Nguyen <laurent.nguyen@microsoft.com>
2023-09-15 17:33:27 +02:00
import { appThemeFabric } from "./Platform/Fabric/FabricTheme";
import "./Shared/appInsights";
import { useConfig } from "./hooks/useConfig";
import { useKnockoutExplorer } from "./hooks/useKnockoutExplorer";
2021-01-20 09:15:01 -06:00
initializeIcons();
2021-01-20 09:15:01 -06:00
const App: React.FunctionComponent = () => {
const isCarouselOpen = useCarousel((state) => state.shouldOpen);
2023-06-06 11:43:53 -07:00
const isCopilotCarouselOpen = useCarousel((state) => state.showCopilotCarousel);
const config = useConfig();
Initial Fabric support (#1607) * Add Platform.Fabric to run in context of Fabric * Use separate StyleConstants We want to have more flexibility with Styles at runtime but Constants depend on ConfigContext and therefore get loaded very early at startup. * Add Fabric specific styles and Fluent theme documentDBFabric.less contains all styles for Fabric. We use React.lazy to import them conditionally at runtime preventing webpack from preprocessing them into main.css. * Restyle CommandBar for Fabric with more roundness and native colors. * Disable Notebooks when running in Fabric * Disable Synapse and Scripts commands for Fabric * Fix code formatting issues * Fetch encrypted token from sessionStorage for fabric platform * Fix Tabs style * Dark refresh icons for Fabric * Use new ResourceTree2 for Fabric * Fluent tree should have a fixed width otherwise the action buttons jump around on hover. * Disable remaining Script actions in Fabric * Revert accidentally committed change which broke a test * Fix cross-origin error second try * Adjust @FabrixBoxMargin css * Hide Database Scale node on Fabric * Remove all Collection child nodes on Fabric * Add a comment about why we need FabricPlatform.tsx * Fix equality checks * Fix more Colors for Fabric * Switch resource tree to "medium" size * Fix formatting again * Fix formatting again * Disable no-var-requires error on some intended var import. * Increase memory limit for build * Use standard Segoe UI font for Fabric * Improve Tabs design for Fabric * Fix active Tab style bug in Portal introduced with 39a7765aef807de5c1e7c82b094765072a10924c --------- Co-authored-by: Laurent Nguyen <laurent.nguyen@microsoft.com>
2023-09-15 17:33:27 +02:00
if (config?.platform === Platform.Fabric) {
loadTheme(appThemeFabric);
import("../less/documentDBFabric.less");
Initial Fabric support (#1607) * Add Platform.Fabric to run in context of Fabric * Use separate StyleConstants We want to have more flexibility with Styles at runtime but Constants depend on ConfigContext and therefore get loaded very early at startup. * Add Fabric specific styles and Fluent theme documentDBFabric.less contains all styles for Fabric. We use React.lazy to import them conditionally at runtime preventing webpack from preprocessing them into main.css. * Restyle CommandBar for Fabric with more roundness and native colors. * Disable Notebooks when running in Fabric * Disable Synapse and Scripts commands for Fabric * Fix code formatting issues * Fetch encrypted token from sessionStorage for fabric platform * Fix Tabs style * Dark refresh icons for Fabric * Use new ResourceTree2 for Fabric * Fluent tree should have a fixed width otherwise the action buttons jump around on hover. * Disable remaining Script actions in Fabric * Revert accidentally committed change which broke a test * Fix cross-origin error second try * Adjust @FabrixBoxMargin css * Hide Database Scale node on Fabric * Remove all Collection child nodes on Fabric * Add a comment about why we need FabricPlatform.tsx * Fix equality checks * Fix more Colors for Fabric * Switch resource tree to "medium" size * Fix formatting again * Fix formatting again * Disable no-var-requires error on some intended var import. * Increase memory limit for build * Use standard Segoe UI font for Fabric * Improve Tabs design for Fabric * Fix active Tab style bug in Portal introduced with 39a7765aef807de5c1e7c82b094765072a10924c --------- Co-authored-by: Laurent Nguyen <laurent.nguyen@microsoft.com>
2023-09-15 17:33:27 +02:00
}
StyleConstants.updateStyles();
2021-07-08 21:32:22 -07:00
const explorer = useKnockoutExplorer(config?.platform);
2021-01-20 09:15:01 -06:00
2021-03-14 22:53:16 -05:00
if (!explorer) {
return <LoadingExplorer />;
}
2021-01-20 09:15:01 -06:00
return (
<KeyboardShortcutRoot>
<div className="flexContainer" aria-hidden="false" data-test="DataExplorerRoot">
<div id="divExplorer" className="flexContainer hideOverflows">
<div id="freeTierTeachingBubble"> </div>
{/* Main Command Bar - Start */}
<CommandBar container={explorer} />
{/* Collections Tree and Tabs - Begin */}
<SidebarContainer explorer={explorer} />
{/* Collections Tree and Tabs - End */}
<div
className="dataExplorerErrorConsoleContainer"
role="contentinfo"
aria-label="Notification console"
id="explorerNotificationConsole"
>
<NotificationConsole />
</div>
</div>
<SidePanel />
<Dialog />
{<QuickstartCarousel isOpen={isCarouselOpen} />}
{<SQLQuickstartTutorial />}
{<MongoQuickstartTutorial />}
{<QueryCopilotCarousel isOpen={isCopilotCarouselOpen} explorer={explorer} />}
2021-01-20 09:15:01 -06:00
</div>
</KeyboardShortcutRoot>
2021-01-20 09:15:01 -06:00
);
};
const mainElement = document.getElementById("Main");
ReactDOM.render(<App />, mainElement);
Initial Fabric support (#1607) * Add Platform.Fabric to run in context of Fabric * Use separate StyleConstants We want to have more flexibility with Styles at runtime but Constants depend on ConfigContext and therefore get loaded very early at startup. * Add Fabric specific styles and Fluent theme documentDBFabric.less contains all styles for Fabric. We use React.lazy to import them conditionally at runtime preventing webpack from preprocessing them into main.css. * Restyle CommandBar for Fabric with more roundness and native colors. * Disable Notebooks when running in Fabric * Disable Synapse and Scripts commands for Fabric * Fix code formatting issues * Fetch encrypted token from sessionStorage for fabric platform * Fix Tabs style * Dark refresh icons for Fabric * Use new ResourceTree2 for Fabric * Fluent tree should have a fixed width otherwise the action buttons jump around on hover. * Disable remaining Script actions in Fabric * Revert accidentally committed change which broke a test * Fix cross-origin error second try * Adjust @FabrixBoxMargin css * Hide Database Scale node on Fabric * Remove all Collection child nodes on Fabric * Add a comment about why we need FabricPlatform.tsx * Fix equality checks * Fix more Colors for Fabric * Switch resource tree to "medium" size * Fix formatting again * Fix formatting again * Disable no-var-requires error on some intended var import. * Increase memory limit for build * Use standard Segoe UI font for Fabric * Improve Tabs design for Fabric * Fix active Tab style bug in Portal introduced with 39a7765aef807de5c1e7c82b094765072a10924c --------- Co-authored-by: Laurent Nguyen <laurent.nguyen@microsoft.com>
2023-09-15 17:33:27 +02:00
2021-03-14 22:53:16 -05:00
function LoadingExplorer(): JSX.Element {
return (
<div className="splashLoaderContainer">
<div className="splashLoaderContentContainer">
<p className="connectExplorerContent">
<img src={hdeConnectImage} alt="Azure Cosmos DB" />
</p>
<p className="splashLoaderTitle" id="explorerLoadingStatusTitle">
Welcome to Azure Cosmos DB
</p>
<p className="splashLoaderText" id="explorerLoadingStatusText" role="alert">
Connecting...
</p>
</div>
</div>
);
}